Skip to content

Commit 1703e6b

Browse files
committed
Enable Typescript noImplicitThis
1 parent 98d7e04 commit 1703e6b

24 files changed

+187
-170
lines changed

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"stripInternal": true,
2424
"strict": false,
2525
"strictFunctionTypes": true,
26+
"noImplicitThis": true,
2627
"noUnusedLocals": true,
2728
"noUnusedParameters": true,
2829
"noPropertyAccessFromIndexSignature": false,

web_src/js/components/DashboardRepoList.vue

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import {createApp, nextTick} from 'vue';
2+
import {nextTick, defineComponent} from 'vue';
33
import {SvgIcon} from '../svg.ts';
44
import {GET} from '../modules/fetch.ts';
55
import {fomanticQuery} from '../modules/fomantic/base.ts';
@@ -24,7 +24,7 @@ const commitStatus: CommitStatusMap = {
2424
warning: {name: 'gitea-exclamation', color: 'yellow'},
2525
};
2626
27-
const sfc = {
27+
export default defineComponent({
2828
components: {SvgIcon},
2929
data() {
3030
const params = new URLSearchParams(window.location.search);
@@ -335,16 +335,8 @@ const sfc = {
335335
}
336336
},
337337
},
338-
};
339-
340-
export function initDashboardRepoList() {
341-
const el = document.querySelector('#dashboard-repo-list');
342-
if (el) {
343-
createApp(sfc).mount(el);
344-
}
345-
}
338+
});
346339
347-
export default sfc; // activate the IDE's Vue plugin
348340
</script>
349341
<template>
350342
<div>

web_src/js/components/DiffCommitSelector.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<script lang="ts">
2+
import {defineComponent} from 'vue';
23
import {SvgIcon} from '../svg.ts';
34
import {GET} from '../modules/fetch.ts';
45
import {generateAriaId} from '../modules/fomantic/base.ts';
56
6-
export default {
7+
export default defineComponent({
78
components: {SvgIcon},
89
data: () => {
910
const el = document.querySelector('#diff-commit-select');
@@ -55,11 +56,11 @@ export default {
5556
switch (event.key) {
5657
case 'ArrowDown': // select next element
5758
event.preventDefault();
58-
this.focusElem(item.nextElementSibling, item);
59+
this.focusElem(item.nextElementSibling as HTMLElement, item);
5960
break;
6061
case 'ArrowUp': // select previous element
6162
event.preventDefault();
62-
this.focusElem(item.previousElementSibling, item);
63+
this.focusElem(item.previousElementSibling as HTMLElement, item);
6364
break;
6465
case 'Escape': // close menu
6566
event.preventDefault();
@@ -118,9 +119,9 @@ export default {
118119
// set correct tabindex to allow easier navigation
119120
this.$nextTick(() => {
120121
if (this.menuVisible) {
121-
this.focusElem(this.$refs.showAllChanges, this.$refs.expandBtn);
122+
this.focusElem(this.$refs.showAllChanges as HTMLElement, this.$refs.expandBtn as HTMLElement);
122123
} else {
123-
this.focusElem(this.$refs.expandBtn, this.$refs.showAllChanges);
124+
this.focusElem(this.$refs.expandBtn as HTMLElement, this.$refs.showAllChanges as HTMLElement);
124125
}
125126
});
126127
},
@@ -188,7 +189,7 @@ export default {
188189
}
189190
},
190191
},
191-
};
192+
});
192193
</script>
193194
<template>
194195
<div class="ui scrolling dropdown custom diff-commit-selector">

web_src/js/components/RepoActionView.vue

Lines changed: 35 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import {SvgIcon} from '../svg.ts';
33
import ActionRunStatus from './ActionRunStatus.vue';
4-
import {createApp} from 'vue';
4+
import {defineComponent} from 'vue';
55
import {createElementFromAttrs, toggleElem} from '../utils/dom.ts';
66
import {formatDatetime} from '../utils/time.ts';
77
import {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,
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,6 +153,15 @@ const sfc = {
148153
};
149154
},
150155
156+
watch: {
157+
optionAlwaysAutoScroll() {
158+
this.saveLocaleStorageOptions();
159+
},
160+
optionAlwaysExpandRunning() {
161+
this.saveLocaleStorageOptions();
162+
},
163+
},
164+
151165
async mounted() {
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
@@ -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

Comments
 (0)