enhance(repo): make Commit Graph discoverable and fix UI (#40570)

The commit graph was only discoverable from the Commits page, which made
an existing feature hard to find. Add the same "Commit Graph" button to
the Activity page header beside the period selector and keep the
original button in place.

<table><tr><td><img
src="https://raw.githubusercontent.com/TuanNancy/gitea/assets/pr-40570-screenshots/screenshots/pr-40570-before.png"
width="512" alt="Before: Activity header without Commit
Graph"></td><td><img
src="https://raw.githubusercontent.com/TuanNancy/gitea/assets/pr-40570-screenshots/screenshots/pr-40570-after.png"
width="512" alt="After: Activity header with Commit Graph
button"></td></tr></table>

Fixes: https://github.com/go-gitea/gitea/issues/6140

Assisted-by: OpenCode:hy4-flash-free

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Vu Nguyen Anh Tuanandwxiaoguang authored and GitHub committed 2026-11-29 01:16:29 +00:00
1 parent b22f1fed80
commit 024af0ebca
6 files changed
+48 -36

No files matched your search

+1
View File
@@ -26,6 +26,7 @@ Search "repo/branch_dropdown" in the template directory to find all occurrences.
data-text-create-ref-from="{{ctx.Locale.Tr "repo.branch.create_from"}}"
data-text-no-results="{{ctx.Locale.Tr "no_results_found"}}"
data-text-view-all-branches="{{ctx.Locale.Tr "repo.view_all_branches"}}"
data-text-view-commit-graph="{{ctx.Locale.Tr "repo.commit_graph"}}"
data-text-view-all-tags="{{ctx.Locale.Tr "repo.view_all_tags"}}"
data-current-repo-default-branch="{{.Repository.DefaultBranch}}"
+1 -1
View File
@@ -9,7 +9,7 @@
<div class="ui multiple selection search dropdown" id="flow-select-refs-dropdown">
<input type="hidden" name="flow">
<div class="default text">{{ctx.Locale.Tr "repo.commit_graph.select"}}</div>
<div class="menu">
<div class="menu flex-items-menu">
<div class="item" data-value="...flow-hide-pr-refs">
{{svg "octicon-eye-closed"}}
<span class="gt-ellipsis" title="{{ctx.Locale.Tr "repo.commit_graph.hide_pr_refs"}}">{{ctx.Locale.Tr "repo.commit_graph.hide_pr_refs"}}</span>
+20 -14
View File
@@ -1,20 +1,26 @@
<h2 class="ui header activity-header">
<h2 class="ui header flex-left-right">
<span>{{DateUtils.AbsoluteLong .DateFrom}} - {{DateUtils.AbsoluteLong .DateUntil}}</span>
<!-- Period -->
<div class="ui floating dropdown jump">
<div class="ui basic compact button">
{{ctx.Locale.Tr "repo.activity.period.filter_label"}} <strong>{{.PeriodText}}</strong>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
</div>
<div class="left menu">
<a class="{{if eq .Period "daily"}}active {{end}}item" href="{{$.RepoLink}}/activity/daily">{{ctx.Locale.Tr "repo.activity.period.daily"}}</a>
<a class="{{if eq .Period "halfweekly"}}active {{end}}item" href="{{$.RepoLink}}/activity/halfweekly">{{ctx.Locale.Tr "repo.activity.period.halfweekly"}}</a>
<a class="{{if eq .Period "weekly"}}active {{end}}item" href="{{$.RepoLink}}/activity/weekly">{{ctx.Locale.Tr "repo.activity.period.weekly"}}</a>
<a class="{{if eq .Period "monthly"}}active {{end}}item" href="{{$.RepoLink}}/activity/monthly">{{ctx.Locale.Tr "repo.activity.period.monthly"}}</a>
<a class="{{if eq .Period "quarterly"}}active {{end}}item" href="{{$.RepoLink}}/activity/quarterly">{{ctx.Locale.Tr "repo.activity.period.quarterly"}}</a>
<a class="{{if eq .Period "semiyearly"}}active {{end}}item" href="{{$.RepoLink}}/activity/semiyearly">{{ctx.Locale.Tr "repo.activity.period.semiyearly"}}</a>
<a class="{{if eq .Period "yearly"}}active {{end}}item" href="{{$.RepoLink}}/activity/yearly">{{ctx.Locale.Tr "repo.activity.period.yearly"}}</a>
<div>
<div class="ui floating dropdown jump">
<div class="ui basic compact button">
{{ctx.Locale.Tr "repo.activity.period.filter_label"}} <strong>{{.PeriodText}}</strong>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
</div>
<div class="left menu">
<a class="{{if eq .Period "daily"}}active {{end}}item" href="{{$.RepoLink}}/activity/daily">{{ctx.Locale.Tr "repo.activity.period.daily"}}</a>
<a class="{{if eq .Period "halfweekly"}}active {{end}}item" href="{{$.RepoLink}}/activity/halfweekly">{{ctx.Locale.Tr "repo.activity.period.halfweekly"}}</a>
<a class="{{if eq .Period "weekly"}}active {{end}}item" href="{{$.RepoLink}}/activity/weekly">{{ctx.Locale.Tr "repo.activity.period.weekly"}}</a>
<a class="{{if eq .Period "monthly"}}active {{end}}item" href="{{$.RepoLink}}/activity/monthly">{{ctx.Locale.Tr "repo.activity.period.monthly"}}</a>
<a class="{{if eq .Period "quarterly"}}active {{end}}item" href="{{$.RepoLink}}/activity/quarterly">{{ctx.Locale.Tr "repo.activity.period.quarterly"}}</a>
<a class="{{if eq .Period "semiyearly"}}active {{end}}item" href="{{$.RepoLink}}/activity/semiyearly">{{ctx.Locale.Tr "repo.activity.period.semiyearly"}}</a>
<a class="{{if eq .Period "yearly"}}active {{end}}item" href="{{$.RepoLink}}/activity/yearly">{{ctx.Locale.Tr "repo.activity.period.yearly"}}</a>
</div>
</div>
<a href="{{$.RepoLink}}/graph" class="ui basic compact button">
{{svg "octicon-git-branch"}}
{{ctx.Locale.Tr "repo.commit_graph"}}
</a>
</div>
</h2>
+4
View File
@@ -269,6 +269,10 @@ select.ui.dropdown {
border-bottom-right-radius: 0 !important;
}
.ui.buttons .ui.selection.active.dropdown + .ui.button {
border-left-color: var(--color-primary);
}
.ui.selection.active.dropdown .menu {
border-color: var(--color-primary);
box-shadow: 0 6px 18px var(--color-shadow);
+11 -14
View File
@@ -907,13 +907,6 @@
color: inherit;
}
.repository .activity-header {
display: flex;
justify-content: space-between;
gap: 8px;
flex-wrap: wrap;
}
/* if the element is for a checkbox, then it should have a padding-left to align to the checkbox's text */
.repository.settings.branches .branch-protection .ui.checkbox .help,
.repository.settings.branches .branch-protection .checkbox-sub-item {
@@ -1678,8 +1671,18 @@ tbody.commit-list {
margin-top: 4px;
}
.ui.dropdown.branch-selector-dropdown .scrolling.menu {
.ui.dropdown.branch-selector-dropdown > .menu > .scrolling.menu {
max-width: min(400px, 90vw);
border-top: none;
padding-bottom: 0;
display: flex;
flex-direction: column;
gap: 0.25em;
}
.ui.dropdown.branch-selector-dropdown .menu .item {
min-height: 30px;
padding: 0 10px !important;
}
.branch-selector-dropdown .ui.button.branch-dropdown-button {
@@ -1727,13 +1730,7 @@ tbody.commit-list {
border-top: 1px solid var(--color-secondary);
}
.branch-selector-dropdown .scrolling.menu {
border-top: none !important;
}
.branch-selector-dropdown .menu .item .rss-icon {
position: absolute;
right: 4px;
visibility: hidden; /* only show RSS icon on hover */
}
@@ -48,6 +48,7 @@ const textCreateBranch = props.elRoot.getAttribute('data-text-create-branch')!;
const textCreateRefFrom = props.elRoot.getAttribute('data-text-create-ref-from')!;
const textNoResults = props.elRoot.getAttribute('data-text-no-results')!;
const textViewAllBranches = props.elRoot.getAttribute('data-text-view-all-branches')!;
const textViewCommitGraph = props.elRoot.getAttribute('data-text-view-commit-graph')!;
const textViewAllTags = props.elRoot.getAttribute('data-text-view-all-tags')!;
const currentRepoDefaultBranch = props.elRoot.getAttribute('data-current-repo-default-branch')!;
@@ -214,7 +215,7 @@ async function loadTabItems() {
}
</script>
<template>
<div class="ui dropdown custom branch-selector-dropdown ellipsis-text-items" ref="elDropdown">
<div class="ui dropdown custom branch-selector-dropdown" ref="elDropdown">
<div tabindex="0" class="ui compact button branch-dropdown-button" @click="menuVisible = !menuVisible">
<span class="flex-text-block gt-ellipsis">
<template v-if="dropdownFixedText">{{ dropdownFixedText }}</template>
@@ -241,14 +242,16 @@ async function loadTabItems() {
</button>
</div>
<div class="branch-tag-divider"/>
<div class="scrolling menu" ref="elScrollContainer">
<div class="scrolling menu flex-items-menu" ref="elScrollContainer">
<svg-icon name="octicon-rss" symbol-id="svg-symbol-octicon-rss"/>
<div class="loading-indicator is-loading" v-if="tabLoadingStates[selectedTab] === 'loading'"/>
<div v-for="(item, index) in filteredItems" :key="item.refShortName" class="item" :class="{selected: item.selected, active: activeItemIndex === index}" @click="selectItem(item)">
{{ item.refShortName }}
<div class="ui label" v-if="item.refType === 'branch' && item.refShortName === currentRepoDefaultBranch">
{{ textDefaultBranchLabel }}
</div>
<span class="tw-flex-1 gt-ellipsis">
{{ item.refShortName }}
<span class="ui label" v-if="item.refType === 'branch' && item.refShortName === currentRepoDefaultBranch">
{{ textDefaultBranchLabel }}
</span>
</span>
<a v-if="enableFeed && selectedTab === 'branches'" role="button" class="rss-icon" target="_blank" @click.stop :href="item.rssFeedLink">
<!-- creating a lot of Vue component is pretty slow, so we use a static SVG here -->
<svg width="14" height="14" class="svg octicon-rss"><use href="#svg-symbol-octicon-rss"/></svg>
@@ -277,8 +280,9 @@ async function loadTabItems() {
{{ textNoResults }}
</div>
<template v-if="showViewAllRefsEntry">
<div class="divider tw-m-0"/>
<div class="divider"/>
<a v-if="selectedTab === 'branches'" class="item" :href="currentRepoLink + '/branches'">{{ textViewAllBranches }}</a>
<a v-if="selectedTab === 'branches'" class="item" :href="currentRepoLink + '/graph'">{{ textViewCommitGraph }}</a>
<a v-if="selectedTab === 'tags'" class="item" :href="currentRepoLink + '/tags'">{{ textViewAllTags }}</a>
</template>
</div>