1
1
<script lang="ts">
2
2
import {SvgIcon } from ' ../svg.ts' ;
3
3
import ActionRunStatus from ' ./ActionRunStatus.vue' ;
4
- import {createApp } from ' vue' ;
4
+ import {defineComponent , type PropType } from ' vue' ;
5
5
import {createElementFromAttrs , toggleElem } from ' ../utils/dom.ts' ;
6
6
import {formatDatetime } from ' ../utils/time.ts' ;
7
7
import {renderAnsi } from ' ../render/ansi.ts' ;
@@ -38,7 +38,7 @@ function parseLineCommand(line: LogLine): LogLineCommand | null {
38
38
return null ;
39
39
}
40
40
41
- function isLogElementInViewport(el : HTMLElement ): boolean {
41
+ function isLogElementInViewport(el : Element ): boolean {
42
42
const rect = el .getBoundingClientRect ();
43
43
return rect .top >= 0 && rect .bottom <= window .innerHeight ; // only check height but not width
44
44
}
@@ -57,25 +57,28 @@ function getLocaleStorageOptions(): LocaleStorageOptions {
57
57
return {autoScroll: true , expandRunning: false };
58
58
}
59
59
60
- const sfc = {
60
+ export default defineComponent ( {
61
61
name: ' RepoActionView' ,
62
62
components: {
63
63
SvgIcon ,
64
64
ActionRunStatus ,
65
65
},
66
66
props: {
67
- runIndex: String ,
68
- jobIndex: String ,
69
- actionsURL: String ,
70
- locale: Object ,
71
- },
72
-
73
- watch: {
74
- optionAlwaysAutoScroll() {
75
- this .saveLocaleStorageOptions ();
67
+ runIndex: {
68
+ type: String ,
69
+ default: ' ' ,
76
70
},
77
- optionAlwaysExpandRunning() {
78
- this .saveLocaleStorageOptions ();
71
+ jobIndex: {
72
+ type: String ,
73
+ default: ' ' ,
74
+ },
75
+ actionsURL: {
76
+ type: String ,
77
+ default: ' ' ,
78
+ },
79
+ locale: {
80
+ type: Object as PropType <Record <string , string >>,
81
+ default: null ,
79
82
},
80
83
},
81
84
@@ -102,10 +105,11 @@ const sfc = {
102
105
link: ' ' ,
103
106
title: ' ' ,
104
107
titleHTML: ' ' ,
105
- status: ' ' ,
108
+ status: ' unknown ' as RunStatus ,
106
109
canCancel: false ,
107
110
canApprove: false ,
108
111
canRerun: false ,
112
+ canDeleteArtifact: false ,
109
113
done: false ,
110
114
workflowID: ' ' ,
111
115
workflowLink: ' ' ,
@@ -131,6 +135,7 @@ const sfc = {
131
135
branch: {
132
136
name: ' ' ,
133
137
link: ' ' ,
138
+ isDeleted: false ,
134
139
},
135
140
},
136
141
},
@@ -148,7 +153,16 @@ const sfc = {
148
153
};
149
154
},
150
155
151
- async mounted() {
156
+ watch: {
157
+ optionAlwaysAutoScroll() {
158
+ this .saveLocaleStorageOptions ();
159
+ },
160
+ optionAlwaysExpandRunning() {
161
+ this .saveLocaleStorageOptions ();
162
+ },
163
+ },
164
+
165
+ async mounted() { // eslint-disable-line @typescript-eslint/no-misused-promises
152
166
// load job data and then auto-reload periodically
153
167
// need to await first loadJob so this.currentJobStepsStates is initialized and can be used in hashChangeListener
154
168
await this .loadJob ();
@@ -186,6 +200,7 @@ const sfc = {
186
200
// get the active logs container element, either the `job-step-logs` or the `job-log-list` in the `job-log-group`
187
201
getActiveLogsContainer(stepIndex : number ): HTMLElement {
188
202
const el = this .getJobStepLogsContainer (stepIndex );
203
+ // @ts-expect-error - _stepLogsActiveContainer is a custom property
189
204
return el ._stepLogsActiveContainer ?? el ;
190
205
},
191
206
// begin a log group
@@ -263,7 +278,7 @@ const sfc = {
263
278
const el = this .getJobStepLogsContainer (stepIndex );
264
279
// if the logs container is empty, then auto-scroll if the step is expanded
265
280
if (! el .lastChild ) return this .currentJobStepsStates [stepIndex ].expanded ;
266
- return isLogElementInViewport (el .lastChild );
281
+ return isLogElementInViewport (el .lastChild as Element );
267
282
},
268
283
269
284
appendLogs(stepIndex : number , startTime : number , logLines : LogLine []) {
@@ -380,7 +395,7 @@ const sfc = {
380
395
381
396
toggleTimeDisplay(type : string ) {
382
397
this .timeVisible [` log-time-${type } ` ] = ! this .timeVisible [` log-time-${type } ` ];
383
- for (const el of this .$refs .steps .querySelectorAll (` .log-time-${type } ` )) {
398
+ for (const el of ( this .$refs .steps as HTMLElement ) .querySelectorAll (` .log-time-${type } ` )) {
384
399
toggleElem (el , this .timeVisible [` log-time-${type } ` ]);
385
400
}
386
401
},
@@ -414,59 +429,12 @@ const sfc = {
414
429
// so logline can be selected by querySelector
415
430
await this .loadJob ();
416
431
}
417
- const logLine = this .$refs .steps .querySelector (selectedLogStep );
432
+ const logLine = ( this .$refs .steps as HTMLElement ) .querySelector (selectedLogStep );
418
433
if (! logLine ) return ;
419
- logLine .querySelector (' .line-num' ).click ();
434
+ logLine .querySelector < HTMLAnchorElement > (' .line-num' ).click ();
420
435
},
421
436
},
422
- };
423
-
424
- export default sfc ;
425
-
426
- export function initRepositoryActionView() {
427
- const el = document .querySelector (' #repo-action-view' );
428
- if (! el ) return ;
429
-
430
- // TODO: the parent element's full height doesn't work well now,
431
- // but we can not pollute the global style at the moment, only fix the height problem for pages with this component
432
- const parentFullHeight = document .querySelector <HTMLElement >(' body > div.full.height' );
433
- if (parentFullHeight ) parentFullHeight .style .paddingBottom = ' 0' ;
434
-
435
- const view = createApp (sfc , {
436
- runIndex: el .getAttribute (' data-run-index' ),
437
- jobIndex: el .getAttribute (' data-job-index' ),
438
- actionsURL: el .getAttribute (' data-actions-url' ),
439
- locale: {
440
- approve: el .getAttribute (' data-locale-approve' ),
441
- cancel: el .getAttribute (' data-locale-cancel' ),
442
- rerun: el .getAttribute (' data-locale-rerun' ),
443
- rerun_all: el .getAttribute (' data-locale-rerun-all' ),
444
- scheduled: el .getAttribute (' data-locale-runs-scheduled' ),
445
- commit: el .getAttribute (' data-locale-runs-commit' ),
446
- pushedBy: el .getAttribute (' data-locale-runs-pushed-by' ),
447
- artifactsTitle: el .getAttribute (' data-locale-artifacts-title' ),
448
- areYouSure: el .getAttribute (' data-locale-are-you-sure' ),
449
- confirmDeleteArtifact: el .getAttribute (' data-locale-confirm-delete-artifact' ),
450
- showTimeStamps: el .getAttribute (' data-locale-show-timestamps' ),
451
- showLogSeconds: el .getAttribute (' data-locale-show-log-seconds' ),
452
- showFullScreen: el .getAttribute (' data-locale-show-full-screen' ),
453
- downloadLogs: el .getAttribute (' data-locale-download-logs' ),
454
- status: {
455
- unknown: el .getAttribute (' data-locale-status-unknown' ),
456
- waiting: el .getAttribute (' data-locale-status-waiting' ),
457
- running: el .getAttribute (' data-locale-status-running' ),
458
- success: el .getAttribute (' data-locale-status-success' ),
459
- failure: el .getAttribute (' data-locale-status-failure' ),
460
- cancelled: el .getAttribute (' data-locale-status-cancelled' ),
461
- skipped: el .getAttribute (' data-locale-status-skipped' ),
462
- blocked: el .getAttribute (' data-locale-status-blocked' ),
463
- },
464
- logsAlwaysAutoScroll: el .getAttribute (' data-locale-logs-always-auto-scroll' ),
465
- logsAlwaysExpandRunning: el .getAttribute (' data-locale-logs-always-expand-running' ),
466
- },
467
- });
468
- view .mount (el );
469
- }
437
+ });
470
438
</script >
471
439
<template >
472
440
<div class =" ui container action-view-container" >
0 commit comments