From a288374027d265a3054b7bb48b0019ff3efe40cc Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 4 Jul 2020 17:00:19 -0700 Subject: [PATCH] Update schedule page --- .../components/elements/ConfirmationModal.tsx | 2 +- .../scripts/components/elements/Select.tsx | 36 +++++++++++++ .../scripts/components/elements/Switch.tsx | 13 ++--- .../schedules/ConfirmTaskDeletionModal.tsx | 26 --------- .../server/schedules/DeleteScheduleButton.tsx | 37 +++++-------- .../server/schedules/EditScheduleModal.tsx | 26 ++++----- .../server/schedules/NewTaskButton.tsx | 5 +- .../server/schedules/ScheduleContainer.tsx | 34 ++++++------ .../schedules/ScheduleEditContainer.tsx | 27 +++++----- .../server/schedules/ScheduleRow.tsx | 47 ++++++++-------- .../server/schedules/ScheduleTaskRow.tsx | 54 ++++++++++--------- .../server/schedules/TaskDetailsModal.tsx | 41 +++++++------- 12 files changed, 180 insertions(+), 168 deletions(-) create mode 100644 resources/scripts/components/elements/Select.tsx delete mode 100644 resources/scripts/components/server/schedules/ConfirmTaskDeletionModal.tsx diff --git a/resources/scripts/components/elements/ConfirmationModal.tsx b/resources/scripts/components/elements/ConfirmationModal.tsx index 050ceab73..596a23f69 100644 --- a/resources/scripts/components/elements/ConfirmationModal.tsx +++ b/resources/scripts/components/elements/ConfirmationModal.tsx @@ -18,7 +18,7 @@ const ConfirmationModal = ({ title, appear, children, visible, buttonText, onCon showSpinnerOverlay={showSpinnerOverlay} onDismissed={() => onDismissed()} > -

{title}

+

{title}

{children}

- -
- -); diff --git a/resources/scripts/components/server/schedules/DeleteScheduleButton.tsx b/resources/scripts/components/server/schedules/DeleteScheduleButton.tsx index 179987863..1b6ec5a39 100644 --- a/resources/scripts/components/server/schedules/DeleteScheduleButton.tsx +++ b/resources/scripts/components/server/schedules/DeleteScheduleButton.tsx @@ -1,10 +1,12 @@ import React, { useState } from 'react'; -import Modal from '@/components/elements/Modal'; import deleteSchedule from '@/api/server/schedules/deleteSchedule'; import { ServerContext } from '@/state/server'; import { Actions, useStoreActions } from 'easy-peasy'; import { ApplicationStore } from '@/state'; import { httpErrorToHuman } from '@/api/http'; +import tw from 'twin.macro'; +import Button from '@/components/elements/Button'; +import ConfirmationModal from '@/components/elements/ConfirmationModal'; interface Props { scheduleId: number; @@ -36,34 +38,19 @@ export default ({ scheduleId, onDeleted }: Props) => { return ( <> - setVisible(false)} - showSpinnerOverlay={isLoading} > -

Delete schedule

-

- Are you sure you want to delete this schedule? All tasks will be removed and any running processes - will be terminated. -

-
- - -
-
- + ); }; diff --git a/resources/scripts/components/server/schedules/EditScheduleModal.tsx b/resources/scripts/components/server/schedules/EditScheduleModal.tsx index 544944c7b..5793b875c 100644 --- a/resources/scripts/components/server/schedules/EditScheduleModal.tsx +++ b/resources/scripts/components/server/schedules/EditScheduleModal.tsx @@ -10,6 +10,8 @@ import { httpErrorToHuman } from '@/api/http'; import FlashMessageRender from '@/components/FlashMessageRender'; import useServer from '@/plugins/useServer'; import useFlash from '@/plugins/useFlash'; +import tw from 'twin.macro'; +import Button from '@/components/elements/Button'; type Props = { schedule?: Schedule; @@ -29,43 +31,43 @@ const EditScheduleModal = ({ schedule, ...props }: Omit -

{schedule ? 'Edit schedule' : 'Create new schedule'}

- +

{schedule ? 'Edit schedule' : 'Create new schedule'}

+
-
-
+
+
-
+
-
+
-
+
-

+

The schedule system supports the use of Cronjob syntax when defining when tasks should begin running. Use the fields above to specify when these tasks should begin running.

-
+
-
- +
diff --git a/resources/scripts/components/server/schedules/NewTaskButton.tsx b/resources/scripts/components/server/schedules/NewTaskButton.tsx index c53f1b17c..b46124e64 100644 --- a/resources/scripts/components/server/schedules/NewTaskButton.tsx +++ b/resources/scripts/components/server/schedules/NewTaskButton.tsx @@ -1,6 +1,7 @@ import React, { useState } from 'react'; import { Schedule } from '@/api/server/schedules/getServerSchedules'; import TaskDetailsModal from '@/components/server/schedules/TaskDetailsModal'; +import Button from '@/components/elements/Button'; interface Props { schedule: Schedule; @@ -17,9 +18,9 @@ export default ({ schedule }: Props) => { onDismissed={() => setVisible(false)} /> } - + ); }; diff --git a/resources/scripts/components/server/schedules/ScheduleContainer.tsx b/resources/scripts/components/server/schedules/ScheduleContainer.tsx index 233c53ded..0e4ff6bd2 100644 --- a/resources/scripts/components/server/schedules/ScheduleContainer.tsx +++ b/resources/scripts/components/server/schedules/ScheduleContainer.tsx @@ -11,6 +11,9 @@ import Can from '@/components/elements/Can'; import useServer from '@/plugins/useServer'; import useFlash from '@/plugins/useFlash'; import PageContentBlock from '@/components/elements/PageContentBlock'; +import tw from 'twin.macro'; +import GreyRowBox from '@/components/elements/GreyRowBox'; +import Button from '@/components/elements/Button'; export default ({ match, history }: RouteComponentProps) => { const { uuid } = useServer(); @@ -34,45 +37,38 @@ export default ({ match, history }: RouteComponentProps) => { return ( - + {(!schedules.length && loading) ? - + : <> { schedules.length === 0 ? -

+

There are no schedules configured for this server.

: schedules.map(schedule => ( - { + css={tw`cursor-pointer mb-2`} + onClick={(e: any) => { e.preventDefault(); history.push(`${match.url}/${schedule.id}`, { schedule }); }} > - + )) } -
- {visible && setVisible(false)} - />} - +
diff --git a/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx b/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx index 1abdc5e67..cf9486fd3 100644 --- a/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx +++ b/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx @@ -15,6 +15,9 @@ import useServer from '@/plugins/useServer'; import useFlash from '@/plugins/useFlash'; import { ServerContext } from '@/state/server'; import PageContentBlock from '@/components/elements/PageContentBlock'; +import tw from 'twin.macro'; +import Button from '@/components/elements/Button'; +import GreyRowBox from '@/components/elements/GreyRowBox'; interface Params { id: string; @@ -51,22 +54,22 @@ export default ({ match, history, location: { state } }: RouteComponentProps - + {!schedule || isLoading ? - + : <> -
+ -
+ setShowEditModal(false)} /> -
-
-

Configured Tasks

+
+
+

Configured Tasks

{schedule.tasks.length > 0 ? @@ -79,17 +82,17 @@ export default ({ match, history, location: { state } }: RouteComponentProps 1 && -

+

Task delays are relative to the previous task in the listing.

} : -

+

There are no tasks configured for this schedule.

} -
+
- +
diff --git a/resources/scripts/components/server/schedules/ScheduleRow.tsx b/resources/scripts/components/server/schedules/ScheduleRow.tsx index 2636906f7..aa235028e 100644 --- a/resources/scripts/components/server/schedules/ScheduleRow.tsx +++ b/resources/scripts/components/server/schedules/ScheduleRow.tsx @@ -4,47 +4,48 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCalendarAlt } from '@fortawesome/free-solid-svg-icons/faCalendarAlt'; import format from 'date-fns/format'; import classNames from 'classnames'; +import tw from 'twin.macro'; export default ({ schedule }: { schedule: Schedule }) => ( <> -
- +
+
-
+

{schedule.name}

-

+

Last run at: {schedule.lastRunAt ? format(schedule.lastRunAt, 'MMM Do [at] h:mma') : 'never'}

-
+
-

{schedule.cron.minute}

-

Minute

+

{schedule.cron.minute}

+

Minute

-
-

{schedule.cron.hour}

-

Hour

+
+

{schedule.cron.hour}

+

Hour

-
-

{schedule.cron.dayOfMonth}

-

Day (Month)

+
+

{schedule.cron.dayOfMonth}

+

Day (Month)

-
-

*

-

Month

+
+

*

+

Month

-
-

{schedule.cron.dayOfWeek}

-

Day (Week)

+
+

{schedule.cron.dayOfWeek}

+

Day (Week)

{schedule.isActive ? 'Active' : 'Inactive'}

diff --git a/resources/scripts/components/server/schedules/ScheduleTaskRow.tsx b/resources/scripts/components/server/schedules/ScheduleTaskRow.tsx index f73f5da9d..f9da350e9 100644 --- a/resources/scripts/components/server/schedules/ScheduleTaskRow.tsx +++ b/resources/scripts/components/server/schedules/ScheduleTaskRow.tsx @@ -4,7 +4,6 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faTrashAlt } from '@fortawesome/free-solid-svg-icons/faTrashAlt'; import { faCode } from '@fortawesome/free-solid-svg-icons/faCode'; import { faToggleOn } from '@fortawesome/free-solid-svg-icons/faToggleOn'; -import ConfirmTaskDeletionModal from '@/components/server/schedules/ConfirmTaskDeletionModal'; import deleteScheduleTask from '@/api/server/schedules/deleteScheduleTask'; import { httpErrorToHuman } from '@/api/http'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; @@ -15,6 +14,8 @@ import useServer from '@/plugins/useServer'; import useFlash from '@/plugins/useFlash'; import { ServerContext } from '@/state/server'; import { faFileArchive } from '@fortawesome/free-solid-svg-icons/faFileArchive'; +import tw from 'twin.macro'; +import ConfirmationModal from '@/components/elements/ConfirmationModal'; interface Props { schedule: Schedule; @@ -23,14 +24,14 @@ interface Props { const getActionDetails = (action: string): [ string, any ] => { switch (action) { - case 'command': - return ['Send Command', faCode]; - case 'power': - return ['Send Power Action', faToggleOn]; - case 'backup': - return ['Create Backup', faFileArchive]; - default: - return ['Unknown Action', faCode]; + case 'command': + return [ 'Send Command', faCode ]; + case 'power': + return [ 'Send Power Action', faToggleOn ]; + case 'backup': + return [ 'Create Backup', faFileArchive ]; + default: + return [ 'Unknown Action', faCode ]; } }; @@ -60,38 +61,43 @@ export default ({ schedule, task }: Props) => { const [ title, icon ] = getActionDetails(task.action); return ( -
+
{isEditing && setIsEditing(false)} />} - setVisible(false)} - onConfirmed={() => onConfirmDeletion()} - /> - -
-

+ > + Are you sure you want to delete this task? This action cannot be undone. + + +

+

{title}

{task.payload && -
- {task.action === 'backup' &&

Ignoring files & folders:

} -
+
+ {task.action === 'backup' && +

Ignoring files & folders:

} +
{task.payload}
}
{task.sequenceId > 1 && -
-

+

+

{task.timeOffset}s

-

+

Delay Run By

@@ -100,7 +106,7 @@ export default ({ schedule, task }: Props) => { +
); @@ -148,12 +153,12 @@ export default ({ task, schedule, onDismissed }: Props) => { > {({ isSubmitting }) => ( onDismissed()} showSpinnerOverlay={isSubmitting} > - + )}