11<script lang="ts">
22import {SvgIcon } from ' ../svg.ts' ;
33import ActionRunStatus from ' ./ActionRunStatus.vue' ;
4- import {createApp } from ' vue' ;
4+ import {defineComponent , type PropType } from ' vue' ;
55import {createElementFromAttrs , toggleElem } from ' ../utils/dom.ts' ;
66import {formatDatetime } from ' ../utils/time.ts' ;
77import {renderAnsi } from ' ../render/ansi.ts' ;
@@ -38,7 +38,7 @@ function parseLineCommand(line: LogLine): LogLineCommand | null {
3838 return null ;
3939}
4040
41- function isLogElementInViewport(el : HTMLElement ): boolean {
41+ function isLogElementInViewport(el : Element ): boolean {
4242 const rect = el .getBoundingClientRect ();
4343 return rect .top >= 0 && rect .bottom <= window .innerHeight ; // only check height but not width
4444}
@@ -57,25 +57,28 @@ function getLocaleStorageOptions(): LocaleStorageOptions {
5757 return {autoScroll: true , expandRunning: false };
5858}
5959
60- const sfc = {
60+ export default defineComponent ( {
6161 name: ' RepoActionView' ,
6262 components: {
6363 SvgIcon ,
6464 ActionRunStatus ,
6565 },
6666 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: ' ' ,
7670 },
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 ,
7982 },
8083 },
8184
@@ -102,10 +105,11 @@ const sfc = {
102105 link: ' ' ,
103106 title: ' ' ,
104107 titleHTML: ' ' ,
105- status: ' ' ,
108+ status: ' unknown ' as RunStatus ,
106109 canCancel: false ,
107110 canApprove: false ,
108111 canRerun: false ,
112+ canDeleteArtifact: false ,
109113 done: false ,
110114 workflowID: ' ' ,
111115 workflowLink: ' ' ,
@@ -131,6 +135,7 @@ const sfc = {
131135 branch: {
132136 name: ' ' ,
133137 link: ' ' ,
138+ isDeleted: false ,
134139 },
135140 },
136141 },
@@ -148,7 +153,16 @@ const sfc = {
148153 };
149154 },
150155
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
152166 // load job data and then auto-reload periodically
153167 // need to await first loadJob so this.currentJobStepsStates is initialized and can be used in hashChangeListener
154168 await this .loadJob ();
@@ -186,6 +200,7 @@ const sfc = {
186200 // get the active logs container element, either the `job-step-logs` or the `job-log-list` in the `job-log-group`
187201 getActiveLogsContainer(stepIndex : number ): HTMLElement {
188202 const el = this .getJobStepLogsContainer (stepIndex );
203+ // @ts-expect-error - _stepLogsActiveContainer is a custom property
189204 return el ._stepLogsActiveContainer ?? el ;
190205 },
191206 // begin a log group
@@ -263,7 +278,7 @@ const sfc = {
263278 const el = this .getJobStepLogsContainer (stepIndex );
264279 // if the logs container is empty, then auto-scroll if the step is expanded
265280 if (! el .lastChild ) return this .currentJobStepsStates [stepIndex ].expanded ;
266- return isLogElementInViewport (el .lastChild );
281+ return isLogElementInViewport (el .lastChild as Element );
267282 },
268283
269284 appendLogs(stepIndex : number , startTime : number , logLines : LogLine []) {
@@ -380,7 +395,7 @@ const sfc = {
380395
381396 toggleTimeDisplay(type : string ) {
382397 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 } ` )) {
384399 toggleElem (el , this .timeVisible [` log-time-${type } ` ]);
385400 }
386401 },
@@ -414,59 +429,12 @@ const sfc = {
414429 // so logline can be selected by querySelector
415430 await this .loadJob ();
416431 }
417- const logLine = this .$refs .steps .querySelector (selectedLogStep );
432+ const logLine = ( this .$refs .steps as HTMLElement ) .querySelector (selectedLogStep );
418433 if (! logLine ) return ;
419- logLine .querySelector (' .line-num' ).click ();
434+ logLine .querySelector < HTMLAnchorElement > (' .line-num' ).click ();
420435 },
421436 },
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+ });
470438 </script >
471439<template >
472440 <div class =" ui container action-view-container" >
0 commit comments