mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-28 17:55:15 +02:00
This PR addresses 2 tasks that aim to fix and improve the UI/UX on archived feature toggle deletion: - https://linear.app/unleash/issue/UNL-260/delete-feature-toggle-dialog-update-word-toggles-to-singular-toggle - https://linear.app/unleash/issue/UNL-282/deleting-multiple-toggles-in-the-project-archive-the-batch-selector Essentially: - Makes it clearer that we're deleting a single feature toggle by changing the text to singular toggle - Improves clarity further by adding a list of feature toggles about to be deleted - Fixes a bug where the batch selector would not be cleared after deleting multiple feature toggles ## Deleting one feature toggle (singular)  ## Deleting multiple feature toggles (plural) 
102 lines
3.6 KiB
TypeScript
102 lines
3.6 KiB
TypeScript
import { FC, useState } from 'react';
|
|
import { Button } from '@mui/material';
|
|
import { Delete, Undo } from '@mui/icons-material';
|
|
import {
|
|
DELETE_FEATURE,
|
|
UPDATE_FEATURE,
|
|
} from 'component/providers/AccessProvider/permissions';
|
|
import { PermissionHOC } from 'component/common/PermissionHOC/PermissionHOC';
|
|
import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi';
|
|
import { formatUnknownError } from 'utils/formatUnknownError';
|
|
import { useFeaturesArchive } from 'hooks/api/getters/useFeaturesArchive/useFeaturesArchive';
|
|
import useToast from 'hooks/useToast';
|
|
import { ArchivedFeatureDeleteConfirm } from './ArchivedFeatureActionCell/ArchivedFeatureDeleteConfirm/ArchivedFeatureDeleteConfirm';
|
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
|
import { ArchivedFeatureReviveConfirm } from './ArchivedFeatureActionCell/ArchivedFeatureReviveConfirm/ArchivedFeatureReviveConfirm';
|
|
|
|
interface IArchiveBatchActionsProps {
|
|
selectedIds: string[];
|
|
projectId: string;
|
|
onConfirm?: () => void;
|
|
}
|
|
|
|
export const ArchiveBatchActions: FC<IArchiveBatchActionsProps> = ({
|
|
selectedIds,
|
|
projectId,
|
|
onConfirm,
|
|
}) => {
|
|
const { refetchArchived } = useFeaturesArchive(projectId);
|
|
const [deleteModalOpen, setDeleteModalOpen] = useState(false);
|
|
const [reviveModalOpen, setReviveModalOpen] = useState(false);
|
|
const { trackEvent } = usePlausibleTracker();
|
|
|
|
const onRevive = async () => {
|
|
setReviveModalOpen(true);
|
|
};
|
|
|
|
const onDelete = async () => {
|
|
setDeleteModalOpen(true);
|
|
};
|
|
return (
|
|
<>
|
|
<PermissionHOC projectId={projectId} permission={UPDATE_FEATURE}>
|
|
{({ hasAccess }) => (
|
|
<Button
|
|
disabled={!hasAccess}
|
|
startIcon={<Undo />}
|
|
variant='outlined'
|
|
size='small'
|
|
onClick={onRevive}
|
|
date-testid={'batch_revive'}
|
|
>
|
|
Revive
|
|
</Button>
|
|
)}
|
|
</PermissionHOC>
|
|
<PermissionHOC projectId={projectId} permission={DELETE_FEATURE}>
|
|
{({ hasAccess }) => (
|
|
<Button
|
|
disabled={!hasAccess}
|
|
startIcon={<Delete />}
|
|
variant='outlined'
|
|
size='small'
|
|
onClick={onDelete}
|
|
>
|
|
Delete
|
|
</Button>
|
|
)}
|
|
</PermissionHOC>
|
|
<ArchivedFeatureDeleteConfirm
|
|
deletedFeatures={selectedIds}
|
|
projectId={projectId}
|
|
open={deleteModalOpen}
|
|
setOpen={setDeleteModalOpen}
|
|
refetch={() => {
|
|
refetchArchived();
|
|
onConfirm?.();
|
|
trackEvent('batch_operations', {
|
|
props: {
|
|
eventType: 'features deleted',
|
|
},
|
|
});
|
|
}}
|
|
/>
|
|
<ArchivedFeatureReviveConfirm
|
|
revivedFeatures={selectedIds}
|
|
projectId={projectId}
|
|
open={reviveModalOpen}
|
|
setOpen={setReviveModalOpen}
|
|
refetch={() => {
|
|
refetchArchived();
|
|
onConfirm?.();
|
|
trackEvent('batch_operations', {
|
|
props: {
|
|
eventType: 'features revived',
|
|
},
|
|
});
|
|
}}
|
|
/>
|
|
</>
|
|
);
|
|
};
|