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

feat: Add switches for auto-start and auto-stop#3358

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
presleyp merged 26 commits intomainfromdisable-auto-start/presleyp/3051
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
26 commits
Select commitHold shift + click to select a range
54bf130
Add elements
presleypJul 29, 2022
ecc1137
Add Loading story
presleypJul 29, 2022
6705076
Make form show empty values when manual
presleypJul 29, 2022
91259c4
Make form depend on switches
presleypAug 1, 2022
70228bd
Fix style
presleypAug 1, 2022
52b26bf
Format
presleypAug 1, 2022
b224258
Update unit tests
presleypAug 1, 2022
4f68bb1
Tweaks
presleypAug 1, 2022
ff48adf
Update storybook
presleypAug 2, 2022
bbaee7d
Move util files
presleypAug 8, 2022
f251efa
Pull out more util functions
presleypAug 8, 2022
eab6e5f
Pull out strings
presleypAug 8, 2022
e92a2c1
Add border to section
presleypAug 8, 2022
a35bf20
Make min ttl 1
presleypAug 8, 2022
750f08b
Format
presleypAug 8, 2022
3dfa41b
Fix import
presleypAug 8, 2022
848732a
Fix validation for falsey values
presleypAug 8, 2022
bfbabe1
Format and fix tests
presleypAug 9, 2022
d1420de
Put switches in form, persist form state
presleypAug 10, 2022
0577ea9
Fix bug
presleypAug 10, 2022
a6271ca
Remove helper text when disabled
presleypAug 10, 2022
af4e8e4
Fix storybook
presleypAug 10, 2022
e8ae5ba
Revert "Remove helper text when disabled"
presleypAug 10, 2022
4993c3d
Format
presleypAug 10, 2022
a17dc2e
Use nicer function to set values
presleypAug 10, 2022
bf22caa
Format
presleypAug 10, 2022
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
5 changes: 3 additions & 2 deletionssite/src/components/Section/Section.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ export const Section: SectionFC = ({
}) => {
const styles = useStyles({ layout })
return (
<div className={combineClasses([styles.root, className])}>
<section className={combineClasses([styles.root, className])}>
<div className={styles.inner}>
{(title || description) && (
<div className={styles.header}>
Expand All@@ -49,7 +49,7 @@ export const Section: SectionFC = ({
{alert && <div className={styles.alert}>{alert}</div>}
{children}
</div>
</div>
</section>
)
}

Expand All@@ -63,6 +63,7 @@ const useStyles = makeStyles((theme) => ({
marginBottom: theme.spacing(1),
padding: theme.spacing(6),
borderRadius: theme.shape.borderRadius,
border: `1px solid ${theme.palette.divider}`,

[theme.breakpoints.down("sm")]: {
padding: theme.spacing(4, 3, 4, 3),
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,12 +3,10 @@ import dayjs from "dayjs"
import advancedFormat from "dayjs/plugin/advancedFormat"
import timezone from "dayjs/plugin/timezone"
import utc from "dayjs/plugin/utc"
import { defaultSchedule, emptySchedule } from "pages/WorkspaceSchedulePage/schedule"
import { defaultTTL, emptyTTL } from "pages/WorkspaceSchedulePage/ttl"
import { makeMockApiError } from "testHelpers/entities"
import {
defaultWorkspaceSchedule,
WorkspaceScheduleForm,
WorkspaceScheduleFormProps,
} from "./WorkspaceScheduleForm"
import { WorkspaceScheduleForm, WorkspaceScheduleFormProps } from "./WorkspaceScheduleForm"

dayjs.extend(advancedFormat)
dayjs.extend(utc)
Expand All@@ -29,51 +27,60 @@ export default {

const Template: Story<WorkspaceScheduleFormProps> = (args) => <WorkspaceScheduleForm {...args} />

export const WorkspaceWillNotShutDown = Template.bind({})
WorkspaceWillNotShutDown.args = {
const defaultInitialValues = {
autoStartEnabled: true,
...defaultSchedule(),
autoStopEnabled: true,
ttl: defaultTTL,
}

export const AllDisabled = Template.bind({})
AllDisabled.args = {
initialValues: {
...defaultWorkspaceSchedule(5),
ttl: 0,
autoStartEnabled: false,
...emptySchedule,
autoStopEnabled: false,
ttl: emptyTTL,
},
}

export constWorkspaceWillShutdownInAnHour = Template.bind({})
WorkspaceWillShutdownInAnHour.args = {
export constAutoStart = Template.bind({})
AutoStart.args = {
initialValues: {
...defaultWorkspaceSchedule(5),
ttl: 1,
autoStartEnabled: true,
...defaultSchedule(),
autoStopEnabled: false,
ttl: emptyTTL,
},
}

export const WorkspaceWillShutdownInTwoHours = Template.bind({})
WorkspaceWillShutdownInTwoHours.args = {
initialValues: {
...defaultWorkspaceSchedule(2),
ttl: 2,
},
initialValues: { ...defaultInitialValues, ttl: 2 },
}

export const WorkspaceWillShutdownInADay = Template.bind({})
WorkspaceWillShutdownInADay.args = {
initialValues: {
...defaultWorkspaceSchedule(2),
ttl: 24,
},
initialValues: { ...defaultInitialValues, ttl: 24 },
}

export const WorkspaceWillShutdownInTwoDays = Template.bind({})
WorkspaceWillShutdownInTwoDays.args = {
initialValues: {
...defaultWorkspaceSchedule(2),
ttl: 48,
},
initialValues: { ...defaultInitialValues, ttl: 48 },
}

export const WithError = Template.bind({})
WithError.args = {
initialValues: { ...defaultInitialValues, ttl: 100 },
initialTouched: { ttl: true },
submitScheduleError: makeMockApiError({
message: "Something went wrong.",
validations: [{ field: "ttl_ms", detail: "Invalid time until shutdown." }],
}),
}

export const Loading = Template.bind({})
Loading.args = {
initialValues: defaultInitialValues,
isLoading: true,
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,32 +7,36 @@ import {
import { zones } from "./zones"

const valid: WorkspaceScheduleFormValues = {
autoStartEnabled: true,
sunday: false,
monday: true,
tuesday: true,
wednesday: true,
thursday: true,
friday: true,
saturday: false,

startTime: "09:30",
timezone: "Canada/Eastern",

autoStopEnabled: true,
ttl: 120,
}

describe("validationSchema", () => {
it("allows everything to be falsy", () => {
it("allows everything to be falsy when switches are off", () => {
const values: WorkspaceScheduleFormValues = {
autoStartEnabled: false,
sunday: false,
monday: false,
tuesday: false,
wednesday: false,
thursday: false,
friday: false,
saturday: false,

startTime: "",
timezone: "",

autoStopEnabled: false,
ttl: 0,
}
const validate = () => validationSchema.validateSync(values)
Expand All@@ -48,7 +52,7 @@ describe("validationSchema", () => {
expect(validate).toThrow()
})

it("disallows all days-of-week to be false whenstartTime isset", () => {
it("disallows all days-of-week to be false whenauto-start isenabled", () => {
const values: WorkspaceScheduleFormValues = {
...valid,
sunday: false,
Expand All@@ -63,7 +67,7 @@ describe("validationSchema", () => {
expect(validate).toThrowError(Language.errorNoDayOfWeek)
})

it("disallows empty startTime whenat least one dayisset", () => {
it("disallows empty startTime whenauto-startisenabled", () => {
const values: WorkspaceScheduleFormValues = {
...valid,
sunday: false,
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp