Skip to content

Commit 085f273

Browse files
Optimize the dashboard (#32990)
before: ![image](https://github.com/user-attachments/assets/d0b432e4-a521-4540-a489-d18b9c265674) after: ![image](https://github.com/user-attachments/assets/dbb8b387-d150-41e2-b12b-f9d8450e36d7) ----- ![image](https://github.com/user-attachments/assets/40dcd71e-344b-4043-9811-77227c71aed9) ----- Optimize the dashboard by adding welcoming messages or quick action entry points (such as adding a new repository or organization) to ensure that new users are not greeted by a blank page upon logging in. --------- Co-authored-by: wxiaoguang <[email protected]>
1 parent 72518a8 commit 085f273

File tree

5 files changed

+55
-7
lines changed

5 files changed

+55
-7
lines changed

options/locale/locale_en-US.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,13 @@ show_only_public = Showing only public
385385

386386
issues.in_your_repos = In your repositories
387387

388+
guide_title = No Activity
389+
guide_desc = You are currently not following any repositories or users, so there is no content to display. You can explore repositories or users of interest from the links below.
390+
explore_repos = Explore repositories
391+
explore_users = Explore users
392+
empty_org = There are no organizations yet.
393+
empty_repo = There are no repositories yet.
394+
388395
[explore]
389396
repos = Repositories
390397
users = Users

templates/user/dashboard/dashboard.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
<div class="flex-container-main">
66
{{template "base/alert" .}}
77
{{template "user/heatmap" .}}
8-
{{template "user/dashboard/feeds" .}}
8+
{{if .Feeds}}
9+
{{template "user/dashboard/feeds" .}}
10+
{{else}}
11+
{{template "user/dashboard/guide" .}}
12+
{{end}}
913
</div>
1014
{{template "user/dashboard/repolist" .}}
1115
</div>

templates/user/dashboard/guide.tmpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div class="tw-text-center tw-p-8">
2+
{{svg "octicon-package" 24 "tw-text-placeholder-text"}}
3+
<h3 class="tw-my-4">{{ctx.Locale.Tr "home.guide_title"}}</h3>
4+
<p class="tw-text-placeholder-text">{{ctx.Locale.Tr "home.guide_desc"}}</p>
5+
<div>
6+
<a href="{{AppSubUrl}}/explore/repos">{{ctx.Locale.Tr "home.explore_repos"}}</a>
7+
<span>·</span>
8+
<a href="{{AppSubUrl}}/explore/users">{{ctx.Locale.Tr "home.explore_users"}}</a>
9+
</div>
10+
</div>

templates/user/dashboard/repolist.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ const data = {
55
isMirrorsEnabled: {{.MirrorsEnabled}},
66
isStarsEnabled: {{not .IsDisableStars}},
77

8+
canCreateMigrations: {{not .DisableMigrations}},
9+
10+
textNoOrg: {{ctx.Locale.Tr "home.empty_org"}},
11+
textNoRepo: {{ctx.Locale.Tr "home.empty_repo"}},
812
textRepository: {{ctx.Locale.Tr "repository"}},
913
textOrganization: {{ctx.Locale.Tr "organization"}},
1014
textMyRepos: {{ctx.Locale.Tr "home.my_repos"}},

web_src/js/components/DashboardRepoList.vue

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export default defineComponent({
113113
this.changeReposFilter(this.reposFilter);
114114
fomanticQuery(el.querySelector('.ui.dropdown')).dropdown();
115115
nextTick(() => {
116-
this.$refs.search.focus();
116+
this.$refs.search?.focus();
117117
});
118118
119119
this.textArchivedFilterTitles = {
@@ -243,7 +243,7 @@ export default defineComponent({
243243
if (!this.reposTotalCount) {
244244
const totalCountSearchURL = `${this.subUrl}/repo/search?count_only=1&uid=${this.uid}&team_id=${this.teamId}&q=&page=1&mode=`;
245245
response = await GET(totalCountSearchURL);
246-
this.reposTotalCount = response.headers.get('X-Total-Count') ?? '?';
246+
this.reposTotalCount = parseInt(response.headers.get('X-Total-Count') ?? '0');
247247
}
248248
249249
response = await GET(searchedURL);
@@ -336,7 +336,6 @@ export default defineComponent({
336336
},
337337
},
338338
});
339-
340339
</script>
341340
<template>
342341
<div>
@@ -354,7 +353,15 @@ export default defineComponent({
354353
<svg-icon name="octicon-plus"/>
355354
</a>
356355
</h4>
357-
<div class="ui attached segment repos-search">
356+
<div v-if="!reposTotalCount" class="ui attached segment">
357+
<div v-if="!isLoading" class="empty-repo-or-org">
358+
<svg-icon name="octicon-git-branch" :size="24"/>
359+
<p>{{ textNoRepo }}</p>
360+
</div>
361+
<!-- using the loading indicator here will cause more (unnecessary) page flickers, so at the moment, not use the loading indicator -->
362+
<!-- <div v-else class="is-loading loading-icon-2px tw-min-h-16"/> -->
363+
</div>
364+
<div v-else class="ui attached segment repos-search">
358365
<div class="ui small fluid action left icon input">
359366
<input type="search" spellcheck="false" maxlength="255" @input="changeReposFilter(reposFilter)" v-model="searchQuery" ref="search" @keydown="reposFilterKeyControl" :placeholder="textSearchRepos">
360367
<i class="icon loading-icon-3px" :class="{'is-loading': isLoading}"><svg-icon name="octicon-search" :size="16"/></i>
@@ -438,7 +445,7 @@ export default defineComponent({
438445
class="item navigation tw-py-1" :class="{'disabled': page === 1}"
439446
@click="changePage(page - 1)" :title="textPreviousPage"
440447
>
441-
<svg-icon name="octicon-chevron-left" :size="16" clsas-name="tw-mr-1"/>
448+
<svg-icon name="octicon-chevron-left" :size="16" clsas="tw-mr-1"/>
442449
</a>
443450
<a class="active item tw-py-1">{{ page }}</a>
444451
<a
@@ -467,7 +474,13 @@ export default defineComponent({
467474
<svg-icon name="octicon-plus"/>
468475
</a>
469476
</h4>
470-
<div v-if="organizations.length" class="ui attached table segment tw-rounded-b">
477+
<div v-if="!organizations.length" class="ui attached segment">
478+
<div class="empty-repo-or-org">
479+
<svg-icon name="octicon-organization" :size="24"/>
480+
<p>{{ textNoOrg }}</p>
481+
</div>
482+
</div>
483+
<div v-else class="ui attached table segment tw-rounded-b">
471484
<ul class="repo-owner-name-list">
472485
<li class="tw-flex tw-items-center tw-py-2" v-for="org in organizations" :key="org.name">
473486
<a class="repo-list-link muted" :href="subUrl + '/' + encodeURIComponent(org.name)">
@@ -546,4 +559,14 @@ ul li:not(:last-child) {
546559
.repo-owner-name-list li.active {
547560
background: var(--color-hover);
548561
}
562+
563+
.empty-repo-or-org {
564+
margin-top: 1em;
565+
text-align: center;
566+
color: var(--color-placeholder-text);
567+
}
568+
569+
.empty-repo-or-org p {
570+
margin: 1em auto;
571+
}
549572
</style>

0 commit comments

Comments
 (0)