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

Commitd8a8070

Browse files
fix(site): enable submit when auto start and stop are both disabled (#12055)
1 parent4b1bac3 commitd8a8070

File tree

4 files changed

+60
-7
lines changed

4 files changed

+60
-7
lines changed

‎site/src/components/Badges/Badges.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
importtype{PropsWithChildren,FC}from"react";
1+
import{
2+
typePropsWithChildren,
3+
typeFC,
4+
forwardRef,
5+
HTMLAttributes,
6+
}from"react";
27
importTooltipfrom"@mui/material/Tooltip";
38
import{typeInterpolation,typeTheme}from"@emotion/react";
49
import{Stack}from"components/Stack/Stack";
@@ -74,9 +79,14 @@ export const NotReachableBadge: FC = () => {
7479
);
7580
};
7681

77-
exportconstDisabledBadge:FC=()=>{
82+
exportconstDisabledBadge:FC=forwardRef<
83+
HTMLSpanElement,
84+
HTMLAttributes<HTMLSpanElement>
85+
>((props,ref)=>{
7886
return(
7987
<span
88+
{...props}
89+
ref={ref}
8090
css={[
8191
styles.badge,
8292
(theme)=>({
@@ -89,7 +99,7 @@ export const DisabledBadge: FC = () => {
8999
Disabled
90100
</span>
91101
);
92-
};
102+
});
93103

94104
exportconstEnterpriseBadge:FC=()=>{
95105
return(

‎site/src/pages/WorkspaceSettingsPage/WorkspaceSchedulePage/WorkspaceScheduleForm.stories.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,13 @@ export const Loading: Story = {
105105
isLoading:true,
106106
},
107107
};
108+
109+
exportconstAutoStopAndStartOff:Story={
110+
args:{
111+
initialValues:{
112+
...defaultInitialValues,
113+
autostartEnabled:false,
114+
autostopEnabled:false,
115+
},
116+
},
117+
};

‎site/src/pages/WorkspaceSettingsPage/WorkspaceSchedulePage/WorkspaceScheduleForm.test.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,37 @@ describe("templateInheritance", () => {
379379
expect(ttlInput).toBeDisabled();
380380
});
381381
});
382+
383+
test("form should be enabled when both auto stop and auto start features are disabled, given that the template permits these actions",async()=>{
384+
jest.spyOn(API,"getTemplateByName").mockResolvedValue(MockTemplate);
385+
render(
386+
<WorkspaceScheduleForm
387+
{...defaultFormProps}
388+
initialValues={{
389+
...defaultFormProps.initialValues,
390+
autostopEnabled:false,
391+
autostartEnabled:false,
392+
}}
393+
/>,
394+
);
395+
396+
constsubmitButton=awaitscreen.findByRole("button",{name:"Submit"});
397+
expect(submitButton).toBeEnabled();
398+
});
399+
400+
test("form should be disabled when both auto stop and auto start features are disabled at template level",async()=>{
401+
jest.spyOn(API,"getTemplateByName").mockResolvedValue(MockTemplate);
402+
render(
403+
<WorkspaceScheduleForm
404+
{...defaultFormProps}
405+
allowTemplateAutoStart={false}
406+
allowTemplateAutoStop={false}
407+
initialValues={{
408+
...defaultFormProps.initialValues,
409+
}}
410+
/>,
411+
);
412+
413+
constsubmitButton=awaitscreen.findByRole("button",{name:"Submit"});
414+
expect(submitButton).toBeDisabled();
415+
});

‎site/src/pages/WorkspaceSettingsPage/WorkspaceSchedulePage/WorkspaceScheduleForm.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,9 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
441441
<FormFooter
442442
onCancel={onCancel}
443443
isLoading={isLoading}
444-
submitDisabled={
445-
(!allowTemplateAutoStart&&!allowTemplateAutoStop)||
446-
(!form.values.autostartEnabled&&!form.values.autostopEnabled)
447-
}
444+
// If both options, autostart and autostop, are disabled at the template
445+
// level, the form is disabled.
446+
submitDisabled={!allowTemplateAutoStart&&!allowTemplateAutoStop}
448447
/>
449448
</HorizontalForm>
450449
);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp