loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 https://github.com/go-gitea/gitea/pull/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 <kerwin612@qq.com>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7030
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>

0ko ec35eb25 cddf608c

+52 -2
+5
options/locale_next/locale_en-US.json
··· 1 1 { 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", 2 7 "repo.pulls.merged_title_desc": { 3 8 "one": "merged %[1]d commit from <code>%[2]s</code> into <code>%[3]s</code> %[4]s", 4 9 "other": "merged %[1]d commits from <code>%[2]s</code> into <code>%[3]s</code> %[4]s"
+2
routers/web/user/home.go
··· 90 90 cnt, _ := organization.GetOrganizationCount(ctx, ctxUser) 91 91 ctx.Data["UserOrgsCount"] = cnt 92 92 ctx.Data["MirrorsEnabled"] = setting.Mirror.Enabled 93 + ctx.Data["UsersPageIsDisabled"] = setting.Service.Explore.DisableUsersPage 94 + ctx.Data["OrganizationsPageIsDisabled"] = setting.Service.Explore.DisableOrganizationsPage 93 95 ctx.Data["Date"] = date 94 96 95 97 var uid int64
+5 -1
templates/user/dashboard/dashboard.tmpl
··· 5 5 <div class="flex-container-main"> 6 6 {{template "base/alert" .}} 7 7 {{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}} 9 13 </div> 10 14 {{template "user/dashboard/repolist" .}} 11 15 </div>
+16
templates/user/dashboard/guide.tmpl
··· 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>
+20 -1
tests/integration/user_dashboard_test.go
··· 1 1 // Copyright 2024 The Forgejo Authors. All rights reserved. 2 - // SPDX-License-Identifier: MIT 2 + // SPDX-License-Identifier: GPL-3.0-or-later 3 3 4 4 package integration 5 5 ··· 36 36 assert.EqualValues(t, locale.TrString("new_repo.link"), strings.TrimSpace(links.Find("a[href='/repo/create']").Text())) 37 37 assert.EqualValues(t, locale.TrString("new_migrate.link"), strings.TrimSpace(links.Find("a[href='/repo/migrate']").Text())) 38 38 assert.EqualValues(t, locale.TrString("new_org.link"), strings.TrimSpace(links.Find("a[href='/org/create']").Text())) 39 + } 40 + 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) 39 58 } 40 59 41 60 func TestDashboardTitleRendering(t *testing.T) {
+4
web_src/css/dashboard.css
··· 79 79 .dashboard .secondary-nav .ui.dropdown { 80 80 max-width: 100%; 81 81 } 82 + 83 + .dashboard .help { 84 + color: var(--color-secondary-dark-8); 85 + }