loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add link to job details and tooltip to commit status in repo list in dashboard (#26326)

Tooltip:

![image](https://github.com/go-gitea/gitea/assets/18380374/237cb545-7844-424b-b995-1008eaaaedec)

Link to the target job:

![image](https://github.com/go-gitea/gitea/assets/18380374/0c11a97f-6517-47f2-8773-f381488c084e)

authored by

yp05327 and committed by
GitHub
f6e77984 3be80a86

+36 -10
+6
models/git/commit_status.go
··· 22 22 "code.gitea.io/gitea/modules/setting" 23 23 api "code.gitea.io/gitea/modules/structs" 24 24 "code.gitea.io/gitea/modules/timeutil" 25 + "code.gitea.io/gitea/modules/translation" 25 26 26 27 "xorm.io/builder" 27 28 "xorm.io/xorm" ··· 189 190 func (status *CommitStatus) APIURL(ctx context.Context) string { 190 191 _ = status.loadAttributes(ctx) 191 192 return status.Repo.APIURL() + "/statuses/" + url.PathEscape(status.SHA) 193 + } 194 + 195 + // LocaleString returns the locale string name of the Status 196 + func (status *CommitStatus) LocaleString(lang translation.Locale) string { 197 + return lang.Tr("repo.commitstatus." + status.State.String()) 192 198 } 193 199 194 200 // CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc
+4
modules/structs/commit_status.go
··· 25 25 CommitStatusSuccess: 3, 26 26 } 27 27 28 + func (css CommitStatusState) String() string { 29 + return string(css) 30 + } 31 + 28 32 // NoBetterThan returns true if this State is no better than the given State 29 33 // This function only handles the states defined in CommitStatusPriorities 30 34 func (css CommitStatusState) NoBetterThan(css2 CommitStatusState) bool {
+5
options/locale/locale_en-US.ini
··· 1280 1280 commit.cherry-pick-header = Cherry-pick: %s 1281 1281 commit.cherry-pick-content = Select branch to cherry-pick onto: 1282 1282 1283 + commitstatus.error = Error 1284 + commitstatus.failure = Failure 1285 + commitstatus.pending = Pending 1286 + commitstatus.success = Success 1287 + 1283 1288 ext_issues = Access to External Issues 1284 1289 ext_issues.desc = Link to an external issue tracker. 1285 1290
+4 -1
routers/web/repo/repo.go
··· 600 600 601 601 results := make([]*repo_service.WebSearchRepository, len(repos)) 602 602 for i, repo := range repos { 603 + latestCommitStatus := git_model.CalcCommitStatus(repoToItsLatestCommitStatuses[repo.ID]) 604 + 603 605 results[i] = &repo_service.WebSearchRepository{ 604 606 Repository: &api.Repository{ 605 607 ID: repo.ID, ··· 613 615 Link: repo.Link(), 614 616 Internal: !repo.IsPrivate && repo.Owner.Visibility == api.VisibleTypePrivate, 615 617 }, 616 - LatestCommitStatus: git_model.CalcCommitStatus(repoToItsLatestCommitStatuses[repo.ID]), 618 + LatestCommitStatus: latestCommitStatus, 619 + LocaleLatestCommitStatus: latestCommitStatus.LocaleString(ctx.Locale), 617 620 } 618 621 } 619 622
+3 -2
services/repository/repository.go
··· 28 28 29 29 // WebSearchRepository represents a repository returned by web search 30 30 type WebSearchRepository struct { 31 - Repository *structs.Repository `json:"repository"` 32 - LatestCommitStatus *git.CommitStatus `json:"latest_commit_status"` 31 + Repository *structs.Repository `json:"repository"` 32 + LatestCommitStatus *git.CommitStatus `json:"latest_commit_status"` 33 + LocaleLatestCommitStatus string `json:"locale_latest_commit_status"` 33 34 } 34 35 35 36 // WebSearchResults results of a successful web search
+14 -7
web_src/js/components/DashboardRepoList.vue
··· 69 69 </div> 70 70 <div v-if="repos.length" class="ui attached table segment gt-rounded-bottom"> 71 71 <ul class="repo-owner-name-list"> 72 - <li class="gt-df gt-ac" v-for="repo, index in repos" :class="{'active': index === activeIndex}" :key="repo.id"> 73 - <a class="repo-list-link muted gt-df gt-ac gt-f1" :href="repo.link"> 72 + <li class="gt-df gt-ac gt-py-3" v-for="repo, index in repos" :class="{'active': index === activeIndex}" :key="repo.id"> 73 + <a class="repo-list-link muted gt-df gt-ac gt-f1 gt-gap-3" :href="repo.link"> 74 74 <svg-icon :name="repoIcon(repo)" :size="16" class-name="repo-list-icon"/> 75 75 <div class="text truncate">{{ repo.full_name }}</div> 76 76 <div v-if="repo.archived"> 77 77 <svg-icon name="octicon-archive" :size="16"/> 78 78 </div> 79 79 </a> 80 - <!-- the commit status icon logic is taken from templates/repo/commit_status.tmpl --> 81 - <svg-icon v-if="repo.latest_commit_status_state" :name="statusIcon(repo.latest_commit_status_state)" :class-name="'gt-ml-3 commit-status icon text ' + statusColor(repo.latest_commit_status_state)" :size="16"/> 80 + <a class="gt-df gt-ac" v-if="repo.latest_commit_status_state" :href="repo.latest_commit_status_state_link" :data-tooltip-content="repo.locale_latest_commit_status_state"> 81 + <!-- the commit status icon logic is taken from templates/repo/commit_status.tmpl --> 82 + <svg-icon :name="statusIcon(repo.latest_commit_status_state)" :class-name="'gt-ml-3 commit-status icon text ' + statusColor(repo.latest_commit_status_state)" :size="16"/> 83 + </a> 82 84 </li> 83 85 </ul> 84 86 <div v-if="showMoreReposLink" class="center gt-py-3 gt-border-secondary-top"> ··· 394 396 } 395 397 396 398 if (searchedURL === this.searchURL) { 397 - this.repos = json.data.map((webSearchRepo) => {return {...webSearchRepo.repository, latest_commit_status_state: webSearchRepo.latest_commit_status.State}}); 399 + this.repos = json.data.map((webSearchRepo) => { 400 + return { 401 + ...webSearchRepo.repository, 402 + latest_commit_status_state: webSearchRepo.latest_commit_status.State, 403 + locale_latest_commit_status_state: webSearchRepo.locale_latest_commit_status, 404 + latest_commit_status_state_link: webSearchRepo.latest_commit_status.TargetURL 405 + }; 406 + }); 398 407 const count = response.headers.get('X-Total-Count'); 399 408 if (searchedQuery === '' && searchedMode === '' && this.archivedFilter === 'both') { 400 409 this.reposTotalCount = count; ··· 494 503 } 495 504 496 505 .repo-list-link { 497 - padding: 6px 0; 498 - gap: 6px; 499 506 min-width: 0; /* for text truncation */ 500 507 } 501 508