1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

fix: delete archived feature toggles in the UI (#5411)

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)

![image](https://github.com/Unleash/unleash/assets/14320932/c956f459-ef18-4153-97f7-ffdd6b11613c)

## Deleting multiple feature toggles (plural)

![image](https://github.com/Unleash/unleash/assets/14320932/14f875a4-7f56-4db9-81db-cd06526e5bd5)
This commit is contained in:
Nuno Góis 2023-11-24 09:35:13 +00:00 committed by GitHub
parent ffe37ac709
commit aa8347eb7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 10 deletions

View File

@ -17,13 +17,13 @@ import { ArchivedFeatureReviveConfirm } from './ArchivedFeatureActionCell/Archiv
interface IArchiveBatchActionsProps { interface IArchiveBatchActionsProps {
selectedIds: string[]; selectedIds: string[];
projectId: string; projectId: string;
onReviveConfirm?: () => void; onConfirm?: () => void;
} }
export const ArchiveBatchActions: FC<IArchiveBatchActionsProps> = ({ export const ArchiveBatchActions: FC<IArchiveBatchActionsProps> = ({
selectedIds, selectedIds,
projectId, projectId,
onReviveConfirm, onConfirm,
}) => { }) => {
const { refetchArchived } = useFeaturesArchive(projectId); const { refetchArchived } = useFeaturesArchive(projectId);
const [deleteModalOpen, setDeleteModalOpen] = useState(false); const [deleteModalOpen, setDeleteModalOpen] = useState(false);
@ -73,6 +73,7 @@ export const ArchiveBatchActions: FC<IArchiveBatchActionsProps> = ({
setOpen={setDeleteModalOpen} setOpen={setDeleteModalOpen}
refetch={() => { refetch={() => {
refetchArchived(); refetchArchived();
onConfirm?.();
trackEvent('batch_operations', { trackEvent('batch_operations', {
props: { props: {
eventType: 'features deleted', eventType: 'features deleted',
@ -87,7 +88,7 @@ export const ArchiveBatchActions: FC<IArchiveBatchActionsProps> = ({
setOpen={setReviveModalOpen} setOpen={setReviveModalOpen}
refetch={() => { refetch={() => {
refetchArchived(); refetchArchived();
onReviveConfirm?.(); onConfirm?.();
trackEvent('batch_operations', { trackEvent('batch_operations', {
props: { props: {
eventType: 'features revived', eventType: 'features revived',

View File

@ -349,7 +349,7 @@ export const ArchiveTable = ({
<ArchiveBatchActions <ArchiveBatchActions
selectedIds={Object.keys(selectedRowIds)} selectedIds={Object.keys(selectedRowIds)}
projectId={projectId!} projectId={projectId!}
onReviveConfirm={() => toggleAllRowsSelected(false)} onConfirm={() => toggleAllRowsSelected(false)}
/> />
</BatchSelectionActionsBar> </BatchSelectionActionsBar>
} }

View File

@ -36,6 +36,9 @@ export const ArchivedFeatureDeleteConfirm = ({
const { setToastData, setToastApiError } = useToast(); const { setToastData, setToastApiError } = useToast();
const { deleteFeatures } = useProjectApi(); const { deleteFeatures } = useProjectApi();
const singularOrPluralToggles =
deletedFeatures.length > 1 ? 'toggles' : 'toggle';
const onDeleteFeatureToggle = async () => { const onDeleteFeatureToggle = async () => {
try { try {
if (deletedFeatures.length === 0) { if (deletedFeatures.length === 0) {
@ -46,8 +49,8 @@ export const ArchivedFeatureDeleteConfirm = ({
await refetch(); await refetch();
setToastData({ setToastData({
type: 'success', type: 'success',
title: 'Feature toggles deleted', title: `Feature ${singularOrPluralToggles} deleted`,
text: `You have successfully deleted following features toggles: ${deletedFeatures.join( text: `You have successfully deleted the following feature ${singularOrPluralToggles}: ${deletedFeatures.join(
', ', ', ',
)}.`, )}.`,
}); });
@ -67,9 +70,9 @@ export const ArchivedFeatureDeleteConfirm = ({
return ( return (
<Dialogue <Dialogue
title='Delete feature toggles?' title={`Delete feature ${singularOrPluralToggles}?`}
open={open} open={open}
primaryButtonText='Delete feature toggles' primaryButtonText={`Delete feature ${singularOrPluralToggles}`}
secondaryButtonText='Cancel' secondaryButtonText='Cancel'
onClick={onDeleteFeatureToggle} onClick={onDeleteFeatureToggle}
onClose={clearModal} onClose={clearModal}
@ -84,8 +87,16 @@ export const ArchivedFeatureDeleteConfirm = ({
</Alert> </Alert>
<StyledDeleteParagraph> <StyledDeleteParagraph>
In order to delete feature toggles, please enter the following You are about to delete the following feature{' '}
confirmation text in the text field below:{' '} {singularOrPluralToggles}:{' '}
<strong>{deletedFeatures.join(', ')}</strong>.
</StyledDeleteParagraph>
<StyledDeleteParagraph
sx={(theme) => ({ marginTop: theme.spacing(2) })}
>
In order to delete the feature {singularOrPluralToggles}, please
enter the following confirmation text in the text field below:{' '}
<strong>I want to delete</strong> <strong>I want to delete</strong>
</StyledDeleteParagraph> </StyledDeleteParagraph>