Skip to content

Commit 638a27f

Browse files
committed
fix: render job title as commit message
1 parent 5a75160 commit 638a27f

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

routers/web/repo/actions/view.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"context"
1010
"errors"
1111
"fmt"
12+
"html/template"
1213
"io"
1314
"net/http"
1415
"net/url"
@@ -29,6 +30,7 @@ import (
2930
"code.gitea.io/gitea/modules/setting"
3031
"code.gitea.io/gitea/modules/storage"
3132
api "code.gitea.io/gitea/modules/structs"
33+
"code.gitea.io/gitea/modules/templates"
3234
"code.gitea.io/gitea/modules/timeutil"
3335
"code.gitea.io/gitea/modules/util"
3436
"code.gitea.io/gitea/modules/web"
@@ -87,19 +89,20 @@ type ViewResponse struct {
8789

8890
State struct {
8991
Run struct {
90-
Link string `json:"link"`
91-
Title string `json:"title"`
92-
Status string `json:"status"`
93-
CanCancel bool `json:"canCancel"`
94-
CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve
95-
CanRerun bool `json:"canRerun"`
96-
CanDeleteArtifact bool `json:"canDeleteArtifact"`
97-
Done bool `json:"done"`
98-
WorkflowID string `json:"workflowID"`
99-
WorkflowLink string `json:"workflowLink"`
100-
IsSchedule bool `json:"isSchedule"`
101-
Jobs []*ViewJob `json:"jobs"`
102-
Commit ViewCommit `json:"commit"`
92+
Link string `json:"link"`
93+
Title string `json:"title"`
94+
TitleHTML template.HTML `json:"titleHTML"`
95+
Status string `json:"status"`
96+
CanCancel bool `json:"canCancel"`
97+
CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve
98+
CanRerun bool `json:"canRerun"`
99+
CanDeleteArtifact bool `json:"canDeleteArtifact"`
100+
Done bool `json:"done"`
101+
WorkflowID string `json:"workflowID"`
102+
WorkflowLink string `json:"workflowLink"`
103+
IsSchedule bool `json:"isSchedule"`
104+
Jobs []*ViewJob `json:"jobs"`
105+
Commit ViewCommit `json:"commit"`
103106
} `json:"run"`
104107
CurrentJob struct {
105108
Title string `json:"title"`
@@ -200,7 +203,10 @@ func ViewPost(ctx *context_module.Context) {
200203
}
201204
}
202205

206+
metas := ctx.Repo.Repository.ComposeMetas(ctx)
207+
203208
resp.State.Run.Title = run.Title
209+
resp.State.Run.TitleHTML = templates.NewRenderUtils(ctx).RenderCommitMessage(run.Title, metas)
204210
resp.State.Run.Link = run.Link()
205211
resp.State.Run.CanCancel = !run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
206212
resp.State.Run.CanApprove = run.NeedApproval && ctx.Repo.CanWrite(unit.TypeActions)

web_src/js/components/RepoActionView.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script lang="ts">
22
import {SvgIcon} from '../svg.ts';
33
import ActionRunStatus from './ActionRunStatus.vue';
4-
import {createApp} from 'vue';
4+
import {createApp, nextTick} from 'vue';
5+
import {attachRefIssueContextPopup} from '../features/contextpopup.ts';
56
import {createElementFromAttrs, toggleElem} from '../utils/dom.ts';
67
import {formatDatetime} from '../utils/time.ts';
78
import {renderAnsi} from '../render/ansi.ts';
@@ -51,6 +52,7 @@ const sfc = {
5152
run: {
5253
link: '',
5354
title: '',
55+
titleHTML: '',
5456
status: '',
5557
canCancel: false,
5658
canApprove: false,
@@ -268,6 +270,11 @@ const sfc = {
268270
clearInterval(this.intervalID);
269271
this.intervalID = null;
270272
}
273+
274+
await nextTick();
275+
276+
const refIssues = document.querySelectorAll('.action-info-summary-title-text .ref-issue');
277+
attachRefIssueContextPopup(refIssues);
271278
} catch (e) {
272279
// avoid network error while unloading page, and ignore "abort" error
273280
if (e instanceof TypeError || abortController.signal.aborted) return;
@@ -383,9 +390,8 @@ export function initRepositoryActionView() {
383390
<div class="action-info-summary">
384391
<div class="action-info-summary-title">
385392
<ActionRunStatus :locale-status="locale.status[run.status]" :status="run.status" :size="20"/>
386-
<h2 class="action-info-summary-title-text">
387-
{{ run.title }}
388-
</h2>
393+
<!-- eslint-disable-next-line vue/no-v-html -->
394+
<h2 class="action-info-summary-title-text" v-html="run.titleHTML"/>
389395
</div>
390396
<button class="ui basic small compact button primary" @click="approveRun()" v-if="run.canApprove">
391397
{{ locale.approve }}

0 commit comments

Comments
 (0)