Skip to content

Commit a949d39

Browse files
committed
remove experiment enabled helper fn
1 parent a45ec9e commit a949d39

File tree

6 files changed

+18
-30
lines changed

6 files changed

+18
-30
lines changed

site/src/components/Dashboard/DashboardProvider.tsx

-9
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,3 @@ export const useDashboard = (): DashboardProviderValue => {
110110

111111
return context;
112112
};
113-
114-
export const useIsWorkspaceActionsEnabled = (): boolean => {
115-
const { entitlements } = useDashboard();
116-
const allowAdvancedScheduling =
117-
entitlements.features["advanced_template_scheduling"].enabled;
118-
// This check can be removed when https://github.com/coder/coder/milestone/19
119-
// is merged up
120-
return allowAdvancedScheduling;
121-
};

site/src/components/WorkspaceDeletion/DormantWorkspaceBanner.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Workspace } from "api/typesGenerated";
2-
import { useIsWorkspaceActionsEnabled } from "components/Dashboard/DashboardProvider";
2+
import { useDashboard } from "components/Dashboard/DashboardProvider";
33
import { Alert } from "components/Alert/Alert";
44
import { formatDistanceToNow } from "date-fns";
55
import Link from "@mui/material/Link";
@@ -21,7 +21,9 @@ export const DormantWorkspaceBanner = ({
2121
shouldRedisplayBanner: boolean;
2222
count?: Count;
2323
}): JSX.Element | null => {
24-
const experimentEnabled = useIsWorkspaceActionsEnabled();
24+
const { entitlements } = useDashboard();
25+
const schedulingEnabled =
26+
entitlements.features["advanced_template_scheduling"].enabled;
2527

2628
if (!workspaces) {
2729
return null;
@@ -37,7 +39,7 @@ export const DormantWorkspaceBanner = ({
3739

3840
if (
3941
// Only show this if the experiment is included.
40-
!experimentEnabled ||
42+
!schedulingEnabled ||
4143
!hasDormantWorkspaces ||
4244
// Banners should be redisplayed after dismissal when additional workspaces are newly scheduled for deletion
4345
!shouldRedisplayBanner

site/src/pages/DeploySettingsPage/GeneralSettingsPage/GeneralSettingsPageView.stories.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,7 @@ const meta: Meta<typeof GeneralSettingsPageView> = {
3030
description:
3131
"Enable one or more experiments. These are not ready for production. Separate multiple experiments with commas, or enter '*' to opt-in to all available experiments.",
3232
flag: "experiments",
33-
value: [
34-
"*",
35-
"moons",
36-
"workspace_actions",
37-
"single_tailnet",
38-
"deployment_health_page",
39-
],
33+
value: ["*", "moons", "single_tailnet", "deployment_health_page"],
4034
flag_shorthand: "",
4135
hidden: false,
4236
},

site/src/pages/TemplateSettingsPage/TemplateSchedulePage/TemplateSchedulePageView.stories.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ type Story = StoryObj<typeof TemplateSchedulePageView>;
3131

3232
const defaultArgs = {
3333
allowAdvancedScheduling: true,
34-
allowWorkspaceActions: true,
3534
template: MockTemplate,
3635
onSubmit: action("onSubmit"),
3736
onCancel: action("cancel"),

site/src/pages/WorkspacesPage/WorkspacesPage.tsx

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { usePagination } from "hooks/usePagination";
22
import { Workspace } from "api/typesGenerated";
3-
import {
4-
useDashboard,
5-
useIsWorkspaceActionsEnabled,
6-
} from "components/Dashboard/DashboardProvider";
3+
import { useDashboard } from "components/Dashboard/DashboardProvider";
74
import { type FC, useEffect, useState } from "react";
85
import { Helmet } from "react-helmet-async";
96
import { pageTitle } from "utils/page";
@@ -54,13 +51,16 @@ const WorkspacesPage: FC = () => {
5451
query: filterProps.filter.query,
5552
});
5653

57-
const experimentEnabled = useIsWorkspaceActionsEnabled();
54+
const { entitlements } = useDashboard();
55+
const schedulingEnabled =
56+
entitlements.features["advanced_template_scheduling"].enabled;
57+
5858
// If workspace actions are enabled we need to fetch the dormant
5959
// workspaces as well. This lets us determine whether we should
6060
// show a banner to the user indicating that some of their workspaces
6161
// are at risk of being deleted.
6262
useEffect(() => {
63-
if (experimentEnabled) {
63+
if (schedulingEnabled) {
6464
const includesDormant = filterProps.filter.query.includes("dormant_at");
6565
const dormantQuery = includesDormant
6666
? filterProps.filter.query
@@ -82,12 +82,11 @@ const WorkspacesPage: FC = () => {
8282
// like dormant workspaces don't exist.
8383
setDormantWorkspaces([]);
8484
}
85-
}, [experimentEnabled, data, filterProps.filter.query]);
85+
}, [schedulingEnabled, data, filterProps.filter.query]);
8686
const updateWorkspace = useWorkspaceUpdate(queryKey);
8787
const [checkedWorkspaces, setCheckedWorkspaces] = useState<Workspace[]>([]);
8888
const [isDeletingAll, setIsDeletingAll] = useState(false);
8989
const [urlSearchParams] = searchParamsResult;
90-
const { entitlements } = useDashboard();
9190
const canCheckWorkspaces =
9291
entitlements.features["workspace_batch_actions"].enabled;
9392

site/src/pages/WorkspacesPage/filter/filter.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FC } from "react";
22
import Box from "@mui/material/Box";
3-
import { useIsWorkspaceActionsEnabled } from "components/Dashboard/DashboardProvider";
3+
import { useDashboard } from "components/Dashboard/DashboardProvider";
4+
45
import { Avatar, AvatarProps } from "components/Avatar/Avatar";
56
import { Palette, PaletteColor } from "@mui/material/styles";
67
import { TemplateFilterMenu, StatusFilterMenu } from "./menus";
@@ -68,7 +69,9 @@ export const WorkspacesFilter = ({
6869
error,
6970
menus,
7071
}: WorkspaceFilterProps) => {
71-
const actionsEnabled = useIsWorkspaceActionsEnabled();
72+
const { entitlements } = useDashboard();
73+
const actionsEnabled =
74+
entitlements.features["advanced_template_scheduling"].enabled;
7275
const presets = actionsEnabled ? PRESET_FILTERS : PRESETS_WITH_DORMANT;
7376

7477
return (

0 commit comments

Comments
 (0)