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

refactor(site): refactor the workspace settings form#13198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 3 commits intomainfrombq/improve-ws-autostop
May 8, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -281,7 +281,9 @@ describe("templateInheritance", () => {
};
render(<WorkspaceScheduleForm {...props} />);

const autoStartToggle = await screen.findByLabelText("Enable Autostart");
const autoStartToggle = await screen.findByLabelText("Enable Autostart", {
exact: false,
});
expect(autoStartToggle).toBeDisabled();

const startTimeInput = await screen.findByLabelText("Start time");
Expand DownExpand Up@@ -313,7 +315,9 @@ describe("templateInheritance", () => {

render(<WorkspaceScheduleForm {...props} />);

const autoStartToggle = await screen.findByLabelText("Enable Autostart");
const autoStartToggle = await screen.findByLabelText("Enable Autostart", {
exact: false,
});
expect(autoStartToggle).toBeEnabled();

const startTimeInput = await screen.findByLabelText("Start time");
Expand DownExpand Up@@ -346,7 +350,9 @@ describe("templateInheritance", () => {
jest.spyOn(API, "getTemplateByName").mockResolvedValue(MockTemplate);
render(<WorkspaceScheduleForm {...props} />);

const autoStopToggle = await screen.findByLabelText("Enable Autostop");
const autoStopToggle = await screen.findByLabelText("Enable Autostop", {
exact: false,
});
expect(autoStopToggle).toBeDisabled();

const ttlInput = await screen.findByLabelText(
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ import FormLabel from "@mui/material/FormLabel";
import MenuItem from "@mui/material/MenuItem";
import Switch from "@mui/material/Switch";
import TextField from "@mui/material/TextField";
import Tooltip from "@mui/material/Tooltip";
import { formatDuration, intervalToDuration } from "date-fns";
import dayjs from "dayjs";
import advancedFormat from "dayjs/plugin/advancedFormat";
Expand All@@ -19,14 +18,17 @@ import { type FormikTouched, useFormik } from "formik";
import type { ChangeEvent, FC } from "react";
import * as Yup from "yup";
import type { Template } from "api/typesGenerated";
import { DisabledBadge } from "components/Badges/Badges";
import {
HorizontalForm,
FormFooter,
FormSection,
FormFields,
} from "components/Form/Form";
import { Stack } from "components/Stack/Stack";
import {
StackLabel,
StackLabelHelperText,
} from "components/StackLabel/StackLabel";
import {
defaultSchedule,
emptySchedule,
Expand DownExpand Up@@ -180,6 +182,10 @@ export const validationSchema = Yup.object({
}),
});

// This form utilizes complex, visually-intensive fields. Increasing the space
// between these fields enhances readability and cleanliness.
const FIELDS_SPACING = 4;

export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
error,
initialValues,
Expand DownExpand Up@@ -275,31 +281,30 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
<HorizontalForm onSubmit={form.handleSubmit}>
<FormSection
title="Autostart"
description={
<>
<div css={{ marginBottom: 16 }}>
Select the time and days of week on which you want the workspace
starting automatically.
</div>
{!template.allow_user_autostart && (
<Tooltip title="This option can be enabled in the template settings">
<DisabledBadge />
</Tooltip>
)}
</>
}
description="Select the time and days of week on which you want the workspace starting automatically."
>
<FormFields>
<FormFields spacing={FIELDS_SPACING}>
<FormControlLabel
control={
<Switch
disabled={!template.allow_user_autostart}
name="autostartEnabled"
checked={form.values.autostartEnabled}
onChange={handleToggleAutostart}
size="small"
/>
}
label={Language.startSwitch}
label={
<StackLabel>
{Language.startSwitch}
{!template.allow_user_autostart && (
<StackLabelHelperText>
The template for this workspace does not allow modification
of autostart.
</StackLabelHelperText>
)}
</StackLabel>
}
/>
<Stack direction="row">
<TextField
Expand DownExpand Up@@ -387,34 +392,37 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
title="Autostop"
description={
<>
<div css={{ marginBottom: 16 }}>
Set how many hours should elapse after the workspace started
before the workspace automatically shuts down. This will be
extended by{" "}
{dayjs
.duration({ milliseconds: template.activity_bump_ms })
.humanize()}{" "}
after last activity in the workspace was detected.
</div>
{!template.allow_user_autostop && (
<Tooltip title="This option can be enabled in the template settings">
<DisabledBadge />
</Tooltip>
)}
Set how many hours should elapse after the workspace started before
the workspace automatically shuts down. This will be extended by{" "}
{dayjs
.duration({ milliseconds: template.activity_bump_ms })
.humanize()}{" "}
after last activity in the workspace was detected.
</>
}
>
<FormFields>
<FormFields spacing={FIELDS_SPACING}>
<FormControlLabel
control={
<Switch
size="small"
name="autostopEnabled"
checked={form.values.autostopEnabled}
onChange={handleToggleAutostop}
disabled={!template.allow_user_autostop}
/>
}
label={Language.stopSwitch}
label={
<StackLabel>
{Language.stopSwitch}
{!template.allow_user_autostop && (
<StackLabelHelperText>
The template for this workspace does not allow modification
of autostop.
</StackLabelHelperText>
)}
</StackLabel>
}
/>
<TextField
{...formHelpers("ttl", {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp