Skip to content

Commit d341175

Browse files
committed
fix: revert changes not caught in merge
1 parent 804255e commit d341175

15 files changed

+46
-96
lines changed

site/src/@types/storybook.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ declare module "@storybook/react" {
1919
experiments?: Experiments;
2020
showOrganizations?: boolean;
2121
organizations?: Organization[];
22-
activeOrganization?: Organization;
2322
queries?: { key: QueryKey; data: unknown; isError?: boolean }[];
2423
webSocket?: WebSocketEvent[];
2524
user?: User;

site/src/modules/dashboard/DashboardProvider.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ import { Loader } from "components/Loader/Loader";
1313
import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata";
1414
import { type FC, type PropsWithChildren, createContext } from "react";
1515
import { useQuery } from "react-query";
16-
import { useParams } from "react-router-dom";
1716
import { selectFeatureVisibility } from "./entitlements";
1817

1918
export interface DashboardValue {
2019
entitlements: Entitlements;
2120
experiments: Experiments;
2221
appearance: AppearanceConfig;
2322
organizations: readonly Organization[];
24-
activeOrganization: Organization | undefined;
2523
showOrganizations: boolean;
2624
}
2725

@@ -35,9 +33,6 @@ export const DashboardProvider: FC<PropsWithChildren> = ({ children }) => {
3533
const experimentsQuery = useQuery(experiments(metadata.experiments));
3634
const appearanceQuery = useQuery(appearance(metadata.appearance));
3735
const organizationsQuery = useQuery(organizations());
38-
const { organization: organizationName } = useParams() as {
39-
organization?: string;
40-
};
4136

4237
const error =
4338
entitlementsQuery.error ||
@@ -72,9 +67,6 @@ export const DashboardProvider: FC<PropsWithChildren> = ({ children }) => {
7267
appearance: appearanceQuery.data,
7368
organizations: organizationsQuery.data,
7469
showOrganizations: hasMultipleOrganizations || organizationsEnabled,
75-
activeOrganization: organizationsQuery.data?.find(
76-
(org) => org.name === organizationName,
77-
),
7870
}}
7971
>
8072
{children}

site/src/modules/management/Sidebar.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { organizationsPermissions } from "api/queries/organizations";
22
import { useAuthenticated } from "contexts/auth/RequireAuth";
33
import { useDashboard } from "modules/dashboard/useDashboard";
4-
import { canEditOrganization } from "modules/management/ManagementSettingsLayout";
4+
import {
5+
canEditOrganization,
6+
useManagementSettings,
7+
} from "modules/management/ManagementSettingsLayout";
58
import type { FC } from "react";
69
import { useQuery } from "react-query";
710
import { useLocation, useParams } from "react-router-dom";
@@ -17,7 +20,10 @@ import { type OrganizationWithPermissions, SidebarView } from "./SidebarView";
1720
export const Sidebar: FC = () => {
1821
const location = useLocation();
1922
const { permissions } = useAuthenticated();
20-
const { organizations, activeOrganization } = useDashboard();
23+
const { organizations } = useManagementSettings();
24+
const { organization: organizationName } = useParams() as {
25+
organization?: string;
26+
};
2127

2228
const orgPermissionsQuery = useQuery(
2329
organizationsPermissions(organizations?.map((o) => o.id)),
@@ -46,7 +52,7 @@ export const Sidebar: FC = () => {
4652
// the user is on /organizations but has no editable organizations to
4753
// which we can redirect.
4854
activeSettings={location.pathname.startsWith("/deployment")}
49-
activeOrganizationName={activeOrganization?.name}
55+
activeOrganizationName={organizationName}
5056
organizations={editableOrgs}
5157
permissions={permissions}
5258
/>

site/src/pages/ManagementSettingsPage/CustomRolesPage/CreateEditRolePage.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import type { CustomRoleRequest } from "api/typesGenerated";
99
import { displayError } from "components/GlobalSnackbar/utils";
1010
import { Loader } from "components/Loader/Loader";
11-
import { useDashboard } from "modules/dashboard/useDashboard";
11+
import { useManagementSettings } from "modules/management/ManagementSettingsLayout";
1212
import type { FC } from "react";
1313
import { Helmet } from "react-helmet-async";
1414
import { useMutation, useQuery, useQueryClient } from "react-query";
@@ -19,15 +19,15 @@ import CreateEditRolePageView from "./CreateEditRolePageView";
1919
export const CreateEditRolePage: FC = () => {
2020
const queryClient = useQueryClient();
2121
const navigate = useNavigate();
22-
const { activeOrganization } = useDashboard();
22+
23+
const { organizations } = useManagementSettings();
2324
const { organization: organizationName, roleName } = useParams() as {
2425
organization: string;
2526
roleName: string;
2627
};
28+
const organization = organizations?.find((o) => o.name === organizationName);
29+
const permissionsQuery = useQuery(organizationPermissions(organization?.id));
2730

28-
const permissionsQuery = useQuery(
29-
organizationPermissions(activeOrganization?.id),
30-
);
3131
const createOrganizationRoleMutation = useMutation(
3232
createOrganizationRole(queryClient, organizationName),
3333
);

site/src/pages/ManagementSettingsPage/CustomRolesPage/CustomRolesPage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { SettingsHeader } from "components/SettingsHeader/SettingsHeader";
99
import { Stack } from "components/Stack/Stack";
1010
import { useDashboard } from "modules/dashboard/useDashboard";
1111
import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility";
12+
import { useManagementSettings } from "modules/management/ManagementSettingsLayout";
1213
import { type FC, useEffect, useState } from "react";
1314
import { Helmet } from "react-helmet-async";
1415
import { useMutation, useQuery, useQueryClient } from "react-query";
@@ -22,10 +23,9 @@ export const CustomRolesPage: FC = () => {
2223
const { organization: organizationName } = useParams() as {
2324
organization: string;
2425
};
25-
const { activeOrganization } = useDashboard();
26-
const permissionsQuery = useQuery(
27-
organizationPermissions(activeOrganization?.id),
28-
);
26+
const { organizations } = useManagementSettings();
27+
const organization = organizations?.find((o) => o.name === organizationName);
28+
const permissionsQuery = useQuery(organizationPermissions(organization?.id));
2929
const deleteRoleMutation = useMutation(
3030
deleteOrganizationRole(queryClient, organizationName),
3131
);

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { SettingsHeader } from "components/SettingsHeader/SettingsHeader";
1111
import { Stack } from "components/Stack/Stack";
1212
import { useDashboard } from "modules/dashboard/useDashboard";
1313
import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility";
14+
import { useManagementSettings } from "modules/management/ManagementSettingsLayout";
1415
import { type FC, useEffect } from "react";
1516
import { Helmet } from "react-helmet-async";
1617
import { useQuery } from "react-query";
@@ -24,10 +25,9 @@ export const GroupsPage: FC = () => {
2425
organization: string;
2526
};
2627
const groupsQuery = useQuery(groupsByOrganization(organizationName));
27-
const { organizations, activeOrganization } = useDashboard();
28-
const permissionsQuery = useQuery(
29-
organizationPermissions(activeOrganization?.id),
30-
);
28+
const { organizations } = useManagementSettings();
29+
const organization = organizations?.find((o) => o.name === organizationName);
30+
const permissionsQuery = useQuery(organizationPermissions(organization?.id));
3131

3232
useEffect(() => {
3333
if (groupsQuery.error) {
@@ -58,7 +58,7 @@ export const GroupsPage: FC = () => {
5858
throw new Error("No default organization found");
5959
}
6060

61-
if (!activeOrganization) {
61+
if (!organization) {
6262
return <EmptyState message="Organization not found" />;
6363
}
6464

site/src/pages/ManagementSettingsPage/IdpSyncPage/IdpSyncPage.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { SettingsHeader } from "components/SettingsHeader/SettingsHeader";
1212
import { Stack } from "components/Stack/Stack";
1313
import { useDashboard } from "modules/dashboard/useDashboard";
1414
import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility";
15+
import { useManagementSettings } from "modules/management/ManagementSettingsLayout";
1516
import type { FC } from "react";
1617
import { Helmet } from "react-helmet-async";
1718
import { useQueries } from "react-query";
@@ -27,7 +28,8 @@ export const IdpSyncPage: FC = () => {
2728
};
2829
// IdP sync does not have its own entitlement and is based on templace_rbac
2930
const { template_rbac: isIdpSyncEnabled } = useFeatureVisibility();
30-
const { activeOrganization } = useDashboard();
31+
const { organizations } = useManagementSettings();
32+
const organization = organizations?.find((o) => o.name === organizationName);
3133

3234
const [groupIdpSyncSettingsQuery, roleIdpSyncSettingsQuery, groupsQuery] =
3335
useQueries({
@@ -38,7 +40,7 @@ export const IdpSyncPage: FC = () => {
3840
],
3941
});
4042

41-
if (!activeOrganization) {
43+
if (!organization) {
4244
return <EmptyState message="Organization not found" />;
4345
}
4446

@@ -93,7 +95,7 @@ export const IdpSyncPage: FC = () => {
9395
roleSyncSettings={roleIdpSyncSettingsQuery.data}
9496
groups={groupsQuery.data}
9597
groupsMap={groupsMap}
96-
organization={activeOrganization}
98+
organization={organization}
9799
error={error}
98100
/>
99101
</Cond>

site/src/pages/ManagementSettingsPage/OrganizationMembersPage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Loader } from "components/Loader/Loader";
1616
import { Stack } from "components/Stack/Stack";
1717
import { useAuthenticated } from "contexts/auth/RequireAuth";
1818
import { useDashboard } from "modules/dashboard/useDashboard";
19+
import { useManagementSettings } from "modules/management/ManagementSettingsLayout";
1920
import { type FC, useState } from "react";
2021
import { useMutation, useQuery, useQueryClient } from "react-query";
2122
import { useParams } from "react-router-dom";
@@ -50,10 +51,9 @@ const OrganizationMembersPage: FC = () => {
5051
updateOrganizationMemberRoles(queryClient, organizationName),
5152
);
5253

53-
const { activeOrganization } = useDashboard();
54-
const permissionsQuery = useQuery(
55-
organizationPermissions(activeOrganization?.id),
56-
);
54+
const { organizations } = useManagementSettings();
55+
const organization = organizations?.find((o) => o.name === organizationName);
56+
const permissionsQuery = useQuery(organizationPermissions(organization?.id));
5757

5858
const [memberToDelete, setMemberToDelete] =
5959
useState<OrganizationMemberWithUserData>();

site/src/pages/ManagementSettingsPage/OrganizationProvisionersPage.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Organization } from "api/typesGenerated";
44
import { EmptyState } from "components/EmptyState/EmptyState";
55
import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata";
66
import { useDashboard } from "modules/dashboard/useDashboard";
7+
import { useManagementSettings } from "modules/management/ManagementSettingsLayout";
78
import type { FC } from "react";
89
import { useQuery } from "react-query";
910
import { useParams } from "react-router-dom";
@@ -13,14 +14,14 @@ const OrganizationProvisionersPage: FC = () => {
1314
const { organization: organizationName } = useParams() as {
1415
organization: string;
1516
};
16-
const { activeOrganization } = useDashboard();
1717
const { entitlements } = useDashboard();
18-
18+
const { organizations } = useManagementSettings();
1919
const { metadata } = useEmbeddedMetadata();
2020
const buildInfoQuery = useQuery(buildInfo(metadata["build-info"]));
2121
const provisionersQuery = useQuery(provisionerDaemonGroups(organizationName));
2222

23-
if (!activeOrganization) {
23+
const organization = organizations?.find((o) => o.name === organizationName);
24+
if (!organization) {
2425
return <EmptyState message="Organization not found" />;
2526
}
2627

@@ -35,8 +36,3 @@ const OrganizationProvisionersPage: FC = () => {
3536
};
3637

3738
export default OrganizationProvisionersPage;
38-
39-
const getOrganizationByName = (
40-
organizations: readonly Organization[],
41-
name: string,
42-
) => organizations.find((org) => org.name === name);

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,10 @@ const meta: Meta<typeof OrganizationSettingsPage> = {
3838
export default meta;
3939
type Story = StoryObj<typeof OrganizationSettingsPage>;
4040

41-
export const NoRedirectableOrganizations: Story = {
42-
parameters: {
43-
organizations: [MockDefaultOrganization],
44-
activeOrganization: undefined,
45-
},
46-
};
41+
export const NoRedirectableOrganizations: Story = {};
4742

4843
export const OrganizationDoesNotExist: Story = {
4944
parameters: {
50-
organizations: [MockDefaultOrganization],
51-
activeOrganization: MockOrganization2,
5245
reactRouter: reactRouterParameters({
5346
location: { pathParams: { organization: "does-not-exist" } },
5447
routing: { path: "/organizations/:organization" },

site/src/pages/ManagementSettingsPage/OrganizationSettingsPage.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ const OrganizationSettingsPage: FC = () => {
3535
deleteOrganization(queryClient),
3636
);
3737

38-
const organization =
39-
organizations && organizationName
40-
? getOrganizationByName(organizations, organizationName)
41-
: undefined;
38+
const organization = organizations?.find((o) => o.name === organizationName);
4239
const permissionsQuery = useQuery(
4340
organizationsPermissions(organizations?.map((o) => o.id)),
4441
);
@@ -116,10 +113,3 @@ const OrganizationSettingsPage: FC = () => {
116113
};
117114

118115
export default OrganizationSettingsPage;
119-
120-
const getOrganizationByName = (
121-
organizations: readonly Organization[],
122-
name: string,
123-
) => {
124-
return organizations.find((org) => org.name === name);
125-
};

site/src/pages/WorkspacePage/WorkspacePage.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,6 @@ describe("WorkspacePage", () => {
562562
entitlements: MockEntitlements,
563563
experiments: [],
564564
organizations: [MockOrganization],
565-
activeOrganization: MockOrganization,
566565
showOrganizations: true,
567566
}}
568567
>

site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,21 +270,20 @@ export const InvalidPageNumber: Story = {
270270
},
271271
};
272272

273-
const mockOrganization: Organization = {
274-
...MockOrganization,
275-
name: "limbus-co",
276-
display_name: "Limbus Company, LLC",
277-
};
278-
279273
export const ShowOrganizations: Story = {
280274
args: {
281275
workspaces: [{ ...MockWorkspace, organization_name: "limbus-co" }],
282276
},
283277

284278
parameters: {
285279
showOrganizations: true,
286-
activeOrganization: mockOrganization,
287-
organizations: [mockOrganization],
280+
organizations: [
281+
{
282+
...MockOrganization,
283+
name: "limbus-co",
284+
display_name: "Limbus Company, LLC",
285+
},
286+
],
288287
},
289288

290289
play: async ({ canvasElement }) => {

site/src/router.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -431,23 +431,6 @@ export const router = createBrowserRouter(
431431
</Route>
432432
</Route>
433433

434-
{/**
435-
* @todo 2024-10-24 - MES - The current deployment page is
436-
* almost empty, which isn't great for two reasons:
437-
*
438-
* 1. Even though none of our links lead to the page, the
439-
* user is still able to navigate straight there by
440-
* accident.
441-
* 2. If the user has access to some deployment pages, but
442-
* tries accessing one that they shouldn't be able to
443-
* access, we have to reroute them somewhere. The base
444-
* deployment route is the only safe option, because not
445-
* even the general page is accessible by everyone.
446-
*
447-
* Should update the base /deployment page so that there's
448-
* something there, but that will require coordination with
449-
* the design team.
450-
*/}
451434
<Route path="/deployment" element={<ManagementSettingsLayout />}>
452435
<Route element={<DeploymentSettingsProvider />}>
453436
<Route path="general" element={<GeneralSettingsPage />} />

site/src/testHelpers/storybook.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,9 @@ export const withDashboardProvider = (
2626
features = [],
2727
experiments = [],
2828
showOrganizations = false,
29+
organizations = [MockDefaultOrganization],
2930
} = parameters;
3031

31-
// Only set a default value for activeOrganizations if the original
32-
// organizations array wasn't specified. In some cases, we want to have a
33-
// list of organizations, but not have one be active
34-
let { organizations, activeOrganization } = parameters;
35-
if (organizations === undefined) {
36-
organizations = [MockDefaultOrganization];
37-
activeOrganization = MockDefaultOrganization;
38-
}
39-
4032
const entitlements: Entitlements = {
4133
...MockEntitlements,
4234
has_license: features.length > 0,
@@ -57,7 +49,6 @@ export const withDashboardProvider = (
5749
experiments,
5850
organizations,
5951
showOrganizations,
60-
activeOrganization,
6152
appearance: MockAppearanceConfig,
6253
}}
6354
>

0 commit comments

Comments
 (0)