Skip to content

Commit eafd897

Browse files
committed
update ui to use list all orgs
1 parent adc590d commit eafd897

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

site/src/api/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ class ApiMethods {
565565

566566
getOrganizations = async (): Promise<TypesGen.Organization[]> => {
567567
const response = await this.axios.get<TypesGen.Organization[]>(
568-
"/api/v2/users/me/organizations",
568+
"/api/v2/organizations",
569569
);
570570
return response.data;
571571
};

site/src/api/queries/organizations.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
CreateOrganizationRequest,
55
UpdateOrganizationRequest,
66
} from "api/typesGenerated";
7-
import { meKey, myOrganizationsKey } from "./users";
7+
import { meKey } from "./users";
88

99
export const createOrganization = (queryClient: QueryClient) => {
1010
return {
@@ -13,7 +13,7 @@ export const createOrganization = (queryClient: QueryClient) => {
1313

1414
onSuccess: async () => {
1515
await queryClient.invalidateQueries(meKey);
16-
await queryClient.invalidateQueries(myOrganizationsKey);
16+
await queryClient.invalidateQueries(organizationsKey);
1717
},
1818
};
1919
};
@@ -29,7 +29,7 @@ export const updateOrganization = (queryClient: QueryClient) => {
2929
API.updateOrganization(variables.orgId, variables.req),
3030

3131
onSuccess: async () => {
32-
await queryClient.invalidateQueries(myOrganizationsKey);
32+
await queryClient.invalidateQueries(organizationsKey);
3333
},
3434
};
3535
};
@@ -40,7 +40,7 @@ export const deleteOrganization = (queryClient: QueryClient) => {
4040

4141
onSuccess: async () => {
4242
await queryClient.invalidateQueries(meKey);
43-
await queryClient.invalidateQueries(myOrganizationsKey);
43+
await queryClient.invalidateQueries(organizationsKey);
4444
},
4545
};
4646
};
@@ -78,3 +78,12 @@ export const removeOrganizationMember = (
7878
},
7979
};
8080
};
81+
82+
export const organizationsKey = ["organizations", "me"] as const;
83+
84+
export const organizations = () => {
85+
return {
86+
queryKey: organizationsKey,
87+
queryFn: () => API.getOrganizations(),
88+
};
89+
};

site/src/api/queries/users.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,3 @@ export const updateAppearanceSettings = (
249249
},
250250
};
251251
};
252-
253-
export const myOrganizationsKey = ["organizations", "me"] as const;
254-
255-
export const myOrganizations = () => {
256-
return {
257-
queryKey: myOrganizationsKey,
258-
queryFn: () => API.getOrganizations(),
259-
};
260-
};

site/src/pages/ManagementSettingsPage/ManagementSettingsLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createContext, type FC, Suspense, useContext } from "react";
22
import { useQuery } from "react-query";
33
import { Outlet, useLocation, useParams } from "react-router-dom";
44
import { deploymentConfig } from "api/queries/deployment";
5-
import { myOrganizations } from "api/queries/users";
5+
import { organizations } from "api/queries/organizations";
66
import type { Organization } from "api/typesGenerated";
77
import { Loader } from "components/Loader/Loader";
88
import { Margins } from "components/Margins/Margins";
@@ -39,7 +39,7 @@ export const ManagementSettingsLayout: FC = () => {
3939
const { experiments } = useDashboard();
4040
const { organization } = useParams() as { organization: string };
4141
const deploymentConfigQuery = useQuery(deploymentConfig());
42-
const organizationsQuery = useQuery(myOrganizations());
42+
const organizationsQuery = useQuery(organizations());
4343

4444
const multiOrgExperimentEnabled = experiments.includes("multi-organization");
4545

0 commit comments

Comments
 (0)