From 8346606392e5a35a3a8ab6df6d92ecbdce0a1c40 Mon Sep 17 00:00:00 2001 From: YanJin Date: Sat, 30 Jul 2022 09:57:41 +0200 Subject: [PATCH] ZKUI-238: Enable previous version for transition edition under certain conditions If the `applyToVersion` in the existing workflow is `Previous version` it should be selected in the form. We disable the `Previous version` for the edition only both two conditions are met: 1. the bucket is not versioned 2. the default value is `Current version` --- src/react/workflow/TransitionForm.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/react/workflow/TransitionForm.tsx b/src/react/workflow/TransitionForm.tsx index 1418970f2..57356819f 100644 --- a/src/react/workflow/TransitionForm.tsx +++ b/src/react/workflow/TransitionForm.tsx @@ -64,7 +64,7 @@ export const TransitionForm = ({ const { errors } = formState; const isEditing = !!getValues(`${prefix}workflowId`); - + const applyToVersion = getValues(`${prefix}applyToVersion`); const locationName = watch(`${prefix}locationName`); const triggerDelayDays = watch(`${prefix}triggerDelayDays`); @@ -73,8 +73,11 @@ export const TransitionForm = ({ const isSourceBucketVersionned = sourceBucket ? isVersioning(sourceBucket.VersionStatus) : false; + // Disable the previous version if the bucket is not versionned and the default value is `Current version` + const isPreviousVersionDisabled = + !isSourceBucketVersionned && applyToVersion === 'current'; useMemo(() => { - if (!isSourceBucketVersionned) { + if (!isSourceBucketVersionned && !isEditing) { setValue(`${prefix}applyToVersion`, 'current'); } }, [isSourceBucketVersionned]); @@ -280,15 +283,15 @@ export const TransitionForm = ({ id="previous" value="previous" {...register(`${prefix}applyToVersion`)} - disabled={!isSourceBucketVersionned} + disabled={isPreviousVersionDisabled} /> Previous version - {!isSourceBucketVersionned ? ( + {isPreviousVersionDisabled ? ( <>