Skip to content

Commit

Permalink
FD-678 schedule workflow input fix (#1564)
Browse files Browse the repository at this point in the history
* rbac changes implemented

* schedule workflow input fix

* edit schedule workflow toDate field fix
  • Loading branch information
soson authored Jun 12, 2024
1 parent acaf324 commit 048c65b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const ScheduleWorkflowModal: FC<Props> = ({ scheduledWorkflow, workflow, isOpen,
cronString: scheduledWorkflow?.cronString || DEFAULT_CRON_STRING,
enabled: scheduledWorkflow?.enabled ?? false,
fromDate: scheduledWorkflow?.fromDate && resetDateFormat(scheduledWorkflow?.fromDate),
toDate: scheduledWorkflow.toDate && resetDateFormat(scheduledWorkflow?.toDate),
// TODO: FIXME
// performTillDate: scheduledWorkflow?.fromDate && resetDateFormat(scheduledWorkflow?.performTillDate),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ type Props = {
onSubmit: (workflow: CreateScheduleInput) => void;
};

type ClientSchedule = Omit<CreateScheduleInput, 'workflowContext'> & {
workflowContext: Record<string, string>;
};

const ScheduleWorkflowModal: FC<Props> = ({ workflow, isOpen, onClose, onSubmit }) => {
const [{ data: scheduledWorkflows, fetching: isLoadingScheduledWorkflows }] = useQuery<
GetSchedulesQuery,
Expand All @@ -120,16 +124,14 @@ const ScheduleWorkflowModal: FC<Props> = ({ workflow, isOpen, onClose, onSubmit

const [shouldShowInputParams, { toggle: toggleShouldShowInputParams }] = useBoolean(false);

const { values, errors, handleChange, submitForm, setFieldValue, resetForm } = useFormik<CreateScheduleInput>({
const { values, errors, handleChange, submitForm, setFieldValue, resetForm } = useFormik<ClientSchedule>({
enableReinitialize: true,
validationSchema,
validateOnMount: false,
initialValues: {
workflowName: workflow.name,
workflowVersion: workflow.version?.toString() ?? '',
workflowContext: JSON.stringify(
getInitialValuesFromParsedInputParameters(parsedInputParameters, dynamicInputParameters),
),
workflowContext: getInitialValuesFromParsedInputParameters(parsedInputParameters, dynamicInputParameters),
name: '',
cronString: DEFAULT_CRON_STRING,
enabled: false,
Expand All @@ -139,6 +141,7 @@ const ScheduleWorkflowModal: FC<Props> = ({ workflow, isOpen, onClose, onSubmit
onSubmit: (formValues) => {
const formattedValues: CreateScheduleInput = {
...formValues,
workflowContext: JSON.stringify(formValues.workflowContext),
cronString: formValues.cronString || DEFAULT_CRON_STRING,
...(formValues.fromDate && {
fromDate: moment(formValues.fromDate).format('yyyy-MM-DDTHH:mm:ss.SSSZ'),
Expand All @@ -157,7 +160,7 @@ const ScheduleWorkflowModal: FC<Props> = ({ workflow, isOpen, onClose, onSubmit
return <Progress size="xs" isIndeterminate />;
}

const inputParametersKeys = Object.keys(JSON.parse(values.workflowContext ?? '{}'));
const inputParametersKeys = Object.keys(values.workflowContext);

return (
<Modal size="3xl" isOpen={isOpen} onClose={onClose}>
Expand Down Expand Up @@ -254,8 +257,13 @@ const ScheduleWorkflowModal: FC<Props> = ({ workflow, isOpen, onClose, onSubmit
<GridItem key={inputParameterKey}>
<ExecuteWorkflowModalFormInput
inputParameterKey={inputParameterKey}
onChange={(key, value) => setFieldValue(`workflowContext.${key}`, value)}
values={JSON.parse(values.workflowContext ?? '{}')}
onChange={(key, value) =>
setFieldValue(`workflowContext`, {
...values.workflowContext,
[key]: value,
})
}
values={values.workflowContext}
parsedInputParameters={parsedInputParameters}
/>
</GridItem>
Expand Down

0 comments on commit 048c65b

Please sign in to comment.