mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-14 05:56:14 +01:00
Merge pull request 'Allow org members to navigate between the org and the dashboard' (#3642) from 0ko/forgejo:ui-add-org-dashboard-goto into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3642 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Otto <otto@codeberg.org>
This commit is contained in:
commit
8c3511a8b3
5 changed files with 58 additions and 2 deletions
|
@ -2733,6 +2733,7 @@ org_name_holder = Organization name
|
||||||
org_full_name_holder = Organization full name
|
org_full_name_holder = Organization full name
|
||||||
org_name_helper = Organization names should be short and memorable.
|
org_name_helper = Organization names should be short and memorable.
|
||||||
create_org = Create organization
|
create_org = Create organization
|
||||||
|
open_dashboard = Open dashboard
|
||||||
repo_updated = Updated
|
repo_updated = Updated
|
||||||
members = Members
|
members = Members
|
||||||
teams = Teams
|
teams = Teams
|
||||||
|
|
1
release-notes/8.0.0/feat/3642.md
Normal file
1
release-notes/8.0.0/feat/3642.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Allow navigating to the organization dashboard from the organization view
|
|
@ -7,7 +7,7 @@
|
||||||
{{if .Org.Visibility.IsLimited}}<span class="ui large basic horizontal label">{{ctx.Locale.Tr "org.settings.visibility.limited_shortname"}}</span>{{end}}
|
{{if .Org.Visibility.IsLimited}}<span class="ui large basic horizontal label">{{ctx.Locale.Tr "org.settings.visibility.limited_shortname"}}</span>{{end}}
|
||||||
{{if .Org.Visibility.IsPrivate}}<span class="ui large basic horizontal label">{{ctx.Locale.Tr "org.settings.visibility.private_shortname"}}</span>{{end}}
|
{{if .Org.Visibility.IsPrivate}}<span class="ui large basic horizontal label">{{ctx.Locale.Tr "org.settings.visibility.private_shortname"}}</span>{{end}}
|
||||||
</span>
|
</span>
|
||||||
<span class="tw-flex tw-items-center tw-gap-1 tw-ml-auto tw-text-16 tw-whitespace-nowrap">
|
<span class="tw-flex tw-items-center top-right-buttons tw-ml-auto tw-text-16 tw-whitespace-nowrap">
|
||||||
{{if .EnableFeed}}
|
{{if .EnableFeed}}
|
||||||
<a class="ui basic label button tw-mr-0" href="{{.Org.HomeLink}}.rss" data-tooltip-content="{{ctx.Locale.Tr "rss_feed"}}">
|
<a class="ui basic label button tw-mr-0" href="{{.Org.HomeLink}}.rss" data-tooltip-content="{{ctx.Locale.Tr "rss_feed"}}">
|
||||||
{{svg "octicon-rss" 24}}
|
{{svg "octicon-rss" 24}}
|
||||||
|
@ -16,6 +16,9 @@
|
||||||
{{if .IsSigned}}
|
{{if .IsSigned}}
|
||||||
{{template "org/follow_unfollow" .}}
|
{{template "org/follow_unfollow" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{if .IsOrganizationMember}}
|
||||||
|
<a class="ui basic button tw-mr-0" href="{{.OrgLink}}/dashboard">{{ctx.Locale.Tr "org.open_dashboard"}}</a>
|
||||||
|
{{end}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{{if .RenderedDescription}}<div class="render-content markup">{{.RenderedDescription}}</div>{{end}}
|
{{if .RenderedDescription}}<div class="render-content markup">{{.RenderedDescription}}</div>{{end}}
|
||||||
|
|
|
@ -92,7 +92,7 @@
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<a class="ui primary basic button" href="{{.ContextUser.HomeLink}}" title="{{ctx.Locale.Tr "home.view_home" .ContextUser.Name}}">
|
<a class="ui basic button" href="{{.ContextUser.HomeLink}}" title="{{ctx.Locale.Tr "home.view_home" .ContextUser.Name}}">
|
||||||
{{ctx.Locale.Tr "home.view_home" (.ContextUser.ShortName 40)}}
|
{{ctx.Locale.Tr "home.view_home" (.ContextUser.ShortName 40)}}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
51
tests/integration/org_nav_test.go
Normal file
51
tests/integration/org_nav_test.go
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/tests"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This test makes sure that organization members are able to navigate between `/<orgname>` and `/org/<orgname>/<section>` freely.
|
||||||
|
// The `/org/<orgname>/<section>` page is only accessible to the members of the organization. It doesn't have
|
||||||
|
// a special logic to show the button or not.
|
||||||
|
// The `/<orgname>` page utilizes the `IsOrganizationMember` function to show the button for navigation to
|
||||||
|
// the organization dashboard. That function is covered by a test and is supposed to be true for the
|
||||||
|
// owners/admins/members of the organization.
|
||||||
|
func TestOrgNavigationDashboard(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
// Login as the future organization admin and create an organization
|
||||||
|
session1 := loginUser(t, "user2")
|
||||||
|
session1.MakeRequest(t, NewRequestWithValues(t, "POST", "/org/create", map[string]string{
|
||||||
|
"_csrf": GetCSRF(t, session1, "/org/create"),
|
||||||
|
"org_name": "org_navigation_test",
|
||||||
|
"visibility": "0",
|
||||||
|
"repo_admin_change_team_access": "on",
|
||||||
|
}), http.StatusSeeOther)
|
||||||
|
|
||||||
|
// Check if the "Open dashboard" button is available to the org admin (member)
|
||||||
|
resp := session1.MakeRequest(t, NewRequest(t, "GET", "/org_navigation_test"), http.StatusOK)
|
||||||
|
doc := NewHTMLParser(t, resp.Body)
|
||||||
|
doc.AssertElement(t, "#org-info a[href='/org/org_navigation_test/dashboard']", true)
|
||||||
|
|
||||||
|
// Check if the "View <orgname>" button is available on dashboard for the org admin (member)
|
||||||
|
resp = session1.MakeRequest(t, NewRequest(t, "GET", "/org/org_navigation_test/dashboard"), http.StatusOK)
|
||||||
|
doc = NewHTMLParser(t, resp.Body)
|
||||||
|
doc.AssertElement(t, ".dashboard .secondary-nav a[href='/org_navigation_test']", true)
|
||||||
|
|
||||||
|
// Login a non-member user
|
||||||
|
session2 := loginUser(t, "user4")
|
||||||
|
|
||||||
|
// Check if the "Open dashboard" button is available to non-member
|
||||||
|
resp = session2.MakeRequest(t, NewRequest(t, "GET", "/org_navigation_test"), http.StatusOK)
|
||||||
|
doc = NewHTMLParser(t, resp.Body)
|
||||||
|
doc.AssertElement(t, "#org-info a[href='/org/org_navigation_test/dashboard']", false)
|
||||||
|
|
||||||
|
// There's no need to test "View <orgname>" button on dashboard as non-member
|
||||||
|
// because this page is not supposed to be visitable for this user
|
||||||
|
}
|
Loading…
Reference in a new issue