mirror of
https://github.com/coder/coder.git
synced 2026-09-21 20:51:01 +08:00
fix(site): resolve circular dependency between WorkspacesPage components (#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>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import type { WorkspaceStatus } from "api/typesGenerated";
|
||||
|
||||
/**
|
||||
* The set of all workspace statuses that indicate that the state for a
|
||||
* workspace is in the middle of a transition and will eventually reach a more
|
||||
* stable state/status.
|
||||
*/
|
||||
export const ACTIVE_BUILD_STATUSES: readonly WorkspaceStatus[] = [
|
||||
"canceling",
|
||||
"deleting",
|
||||
"pending",
|
||||
"starting",
|
||||
"stopping",
|
||||
];
|
||||
@@ -6,11 +6,11 @@ import type {
|
||||
Workspace,
|
||||
WorkspaceBuild,
|
||||
} from "api/typesGenerated";
|
||||
import { ACTIVE_BUILD_STATUSES } from "modules/workspaces/status";
|
||||
import { useQueryClient } from "react-query";
|
||||
import { action } from "storybook/internal/actions";
|
||||
import { expect, screen, userEvent, within } from "storybook/test";
|
||||
import { BatchUpdateModalForm } from "./BatchUpdateModalForm";
|
||||
import { ACTIVE_BUILD_STATUSES } from "./WorkspacesPage";
|
||||
|
||||
type Writeable<T> = { -readonly [Key in keyof T]: T[Key] };
|
||||
type MutableWorkspace = Writeable<Omit<Workspace, "latest_build">> & {
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
} from "components/Dialog/Dialog";
|
||||
import { Spinner } from "components/Spinner/Spinner";
|
||||
import { TriangleAlert } from "lucide-react";
|
||||
import { ACTIVE_BUILD_STATUSES } from "modules/workspaces/status";
|
||||
import {
|
||||
type FC,
|
||||
type ForwardedRef,
|
||||
@@ -25,7 +26,6 @@ import {
|
||||
} from "react";
|
||||
import { useQueries } from "react-query";
|
||||
import { cn } from "utils/cn";
|
||||
import { ACTIVE_BUILD_STATUSES } from "./WorkspacesPage";
|
||||
|
||||
export const BatchUpdateModalForm: FC<BatchUpdateModalFormProps> = ({
|
||||
open,
|
||||
|
||||
@@ -2,7 +2,6 @@ import { getErrorDetail, getErrorMessage } from "api/errors";
|
||||
import { workspacePermissionsByOrganization } from "api/queries/organizations";
|
||||
import { templates, templateVersionRoot } from "api/queries/templates";
|
||||
import { workspaces } from "api/queries/workspaces";
|
||||
import type { WorkspaceStatus } from "api/typesGenerated";
|
||||
import { useFilter } from "components/Filter/Filter";
|
||||
import { useUserFilterMenu } from "components/Filter/UserFilter";
|
||||
import { displayError } from "components/GlobalSnackbar/utils";
|
||||
@@ -11,6 +10,7 @@ import { useEffectEvent } from "hooks/hookPolyfills";
|
||||
import { usePagination } from "hooks/usePagination";
|
||||
import { useDashboard } from "modules/dashboard/useDashboard";
|
||||
import { useOrganizationsFilterMenu } from "modules/tableFiltering/options";
|
||||
import { ACTIVE_BUILD_STATUSES } from "modules/workspaces/status";
|
||||
import { type FC, useMemo, useState } from "react";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { useQuery, useQueryClient } from "react-query";
|
||||
@@ -22,19 +22,6 @@ import { useBatchActions } from "./batchActions";
|
||||
import { useStatusFilterMenu, useTemplateFilterMenu } from "./filter/menus";
|
||||
import { WorkspacesPageView } from "./WorkspacesPageView";
|
||||
|
||||
/**
|
||||
* The set of all workspace statuses that indicate that the state for a
|
||||
* workspace is in the middle of a transition and will eventually reach a more
|
||||
* stable state/status.
|
||||
*/
|
||||
export const ACTIVE_BUILD_STATUSES: readonly WorkspaceStatus[] = [
|
||||
"canceling",
|
||||
"deleting",
|
||||
"pending",
|
||||
"starting",
|
||||
"stopping",
|
||||
];
|
||||
|
||||
// To reduce the number of fetches, we reduce the fetch interval if there are no
|
||||
// active workspace builds.
|
||||
const ACTIVE_BUILDS_REFRESH_INTERVAL = 5_000;
|
||||
|
||||
Reference in New Issue
Block a user