Skip to content

Commit 130d5d6

Browse files
refactor(site): refactor workspace notifications (#11520)
1 parent bdefd4e commit 130d5d6

16 files changed

+616
-395
lines changed

site/.storybook/preview.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function withQuery(Story, { parameters }) {
7878
defaultOptions: {
7979
queries: {
8080
staleTime: Infinity,
81+
retry: false,
8182
},
8283
},
8384
});

site/src/AppRouter.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ export const AppRouter: FC = () => {
370370

371371
{/* In order for the 404 page to work properly the routes that start with
372372
top level parameter must be fully qualified. */}
373-
<Route path="/:username/:workspace" element={<WorkspacePage />} />
374373
<Route
375374
path="/:username/:workspace/builds/:buildNumber"
376375
element={<WorkspaceBuildPage />}
@@ -413,6 +412,7 @@ export const AppRouter: FC = () => {
413412
</Route>
414413

415414
{/* Pages that don't have the dashboard layout */}
415+
<Route path="/:username/:workspace" element={<WorkspacePage />} />
416416
<Route
417417
path="/templates/:template/versions/:version/edit"
418418
element={<TemplateVersionEditorPage />}

site/src/api/queries/workspaceQuota.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const workspaceQuota = (username: string) => {
1212
};
1313
};
1414

15-
const getWorkspaceResolveAutostartQueryKey = (workspaceId: string) => [
15+
export const getWorkspaceResolveAutostartQueryKey = (workspaceId: string) => [
1616
workspaceId,
1717
"workspaceResolveAutostart",
1818
];

site/src/components/WorkspaceDeletion/DormantWorkspaceBanner.tsx

-76
This file was deleted.

site/src/components/WorkspaceDeletion/index.ts

-2
This file was deleted.

site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { type FC, type ReactNode } from "react";
99
import type { Workspace } from "api/typesGenerated";
1010
import { Pill } from "components/Pill/Pill";
1111
import { ChooseOne, Cond } from "components/Conditionals/ChooseOne";
12-
import { DormantDeletionText } from "components/WorkspaceDeletion";
12+
import { DormantDeletionText } from "./DormantDeletionText";
1313
import { getDisplayWorkspaceStatus } from "utils/workspace";
1414
import { useClassName } from "hooks/useClassName";
1515
import { formatDistanceToNow } from "date-fns";

site/src/pages/WorkspacePage/Workspace.stories.tsx

+13-79
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,24 @@ import EventSource from "eventsourcemock";
99
import { ProxyContext, getPreferredProxy } from "contexts/ProxyContext";
1010
import { DashboardProviderContext } from "components/Dashboard/DashboardProvider";
1111
import { WorkspaceBuildLogsSection } from "pages/WorkspacePage/WorkspaceBuildLogsSection";
12+
import { WorkspacePermissions } from "./permissions";
1213

1314
const MockedAppearance = {
1415
config: Mocks.MockAppearanceConfig,
1516
isPreview: false,
1617
setPreview: () => {},
1718
};
1819

20+
const permissions: WorkspacePermissions = {
21+
readWorkspace: true,
22+
updateWorkspace: true,
23+
updateTemplate: true,
24+
viewDeploymentValues: true,
25+
};
26+
1927
const meta: Meta<typeof Workspace> = {
2028
title: "pages/WorkspacePage/Workspace",
29+
args: { permissions },
2130
component: Workspace,
2231
decorators: [
2332
(Story) => (
@@ -68,8 +77,6 @@ export const Running: Story = {
6877
workspace: Mocks.MockWorkspace,
6978
handleStart: action("start"),
7079
handleStop: action("stop"),
71-
canUpdateWorkspace: true,
72-
workspaceErrors: {},
7380
buildInfo: Mocks.MockBuildInfo,
7481
template: Mocks.MockTemplate,
7582
},
@@ -78,7 +85,10 @@ export const Running: Story = {
7885
export const WithoutUpdateAccess: Story = {
7986
args: {
8087
...Running.args,
81-
canUpdateWorkspace: false,
88+
permissions: {
89+
...permissions,
90+
updateWorkspace: false,
91+
},
8292
},
8393
};
8494

@@ -110,18 +120,6 @@ export const Stopping: Story = {
110120
},
111121
};
112122

113-
export const Failed: Story = {
114-
args: {
115-
...Running.args,
116-
workspace: Mocks.MockFailedWorkspace,
117-
workspaceErrors: {
118-
buildError: Mocks.mockApiError({
119-
message: "A workspace build is already active.",
120-
}),
121-
},
122-
},
123-
};
124-
125123
export const FailedWithLogs: Story = {
126124
args: {
127125
...Running.args,
@@ -186,70 +184,6 @@ export const Canceled: Story = {
186184
},
187185
};
188186

189-
export const Outdated: Story = {
190-
args: {
191-
...Running.args,
192-
workspace: Mocks.MockOutdatedWorkspace,
193-
},
194-
};
195-
196-
export const CantAutostart: Story = {
197-
args: {
198-
...Running.args,
199-
canAutostart: false,
200-
workspace: Mocks.MockOutdatedRunningWorkspaceRequireActiveVersion,
201-
},
202-
};
203-
204-
export const GetBuildsError: Story = {
205-
args: {
206-
...Running.args,
207-
workspaceErrors: {
208-
getBuildsError: Mocks.mockApiError({
209-
message: "There is a problem fetching builds.",
210-
}),
211-
},
212-
},
213-
};
214-
215-
export const CancellationError: Story = {
216-
args: {
217-
...Failed.args,
218-
workspaceErrors: {
219-
cancellationError: Mocks.mockApiError({
220-
message: "Job could not be canceled.",
221-
}),
222-
},
223-
buildLogs: <WorkspaceBuildLogsSection logs={makeFailedBuildLogs()} />,
224-
},
225-
};
226-
227-
export const Deprecated: Story = {
228-
args: {
229-
...Running.args,
230-
template: {
231-
...Mocks.MockTemplate,
232-
deprecated: true,
233-
deprecation_message:
234-
"Template deprecated due to reasons. [Learn more](#)",
235-
},
236-
},
237-
};
238-
239-
export const Unhealthy: Story = {
240-
args: {
241-
...Running.args,
242-
workspace: {
243-
...Mocks.MockWorkspace,
244-
latest_build: { ...Mocks.MockWorkspace.latest_build, status: "running" },
245-
health: {
246-
healthy: false,
247-
failing_agents: [],
248-
},
249-
},
250-
},
251-
};
252-
253187
function makeFailedBuildLogs(): ProvisionerJobLog[] {
254188
return [
255189
{

0 commit comments

Comments
 (0)