From bae271cbbfd14e2a6ab3c5e2d3e5cb2b8240ea3a Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Fri, 4 Aug 2023 07:24:05 +0000 Subject: [PATCH 1/4] add --- web_src/js/components/DashboardRepoList.vue | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/web_src/js/components/DashboardRepoList.vue b/web_src/js/components/DashboardRepoList.vue index d68ee45ee3d3c..bc395470cc2af 100644 --- a/web_src/js/components/DashboardRepoList.vue +++ b/web_src/js/components/DashboardRepoList.vue @@ -77,8 +77,10 @@ - - + + + +
@@ -394,7 +396,7 @@ const sfc = { } if (searchedURL === this.searchURL) { - this.repos = json.data.map((webSearchRepo) => {return {...webSearchRepo.repository, latest_commit_status_state: webSearchRepo.latest_commit_status.State}}); + this.repos = json.data.map((webSearchRepo) => {return {...webSearchRepo.repository, latest_commit_status_state: webSearchRepo.latest_commit_status.State, latest_commit_status_state_link: webSearchRepo.latest_commit_status.TargetURL}}); const count = response.headers.get('X-Total-Count'); if (searchedQuery === '' && searchedMode === '' && this.archivedFilter === 'both') { this.reposTotalCount = count; @@ -503,6 +505,10 @@ ul li:not(:last-child) { color: var(--color-text-light-2); } +.repo-list-status-link { + padding: 6px 0; +} + .repo-list-icon { min-width: 16px; margin-right: 2px; From dbf01b73b7355f246a9dea94abf0e12c4a5da299 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Mon, 7 Aug 2023 02:48:47 +0000 Subject: [PATCH 2/4] improve --- web_src/js/components/DashboardRepoList.vue | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/web_src/js/components/DashboardRepoList.vue b/web_src/js/components/DashboardRepoList.vue index bc395470cc2af..60fb1dfcfe274 100644 --- a/web_src/js/components/DashboardRepoList.vue +++ b/web_src/js/components/DashboardRepoList.vue @@ -69,15 +69,15 @@
    -
  • - +
  • +
    {{ repo.full_name }}
    - + @@ -496,8 +496,6 @@ ul li:not(:last-child) { } .repo-list-link { - padding: 6px 0; - gap: 6px; min-width: 0; /* for text truncation */ } @@ -505,10 +503,6 @@ ul li:not(:last-child) { color: var(--color-text-light-2); } -.repo-list-status-link { - padding: 6px 0; -} - .repo-list-icon { min-width: 16px; margin-right: 2px; From e99d0ad3d7c8c53f01fe443ebdd6352940eaaac1 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Mon, 7 Aug 2023 07:36:42 +0000 Subject: [PATCH 3/4] add locale --- models/git/commit_status.go | 6 ++++++ modules/structs/commit_status.go | 4 ++++ options/locale/locale_en-US.ini | 4 ++++ routers/web/repo/repo.go | 5 ++++- services/repository/repository.go | 5 +++-- web_src/js/components/DashboardRepoList.vue | 11 +++++++++-- 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/models/git/commit_status.go b/models/git/commit_status.go index e7616fb167392..893fef1722264 100644 --- a/models/git/commit_status.go +++ b/models/git/commit_status.go @@ -22,6 +22,7 @@ import ( "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/timeutil" + "code.gitea.io/gitea/modules/translation" "xorm.io/builder" "xorm.io/xorm" @@ -191,6 +192,11 @@ func (status *CommitStatus) APIURL(ctx context.Context) string { return status.Repo.APIURL() + "/statuses/" + url.PathEscape(status.SHA) } +// LocaleString returns the locale string name of the Status +func (status *CommitStatus) LocaleString(lang translation.Locale) string { + return lang.Tr(status.State.String()) +} + // CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus { var lastStatus *CommitStatus diff --git a/modules/structs/commit_status.go b/modules/structs/commit_status.go index de1d8fa566cd0..fda795dca6614 100644 --- a/modules/structs/commit_status.go +++ b/modules/structs/commit_status.go @@ -25,6 +25,10 @@ var commitStatusPriorities = map[CommitStatusState]int{ CommitStatusSuccess: 3, } +func (css CommitStatusState) String() string { + return string(css) +} + // NoBetterThan returns true if this State is no better than the given State // This function only handles the states defined in CommitStatusPriorities func (css CommitStatusState) NoBetterThan(css2 CommitStatusState) bool { diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index b2eeab617e48a..cc9c5033eeba8 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -112,6 +112,10 @@ step2 = Step 2: error = Error error404 = The page you are trying to reach either does not exist or you are not authorized to view it. +failure = Failure +pending = Pending +success = Success + never = Never unknown = Unknown diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index 0de804dbce6fa..4409381bc5081 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -600,6 +600,8 @@ func SearchRepo(ctx *context.Context) { results := make([]*repo_service.WebSearchRepository, len(repos)) for i, repo := range repos { + latestCommitStatus := git_model.CalcCommitStatus(repoToItsLatestCommitStatuses[repo.ID]) + results[i] = &repo_service.WebSearchRepository{ Repository: &api.Repository{ ID: repo.ID, @@ -613,7 +615,8 @@ func SearchRepo(ctx *context.Context) { Link: repo.Link(), Internal: !repo.IsPrivate && repo.Owner.Visibility == api.VisibleTypePrivate, }, - LatestCommitStatus: git_model.CalcCommitStatus(repoToItsLatestCommitStatuses[repo.ID]), + LatestCommitStatus: latestCommitStatus, + LocaleLatestCommitStatus: latestCommitStatus.LocaleString(ctx.Locale), } } diff --git a/services/repository/repository.go b/services/repository/repository.go index cd3658dcd8e06..ade747582f57b 100644 --- a/services/repository/repository.go +++ b/services/repository/repository.go @@ -28,8 +28,9 @@ import ( // WebSearchRepository represents a repository returned by web search type WebSearchRepository struct { - Repository *structs.Repository `json:"repository"` - LatestCommitStatus *git.CommitStatus `json:"latest_commit_status"` + Repository *structs.Repository `json:"repository"` + LatestCommitStatus *git.CommitStatus `json:"latest_commit_status"` + LocaleLatestCommitStatus string `json:"locale_latest_commit_status"` } // WebSearchResults results of a successful web search diff --git a/web_src/js/components/DashboardRepoList.vue b/web_src/js/components/DashboardRepoList.vue index 60fb1dfcfe274..008149ca6069a 100644 --- a/web_src/js/components/DashboardRepoList.vue +++ b/web_src/js/components/DashboardRepoList.vue @@ -77,7 +77,7 @@
- + @@ -396,7 +396,14 @@ const sfc = { } if (searchedURL === this.searchURL) { - this.repos = json.data.map((webSearchRepo) => {return {...webSearchRepo.repository, latest_commit_status_state: webSearchRepo.latest_commit_status.State, latest_commit_status_state_link: webSearchRepo.latest_commit_status.TargetURL}}); + this.repos = json.data.map((webSearchRepo) => { + return { + ...webSearchRepo.repository, + latest_commit_status_state: webSearchRepo.latest_commit_status.State, + locale_latest_commit_status_state: webSearchRepo.locale_latest_commit_status, + latest_commit_status_state_link: webSearchRepo.latest_commit_status.TargetURL + }; + }); const count = response.headers.get('X-Total-Count'); if (searchedQuery === '' && searchedMode === '' && this.archivedFilter === 'both') { this.reposTotalCount = count; From f10f512639c1237025bab9a13daed4c46f767493 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Tue, 15 Aug 2023 00:07:03 +0000 Subject: [PATCH 4/4] add prefixes --- models/git/commit_status.go | 2 +- options/locale/locale_en-US.ini | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/models/git/commit_status.go b/models/git/commit_status.go index 893fef1722264..24fee8c3b4f24 100644 --- a/models/git/commit_status.go +++ b/models/git/commit_status.go @@ -194,7 +194,7 @@ func (status *CommitStatus) APIURL(ctx context.Context) string { // LocaleString returns the locale string name of the Status func (status *CommitStatus) LocaleString(lang translation.Locale) string { - return lang.Tr(status.State.String()) + return lang.Tr("repo.commitstatus." + status.State.String()) } // CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index cc9c5033eeba8..34af73d522790 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -112,10 +112,6 @@ step2 = Step 2: error = Error error404 = The page you are trying to reach either does not exist or you are not authorized to view it. -failure = Failure -pending = Pending -success = Success - never = Never unknown = Unknown @@ -1281,6 +1277,11 @@ commit.cherry-pick = Cherry-pick commit.cherry-pick-header = Cherry-pick: %s commit.cherry-pick-content = Select branch to cherry-pick onto: +commitstatus.error = Error +commitstatus.failure = Failure +commitstatus.pending = Pending +commitstatus.success = Success + ext_issues = Access to External Issues ext_issues.desc = Link to an external issue tracker.