From 90036a459161ecd4c59e0c78351358ff55ec1330 Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Tue, 25 Apr 2023 14:12:06 +0300 Subject: [PATCH] chore: patch 4.22.7 (#3618) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## About the changes Closes # ### Important files ## Discussion points --------- Signed-off-by: andreas-unleash Co-authored-by: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> --- .../ArchivedFeatureDeleteConfirm.tsx | 12 ++++++++++-- .../hooks/api/actions/useProjectApi/useProjectApi.ts | 10 ++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/frontend/src/component/archive/ArchiveTable/ArchivedFeatureActionCell/ArchivedFeatureDeleteConfirm/ArchivedFeatureDeleteConfirm.tsx b/frontend/src/component/archive/ArchiveTable/ArchivedFeatureActionCell/ArchivedFeatureDeleteConfirm/ArchivedFeatureDeleteConfirm.tsx index 7f6adffc82..054cfa1bf9 100644 --- a/frontend/src/component/archive/ArchiveTable/ArchivedFeatureActionCell/ArchivedFeatureDeleteConfirm/ArchivedFeatureDeleteConfirm.tsx +++ b/frontend/src/component/archive/ArchiveTable/ArchivedFeatureActionCell/ArchivedFeatureDeleteConfirm/ArchivedFeatureDeleteConfirm.tsx @@ -5,6 +5,7 @@ import Input from 'component/common/Input/Input'; import { formatUnknownError } from 'utils/formatUnknownError'; import useToast from 'hooks/useToast'; import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi'; +import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; interface IArchivedFeatureDeleteConfirmProps { deletedFeatures: string[]; @@ -34,14 +35,21 @@ export const ArchivedFeatureDeleteConfirm = ({ }: IArchivedFeatureDeleteConfirmProps) => { const [confirmName, setConfirmName] = useState(''); const { setToastData, setToastApiError } = useToast(); - const { deleteFeatures } = useProjectApi(); + const { deleteFeature, deleteFeatures } = useProjectApi(); + const { uiConfig } = useUiConfig(); const onDeleteFeatureToggle = async () => { try { if (deletedFeatures.length === 0) { return; } - await deleteFeatures(projectId, deletedFeatures); + + if (uiConfig?.flags?.bulkOperations) { + await deleteFeatures(projectId, deletedFeatures); + } else { + await deleteFeature(deletedFeatures[0]); + } + await refetch(); setToastData({ type: 'success', diff --git a/frontend/src/hooks/api/actions/useProjectApi/useProjectApi.ts b/frontend/src/hooks/api/actions/useProjectApi/useProjectApi.ts index df7eb4edef..751a991cf3 100644 --- a/frontend/src/hooks/api/actions/useProjectApi/useProjectApi.ts +++ b/frontend/src/hooks/api/actions/useProjectApi/useProjectApi.ts @@ -223,6 +223,15 @@ const useProjectApi = () => { return makeRequest(req.caller, req.id); }; + const deleteFeature = async (featureId: string) => { + const path = `api/admin/archive/${featureId}`; + const req = createRequest(path, { + method: 'DELETE', + }); + + return makeRequest(req.caller, req.id); + }; + const deleteFeatures = async (projectId: string, featureIds: string[]) => { const path = `api/admin/projects/${projectId}/delete`; const req = createRequest(path, { @@ -267,6 +276,7 @@ const useProjectApi = () => { archiveFeatures, reviveFeatures, staleFeatures, + deleteFeature, deleteFeatures, searchProjectUser, errors,