Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ linters:
- name: identical-branches
- name: if-return
- name: increment-decrement
- name: indent-error-flow
- name: modifies-value-receiver
- name: package-comments
- name: range
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ export default defineConfig([
'no-dupe-keys': [2],
'no-duplicate-case': [2],
'no-duplicate-imports': [0],
'no-else-return': [2],
'no-else-return': [0],
'no-empty-character-class': [2],
'no-empty-function': [0],
'no-empty-pattern': [2],
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/org/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<td>
<a href="{{.HomeLink}}">{{if and DefaultShowFullName .FullName}}{{.FullName}} ({{.Name}}){{else}}{{.Name}}{{end}}</a>
{{if .Visibility.IsPrivate}}
<span class="text gold">{{svg "octicon-lock"}}</span>
{{svg "octicon-lock"}}
{{end}}
{{if eq .Type 3}}{{/* Reserved organization */}}
<span class="ui mini label">{{ctx.Locale.Tr "admin.users.reserved"}}</span>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/packages/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<td>
<a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>
{{if .Owner.Visibility.IsPrivate}}
<span class="text gold">{{svg "octicon-lock"}}</span>
{{svg "octicon-lock"}}
{{end}}
</td>
<td>{{.Package.Type.Name}}</td>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/repo/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<td>
<a class="tw-break-anywhere" href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>
{{if .Owner.Visibility.IsPrivate}}
<span class="text gold">{{svg "octicon-lock"}}</span>
{{svg "octicon-lock"}}
{{end}}
</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion templates/org/team/repositories.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{{range $.TeamRepos}}
<div class="flex-item tw-items-center">
<div class="flex-item-leading">
{{template "repo/icon" .}}
{{template "repo/icon" (dict "Repo" . "Size" 24)}}
</div>
<div class="flex-item-main">
<a class="flex-item-title text primary" href="{{$.Org.HomeLink}}/{{.Name | PathEscape}}">
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/header.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="repo-header">
<div class="flex-item tw-items-center">
<div class="flex-item-leading">
{{template "repo/icon" .}}
{{template "repo/icon" (dict "Repo" . "Size" 24 "ShowRepoAvatar" true)}}
</div>
<div class="flex-item-main">
<div class="flex-item-title tw-text-18">
Expand Down
26 changes: 18 additions & 8 deletions templates/repo/icon.tmpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
{{$avatarLink := (.RelAvatarLink ctx)}}
{{if $avatarLink}}
<img class="ui avatar tw-align-middle" src="{{$avatarLink}}" width="24" height="24" alt aria-hidden="true">
{{else if $.IsMirror}}
{{svg "octicon-mirror" 24}}
{{else if $.IsFork}}
{{svg "octicon-repo-forked" 24}}
{{/* Template Attributes:
* Repo (string, required): The repo
* Size (int, required): Icon size in pixels
* ShowRepoAvatar (boolean, optional): Render the repo's avatar, if one is set
* ShowRepoOwnerAvatar (boolean, optional): Render the repo's owner avatar
*
* Note: Keep the icon logic in sync with web_src/js/utils/mappings.ts
*/}}
{{$avatarLink := (.Repo.RelAvatarLink ctx)}}
{{if .ShowRepoOwnerAvatar}}
{{ctx.AvatarUtils.Avatar .Repo.Owner .Size}}
{{else if and $avatarLink .ShowRepoAvatar}}
<img class="ui avatar tw-align-middle" src="{{$avatarLink}}" width="{{.Size}}" height="{{.Size}}" alt aria-hidden="true">
{{else if .Repo.IsMirror}}
{{svg "octicon-mirror" .Size}}
{{else if .Repo.IsFork}}
{{svg "octicon-repo-forked" .Size}}
{{else}}
{{svg "octicon-repo" 24}}
{{svg "octicon-repo" .Size}}
{{end}}
4 changes: 2 additions & 2 deletions templates/repo/pulse.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@
<div class="ui attached segment horizontal segments">
{{if .Permission.CanRead ctx.Consts.RepoUnitTypePullRequests}}
<a href="#merged-pull-requests" class="ui attached segment text center">
<span class="text purple">{{svg "octicon-git-pull-request"}}</span> <strong>{{.Activity.MergedPRCount}}</strong><br>
<span class="text purple">{{svg "octicon-git-merge"}}</span> <strong>{{.Activity.MergedPRCount}}</strong><br>
{{ctx.Locale.TrN .Activity.MergedPRCount "repo.activity.merged_prs_count_1" "repo.activity.merged_prs_count_n"}}
</a>
<a href="#proposed-pull-requests" class="ui attached segment text center">
<span class="text green">{{svg "octicon-git-branch"}}</span> <strong>{{.Activity.OpenedPRCount}}</strong><br>
<span class="text green">{{svg "octicon-git-pull-request"}}</span> <strong>{{.Activity.OpenedPRCount}}</strong><br>
{{ctx.Locale.TrN .Activity.OpenedPRCount "repo.activity.opened_prs_count_1" "repo.activity.opened_prs_count_n"}}
</a>
{{end}}
Expand Down
8 changes: 2 additions & 6 deletions templates/shared/repo/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
{{range .Repos}}
<div class="flex-item">
<div class="flex-item-leading">
{{if $.ShowRepoOwnerAvatar}}
{{ctx.AvatarUtils.Avatar .Owner 24}}
{{else}}
{{template "repo/icon" .}}
{{end}}
{{template "repo/icon" (dict "Repo" . "Size" 24 "ShowRepoOwnerAvatar" $.ShowRepoOwnerAvatar "ShowRepoAvatar" true)}}
</div>
<div class="flex-item-main">
<div class="flex-item-header">
Expand Down Expand Up @@ -48,7 +44,7 @@
</a>
{{end}}
<a class="flex-text-inline" href="{{.Link}}/forks">
<span class="tw-contents" aria-label="{{ctx.Locale.Tr "repo.forks"}}">{{svg "octicon-git-branch" 16}}</span>
<span class="tw-contents" aria-label="{{ctx.Locale.Tr "repo.forks"}}">{{svg "octicon-repo-forked" 16}}</span>
<span {{if ge .NumForks 1000}}data-tooltip-content="{{.NumForks}}"{{end}}>{{CountFmt .NumForks}}</span>
</a>
</div>
Expand Down
24 changes: 2 additions & 22 deletions templates/user/settings/repos.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,7 @@
<div class="item {{if not $repo}}tw-py-1{{end}}">{{/* if not repo, then there are "adapt" buttons, so the padding shouldn't be that default large*/}}
<div class="content">
{{if $repo}}
{{if $repo.IsPrivate}}
<span class="text gold icon">{{svg "octicon-lock"}}</span>
{{else if $repo.IsFork}}
<span class="icon">{{svg "octicon-repo-forked"}}</span>
{{else if $repo.IsMirror}}
<span class="icon">{{svg "octicon-mirror"}}</span>
{{else if $repo.IsTemplate}}
<span class="icon">{{svg "octicon-repo-template"}}</span>
Copy link
Contributor

@wxiaoguang wxiaoguang Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsTemplate is missing in icon.tmpl

If intentionally, should the comment #36046 (comment) be added to the template code? ps: I don't understand why IsTemplate is in a separate "group".

Copy link
Member

@lunny lunny Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both mirror repositories and regular repositories(public or private) could be template repositories.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If intentionally, should the comment #36046 (comment) be added to the template code? ps: I don't understand why IsTemplate is in a separate "group".

If intentionally, should the comment #36046 (comment) be added to the template code?

Copy link
Member Author

@silverwind silverwind Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add it. And yes I've implemented that only group 1 is represented with the icon, all other groups are represented with tags in places that have enough room to display them (not on frontpage repo list).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought maybe we should make an exception for templates. I think it's highly unlikely that a repo is both a mirror and a template, so I guess showing a template icon in such a case would make more sense.

{{else}}
<span class="icon">{{svg "octicon-repo"}}</span>
{{end}}
{{template "repo/icon" (dict "Repo" $repo "Size" 16)}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to have labels(private, template & etc.) for this repository

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean adding labels in this specific place (and below)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, it appears that the labels are only shown on the repository detail page. They could also be displayed on the list page, but I’m not sure whether we should enable that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In lists we can add them, yes.

<a class="muted name" href="{{$repo.Link}}">{{$repo.OwnerName}}/{{$repo.Name}}</a>
<span class="text light-3" {{if not (eq $repo.Size 0)}} data-tooltip-content="{{$repo.SizeDetailsString}}"{{end}}>{{FileSize $repo.Size}}</span>
{{if $repo.IsFork}}
Expand Down Expand Up @@ -85,17 +75,7 @@
{{range .Repos}}
<div class="item">
<div class="content flex-text-block">
{{if .IsPrivate}}
{{svg "octicon-lock" 16 "text gold"}}
{{else if .IsFork}}
{{svg "octicon-repo-forked"}}
{{else if .IsMirror}}
{{svg "octicon-mirror"}}
{{else if .IsTemplate}}
{{svg "octicon-repo-template"}}
{{else}}
{{svg "octicon-repo"}}
{{end}}
{{template "repo/icon" (dict "Repo" . "Size" 16)}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the above

<a class="name" href="{{.Link}}">{{.OwnerName}}/{{.Name}}</a>
<span>{{FileSize .Size}}</span>
{{if .IsFork}}
Expand Down
4 changes: 0 additions & 4 deletions web_src/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,6 @@ img.ui.avatar,
color: var(--color-grey-light) !important;
}

.text.gold {
color: var(--color-gold) !important;
}

.text.small {
font-size: 0.75em;
}
Expand Down
1 change: 0 additions & 1 deletion web_src/css/themes/theme-gitea-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ gitea-theme-meta-info {
/* other colors */
--color-grey: #384149;
--color-grey-light: #818f9e;
--color-gold: #b1983b;
--color-white: #ffffff;
--color-diff-added-linenum-bg: #274227;
--color-diff-added-row-bg: #203224;
Expand Down
1 change: 0 additions & 1 deletion web_src/css/themes/theme-gitea-light.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ gitea-theme-meta-info {
/* other colors */
--color-grey: #697077;
--color-grey-light: #7c838a;
--color-gold: #a1882b;
--color-white: #ffffff;
--color-diff-added-linenum-bg: #d1f8d9;
--color-diff-added-row-bg: #e6ffed;
Expand Down
16 changes: 3 additions & 13 deletions web_src/js/components/DashboardRepoList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {nextTick, defineComponent} from 'vue';
import {SvgIcon} from '../svg.ts';
import {GET} from '../modules/fetch.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';
import {getRepoIcon} from '../utils/mappings.ts';

const {appSubUrl, assetUrlPrefix, pageData} = window.config;

Expand Down Expand Up @@ -283,19 +284,8 @@ export default defineComponent({
}
},

repoIcon(repo: any) {
if (repo.fork) {
return 'octicon-repo-forked';
} else if (repo.mirror) {
return 'octicon-mirror';
} else if (repo.template) {
return `octicon-repo-template`;
} else if (repo.private) {
return 'octicon-lock';
} else if (repo.internal) {
return 'octicon-repo';
}
return 'octicon-repo';
repoIcon(repo: Record<string, any>) {
return getRepoIcon(repo);
},

statusIcon(status: CommitStatus) {
Expand Down
10 changes: 10 additions & 0 deletions web_src/js/utils/mappings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// repo icon, keep in sync with templates/repo/icon.tmpl
export function getRepoIcon(repo: Record<string, any>) {
if (repo.mirror) {
return 'octicon-mirror';
} else if (repo.fork) {
return 'octicon-repo-forked';
} else {
return 'octicon-repo';
}
}