Skip to content

Commit 69865ca

Browse files
committed
Remove (almost) server side data rendering from repo-search component template
1 parent 53e6c94 commit 69865ca

File tree

2 files changed

+68
-40
lines changed

2 files changed

+68
-40
lines changed

public/js/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,26 @@ function initVueComponents(){
16871687
type: Number,
16881688
required: true
16891689
},
1690+
orgs: {
1691+
type: Array,
1692+
default: []
1693+
},
1694+
isOrg: {
1695+
type: Boolean,
1696+
default: true
1697+
},
1698+
canCreateOrg: {
1699+
type: Boolean,
1700+
default: false
1701+
},
1702+
orgsTotal: {
1703+
type: Number,
1704+
default: 0
1705+
},
1706+
moreReposLink: {
1707+
type: String,
1708+
default: ''
1709+
}
16901710
},
16911711

16921712
data: function() {

templates/user/dashboard/dashboard.tmpl

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,34 @@
88
{{template "user/dashboard/feeds" .}}
99
</div>
1010
<div id="app" class="six wide column">
11-
<repo-search :search-limit="searchLimit" :suburl="suburl" :uid="uid" inline-template v-cloak>
11+
<repo-search
12+
:search-limit="searchLimit"
13+
:suburl="suburl"
14+
:uid="uid"
15+
:more-repos-link="'{{.ContextUser.HomeLink}}'"
16+
{{if not .ContextUser.IsOrganization}}
17+
:orgs="[
18+
{{range .ContextUser.Orgs}}
19+
{name: '{{.Name}}', num_repos: '{{.NumRepos}}'},
20+
{{end}}
21+
]"
22+
:is-org="false"
23+
:orgs-total="{{.ContextUser.GetOrganizationCount}}"
24+
:can-create-org="{{.SignedUser.CanCreateOrganization}}"
25+
{{end}}
26+
inline-template
27+
v-cloak
28+
>
1229
<div>
13-
{{if not .ContextUser.IsOrganization}}
14-
<div class="ui two item stackable tabable menu">
30+
<div v-if="!isOrg" class="ui two item stackable tabable menu">
1531
<a :class="{item: true, active: tab === 'repos'}" @click="changeTab('repos')">{{.i18n.Tr "repository"}}</a>
1632
<a :class="{item: true, active: tab === 'orgs'}" @click="changeTab('orgs')">{{.i18n.Tr "organization"}}</a>
1733
</div>
18-
{{end}}
19-
<div v-if="tab === 'repos'" class="ui tab active list">
34+
<div v-show="tab === 'repos'" class="ui tab active list">
2035
<h4 class="ui top attached header">
21-
{{.i18n.Tr "home.my_repos"}} <span class="ui grey label">${ reposTotal }</span>
36+
{{.i18n.Tr "home.my_repos"}} <span class="ui grey label">${reposTotal}</span>
2237
<div class="ui right">
23-
<a class="poping up" href="{{AppSubUrl}}/repo/create" data-content="{{.i18n.Tr "new_repo"}}" data-variation="tiny inverted" data-position="left center">
38+
<a class="poping up" :href="suburl + '/repo/create>'" data-content="{{.i18n.Tr "new_repo"}}" data-variation="tiny inverted" data-position="left center">
2439
<i class="plus icon"></i>
2540
<span class="sr-only">{{.i18n.Tr "new_repo"}}</span>
2641
</a>
@@ -42,51 +57,44 @@
4257
<div class="ui attached table segment">
4358
<ul class="repo-owner-name-list">
4459
<li v-for="repo in repos" :class="{'private': repo.private}" v-show="showRepo(repo, reposFilter)">
45-
<a :href="'{{AppSubUrl}}/' + repo.full_name">
60+
<a :href="suburl + '/' + repo.full_name">
4661
<i :class="repoClass(repo)"></i>
47-
<strong class="text truncate item-name">${ repo.full_name }</strong>
62+
<strong class="text truncate item-name">${repo.full_name}</strong>
4863
<span class="ui right text light grey">
49-
${ repo.stars_count } <i class="octicon octicon-star rear"></i>
64+
${repo.stars_count} <i class="octicon octicon-star rear"></i>
5065
</span>
5166
</a>
5267
</li>
5368
<li v-if="repos.length < reposTotal">
54-
<a href="{{.ContextUser.HomeLink}}">{{.i18n.Tr "home.show_more_repos"}}</a>
69+
<a :href="moreReposLink">{{.i18n.Tr "home.show_more_repos"}}</a>
5570
</li>
5671
</ul>
5772
</div>
5873
</div>
59-
60-
{{if not .ContextUser.IsOrganization}}
61-
<div v-if="tab === 'orgs'" class="ui tab active list">
62-
<h4 class="ui top attached header">
63-
{{.i18n.Tr "home.my_orgs"}} <span class="ui grey label">{{.ContextUser.GetOrganizationCount}}</span>
64-
<div class="ui right">
65-
{{if .SignedUser.CanCreateOrganization}}
66-
<a class="poping up" href="{{AppSubUrl}}/org/create" data-content="{{.i18n.Tr "new_org"}}" data-variation="tiny inverted" data-position="left center">
67-
<i class="plus icon"></i>
68-
<span class="sr-only">{{.i18n.Tr "new_org"}}</span>
69-
</a>
70-
{{end}}
71-
</div>
72-
</h4>
73-
<div class="ui attached table segment">
74-
<ul class="repo-owner-name-list">
75-
{{range .ContextUser.Orgs}}
76-
<li>
77-
<a href="{{AppSubUrl}}/{{.Name}}">
78-
<i class="octicon octicon-organization"></i>
79-
<strong class="text truncate item-name">{{.Name}}</strong>
80-
<span class="ui right text light grey">
81-
{{.NumRepos}} <i class="octicon octicon-repo rear"></i>
82-
</span>
83-
</a>
84-
</li>
85-
{{end}}
86-
</ul>
74+
<div v-if="!isOrg" v-show="tab === 'orgs'" class="ui tab active list">
75+
<h4 class="ui top attached header">
76+
{{.i18n.Tr "home.my_orgs"}} <span class="ui grey label">${orgsTotal}</span>
77+
<div v-if="canCreateOrg" class="ui right">
78+
<a class="poping up" :href="suburl + '/org/create'" data-content="{{.i18n.Tr "new_org"}}" data-variation="tiny inverted" data-position="left center">
79+
<i class="plus icon"></i>
80+
<span class="sr-only">{{.i18n.Tr "new_org"}}</span>
81+
</a>
8782
</div>
83+
</h4>
84+
<div class="ui attached table segment">
85+
<ul class="repo-owner-name-list">
86+
<li v-for="org in orgs">
87+
<a :href="suburl + '/' + org.name">
88+
<i class="octicon octicon-organization"></i>
89+
<strong class="text truncate item-name">${org.name}</strong>
90+
<span class="ui right text light grey">
91+
${org.num_repos} <i class="octicon octicon-repo rear"></i>
92+
</span>
93+
</a>
94+
</li>
95+
</ul>
8896
</div>
89-
{{end}}
97+
</div>
9098
</div>
9199
</repo-search>
92100
</div>

0 commit comments

Comments
 (0)