Skip to content

Commit d3adc0d

Browse files
committed
refactor
1 parent dad057b commit d3adc0d

File tree

3 files changed

+149
-169
lines changed

3 files changed

+149
-169
lines changed

templates/user/dashboard/repolist.tmpl

+95-78
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,101 @@
1+
<script type="module">
2+
const data = {
3+
...window.config.pageData.dashboardRepoList, // it only contains searchLimit and uid
4+
5+
isMirrorsEnabled: {{.IsMirrorsEnabled}},
6+
isStarsEnabled: {{not .IsDisableStars}},
7+
8+
textRepository: {{.locale.Tr "repository"}},
9+
textOrganization: {{.locale.Tr "organization"}},
10+
textMyRepos: {{.locale.Tr "home.my_repos"}},
11+
textNewRepo: {{.locale.Tr "new_repo"}},
12+
textSearchRepos: {{.locale.Tr "home.search_repos"}},
13+
textFilter: {{.locale.Tr "home.filter"}},
14+
textShowArchived: {{.locale.Tr "home.show_archived"}},
15+
textShowPrivate: {{.locale.Tr "home.show_private"}},
16+
17+
textShowBothArchivedUnarchived: {{.locale.Tr "home.show_both_archived_unarchived"}},
18+
textShowOnlyUnarchived: {{.locale.Tr "home.show_only_unarchived"}},
19+
textShowOnlyArchived: {{.locale.Tr "home.show_only_archived"}},
20+
21+
textShowBothPrivatePublic: {{.locale.Tr "home.show_both_private_public"}},
22+
textShowOnlyPublic: {{.locale.Tr "home.show_only_public"}},
23+
textShowOnlyPrivate: {{.locale.Tr "home.show_only_private"}},
24+
25+
textAll: {{.locale.Tr "all"}},
26+
textSources: {{.locale.Tr "sources"}},
27+
textForks: {{.locale.Tr "forks"}},
28+
textMirrors: {{.locale.Tr "mirrors"}},
29+
textCollaborative: {{.locale.Tr "collaborative"}},
30+
31+
textFirstPage: {{.locale.Tr "admin.first_page"}},
32+
textPreviousPage: {{.locale.Tr "repo.issues.previous"}},
33+
textNextPage: {{.locale.Tr "repo.issues.next"}},
34+
textLastPage: {{.locale.Tr "admin.last_page"}},
35+
36+
textMyOrgs: {{.locale.Tr "home.my_orgs"}},
37+
textNewOrg: {{.locale.Tr "new_org"}},
38+
};
39+
40+
{{if .Team}}
41+
data.teamId = {{.Team.ID}};
42+
{{end}}
43+
44+
{{if not .ContextUser.IsOrganization}}
45+
data.organizations = [{{range .Orgs}}{'name': {{.Name}}, 'num_repos': {{.NumRepos}}},{{end}}];
46+
data.isOrganization = false;
47+
data.organizationsTotalCount = {{.UserOrgsCount}}
48+
data.canCreateOrganization = {{.SignedUser.CanCreateOrganization}}
49+
{{end}}
50+
51+
window.config.pageData.dashboardRepoList = data;
52+
</script>
53+
154
<div id="dashboard-repo-list" class="six wide column">
2-
<repo-search
3-
:search-limit="searchLimit"
4-
:sub-url="subUrl"
5-
:uid="uid"
6-
{{if .Team}}
7-
:team-id="{{.Team.ID}}"
8-
{{end}}
9-
:more-repos-link="'{{.ContextUser.HomeLink}}'"
10-
{{if not .ContextUser.IsOrganization}}
11-
:organizations="[
12-
{{range .Orgs}}
13-
{name: '{{.Name}}', num_repos: '{{.NumRepos}}'},
14-
{{end}}
15-
]"
16-
:is-organization="false"
17-
:organizations-total-count="{{.UserOrgsCount}}"
18-
:can-create-organization="{{.SignedUser.CanCreateOrganization}}"
19-
{{end}}
20-
inline-template
21-
v-cloak
22-
></repo-search>
55+
<repo-search></repo-search>
2356
</div>
2457

