mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 06:43:34 +01:00
fix: render job title as commit message (#32748)
resolves #32724 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> (cherry picked from commit ad994780af48e2aff27b0e7e496fd559dc0fe3fc) Conflicts: routers/web/repo/actions/view.go because of RenderCommitMessage context
This commit is contained in:
parent
63faaaeda4
commit
b811574d47
2 changed files with 19 additions and 13 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -25,6 +26,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/storage"
|
"code.gitea.io/gitea/modules/storage"
|
||||||
|
"code.gitea.io/gitea/modules/templates"
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
|
@ -108,16 +110,17 @@ type ViewRequest struct {
|
||||||
type ViewResponse struct {
|
type ViewResponse struct {
|
||||||
State struct {
|
State struct {
|
||||||
Run struct {
|
Run struct {
|
||||||
Link string `json:"link"`
|
Link string `json:"link"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Status string `json:"status"`
|
TitleHTML template.HTML `json:"titleHTML"`
|
||||||
CanCancel bool `json:"canCancel"`
|
Status string `json:"status"`
|
||||||
CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve
|
CanCancel bool `json:"canCancel"`
|
||||||
CanRerun bool `json:"canRerun"`
|
CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve
|
||||||
CanDeleteArtifact bool `json:"canDeleteArtifact"`
|
CanRerun bool `json:"canRerun"`
|
||||||
Done bool `json:"done"`
|
CanDeleteArtifact bool `json:"canDeleteArtifact"`
|
||||||
Jobs []*ViewJob `json:"jobs"`
|
Done bool `json:"done"`
|
||||||
Commit ViewCommit `json:"commit"`
|
Jobs []*ViewJob `json:"jobs"`
|
||||||
|
Commit ViewCommit `json:"commit"`
|
||||||
} `json:"run"`
|
} `json:"run"`
|
||||||
CurrentJob struct {
|
CurrentJob struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
|
@ -194,7 +197,10 @@ func ViewPost(ctx *context_module.Context) {
|
||||||
|
|
||||||
resp := &ViewResponse{}
|
resp := &ViewResponse{}
|
||||||
|
|
||||||
|
metas := ctx.Repo.Repository.ComposeMetas(ctx)
|
||||||
|
|
||||||
resp.State.Run.Title = run.Title
|
resp.State.Run.Title = run.Title
|
||||||
|
resp.State.Run.TitleHTML = templates.RenderCommitMessage(ctx, run.Title, metas)
|
||||||
resp.State.Run.Link = run.Link()
|
resp.State.Run.Link = run.Link()
|
||||||
resp.State.Run.CanCancel = !run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
|
resp.State.Run.CanCancel = !run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
|
||||||
resp.State.Run.CanApprove = run.NeedApproval && ctx.Repo.CanWrite(unit.TypeActions)
|
resp.State.Run.CanApprove = run.NeedApproval && ctx.Repo.CanWrite(unit.TypeActions)
|
||||||
|
|
|
@ -42,6 +42,7 @@ const sfc = {
|
||||||
run: {
|
run: {
|
||||||
link: '',
|
link: '',
|
||||||
title: '',
|
title: '',
|
||||||
|
titleHTML: '',
|
||||||
status: '',
|
status: '',
|
||||||
canCancel: false,
|
canCancel: false,
|
||||||
canApprove: false,
|
canApprove: false,
|
||||||
|
@ -424,9 +425,8 @@ export function initRepositoryActionView() {
|
||||||
<div class="action-info-summary">
|
<div class="action-info-summary">
|
||||||
<div class="action-info-summary-title">
|
<div class="action-info-summary-title">
|
||||||
<ActionRunStatus :locale-status="locale.status[run.status]" :status="run.status" :size="20"/>
|
<ActionRunStatus :locale-status="locale.status[run.status]" :status="run.status" :size="20"/>
|
||||||
<h2 class="action-info-summary-title-text">
|
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||||
{{ run.title }}
|
<h2 class="action-info-summary-title-text" v-html="run.titleHTML"/>
|
||||||
</h2>
|
|
||||||
</div>
|
</div>
|
||||||
<button class="ui basic small compact button primary" @click="approveRun()" v-if="run.canApprove">
|
<button class="ui basic small compact button primary" @click="approveRun()" v-if="run.canApprove">
|
||||||
{{ locale.approve }}
|
{{ locale.approve }}
|
||||||
|
|
Loading…
Reference in a new issue