feat: add suggestions to issue output
This commit is contained in:
@ -1,15 +1,21 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"forge.cadoles.com/wpetit/clearcase/internal/core/model"
|
||||
"forge.cadoles.com/wpetit/clearcase/internal/http/form"
|
||||
common "forge.cadoles.com/wpetit/clearcase/internal/http/handler/webui/common/component"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/yuin/goldmark"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type IssuePageVModel struct {
|
||||
IssueURL string
|
||||
SummaryForm *form.Form
|
||||
IssueForm *form.Form
|
||||
IssueTips string
|
||||
Projects []*model.Project
|
||||
SelectedProjectID string
|
||||
}
|
||||
@ -128,6 +134,22 @@ templ IssuePage(vmodel IssuePageVModel) {
|
||||
</div>
|
||||
</div>
|
||||
<progress id="generation-progress" class="htmx-indicator progress"></progress>
|
||||
if vmodel.IssueTips != "" {
|
||||
{{ html := markdownToHTML(ctx, vmodel.IssueTips) }}
|
||||
if html != "" {
|
||||
<article class="message is-info mt-5">
|
||||
<div class="message-header">
|
||||
<p><span class="icon"><i class="fa fa-lightbulb"></i></span>Suggestions</p>
|
||||
<button class="delete" aria-label="delete" hx-on:click="onCloseMessage(this)"></button>
|
||||
</div>
|
||||
<div class="message-body">
|
||||
<div class="content">
|
||||
@templ.Raw(html)
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
}
|
||||
}
|
||||
</section>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
@ -183,3 +205,13 @@ func projectsToOptions(projects []*model.Project) []string {
|
||||
}
|
||||
return options
|
||||
}
|
||||
|
||||
func markdownToHTML(ctx context.Context, text string) string {
|
||||
var buff bytes.Buffer
|
||||
if err := goldmark.Convert([]byte(text), &buff); err != nil {
|
||||
slog.ErrorContext(ctx, "could not convert markdown to html", slog.Any("error", errors.WithStack(err)))
|
||||
return ""
|
||||
}
|
||||
|
||||
return buff.String()
|
||||
}
|
||||
|
Reference in New Issue
Block a user