Skip to content

Commit ec35eb2

Browse files
author
0ko
committed
feat(ui): welcome screen for user dashboard (#7030)
It is shown when there's no activity in the feed. This is a partial implementation of go-gitea/gitea#32990. Differences: * drawer icon instead of package icon * h2 instead of h3 * explore links include a link to organizations list * explore links are hidden for hidden explore sections * locales are in JSON, I think it's the time to start using it, the hint is simpler and doesn't lie about following users to get their updates in the feed, which isn't a feature yet * hint uses general hint color instead of input placeholder color * the large icon still uses placeholder color, but I think it's ok Things to improve later: * use 24px variant of icon. This will require reworking `tools/generate-svg.js` * the vue part wasn't ported, but it'd be also nice to have Inspired-by: Kerwin Bryant <[email protected]> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7030 Reviewed-by: Michael Kriese <[email protected]>
1 parent cddf608 commit ec35eb2

6 files changed

Lines changed: 52 additions & 2 deletions

File tree

options/locale_next/locale_en-US.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"home.welcome.no_activity": "No activity",
3+
"home.welcome.activity_hint": "There is nothing in your feed yet. Your actions and activity from repositories that you watch will show up here.",
4+
"home.explore_repos": "Explore repositories",
5+
"home.explore_users": "Explore users",
6+
"home.explore_orgs": "Explore organizations",
27
"repo.pulls.merged_title_desc": {
38
"one": "merged %[1]d commit from <code>%[2]s</code> into <code>%[3]s</code> %[4]s",
49
"other": "merged %[1]d commits from <code>%[2]s</code> into <code>%[3]s</code> %[4]s"

routers/web/user/home.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ func Dashboard(ctx *context.Context) {
9090
cnt, _ := organization.GetOrganizationCount(ctx, ctxUser)
9191
ctx.Data["UserOrgsCount"] = cnt
9292
ctx.Data["MirrorsEnabled"] = setting.Mirror.Enabled
93+
ctx.Data["UsersPageIsDisabled"] = setting.Service.Explore.DisableUsersPage
94+
ctx.Data["OrganizationsPageIsDisabled"] = setting.Service.Explore.DisableOrganizationsPage
9395
ctx.Data["Date"] = date
9496

9597
var uid int64

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>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div id="empty-feed" class="tw-text-center tw-p-8">
2+
{{svg "octicon-inbox" 64 "tw-text-placeholder-text"}}
3+
<h2>{{ctx.Locale.Tr "home.welcome.no_activity"}}</h2>
4+
<p class="help">{{ctx.Locale.Tr "home.welcome.activity_hint"}}</p>
5+
<div>
6+
<a href="{{AppSubUrl}}/explore/repos">{{ctx.Locale.Tr "home.explore_repos"}}</a>
7+
{{if not .UsersPageIsDisabled}}
8+
<span>·</span>
9+
<a href="{{AppSubUrl}}/explore/users">{{ctx.Locale.Tr "home.explore_users"}}</a>
10+
{{end}}
11+
{{if not .OrganizationsPageIsDisabled}}
12+
<span>·</span>
13+
<a href="{{AppSubUrl}}/explore/organizations">{{ctx.Locale.Tr "home.explore_orgs"}}</a>
14+
{{end}}
15+
</div>
16+
</div>

tests/integration/user_dashboard_test.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright 2024 The Forgejo Authors. All rights reserved.
2-
// SPDX-License-Identifier: MIT
2+
// SPDX-License-Identifier: GPL-3.0-or-later
33

44
package integration
55

@@ -38,6 +38,25 @@ func TestUserDashboardActionLinks(t *testing.T) {
3838
assert.EqualValues(t, locale.TrString("new_org.link"), strings.TrimSpace(links.Find("a[href='/org/create']").Text()))
3939
}
4040

41+
func TestUserDashboardFeedWelcome(t *testing.T) {
42+
require.NoError(t, unittest.PrepareTestDatabase())
43+
44+
// User2 has some activity in feed
45+
session := loginUser(t, "user2")
46+
page := NewHTMLParser(t, session.MakeRequest(t, NewRequest(t, "GET", "/"), http.StatusOK).Body)
47+
testUserDashboardFeedType(t, page, false)
48+
49+
// User1 doesn't have any activity in feed
50+
session = loginUser(t, "user1")
51+
page = NewHTMLParser(t, session.MakeRequest(t, NewRequest(t, "GET", "/"), http.StatusOK).Body)
52+
testUserDashboardFeedType(t, page, true)
53+
}
54+
55+
func testUserDashboardFeedType(t *testing.T, page *HTMLDoc, isEmpty bool) {
56+
page.AssertElement(t, "#activity-feed", !isEmpty)
57+
page.AssertElement(t, "#empty-feed", isEmpty)
58+
}
59+
4160
func TestDashboardTitleRendering(t *testing.T) {
4261
onGiteaRun(t, func(t *testing.T, u *url.URL) {
4362
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4})

web_src/css/dashboard.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,7 @@
7979
.dashboard .secondary-nav .ui.dropdown {
8080
max-width: 100%;
8181
}
82+
83+
.dashboard .help {
84+
color: var(--color-secondary-dark-8);
85+
}

0 commit comments

Comments
 (0)