Hide task delay on frontend if queue driver is set to sync (#375)

This commit is contained in:
Boy132 2024-06-13 08:23:24 +02:00 committed by GitHub
parent cd4fc1a95d
commit ce1163d387
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 13 deletions

View File

@ -27,6 +27,7 @@ class AssetComposer
'enabled' => config('recaptcha.enabled', false), 'enabled' => config('recaptcha.enabled', false),
'siteKey' => config('recaptcha.website_key') ?? '', 'siteKey' => config('recaptcha.website_key') ?? '',
], ],
'usesSyncDriver' => config('queue.default') === 'sync',
]); ]);
} }
} }

View File

@ -20,6 +20,7 @@ import { ServerContext } from '@/state/server';
import tw from 'twin.macro'; import tw from 'twin.macro';
import ConfirmationModal from '@/components/elements/ConfirmationModal'; import ConfirmationModal from '@/components/elements/ConfirmationModal';
import Icon from '@/components/elements/Icon'; import Icon from '@/components/elements/Icon';
import { useStoreState } from 'easy-peasy';
interface Props { interface Props {
schedule: Schedule; schedule: Schedule;
@ -46,6 +47,7 @@ export default ({ schedule, task }: Props) => {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [isEditing, setIsEditing] = useState(false); const [isEditing, setIsEditing] = useState(false);
const appendSchedule = ServerContext.useStoreActions((actions) => actions.schedules.appendSchedule); const appendSchedule = ServerContext.useStoreActions((actions) => actions.schedules.appendSchedule);
const usesSyncDriver = useStoreState((state) => state.settings.data!.usesSyncDriver);
const onConfirmDeletion = () => { const onConfirmDeletion = () => {
setIsLoading(true); setIsLoading(true);
@ -109,7 +111,7 @@ export default ({ schedule, task }: Props) => {
</div> </div>
</div> </div>
)} )}
{task.sequenceId > 1 && task.timeOffset > 0 && ( {!usesSyncDriver && task.sequenceId > 1 && task.timeOffset > 0 && (
<div css={tw`mr-6`}> <div css={tw`mr-6`}>
<div css={tw`flex items-center px-2 py-1 bg-neutral-500 text-sm rounded-full`}> <div css={tw`flex items-center px-2 py-1 bg-neutral-500 text-sm rounded-full`}>
<Icon icon={faClock} css={tw`w-3 h-3 mr-2`} /> <Icon icon={faClock} css={tw`w-3 h-3 mr-2`} />

View File

@ -17,6 +17,7 @@ import Select from '@/components/elements/Select';
import ModalContext from '@/context/ModalContext'; import ModalContext from '@/context/ModalContext';
import asModal from '@/hoc/asModal'; import asModal from '@/hoc/asModal';
import FormikSwitch from '@/components/elements/FormikSwitch'; import FormikSwitch from '@/components/elements/FormikSwitch';
import { useStoreState } from 'easy-peasy';
interface Props { interface Props {
schedule: Schedule; schedule: Schedule;
@ -71,6 +72,7 @@ const TaskDetailsModal = ({ schedule, task }: Props) => {
const uuid = ServerContext.useStoreState((state) => state.server.data!.uuid); const uuid = ServerContext.useStoreState((state) => state.server.data!.uuid);
const appendSchedule = ServerContext.useStoreActions((actions) => actions.schedules.appendSchedule); const appendSchedule = ServerContext.useStoreActions((actions) => actions.schedules.appendSchedule);
const backupLimit = ServerContext.useStoreState((state) => state.server.data!.featureLimits.backups); const backupLimit = ServerContext.useStoreState((state) => state.server.data!.featureLimits.backups);
const usesSyncDriver = useStoreState((state) => state.settings.data!.usesSyncDriver);
useEffect(() => { useEffect(() => {
return () => { return () => {
@ -121,7 +123,7 @@ const TaskDetailsModal = ({ schedule, task }: Props) => {
<FlashMessageRender byKey={'schedule:task'} css={tw`mb-4`} /> <FlashMessageRender byKey={'schedule:task'} css={tw`mb-4`} />
<h2 css={tw`text-2xl mb-6`}>{task ? 'Edit Task' : 'Create Task'}</h2> <h2 css={tw`text-2xl mb-6`}>{task ? 'Edit Task' : 'Create Task'}</h2>
<div css={tw`flex`}> <div css={tw`flex`}>
<div css={tw`mr-2 w-1/3`}> <div className={!usesSyncDriver ? 'mr-2 w-1/3' : 'w-full'}>
<Label>Action</Label> <Label>Action</Label>
<ActionListener /> <ActionListener />
<FormikFieldWrapper name={'action'}> <FormikFieldWrapper name={'action'}>
@ -132,15 +134,17 @@ const TaskDetailsModal = ({ schedule, task }: Props) => {
</FormikField> </FormikField>
</FormikFieldWrapper> </FormikFieldWrapper>
</div> </div>
<div css={tw`flex-1 ml-6`}> {!usesSyncDriver && (
<Field <div css={tw`flex-1 ml-6`}>
name={'timeOffset'} <Field
label={'Time offset (in seconds)'} name={'timeOffset'}
description={ label={'Time offset (in seconds)'}
'The amount of time to wait after the previous task executes before running this one. If this is the first task on a schedule this will not be applied.' description={
} 'The amount of time to wait after the previous task executes before running this one. If this is the first task on a schedule this will not be applied.'
/> }
</div> />
</div>
)}
</div> </div>
<div css={tw`mt-6`}> <div css={tw`mt-6`}>
{values.action === 'command' ? ( {values.action === 'command' ? (

View File

@ -55,8 +55,9 @@ export default () => {
</div> </div>
<div css={tw`ml-4`}> <div css={tw`ml-4`}>
<a <a
href={`sftp://${username}.${id}@${sftp.alias ? sftp.alias : ip(sftp.ip)}:${sftp.port href={`sftp://${username}.${id}@${sftp.alias ? sftp.alias : ip(sftp.ip)}:${
}`} sftp.port
}`}
> >
<Button.Text variant={Button.Variants.Secondary}>Launch SFTP</Button.Text> <Button.Text variant={Button.Variants.Secondary}>Launch SFTP</Button.Text>
</a> </a>

View File

@ -7,6 +7,7 @@ export interface SiteSettings {
enabled: boolean; enabled: boolean;
siteKey: string; siteKey: string;
}; };
usesSyncDriver: boolean;
} }
export interface SettingsStore { export interface SettingsStore {