Skip to content

Commit

Permalink
label some template settings as enterprise (#12952)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslilac committed Apr 15, 2024
1 parent d3790bb commit 7cf8577
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface TemplateSettingsForm {
// Helpful to show field errors on Storybook
initialTouched?: FormikTouched<UpdateTemplateMeta>;
accessControlEnabled: boolean;
advancedSchedulingEnabled: boolean;
portSharingExperimentEnabled: boolean;
portSharingControlsEnabled: boolean;
}
Expand All @@ -73,6 +74,7 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
isSubmitting,
initialTouched,
accessControlEnabled,
advancedSchedulingEnabled,
portSharingExperimentEnabled,
portSharingControlsEnabled,
}) => {
Expand Down Expand Up @@ -195,39 +197,54 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
</Stack>
</Stack>
</label>
<label htmlFor="require_active_version">
<Stack direction="row" spacing={1}>
<Checkbox
id="require_active_version"
name="require_active_version"
checked={form.values.require_active_version}
onChange={form.handleChange}
/>
<Stack spacing={2}>
<label htmlFor="require_active_version">
<Stack direction="row" spacing={1}>
<Checkbox
id="require_active_version"
name="require_active_version"
checked={form.values.require_active_version}
onChange={form.handleChange}
disabled={
!template.require_active_version &&
!advancedSchedulingEnabled
}
/>

<Stack direction="column" spacing={0.5}>
<Stack
direction="row"
alignItems="center"
spacing={0.5}
css={styles.optionText}
>
Require workspaces automatically update when started.
<HelpTooltip>
<HelpTooltipTrigger />
<HelpTooltipContent>
<HelpTooltipText>
This setting is not enforced for template admins.
</HelpTooltipText>
</HelpTooltipContent>
</HelpTooltip>
<Stack direction="column" spacing={0.5}>
<Stack
direction="row"
alignItems="center"
spacing={0.5}
css={styles.optionText}
>
Require workspaces automatically update when started.
<HelpTooltip>
<HelpTooltipTrigger />
<HelpTooltipContent>
<HelpTooltipText>
This setting is not enforced for template admins.
</HelpTooltipText>
</HelpTooltipContent>
</HelpTooltip>
</Stack>
<span css={styles.optionHelperText}>
Workspaces that are manually started or auto-started will
use the active template version.
</span>
</Stack>
</Stack>
</label>

{!advancedSchedulingEnabled && (
<Stack direction="row">
<EnterpriseBadge />
<span css={styles.optionHelperText}>
Workspaces that are manually started or auto-started will use
the active template version.
Enterprise license required to enabled.
</span>
</Stack>
</Stack>
</label>
)}
</Stack>
</Stack>
</FormSection>

Expand All @@ -241,7 +258,9 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
helperText:
"Leave the message empty to keep the template active. Any message provided will mark the template as deprecated. Use this message to inform users of the deprecation and how to migrate to a new template.",
})}
disabled={isSubmitting || !accessControlEnabled}
disabled={
isSubmitting || (!template.deprecated && !accessControlEnabled)
}
fullWidth
label="Deprecation Message"
/>
Expand All @@ -250,6 +269,8 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
<EnterpriseBadge />
<span css={styles.optionHelperText}>
Enterprise license required to deprecate templates.
{template.deprecated &&
" You cannot change the message, but you may remove it to mark this template as no longer deprecated."}
</span>
</Stack>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const TemplateSettingsPage: FC = () => {
const queryClient = useQueryClient();
const { entitlements, experiments } = useDashboard();
const accessControlEnabled = entitlements.features.access_control.enabled;
const advancedSchedulingEnabled =
entitlements.features.advanced_template_scheduling.enabled;
const sharedPortsExperimentEnabled = experiments.includes("shared-ports");
const sharedPortControlsEnabled =
entitlements.features.control_shared_ports.enabled;
Expand Down Expand Up @@ -70,6 +72,7 @@ export const TemplateSettingsPage: FC = () => {
});
}}
accessControlEnabled={accessControlEnabled}
advancedSchedulingEnabled={advancedSchedulingEnabled}
sharedPortsExperimentEnabled={sharedPortsExperimentEnabled}
sharedPortControlsEnabled={sharedPortControlsEnabled}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const meta: Meta<typeof TemplateSettingsPageView> = {
args: {
template: MockTemplate,
accessControlEnabled: true,
advancedSchedulingEnabled: true,
},
};

Expand Down Expand Up @@ -36,5 +37,19 @@ export const SaveTemplateSettingsError: Story = {
export const NoEntitlements: Story = {
args: {
accessControlEnabled: false,
advancedSchedulingEnabled: false,
},
};

export const NoEntitlementsExpiredSettings: Story = {
args: {
template: {
...MockTemplate,
deprecated: true,
deprecation_message: "This template tastes bad",
require_active_version: true,
},
accessControlEnabled: false,
advancedSchedulingEnabled: false,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface TemplateSettingsPageViewProps {
typeof TemplateSettingsForm
>["initialTouched"];
accessControlEnabled: boolean;
advancedSchedulingEnabled: boolean;
sharedPortsExperimentEnabled: boolean;
sharedPortControlsEnabled: boolean;
}
Expand All @@ -25,6 +26,7 @@ export const TemplateSettingsPageView: FC<TemplateSettingsPageViewProps> = ({
submitError,
initialTouched,
accessControlEnabled,
advancedSchedulingEnabled,
sharedPortsExperimentEnabled,
sharedPortControlsEnabled,
}) => {
Expand All @@ -42,6 +44,7 @@ export const TemplateSettingsPageView: FC<TemplateSettingsPageViewProps> = ({
onCancel={onCancel}
error={submitError}
accessControlEnabled={accessControlEnabled}
advancedSchedulingEnabled={advancedSchedulingEnabled}
portSharingExperimentEnabled={sharedPortsExperimentEnabled}
portSharingControlsEnabled={sharedPortControlsEnabled}
/>
Expand Down

0 comments on commit 7cf8577

Please sign in to comment.