From 1518f4ed123ae5f4f094e7a335b1d1400949265d Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 8 Dec 2024 03:58:18 +0100 Subject: Fix typescript errors in Vue files, fix regression in "Recent Commits" chart (#32649) - Fix all typescript errors in `.vue` files - Fix regression from https://github.com/go-gitea/gitea/pull/32329 where "Recent Commits" chart would not render. --------- Co-authored-by: wxiaoguang --- web_src/js/components/DashboardRepoList.vue | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'web_src/js/components/DashboardRepoList.vue') diff --git a/web_src/js/components/DashboardRepoList.vue b/web_src/js/components/DashboardRepoList.vue index 3d3ac2fc69..41793d60ed 100644 --- a/web_src/js/components/DashboardRepoList.vue +++ b/web_src/js/components/DashboardRepoList.vue @@ -6,8 +6,17 @@ import {fomanticQuery} from '../modules/fomantic/base.ts'; const {appSubUrl, assetUrlPrefix, pageData} = window.config; +type CommitStatus = 'pending' | 'success' | 'error' | 'failure' | 'warning'; + +type CommitStatusMap = { + [status in CommitStatus]: { + name: string, + color: string, + }; +}; + // make sure this matches templates/repo/commit_status.tmpl -const commitStatus = { +const commitStatus: CommitStatusMap = { pending: {name: 'octicon-dot-fill', color: 'yellow'}, success: {name: 'octicon-check', color: 'green'}, error: {name: 'gitea-exclamation', color: 'red'}, @@ -281,18 +290,18 @@ const sfc = { return 'octicon-repo'; }, - statusIcon(status) { + statusIcon(status: CommitStatus) { return commitStatus[status].name; }, - statusColor(status) { + statusColor(status: CommitStatus) { return commitStatus[status].color; }, reposFilterKeyControl(e) { switch (e.key) { case 'Enter': - document.querySelector('.repo-owner-name-list li.active a')?.click(); + document.querySelector('.repo-owner-name-list li.active a')?.click(); break; case 'ArrowUp': if (this.activeIndex > 0) { -- cgit v1.2.3