Skip to content

Commit

Permalink
Fix use as draft redirection (#9284)
Browse files Browse the repository at this point in the history
When hitting use as draft in workflow version action, redirects to
workflow newly created
  • Loading branch information
thomtrp authored Dec 30, 2024
1 parent 7388f2b commit c3c07e0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { SingleRecordActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/SingleRecordActionHook';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { buildShowPageURL } from '@/object-record/record-show/utils/buildShowPageURL';
import { OverrideWorkflowDraftConfirmationModal } from '@/workflow/components/OverrideWorkflowDraftConfirmationModal';
import { useCreateNewWorkflowVersion } from '@/workflow/hooks/useCreateNewWorkflowVersion';
import { useWorkflowVersion } from '@/workflow/hooks/useWorkflowVersion';
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
import { openOverrideWorkflowDraftConfirmationModalState } from '@/workflow/states/openOverrideWorkflowDraftConfirmationModalState';
import { useNavigate } from 'react-router-dom';
import { useSetRecoilState } from 'recoil';
import { isDefined } from 'twenty-ui';

Expand All @@ -21,6 +24,8 @@ export const useUseAsDraftWorkflowVersionSingleRecordAction: SingleRecordActionH
openOverrideWorkflowDraftConfirmationModalState,
);

const navigate = useNavigate();

const workflowStatuses = workflow?.statuses;

const shouldBeRegistered =
Expand All @@ -44,6 +49,12 @@ export const useUseAsDraftWorkflowVersionSingleRecordAction: SingleRecordActionH
trigger: workflowVersion.trigger,
steps: workflowVersion.steps,
});
navigate(
buildShowPageURL(
CoreObjectNameSingular.Workflow,
workflowVersion.workflow.id,
),
);
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord';
import { buildShowPageURL } from '@/object-record/record-show/utils/buildShowPageURL';
import { OverrideWorkflowDraftConfirmationModal } from '@/workflow/components/OverrideWorkflowDraftConfirmationModal';
import { useActivateWorkflowVersion } from '@/workflow/hooks/useActivateWorkflowVersion';
import { useCreateNewWorkflowVersion } from '@/workflow/hooks/useCreateNewWorkflowVersion';
import { useDeactivateWorkflowVersion } from '@/workflow/hooks/useDeactivateWorkflowVersion';
import { useWorkflowVersion } from '@/workflow/hooks/useWorkflowVersion';
import { openOverrideWorkflowDraftConfirmationModalState } from '@/workflow/states/openOverrideWorkflowDraftConfirmationModalState';
import { Workflow, WorkflowVersion } from '@/workflow/types/Workflow';
import { useNavigate } from 'react-router-dom';
import { useSetRecoilState } from 'recoil';
import {
Button,
Expand Down Expand Up @@ -78,6 +80,8 @@ export const RecordShowPageWorkflowVersionHeader = ({
openOverrideWorkflowDraftConfirmationModalState,
);

const navigate = useNavigate();

return (
<>
{showUseAsDraftButton ? (
Expand All @@ -97,6 +101,12 @@ export const RecordShowPageWorkflowVersionHeader = ({
trigger: workflowVersion.trigger,
steps: workflowVersion.steps,
});
navigate(
buildShowPageURL(
CoreObjectNameSingular.Workflow,
workflowVersion.workflow.id,
),
);
}
}}
/>
Expand Down

0 comments on commit c3c07e0

Please sign in to comment.