2558
<template id="dashboard-repo-list-template">
2659
<div>
2760
<div v-if="!isOrganization" class="ui two item tabable menu">
28-
<a :class="{item: true, active: tab === 'repos'}" @click="changeTab('repos')">{{.locale.Tr "repository"}}</a>
29-
<a :class="{item: true, active: tab === 'organizations'}" @click="changeTab('organizations')">{{.locale.Tr "organization"}}</a>
61+
<a :class="{item: true, active: tab === 'repos'}" @click="changeTab('repos')">${textRepository}</a>
62+
<a :class="{item: true, active: tab === 'organizations'}" @click="changeTab('organizations')">${textOrganization}</a>
3063
</div>
3164
<div v-show="tab === 'repos'" class="ui tab active list dashboard-repos">
3265
<h4 class="ui top attached header gt-df gt-ac">
3366
<div class="gt-f1 gt-df gt-ac">
34-
{{.locale.Tr "home.my_repos"}}
67+
${textMyRepos}
3568
<span class="ui grey label gt-ml-3">${reposTotalCount}</span>
3669
</div>
37-
<a class="tooltip" :href="subUrl + '/repo/create'" data-content="{{.locale.Tr "new_repo"}}" data-position="left center">
38-
{{svg "octicon-plus"}}
39-
<span class="sr-only">{{.locale.Tr "new_repo"}}</span>
70+
<a class="tooltip" :href="subUrl + '/repo/create'" :data-content="textNewRepo" data-position="left center">
71+
<svg-icon name="octicon-plus"></svg-icon>
72+
<span class="sr-only">${textNewRepo}</span>
4073
</a>
4174
</h4>
4275
<div class="ui attached segment repos-search">
4376
<div class="ui fluid right action left icon input" :class="{loading: isLoading}">
44-
<input @input="changeReposFilter(reposFilter)" v-model="searchQuery" ref="search" placeholder="{{.locale.Tr "home.search_repos"}}">
45-
<i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i>
46-
<div class="ui dropdown icon button" title="{{.locale.Tr "home.filter"}}">
47-
<i class="icon gt-df gt-ac gt-jc gt-m-0">{{svg "octicon-filter" 16}}</i>
77+
<input @input="changeReposFilter(reposFilter)" v-model="searchQuery" ref="search" :placeholder="textSearchRepos">
78+
<i class="icon gt-df gt-ac gt-jc"><svg-icon name="octicon-search" :size="16"></svg-icon></i>
79+
<div class="ui dropdown icon button" :title="textFilter">
80+
<i class="icon gt-df gt-ac gt-jc gt-m-0"><svg-icon name="octicon-filter" :size="16"></svg-icon></i>
4881
<div class="menu">
4982
<a class="item" @click="toggleArchivedFilter()">
50-
<div class="ui checkbox"
51-
ref="checkboxArchivedFilter"
52-
data-title-both="{{.locale.Tr "home.show_both_archived_unarchived"}}"
53-
data-title-unarchived="{{.locale.Tr "home.show_only_unarchived"}}"
54-
data-title-archived="{{.locale.Tr "home.show_only_archived"}}"
55-
:title="checkboxArchivedFilterTitle"
56-
>
83+
<div class="ui checkbox" ref="checkboxArchivedFilter" :title="checkboxArchivedFilterTitle">
5784
<!--the "hidden" is necessary to make the checkbox work without Fomantic UI js,
5885
otherwise if the "input" handles click event for intermediate status, it breaks the internal state-->
5986
<input type="checkbox" class="hidden" v-bind.prop="checkboxArchivedFilterProps">
6087
<label>
61-
{{svg "octicon-archive" 16 "gt-mr-2"}}
62-
{{.locale.Tr "home.show_archived"}}
88+
<svg-icon name="octicon-archive" :size="16" class-name="gt-mr-2"></svg-icon>
89+
${textShowArchived}
6390
</label>
6491
</div>
6592
</a>
6693
<a class="item" @click="togglePrivateFilter()">
67-
<div class="ui checkbox"
68-
ref="checkboxPrivateFilter"
69-
data-title-both="{{.locale.Tr "home.show_both_private_public"}}"
70-
data-title-public="{{.locale.Tr "home.show_only_public"}}"
71-
data-title-private="{{.locale.Tr "home.show_only_private"}}"
72-
:title="checkboxPrivateFilterTitle"
73-
>
94+
<div class="ui checkbox" ref="checkboxPrivateFilter" :title="checkboxPrivateFilterTitle">
7495
<input type="checkbox" class="hidden" v-bind.prop="checkboxPrivateFilterProps">
7596
<label>
76-
{{svg "octicon-lock" 16 "gt-mr-2"}}
77-
{{.locale.Tr "home.show_private"}}
97+
<svg-icon name="octicon-lock" :size="16" class-name="gt-mr-2"></svg-icon>
98+
${textShowPrivate}
7899
</label>
79100
</div>
80101
</a>
@@ -83,25 +104,23 @@
83104
</div>
84105
<div class="ui secondary tiny pointing borderless menu center grid repos-filter">
85106
<a class="item" :class="{active: reposFilter === 'all'}" @click="changeReposFilter('all')">
86-
{{.locale.Tr "all"}}
107+
${textAll}
87108
<div v-show="reposFilter === 'all'" class="ui circular mini grey label">${repoTypeCount}</div>
88109
</a>
89110
<a class="item" :class="{active: reposFilter === 'sources'}" @click="changeReposFilter('sources')">
90-
{{.locale.Tr "sources"}}
111+
${textSources}
91112
<div v-show="reposFilter === 'sources'" class="ui circular mini grey label">${repoTypeCount}</div>
92113
</a>
93114
<a class="item" :class="{active: reposFilter === 'forks'}" @click="changeReposFilter('forks')">
94-
{{.locale.Tr "forks"}}
115+
${textForks}
95116
<div v-show="reposFilter === 'forks'" class="ui circular mini grey label">${repoTypeCount}</div>
96117
</a>
97-
{{if .MirrorsEnabled}}
98-
<a class="item" :class="{active: reposFilter === 'mirrors'}" @click="changeReposFilter('mirrors')">
99-
{{.locale.Tr "mirrors"}}
118+
<a class="item" :class="{active: reposFilter === 'mirrors'}" @click="changeReposFilter('mirrors')" v-if="isMirrorsEnabled">
119+
${textMirrors}
100120
<div v-show="reposFilter === 'mirrors'" class="ui circular mini grey label">${repoTypeCount}</div>
101121
</a>
102-
{{end}}
103122
<a class="item" :class="{active: reposFilter === 'collaborative'}" @click="changeReposFilter('collaborative')">
104-
{{.locale.Tr "collaborative"}}
123+
${textCollaborative}
105124
<div v-show="reposFilter === 'collaborative'" class="ui circular mini grey label">${repoTypeCount}</div>
106125
</a>
107126
</div>
@@ -114,36 +133,34 @@
114133
<component v-bind:is="repoIcon(repo)" size="16" class="gt-mr-2"></component>
115134
<div class="text gt-bold truncate gt-ml-1">${repo.full_name}</div>
116135
<span v-if="repo.archived">
117-
{{svg "octicon-archive" 16 "gt-ml-2"}}
136+
<svg-icon name="octicon-archive" :size="16" class-name="gt-ml-2"></svg-icon>
118137
</span>
119138
</div>
120-
{{if not .DisableStars}}
121-
<div class="text light grey gt-df gt-ac">
122-
${repo.stars_count}
123-
{{svg "octicon-star" 16 "gt-ml-2"}}
124-
</div>
125-
{{end}}
139+
<div class="text light grey gt-df gt-ac" v-if="isStarsEnabled">
140+
${repo.stars_count}
141+
<svg-icon name="octicon-star" :size="16" class-name="gt-ml-2"></svg-icon>
142+
</div>
126143
</a>
127144
</li>
128145
</ul>
129146
<div v-if="showMoreReposLink" class="center gt-py-3 gt-border-secondary-top">
130147
<div class="ui borderless pagination menu narrow">
131148
<a class="item navigation gt-py-2" :class="{'disabled': page === 1}"
132-
@click="changePage(1)" title="{{$.locale.Tr "admin.first_page"}}">
133-
{{svg "gitea-double-chevron-left" 16 "gt-mr-2"}}
149+
@click="changePage(1)" :title="textFirstPage">
150+
<svg-icon name="gitea-double-chevron-left" :size="16" class-name="gt-mr-2"></svg-icon>
134151
</a>
135152
<a class="item navigation gt-py-2" :class="{'disabled': page === 1}"
136-
@click="changePage(page - 1)" title="{{$.locale.Tr "repo.issues.previous"}}">
137-
{{svg "octicon-chevron-left" 16 "gt-mr-2"}}
153+
@click="changePage(page - 1)" :title="textPreviousPage">
154+
<svg-icon name="octicon-chevron-left" :size="16" clsas-name="gt-mr-2"></svg-icon>
138155
</a>
139156
<a class="active item gt-py-2">${page}</a>
140157
<a class="item navigation" :class="{'disabled': page === finalPage}"
141-
@click="changePage(page + 1)" title="{{$.locale.Tr "repo.issues.next"}}">
142-
{{svg "octicon-chevron-right" 16 "gt-ml-2"}}
158+
@click="changePage(page + 1)" :title="textNextPage">
159+
<svg-icon name="octicon-chevron-right" :size="16" class-name="gt-ml-2"></svg-icon>
143160
</a>
144161
<a class="item navigation gt-py-2" :class="{'disabled': page === finalPage}"
145-
@click="changePage(finalPage)" title="{{$.locale.Tr "admin.last_page"}}">
146-
{{svg "gitea-double-chevron-right" 16 "gt-ml-2"}}
162+
@click="changePage(finalPage)" :title="textLastPage">
163+
<svg-icon name="gitea-double-chevron-right" :size="16" class-name="gt-ml-2"></svg-icon>
147164
</a>
148165
</div>
149166
</div>
@@ -152,25 +169,25 @@
152169
<div v-if="!isOrganization" v-show="tab === 'organizations'" class="ui tab active list dashboard-orgs">
153170
<h4 class="ui top attached header gt-df gt-ac">
154171
<div class="gt-f1 gt-df gt-ac">
155-
{{.locale.Tr "home.my_orgs"}}
172+
${textMyOrgs}
156173
<span class="ui grey label gt-ml-3">${organizationsTotalCount}</span>
157174
</div>
158-
<a v-if="canCreateOrganization" class="tooltip" :href="subUrl + '/org/create'" data-content="{{.locale.Tr "new_org"}}" data-position="left center">
159-
{{svg "octicon-plus"}}
160-
<span class="sr-only">{{.locale.Tr "new_org"}}</span>
175+
<a v-if="canCreateOrganization" class="tooltip" :href="subUrl + '/org/create'" :data-content="textNewOrg" data-position="left center">
176+
<svg-icon name="octicon-plus"></svg-icon>
177+
<span class="sr-only">${textNewOrg}</span>
161178
</a>
162179
</h4>
163180
<div v-if="organizations.length" class="ui attached table segment gt-rounded-bottom">
164181
<ul class="repo-owner-name-list">
165182
<li v-for="org in organizations">
166183
<a class="repo-list-link gt-df gt-ac gt-sb" :href="subUrl + '/' + encodeURIComponent(org.name)">
167184
<div class="text truncate item-name gt-f1">
168-
{{svg "octicon-organization" 16 "gt-mr-2"}}
185+
<svg-icon name="octicon-organization" :size="16" class-name="gt-mr-2"></svg-icon>
169186
<strong>${org.name}</strong>
170187
</div>
171188
<div class="text light grey gt-df gt-ac">
172189
${org.num_repos}
173-
{{svg "octicon-repo" 16 "gt-ml-2 gt-mt-1"}}
190+
<svg-icon name="octicon-repo" :size="16" class-name="gt-ml-2 gt-mt-1"></svg-icon>
174191
</div>
175192
</a>
176193
</li>

0 commit comments

Comments
 (0)