Skip to content

Commit d464360

Browse files
fix(site): resolve circular dependency between WorkspacesPage components (coder#19895)
Move `ACTIVE_BUILD_STATUSES` constant from `WorkspacesPage.tsx` to a module to break the circular dependency between `WorkspacesPage.tsx` and `BatchUpdateModalForm.tsx`. This resolves the circular dependency lint error and ensures proper code organization. **Error:** ``` • Circular Dependencies 1) src/pages/WorkspacesPage/WorkspacesPage.tsx -> src/pages/WorkspacesPage/BatchUpdateModalForm.tsx ``` --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f39cf30 commit d464360

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { WorkspaceStatus } from "api/typesGenerated";
2+
3+
/**
4+
* The set of all workspace statuses that indicate that the state for a
5+
* workspace is in the middle of a transition and will eventually reach a more
6+
* stable state/status.
7+
*/
8+
export const ACTIVE_BUILD_STATUSES: readonly WorkspaceStatus[] = [
9+
"canceling",
10+
"deleting",
11+
"pending",
12+
"starting",
13+
"stopping",
14+
];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import type {
66
Workspace,
77
WorkspaceBuild,
88
} from "api/typesGenerated";
9+
import { ACTIVE_BUILD_STATUSES } from "modules/workspaces/status";
910
import { useQueryClient } from "react-query";
1011
import { action } from "storybook/internal/actions";
1112
import { expect, screen, userEvent, within } from "storybook/test";
1213
import { BatchUpdateModalForm } from "./BatchUpdateModalForm";
13-
import { ACTIVE_BUILD_STATUSES } from "./WorkspacesPage";
1414

1515
type Writeable<T> = { -readonly [Key in keyof T]: T[Key] };
1616
type MutableWorkspace = Writeable<Omit<Workspace, "latest_build">> & {

site/src/pages/WorkspacesPage/BatchUpdateModalForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
} from "components/Dialog/Dialog";
1616
import { Spinner } from "components/Spinner/Spinner";
1717
import { TriangleAlert } from "lucide-react";
18+
import { ACTIVE_BUILD_STATUSES } from "modules/workspaces/status";
1819
import {
1920
type FC,
2021
type ForwardedRef,
@@ -25,7 +26,6 @@ import {
2526
} from "react";
2627
import { useQueries } from "react-query";
2728
import { cn } from "utils/cn";
28-
import { ACTIVE_BUILD_STATUSES } from "./WorkspacesPage";
2929

3030
export const BatchUpdateModalForm: FC<BatchUpdateModalFormProps> = ({
3131
open,

site/src/pages/WorkspacesPage/WorkspacesPage.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { getErrorDetail, getErrorMessage } from "api/errors";
22
import { workspacePermissionsByOrganization } from "api/queries/organizations";
33
import { templates, templateVersionRoot } from "api/queries/templates";
44
import { workspaces } from "api/queries/workspaces";
5-
import type { WorkspaceStatus } from "api/typesGenerated";
65
import { useFilter } from "components/Filter/Filter";
76
import { useUserFilterMenu } from "components/Filter/UserFilter";
87
import { displayError } from "components/GlobalSnackbar/utils";
@@ -11,6 +10,7 @@ import { useEffectEvent } from "hooks/hookPolyfills";
1110
import { usePagination } from "hooks/usePagination";
1211
import { useDashboard } from "modules/dashboard/useDashboard";
1312
import { useOrganizationsFilterMenu } from "modules/tableFiltering/options";
13+
import { ACTIVE_BUILD_STATUSES } from "modules/workspaces/status";
1414
import { type FC, useMemo, useState } from "react";
1515
import { Helmet } from "react-helmet-async";
1616
import { useQuery, useQueryClient } from "react-query";
@@ -22,19 +22,6 @@ import { useBatchActions } from "./batchActions";
2222
import { useStatusFilterMenu, useTemplateFilterMenu } from "./filter/menus";
2323
import { WorkspacesPageView } from "./WorkspacesPageView";
2424

25-
/**
26-
* The set of all workspace statuses that indicate that the state for a
27-
* workspace is in the middle of a transition and will eventually reach a more
28-
* stable state/status.
29-
*/
30-
export const ACTIVE_BUILD_STATUSES: readonly WorkspaceStatus[] = [
31-
"canceling",
32-
"deleting",
33-
"pending",
34-
"starting",
35-
"stopping",
36-
];
37-
3825
// To reduce the number of fetches, we reduce the fetch interval if there are no
3926
// active workspace builds.
4027
const ACTIVE_BUILDS_REFRESH_INTERVAL = 5_000;

0 commit comments

Comments
 (0)