Skip to content

Commit 69e963b

Browse files
authored
refactor: move dashboard functionality to modules/dashboard/ (#11721)
1 parent 14f114b commit 69e963b

File tree

68 files changed

+249
-230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+249
-230
lines changed

site/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,9 @@
170170
"vite-plugin-turbosnap": "1.0.2"
171171
},
172172
"browserslist": [
173-
"chrome 66",
174-
"firefox 63",
175-
"edge 79",
176-
"safari 15.4"
173+
"chrome 110",
174+
"firefox 111",
175+
"safari 16.0"
177176
],
178177
"resolutions": {
179178
"optionator": "0.9.3",

site/src/AppRouter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
BrowserRouter as Router,
66
Navigate,
77
} from "react-router-dom";
8+
import { DashboardLayout } from "./modules/dashboard/DashboardLayout";
89
import { RequireAuth } from "./contexts/auth/RequireAuth";
9-
import { DashboardLayout } from "./components/Dashboard/DashboardLayout";
1010
import { FullScreenLoader } from "./components/Loader/FullScreenLoader";
1111
import AuditPage from "./pages/AuditPage/AuditPage";
1212
import { DeploySettingsLayout } from "./pages/DeploySettingsPage/DeploySettingsLayout";

site/src/components/WorkspaceStatusBadge/DormantDeletionText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type FC } from "react";
22
import type { Workspace } from "api/typesGenerated";
33
import { displayDormantDeletion } from "utils/dormant";
4-
import { useDashboard } from "components/Dashboard/DashboardProvider";
4+
import { useDashboard } from "modules/dashboard/useDashboard";
55

66
interface DormantDeletionTextProps {
77
workspace: Workspace;

site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
MockAppearanceConfig,
1616
} from "testHelpers/entities";
1717
import { WorkspaceStatusBadge } from "./WorkspaceStatusBadge";
18-
import { DashboardProviderContext } from "components/Dashboard/DashboardProvider";
18+
import { DashboardContext } from "modules/dashboard/DashboardProvider";
1919
import type { Meta, StoryObj } from "@storybook/react";
2020

2121
const MockedAppearance = {
@@ -29,7 +29,7 @@ const meta: Meta<typeof WorkspaceStatusBadge> = {
2929
component: WorkspaceStatusBadge,
3030
decorators: [
3131
(Story) => (
32-
<DashboardProviderContext.Provider
32+
<DashboardContext.Provider
3333
value={{
3434
buildInfo: MockBuildInfo,
3535
entitlements: MockEntitlementsWithScheduling,
@@ -38,7 +38,7 @@ const meta: Meta<typeof WorkspaceStatusBadge> = {
3838
}}
3939
>
4040
<Story />
41-
</DashboardProviderContext.Provider>
41+
</DashboardContext.Provider>
4242
),
4343
],
4444
};

site/src/contexts/auth/RequireAuth.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Outlet, Navigate, useLocation } from "react-router-dom";
44
import { embedRedirect } from "utils/redirect";
55
import { isApiError } from "api/errors";
66
import { ProxyProvider } from "contexts/ProxyContext";
7-
import { DashboardProvider } from "components/Dashboard/DashboardProvider";
7+
import { DashboardProvider } from "modules/dashboard/DashboardProvider";
88
import { FullScreenLoader } from "components/Loader/FullScreenLoader";
99
import { useAuth } from "./useAuth";
1010

site/src/hooks/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export * from "./useClickable";
22
export * from "./useClickableTableRow";
33
export * from "./useClipboard";
4-
export * from "./useFeatureVisibility";
54
export * from "./usePagination";
65
export * from "./useTab";

site/src/components/Dashboard/DashboardLayout.tsx renamed to site/src/modules/dashboard/DashboardLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import Button from "@mui/material/Button";
44
import InfoOutlined from "@mui/icons-material/InfoOutlined";
55
import { type FC, type HTMLAttributes, Suspense } from "react";
66
import { Outlet } from "react-router-dom";
7+
import { LicenseBanner } from "modules/dashboard/LicenseBanner/LicenseBanner";
8+
import { ServiceBanner } from "modules/dashboard/ServiceBanner/ServiceBanner";
79
import { usePermissions } from "contexts/auth/usePermissions";
8-
import { LicenseBanner } from "components/Dashboard/LicenseBanner/LicenseBanner";
910
import { Loader } from "components/Loader/Loader";
10-
import { ServiceBanner } from "components/Dashboard/ServiceBanner/ServiceBanner";
1111
import { dashboardContentBottomPadding } from "theme/constants";
1212
import { docs } from "utils/docs";
1313
import { Navbar } from "./Navbar/Navbar";

site/src/components/Dashboard/DashboardProvider.tsx renamed to site/src/modules/dashboard/DashboardProvider.tsx

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
type PropsWithChildren,
1515
createContext,
1616
useCallback,
17-
useContext,
1817
useState,
1918
} from "react";
2019
import { appearance } from "api/queries/appearance";
@@ -27,16 +26,16 @@ interface Appearance {
2726
setPreview: (config: AppearanceConfig) => void;
2827
}
2928

30-
interface DashboardProviderValue {
29+
export interface DashboardValue {
3130
buildInfo: BuildInfoResponse;
3231
entitlements: Entitlements;
3332
experiments: Experiments;
3433
appearance: Appearance;
3534
}
3635

37-
export const DashboardProviderContext = createContext<
38-
DashboardProviderValue | undefined
39-
>(undefined);
36+
export const DashboardContext = createContext<DashboardValue | undefined>(
37+
undefined,
38+
);
4039

4140
export const DashboardProvider: FC<PropsWithChildren> = ({ children }) => {
4241
const buildInfoQuery = useQuery(buildInfo());
@@ -83,7 +82,7 @@ export const DashboardProvider: FC<PropsWithChildren> = ({ children }) => {
8382
}
8483

8584
return (
86-
<DashboardProviderContext.Provider
85+
<DashboardContext.Provider
8786
value={{
8887
buildInfo: buildInfoQuery.data,
8988
entitlements: entitlementsQuery.data,
@@ -96,23 +95,6 @@ export const DashboardProvider: FC<PropsWithChildren> = ({ children }) => {
9695
}}
9796
>
9897
{children}
99-
</DashboardProviderContext.Provider>
98+
</DashboardContext.Provider>
10099
);
101100
};
102-
103-
export const useDashboard = (): DashboardProviderValue => {
104-
const context = useContext(DashboardProviderContext);
105-
106-
if (!context) {
107-
throw new Error(
108-
"useDashboard only can be used inside of DashboardProvider",
109-
);
110-
}
111-
112-
return context;
113-
};
114-
115-
export const useIsWorkspaceActionsEnabled = (): boolean => {
116-
const { entitlements } = useDashboard();
117-
return entitlements.features["advanced_template_scheduling"].enabled;
118-
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy