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

Commitda10e5f

Browse files
committed
Use default org ID in old pages
The 0000 syntax does not work, it has to be the actual org ID.Technically this is probably not necessary since it means only adminscan create groups which was already the case, but I think being explicitabout the org we are checking is a good idea, even if these pages willeventually go away in favor of the multi-org ones.
1 parent4a7c9d9 commitda10e5f

File tree

6 files changed

+27
-18
lines changed

6 files changed

+27
-18
lines changed

‎site/src/pages/GroupsPage/GroupsPage.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ import { groups } from "api/queries/groups";
66
import{organizationPermissions}from"api/queries/organizations";
77
import{displayError}from"components/GlobalSnackbar/utils";
88
import{Loader}from"components/Loader/Loader";
9+
import{useDashboard}from"modules/dashboard/useDashboard";
910
import{useFeatureVisibility}from"modules/dashboard/useFeatureVisibility";
1011
import{pageTitle}from"utils/page";
1112
importGroupsPageViewfrom"./GroupsPageView";
1213

1314
exportconstGroupsPage:FC=()=>{
15+
const{ organizations}=useDashboard();
1416
const{template_rbac:isTemplateRBACEnabled}=useFeatureVisibility();
15-
constgroupsQuery=useQuery(groups("default"));
16-
constpermissionsQuery=useQuery(
17-
organizationPermissions("00000000-0000-0000-0000-00000000000"),
18-
);
17+
constorganization=organizations.find((o)=>o.is_default)
18+
constgroupsQuery=useQuery(organization ?groups(organization.id) :{enabled:false});
19+
constpermissionsQuery=useQuery(organizationPermissions(organization?.id));
1920

2021
useEffect(()=>{
2122
if(groupsQuery.error){
@@ -33,6 +34,10 @@ export const GroupsPage: FC = () => {
3334
}
3435
},[permissionsQuery.error]);
3536

37+
if(!organization){
38+
thrownewError("No default organization")
39+
}
40+
3641
constpermissions=permissionsQuery.data;
3742
if(!permissions){
3843
return<Loader/>;

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { getErrorMessage } from "api/errors";
88
import{groups}from"api/queries/groups";
99
import{organizationPermissions}from"api/queries/organizations";
1010
importtype{Organization}from"api/typesGenerated";
11+
import{EmptyState}from"components/EmptyState/EmptyState";
1112
import{displayError}from"components/GlobalSnackbar/utils";
1213
import{Loader}from"components/Loader/Loader";
1314
import{PageHeader,PageHeaderTitle}from"components/PageHeader/PageHeader";
@@ -25,8 +26,6 @@ export const GroupsPage: FC = () => {
2526
organizationName ?groups(organizationName) :{enabled:false},
2627
);
2728
const{ organizations}=useOrganizationSettings();
28-
// TODO: If we could query permissions based on the name then we would not
29-
// have to cascade off the organizations query.
3029
constorganization=organizations?.find((o)=>o.name===organizationName);
3130
constpermissionsQuery=useQuery(organizationPermissions(organization?.id));
3231

@@ -56,7 +55,11 @@ export const GroupsPage: FC = () => {
5655
return<Navigateto={`/organizations/${defaultName}/groups`}replace/>;
5756
}
5857
// We expect there to always be a default organization.
59-
thrownewError("No default organization found")
58+
thrownewError("No default organization found");
59+
}
60+
61+
if(!organization){
62+
return<EmptyStatemessage="Organization not found"/>;
6063
}
6164

6265
constpermissions=permissionsQuery.data;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Margins } from "components/Margins/Margins";
88
import{Stack}from"components/Stack/Stack";
99
import{useAuthenticated}from"contexts/auth/RequireAuth";
1010
import{RequirePermission}from"contexts/auth/RequirePermission";
11+
import{useDashboard}from"modules/dashboard/useDashboard";
1112
import{DeploySettingsContext}from"../DeploySettingsPage/DeploySettingsLayout";
1213
import{Sidebar}from"./Sidebar";
1314

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ const OrganizationMembersPage: FC = () => {
3535
updateOrganizationMemberRoles(queryClient,organizationName),
3636
);
3737

38-
// TODO: If we could query permissions based on the name then we would not
39-
// have to cascade off the organizations query.
4038
const{ organizations}=useOrganizationSettings();
4139
constorganization=organizations?.find((o)=>o.name===organizationName);
4240
constpermissionsQuery=useQuery(organizationPermissions(organization?.id));

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { Organization } from "api/typesGenerated";
1010
import{EmptyState}from"components/EmptyState/EmptyState";
1111
import{displaySuccess}from"components/GlobalSnackbar/utils";
1212
import{Loader}from"components/Loader/Loader";
13-
import{AUDIT_LINK,withFilter}from"modules/navigation";
13+
import{linkToAuditing,withFilter}from"modules/navigation";
1414
import{useOrganizationSettings}from"./ManagementSettingsLayout";
1515
import{OrganizationSettingsPageView}from"./OrganizationSettingsPageView";
1616

@@ -29,8 +29,6 @@ const OrganizationSettingsPage: FC = () => {
2929
deleteOrganization(queryClient),
3030
);
3131

32-
// TODO: If we could query permissions based on the name then we would not
33-
// have to cascade off the organizations query.
3432
constorganization=
3533
organizations&&organizationName
3634
?getOrganizationByName(organizations,organizationName)
@@ -47,7 +45,8 @@ const OrganizationSettingsPage: FC = () => {
4745
if(defaultOrg){
4846
return<Navigateto={`/organizations/${defaultOrg.name}`}replace/>;
4947
}
50-
return<EmptyStatemessage="No default organization found"/>;
48+
// We expect there to always be a default organization.
49+
thrownewError("No default organization found");
5150
}
5251

5352
if(!organization){
@@ -75,7 +74,7 @@ const OrganizationSettingsPage: FC = () => {
7574
return(
7675
<Navigate
7776
to={`/deployment${withFilter(
78-
AUDIT_LINK,
77+
linkToAuditing,
7978
`organization:${organization.name}`,
8079
)}`}
8180
replace

‎site/src/pages/UsersPage/UsersLayout.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@ import { linkToUsers } from "modules/navigation";
2121

2222
exportconstUsersLayout:FC=()=>{
2323
const{ permissions}=useAuthenticated();
24-
const{ experiments}=useDashboard();
24+
const{ experiments, organizations}=useDashboard();
2525
constnavigate=useNavigate();
2626
constfeats=useFeatureVisibility();
2727
constlocation=useLocation();
2828
constactiveTab=location.pathname.endsWith("groups") ?"groups" :"users";
29-
constpermissionsQuery=useQuery(
30-
organizationPermissions("00000000-0000-0000-0000-00000000000"),
31-
);
29+
constorganization=organizations.find((o)=>o.is_default)
30+
constpermissionsQuery=useQuery(organizationPermissions(organization?.id));
31+
32+
if(!organization){
33+
thrownewError("No default organization")
34+
}
3235

3336
constcanViewOrganizations=
3437
feats.multiple_organizations&&experiments.includes("multi-organization");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp