Skip to content

Commit 80ac7bf

Browse files
committed
Remove create template xservice
1 parent a95ed6d commit 80ac7bf

File tree

3 files changed

+61
-597
lines changed

3 files changed

+61
-597
lines changed

site/src/pages/CreateTemplatePage/CreateTemplateForm.tsx

Lines changed: 60 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Template,
77
TemplateExample,
88
TemplateVersionVariable,
9+
VariableValue,
910
} from "api/typesGenerated";
1011
import { Stack } from "components/Stack/Stack";
1112
import { TemplateUpload, TemplateUploadProps } from "./TemplateUpload";
@@ -18,7 +19,6 @@ import {
1819
onChangeTrimmed,
1920
templateDisplayNameValidator,
2021
} from "utils/formUtils";
21-
import { CreateTemplateData } from "xServices/createTemplate/createTemplateXService";
2222
import * as Yup from "yup";
2323
import { WorkspaceBuildLogs } from "components/WorkspaceBuildLogs/WorkspaceBuildLogs";
2424
import {
@@ -42,51 +42,27 @@ import {
4242
AutostopRequirementWeeksHelperText,
4343
} from "pages/TemplateSettingsPage/TemplateSchedulePage/AutostopRequirementHelperText";
4444
import MenuItem from "@mui/material/MenuItem";
45+
import { TemplateAutostopRequirementDaysValue } from "utils/schedule";
4546

4647
const MAX_DESCRIPTION_CHAR_LIMIT = 128;
4748
const MAX_TTL_DAYS = 30;
4849

49-
const hours = (h: number) => (h === 1 ? "hour" : "hours");
50-
51-
const DefaultTTLHelperText = (props: { ttl?: number }) => {
52-
const { ttl = 0 } = props;
53-
54-
// Error will show once field is considered touched
55-
if (ttl < 0) {
56-
return null;
57-
}
58-
59-
if (ttl === 0) {
60-
return <span>Workspaces will run until stopped manually.</span>;
61-
}
62-
63-
return (
64-
<span>
65-
Workspaces will default to stopping after {ttl} {hours(ttl)} without
66-
activity.
67-
</span>
68-
);
69-
};
70-
71-
const MaxTTLHelperText = (props: { ttl?: number }) => {
72-
const { ttl = 0 } = props;
73-
74-
// Error will show once field is considered touched
75-
if (ttl < 0) {
76-
return null;
77-
}
78-
79-
if (ttl === 0) {
80-
return <span>Workspaces may run indefinitely.</span>;
81-
}
82-
83-
return (
84-
<span>
85-
Workspaces must stop within {ttl} {hours(ttl)} of starting, regardless of
86-
any active connections.
87-
</span>
88-
);
89-
};
50+
export interface CreateTemplateData {
51+
name: string;
52+
display_name: string;
53+
description: string;
54+
icon: string;
55+
default_ttl_hours: number;
56+
max_ttl_hours: number;
57+
autostop_requirement_days_of_week: TemplateAutostopRequirementDaysValue;
58+
autostop_requirement_weeks: number;
59+
allow_user_autostart: boolean;
60+
allow_user_autostop: boolean;
61+
allow_user_cancel_workspace_jobs: boolean;
62+
parameter_values_by_name?: Record<string, string>;
63+
user_variable_values?: VariableValue[];
64+
allow_everyone_group_access: boolean;
65+
}
9066

9167
const validationSchema = Yup.object({
9268
name: nameValidator("Name"),
@@ -643,6 +619,48 @@ const fillNameAndDisplayWithFilename = async (
643619
]);
644620
};
645621

622+
const hours = (h: number) => (h === 1 ? "hour" : "hours");
623+
624+
const DefaultTTLHelperText = (props: { ttl?: number }) => {
625+
const { ttl = 0 } = props;
626+
627+
// Error will show once field is considered touched
628+
if (ttl < 0) {
629+
return null;
630+
}
631+
632+
if (ttl === 0) {
633+
return <span>Workspaces will run until stopped manually.</span>;
634+
}
635+
636+
return (
637+
<span>
638+
Workspaces will default to stopping after {ttl} {hours(ttl)} without
639+
activity.
640+
</span>
641+
);
642+
};
643+
644+
const MaxTTLHelperText = (props: { ttl?: number }) => {
645+
const { ttl = 0 } = props;
646+
647+
// Error will show once field is considered touched
648+
if (ttl < 0) {
649+
return null;
650+
}
651+
652+
if (ttl === 0) {
653+
return <span>Workspaces may run indefinitely.</span>;
654+
}
655+
656+
return (
657+
<span>
658+
Workspaces must stop within {ttl} {hours(ttl)} of starting, regardless of
659+
any active connections.
660+
</span>
661+
);
662+
};
663+
646664
const useStyles = makeStyles((theme) => ({
647665
ttlFields: {
648666
width: "100%",

site/src/pages/CreateTemplatePage/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
VariableValue,
66
} from "api/typesGenerated";
77
import { calculateAutostopRequirementDaysValue } from "utils/schedule";
8-
import { CreateTemplateData } from "xServices/createTemplate/createTemplateXService";
8+
import { CreateTemplateData } from "./CreateTemplateForm";
99

1010
const provisioner: ProvisionerType =
1111
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Playwright needs to use a different provisioner type!

0 commit comments

Comments
 (0)