271 remove is command menu v2 enabled (#10809)
Closes https://github.com/twentyhq/core-team-issues/issues/271 This PR - Removes the feature flag IS_COMMAND_MENU_V2_ENABLED - Removes all old Right drawer components - Removes the Action menu bar - Removes unused Copilot page
This commit is contained in:
@ -1,133 +0,0 @@
|
||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { useActivateWorkflowVersion } from '@/workflow/hooks/useActivateWorkflowVersion';
|
||||
import { useDeactivateWorkflowVersion } from '@/workflow/hooks/useDeactivateWorkflowVersion';
|
||||
import { useDeleteOneWorkflowVersion } from '@/workflow/hooks/useDeleteOneWorkflowVersion';
|
||||
import { useRunWorkflowVersion } from '@/workflow/hooks/useRunWorkflowVersion';
|
||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import {
|
||||
Button,
|
||||
IconPlayerPlay,
|
||||
IconPlayerStop,
|
||||
IconPower,
|
||||
IconSettingsAutomation,
|
||||
IconTrash,
|
||||
} from 'twenty-ui';
|
||||
import { assertWorkflowWithCurrentVersionIsDefined } from '../utils/assertWorkflowWithCurrentVersionIsDefined';
|
||||
|
||||
export const RecordShowPageWorkflowHeader = ({
|
||||
workflowId,
|
||||
}: {
|
||||
workflowId: string;
|
||||
}) => {
|
||||
const { t } = useLingui();
|
||||
const workflowWithCurrentVersion = useWorkflowWithCurrentVersion(workflowId);
|
||||
|
||||
const isWaitingForWorkflowWithCurrentVersion =
|
||||
!isDefined(workflowWithCurrentVersion) ||
|
||||
!isDefined(workflowWithCurrentVersion.currentVersion);
|
||||
|
||||
const { activateWorkflowVersion } = useActivateWorkflowVersion();
|
||||
const { deactivateWorkflowVersion } = useDeactivateWorkflowVersion();
|
||||
const { deleteOneWorkflowVersion } = useDeleteOneWorkflowVersion();
|
||||
const { runWorkflowVersion } = useRunWorkflowVersion();
|
||||
|
||||
const { enqueueSnackBar } = useSnackBar();
|
||||
const theme = useTheme();
|
||||
|
||||
const trigger = workflowWithCurrentVersion?.currentVersion.trigger;
|
||||
|
||||
const canWorkflowBeTested =
|
||||
trigger?.type === 'MANUAL' && !trigger.settings.objectType;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
title={t`Test`}
|
||||
variant="secondary"
|
||||
Icon={IconPlayerPlay}
|
||||
disabled={isWaitingForWorkflowWithCurrentVersion}
|
||||
onClick={async () => {
|
||||
assertWorkflowWithCurrentVersionIsDefined(workflowWithCurrentVersion);
|
||||
|
||||
if (!canWorkflowBeTested) {
|
||||
enqueueSnackBar(t`Workflow cannot be tested`, {
|
||||
variant: SnackBarVariant.Error,
|
||||
detailedMessage: t`Trigger type should be Manual - when no record(s) are selected`,
|
||||
icon: (
|
||||
<IconSettingsAutomation
|
||||
size={16}
|
||||
color={theme.snackBar.error.color}
|
||||
/>
|
||||
),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await runWorkflowVersion({
|
||||
workflowVersionId: workflowWithCurrentVersion.currentVersion.id,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
{workflowWithCurrentVersion?.currentVersion?.status === 'DRAFT' &&
|
||||
workflowWithCurrentVersion.versions?.length > 1 ? (
|
||||
<Button
|
||||
title={t`Discard Draft`}
|
||||
variant="secondary"
|
||||
Icon={IconTrash}
|
||||
disabled={isWaitingForWorkflowWithCurrentVersion}
|
||||
onClick={() => {
|
||||
assertWorkflowWithCurrentVersionIsDefined(
|
||||
workflowWithCurrentVersion,
|
||||
);
|
||||
|
||||
return deleteOneWorkflowVersion({
|
||||
workflowVersionId: workflowWithCurrentVersion.currentVersion.id,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{workflowWithCurrentVersion?.currentVersion?.status === 'DRAFT' ||
|
||||
workflowWithCurrentVersion?.currentVersion?.status === 'DEACTIVATED' ? (
|
||||
<Button
|
||||
title={t`Activate`}
|
||||
variant="secondary"
|
||||
Icon={IconPower}
|
||||
disabled={isWaitingForWorkflowWithCurrentVersion}
|
||||
onClick={() => {
|
||||
assertWorkflowWithCurrentVersionIsDefined(
|
||||
workflowWithCurrentVersion,
|
||||
);
|
||||
|
||||
return activateWorkflowVersion({
|
||||
workflowVersionId: workflowWithCurrentVersion.currentVersion.id,
|
||||
workflowId: workflowWithCurrentVersion.id,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
) : workflowWithCurrentVersion?.currentVersion?.status === 'ACTIVE' ? (
|
||||
<Button
|
||||
title={t`Deactivate`}
|
||||
variant="secondary"
|
||||
Icon={IconPlayerStop}
|
||||
disabled={isWaitingForWorkflowWithCurrentVersion}
|
||||
onClick={() => {
|
||||
assertWorkflowWithCurrentVersionIsDefined(
|
||||
workflowWithCurrentVersion,
|
||||
);
|
||||
|
||||
return deactivateWorkflowVersion({
|
||||
workflowVersionId: workflowWithCurrentVersion.currentVersion.id,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@ -1,144 +0,0 @@
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
||||
import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { OverrideWorkflowDraftConfirmationModal } from '@/workflow/components/OverrideWorkflowDraftConfirmationModal';
|
||||
import { useActivateWorkflowVersion } from '@/workflow/hooks/useActivateWorkflowVersion';
|
||||
import { useCreateDraftFromWorkflowVersion } from '@/workflow/hooks/useCreateDraftFromWorkflowVersion';
|
||||
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 { useSetRecoilState } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { Button, IconPencil, IconPlayerStop, IconPower } from 'twenty-ui';
|
||||
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
|
||||
export const RecordShowPageWorkflowVersionHeader = ({
|
||||
workflowVersionId,
|
||||
}: {
|
||||
workflowVersionId: string;
|
||||
}) => {
|
||||
const workflowVersion = useWorkflowVersion(workflowVersionId);
|
||||
|
||||
const workflowVersionRelatedWorkflowQuery = useFindOneRecord<
|
||||
Pick<Workflow, '__typename' | 'id' | 'lastPublishedVersionId'>
|
||||
>({
|
||||
objectNameSingular: CoreObjectNameSingular.Workflow,
|
||||
objectRecordId: workflowVersion?.workflowId,
|
||||
recordGqlFields: {
|
||||
id: true,
|
||||
lastPublishedVersionId: true,
|
||||
},
|
||||
skip: !isDefined(workflowVersion),
|
||||
});
|
||||
|
||||
// TODO: In the future, use the workflow.status property to determine if there is a draft version
|
||||
const {
|
||||
records: draftWorkflowVersions,
|
||||
loading: loadingDraftWorkflowVersions,
|
||||
} = useFindManyRecords<WorkflowVersion>({
|
||||
objectNameSingular: CoreObjectNameSingular.WorkflowVersion,
|
||||
filter: {
|
||||
workflowId: {
|
||||
eq: workflowVersion?.workflow.id,
|
||||
},
|
||||
status: {
|
||||
eq: 'DRAFT',
|
||||
},
|
||||
},
|
||||
skip: !isDefined(workflowVersion),
|
||||
limit: 1,
|
||||
});
|
||||
const draftWorkflowVersion: WorkflowVersion | undefined =
|
||||
draftWorkflowVersions[0];
|
||||
|
||||
const showUseAsDraftButton =
|
||||
!loadingDraftWorkflowVersions &&
|
||||
isDefined(workflowVersion) &&
|
||||
!workflowVersionRelatedWorkflowQuery.loading &&
|
||||
isDefined(workflowVersionRelatedWorkflowQuery.record) &&
|
||||
workflowVersion.status !== 'DRAFT' &&
|
||||
workflowVersion.id !==
|
||||
workflowVersionRelatedWorkflowQuery.record.lastPublishedVersionId;
|
||||
|
||||
const hasAlreadyDraftVersion =
|
||||
!loadingDraftWorkflowVersions && isDefined(draftWorkflowVersion);
|
||||
|
||||
const isWaitingForWorkflowVersion = !isDefined(workflowVersion);
|
||||
|
||||
const { activateWorkflowVersion } = useActivateWorkflowVersion();
|
||||
const { deactivateWorkflowVersion } = useDeactivateWorkflowVersion();
|
||||
const { createDraftFromWorkflowVersion } =
|
||||
useCreateDraftFromWorkflowVersion();
|
||||
|
||||
const setOpenOverrideWorkflowDraftConfirmationModal = useSetRecoilState(
|
||||
openOverrideWorkflowDraftConfirmationModalState,
|
||||
);
|
||||
|
||||
const navigate = useNavigateApp();
|
||||
|
||||
return (
|
||||
<>
|
||||
{showUseAsDraftButton ? (
|
||||
<Button
|
||||
title={'Use as Draft'}
|
||||
variant="secondary"
|
||||
Icon={IconPencil}
|
||||
disabled={isWaitingForWorkflowVersion}
|
||||
onClick={async () => {
|
||||
if (hasAlreadyDraftVersion) {
|
||||
setOpenOverrideWorkflowDraftConfirmationModal(true);
|
||||
} else {
|
||||
await createDraftFromWorkflowVersion({
|
||||
workflowId: workflowVersion.workflow.id,
|
||||
workflowVersionIdToCopy: workflowVersion.id,
|
||||
});
|
||||
|
||||
navigate(AppPath.RecordShowPage, {
|
||||
objectNameSingular: CoreObjectNameSingular.Workflow,
|
||||
objectRecordId: workflowVersion.workflow.id,
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{workflowVersion?.status === 'DRAFT' ||
|
||||
workflowVersion?.status === 'DEACTIVATED' ? (
|
||||
<Button
|
||||
title="Activate"
|
||||
variant="secondary"
|
||||
Icon={IconPower}
|
||||
disabled={isWaitingForWorkflowVersion}
|
||||
onClick={() => {
|
||||
return activateWorkflowVersion({
|
||||
workflowVersionId: workflowVersion.id,
|
||||
workflowId: workflowVersion.workflowId,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
) : workflowVersion?.status === 'ACTIVE' ? (
|
||||
<Button
|
||||
title="Deactivate"
|
||||
variant="secondary"
|
||||
Icon={IconPlayerStop}
|
||||
disabled={isWaitingForWorkflowVersion}
|
||||
onClick={() => {
|
||||
return deactivateWorkflowVersion({
|
||||
workflowVersionId: workflowVersion.id,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{isDefined(workflowVersion) && isDefined(draftWorkflowVersion) ? (
|
||||
<OverrideWorkflowDraftConfirmationModal
|
||||
workflowId={workflowVersion.workflowId}
|
||||
workflowVersionIdToCopy={workflowVersionId}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user