Skip to content

Commit

Permalink
ZKUI-238: Enable previous version for transition edition under certai…
Browse files Browse the repository at this point in the history
…n 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`
  • Loading branch information
ChengYanJin committed Jul 30, 2022
1 parent e4ceb3e commit 8346606
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/react/workflow/TransitionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`);

Expand All @@ -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]);
Expand Down Expand Up @@ -280,15 +283,15 @@ export const TransitionForm = ({
id="previous"
value="previous"
{...register(`${prefix}applyToVersion`)}
disabled={!isSourceBucketVersionned}
disabled={isPreviousVersionDisabled}
/>
<Box
ml={1}
style={{ opacity: isSourceBucketVersionned ? 1 : 0.5 }}
style={{ opacity: isPreviousVersionDisabled ? 0.5 : 1 }}
>
Previous version
</Box>
{!isSourceBucketVersionned ? (
{isPreviousVersionDisabled ? (
<>
<IconHelp
tooltipMessage={
Expand Down

0 comments on commit 8346606

Please sign in to comment.