Skip to content

Commit

Permalink
Remove (almost) server side data rendering from repo-search component…
Browse files Browse the repository at this point in the history
… template
  • Loading branch information
Morlinest committed Aug 20, 2017
1 parent 53e6c94 commit 69865ca
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 40 deletions.
20 changes: 20 additions & 0 deletions public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,26 @@ function initVueComponents(){
type: Number,
required: true
},
orgs: {
type: Array,
default: []
},
isOrg: {
type: Boolean,
default: true
},
canCreateOrg: {
type: Boolean,
default: false
},
orgsTotal: {
type: Number,
default: 0
},
moreReposLink: {
type: String,
default: ''
}
},

data: function() {
Expand Down
88 changes: 48 additions & 40 deletions templates/user/dashboard/dashboard.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,34 @@
{{template "user/dashboard/feeds" .}}
</div>
<div id="app" class="six wide column">
<repo-search :search-limit="searchLimit" :suburl="suburl" :uid="uid" inline-template v-cloak>
<repo-search
:search-limit="searchLimit"
:suburl="suburl"
:uid="uid"
:more-repos-link="'{{.ContextUser.HomeLink}}'"
{{if not .ContextUser.IsOrganization}}
:orgs="[
{{range .ContextUser.Orgs}}
{name: '{{.Name}}', num_repos: '{{.NumRepos}}'},
{{end}}
]"
:is-org="false"
:orgs-total="{{.ContextUser.GetOrganizationCount}}"
:can-create-org="{{.SignedUser.CanCreateOrganization}}"
{{end}}
inline-template
v-cloak
>
<div>
{{if not .ContextUser.IsOrganization}}
<div class="ui two item stackable tabable menu">
<div v-if="!isOrg" class="ui two item stackable tabable menu">
<a :class="{item: true, active: tab === 'repos'}" @click="changeTab('repos')">{{.i18n.Tr "repository"}}</a>
<a :class="{item: true, active: tab === 'orgs'}" @click="changeTab('orgs')">{{.i18n.Tr "organization"}}</a>
</div>
{{end}}
<div v-if="tab === 'repos'" class="ui tab active list">
<div v-show="tab === 'repos'" class="ui tab active list">
<h4 class="ui top attached header">
{{.i18n.Tr "home.my_repos"}} <span class="ui grey label">${ reposTotal }</span>
{{.i18n.Tr "home.my_repos"}} <span class="ui grey label">${reposTotal}</span>
<div class="ui right">
<a class="poping up" href="{{AppSubUrl}}/repo/create" data-content="{{.i18n.Tr "new_repo"}}" data-variation="tiny inverted" data-position="left center">
<a class="poping up" :href="suburl + '/repo/create>'" data-content="{{.i18n.Tr "new_repo"}}" data-variation="tiny inverted" data-position="left center">
<i class="plus icon"></i>
<span class="sr-only">{{.i18n.Tr "new_repo"}}</span>
</a>
Expand All @@ -42,51 +57,44 @@
<div class="ui attached table segment">
<ul class="repo-owner-name-list">
<li v-for="repo in repos" :class="{'private': repo.private}" v-show="showRepo(repo, reposFilter)">
<a :href="'{{AppSubUrl}}/' + repo.full_name">
<a :href="suburl + '/' + repo.full_name">
<i :class="repoClass(repo)"></i>
<strong class="text truncate item-name">${ repo.full_name }</strong>
<strong class="text truncate item-name">${repo.full_name}</strong>
<span class="ui right text light grey">
${ repo.stars_count } <i class="octicon octicon-star rear"></i>
${repo.stars_count} <i class="octicon octicon-star rear"></i>
</span>
</a>
</li>
<li v-if="repos.length < reposTotal">
<a href="{{.ContextUser.HomeLink}}">{{.i18n.Tr "home.show_more_repos"}}</a>
<a :href="moreReposLink">{{.i18n.Tr "home.show_more_repos"}}</a>
</li>
</ul>
</div>
</div>

{{if not .ContextUser.IsOrganization}}
<div v-if="tab === 'orgs'" class="ui tab active list">
<h4 class="ui top attached header">
{{.i18n.Tr "home.my_orgs"}} <span class="ui grey label">{{.ContextUser.GetOrganizationCount}}</span>
<div class="ui right">
{{if .SignedUser.CanCreateOrganization}}
<a class="poping up" href="{{AppSubUrl}}/org/create" data-content="{{.i18n.Tr "new_org"}}" data-variation="tiny inverted" data-position="left center">
<i class="plus icon"></i>
<span class="sr-only">{{.i18n.Tr "new_org"}}</span>
</a>
{{end}}
</div>
</h4>
<div class="ui attached table segment">
<ul class="repo-owner-name-list">
{{range .ContextUser.Orgs}}
<li>
<a href="{{AppSubUrl}}/{{.Name}}">
<i class="octicon octicon-organization"></i>
<strong class="text truncate item-name">{{.Name}}</strong>
<span class="ui right text light grey">
{{.NumRepos}} <i class="octicon octicon-repo rear"></i>
</span>
</a>
</li>
{{end}}
</ul>
<div v-if="!isOrg" v-show="tab === 'orgs'" class="ui tab active list">
<h4 class="ui top attached header">
{{.i18n.Tr "home.my_orgs"}} <span class="ui grey label">${orgsTotal}</span>
<div v-if="canCreateOrg" class="ui right">
<a class="poping up" :href="suburl + '/org/create'" data-content="{{.i18n.Tr "new_org"}}" data-variation="tiny inverted" data-position="left center">
<i class="plus icon"></i>
<span class="sr-only">{{.i18n.Tr "new_org"}}</span>
</a>
</div>
</h4>
<div class="ui attached table segment">
<ul class="repo-owner-name-list">
<li v-for="org in orgs">
<a :href="suburl + '/' + org.name">
<i class="octicon octicon-organization"></i>
<strong class="text truncate item-name">${org.name}</strong>
<span class="ui right text light grey">
${org.num_repos} <i class="octicon octicon-repo rear"></i>
</span>
</a>
</li>
</ul>
</div>
{{end}}
</div>
</div>
</repo-search>
</div>
Expand Down

0 comments on commit 69865ca

Please sign in to comment.