Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfc7e2d4

Browse files
committed
fix: show org summary page if not entitled
You cannot edit the settings without being entitled, so show the summarypage instead.
1 parentbec6a26 commitfc7e2d4

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

‎site/src/pages/ManagementSettingsPage/OrganizationSettingsPage.stories.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const meta: Meta<typeof OrganizationSettingsPage> = {
1010
decorators:[withAuthProvider,withDashboardProvider],
1111
parameters:{
1212
user:MockUser,
13+
features:["multiple_organizations"],
1314
permissions:{viewDeploymentValues:true},
1415
queries:[
1516
{
@@ -61,3 +62,23 @@ export const CanEditOrganization: Story = {
6162
],
6263
},
6364
};
65+
66+
exportconstCanEditOrganizationNotEntitled:Story={
67+
parameters:{
68+
reactRouter:reactRouterParameters({
69+
location:{pathParams:{organization:MockDefaultOrganization.name}},
70+
routing:{path:"/organizations/:organization"},
71+
}),
72+
features:[],
73+
queries:[
74+
{
75+
key:["organizations",[MockDefaultOrganization.id],"permissions"],
76+
data:{
77+
[MockDefaultOrganization.id]:{
78+
editOrganization:true,
79+
},
80+
},
81+
},
82+
],
83+
},
84+
};

‎site/src/pages/ManagementSettingsPage/OrganizationSettingsPage.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { screen, within } from "@testing-library/react";
22
import{http,HttpResponse}from"msw";
33
import{
44
MockDefaultOrganization,
5+
MockEntitlementsWithMultiOrg,
56
MockOrganization2,
67
}from"testHelpers/entities";
78
import{
@@ -24,6 +25,9 @@ const renderPage = async () => {
2425
describe("OrganizationSettingsPage",()=>{
2526
it("has no editable organizations",async()=>{
2627
server.use(
28+
http.get("/api/v2/entitlements",()=>{
29+
returnHttpResponse.json(MockEntitlementsWithMultiOrg);
30+
}),
2731
http.get("/api/v2/organizations",()=>{
2832
returnHttpResponse.json([MockDefaultOrganization,MockOrganization2]);
2933
}),
@@ -39,6 +43,9 @@ describe("OrganizationSettingsPage", () => {
3943

4044
it("redirects to default organization",async()=>{
4145
server.use(
46+
http.get("/api/v2/entitlements",()=>{
47+
returnHttpResponse.json(MockEntitlementsWithMultiOrg);
48+
}),
4249
http.get("/api/v2/organizations",()=>{
4350
// Default always preferred regardless of order.
4451
returnHttpResponse.json([MockOrganization2,MockDefaultOrganization]);
@@ -60,6 +67,9 @@ describe("OrganizationSettingsPage", () => {
6067

6168
it("redirects to non-default organization",async()=>{
6269
server.use(
70+
http.get("/api/v2/entitlements",()=>{
71+
returnHttpResponse.json(MockEntitlementsWithMultiOrg);
72+
}),
6373
http.get("/api/v2/organizations",()=>{
6474
returnHttpResponse.json([MockDefaultOrganization,MockOrganization2]);
6575
}),

‎site/src/pages/ManagementSettingsPage/OrganizationSettingsPage.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { Organization } from "api/typesGenerated";
77
import{EmptyState}from"components/EmptyState/EmptyState";
88
import{displaySuccess}from"components/GlobalSnackbar/utils";
99
import{Loader}from"components/Loader/Loader";
10+
import{useFeatureVisibility}from"modules/dashboard/useFeatureVisibility";
1011
importtype{FC}from"react";
1112
import{useMutation,useQuery,useQueryClient}from"react-query";
1213
import{Navigate,useNavigate,useParams}from"react-router-dom";
@@ -22,6 +23,7 @@ const OrganizationSettingsPage: FC = () => {
2223
organization?:string;
2324
};
2425
const{ organizations}=useOrganizationSettings();
26+
constfeats=useFeatureVisibility();
2527

2628
constnavigate=useNavigate();
2729
constqueryClient=useQueryClient();
@@ -69,7 +71,12 @@ const OrganizationSettingsPage: FC = () => {
6971
// The user may not be able to edit this org but they can still see it because
7072
// they can edit members, etc. In this case they will be shown a read-only
7173
// summary page instead of the settings form.
72-
if(!permissions[organization.id]?.editOrganization){
74+
// Similarly, if the feature is not entitled then the user will not be able to
75+
// edit the organization.
76+
if(
77+
!permissions[organization.id]?.editOrganization||
78+
!feats.multiple_organizations
79+
){
7380
return<OrganizationSummaryPageVieworganization={organization}/>;
7481
}
7582

‎site/src/testHelpers/storybook.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const withDashboardProvider = (
2424

2525
constentitlements:Entitlements={
2626
...MockEntitlements,
27+
has_license:features.length>0,
2728
features:withDefaultFeatures(
2829
Object.fromEntries(
2930
features.map((feature)=>[

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp