Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4d449ae

Browse files
committed
web: use seconds in max TTL input
Milliseconds are more difficult to deal with due toall of the zeros.Also, describe this feature as "auto-stop" to beconsistent with our Workspace page UI and CLI. "ttl"is our backend lingo which should eventually be updated.
1 parent7599ad4 commit4d449ae

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

‎site/src/pages/TemplateSettingsPage/TemplateSettingsForm.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import * as Yup from "yup"
1010
exportconstLanguage={
1111
nameLabel:"Name",
1212
descriptionLabel:"Description",
13-
maxTtlLabel:"Max TTL",
13+
maxTtlLabel:"Auto-stop limit",
1414
// This is the same from the CLI on https://github.com/coder/coder/blob/546157b63ef9204658acf58cb653aa9936b70c49/cli/templateedit.go#L59
15-
maxTtlHelperText:"Edit the template maximum time before shutdown inmilliseconds",
15+
maxTtlHelperText:"Edit the template maximum time before shutdown inseconds",
1616
formAriaLabel:"Template settings form",
1717
}
1818

@@ -21,6 +21,11 @@ export const validationSchema = Yup.object({
2121
description:Yup.string(),
2222
max_ttl_ms:Yup.number(),
2323
})
24+
exportinterfaceUpdateTemplateFormMeta{
25+
readonlyname?:string
26+
readonlydescription?:string
27+
readonlymax_ttl?:number
28+
}
2429

2530
exportinterfaceTemplateSettingsForm{
2631
template:Template
@@ -29,7 +34,7 @@ export interface TemplateSettingsForm {
2934
isSubmitting:boolean
3035
error?:unknown
3136
// Helpful to show field errors on Storybook
32-
initialTouched?:FormikTouched<UpdateTemplateMeta>
37+
initialTouched?:FormikTouched<UpdateTemplateFormMeta>
3338
}
3439

3540
exportconstTemplateSettingsForm:FC<TemplateSettingsForm>=({
@@ -40,19 +45,22 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
4045
isSubmitting,
4146
initialTouched,
4247
})=>{
43-
constform:FormikContextType<UpdateTemplateMeta>=useFormik<UpdateTemplateMeta>({
48+
constform:FormikContextType<UpdateTemplateFormMeta>=useFormik<UpdateTemplateFormMeta>({
4449
initialValues:{
4550
name:template.name,
4651
description:template.description,
47-
max_ttl_ms:template.max_ttl_ms,
52+
max_ttl:template.max_ttl_ms/1000,
4853
},
4954
validationSchema,
5055
onSubmit:(data)=>{
51-
onSubmit(data)
56+
onSubmit({
57+
...data,
58+
max_ttl_ms:data.max_ttl!==undefined ?data.max_ttl*1000 :undefined,
59+
})
5260
},
5361
initialTouched,
5462
})
55-
constgetFieldHelpers=getFormHelpersWithError<UpdateTemplateMeta>(form,error)
63+
constgetFieldHelpers=getFormHelpersWithError<UpdateTemplateFormMeta>(form,error)
5664

5765
return(
5866
<formonSubmit={form.handleSubmit}aria-label={Language.formAriaLabel}>
@@ -78,7 +86,7 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
7886
/>
7987

8088
<TextField
81-
{...getFieldHelpers("max_ttl_ms")}
89+
{...getFieldHelpers("max_ttl")}
8290
helperText={Language.maxTtlHelperText}
8391
disabled={isSubmitting}
8492
fullWidth

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp