mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-19 01:17:18 +02:00
fix: bulk update delete flag (#3466)
Allow deleting with BULK_UPDATE flag turned off
This commit is contained in:
parent
e0b59ba689
commit
e864657ef8
@ -5,6 +5,7 @@ import Input from 'component/common/Input/Input';
|
|||||||
import { formatUnknownError } from 'utils/formatUnknownError';
|
import { formatUnknownError } from 'utils/formatUnknownError';
|
||||||
import useToast from 'hooks/useToast';
|
import useToast from 'hooks/useToast';
|
||||||
import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi';
|
import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi';
|
||||||
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
|
|
||||||
interface IArchivedFeatureDeleteConfirmProps {
|
interface IArchivedFeatureDeleteConfirmProps {
|
||||||
deletedFeatures: string[];
|
deletedFeatures: string[];
|
||||||
@ -34,14 +35,21 @@ export const ArchivedFeatureDeleteConfirm = ({
|
|||||||
}: IArchivedFeatureDeleteConfirmProps) => {
|
}: IArchivedFeatureDeleteConfirmProps) => {
|
||||||
const [confirmName, setConfirmName] = useState('');
|
const [confirmName, setConfirmName] = useState('');
|
||||||
const { setToastData, setToastApiError } = useToast();
|
const { setToastData, setToastApiError } = useToast();
|
||||||
const { deleteFeatures } = useProjectApi();
|
const { deleteFeature, deleteFeatures } = useProjectApi();
|
||||||
|
const { uiConfig } = useUiConfig();
|
||||||
|
|
||||||
const onDeleteFeatureToggle = async () => {
|
const onDeleteFeatureToggle = async () => {
|
||||||
try {
|
try {
|
||||||
if (deletedFeatures.length === 0) {
|
if (deletedFeatures.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uiConfig?.flags?.bulkOperations) {
|
||||||
await deleteFeatures(projectId, deletedFeatures);
|
await deleteFeatures(projectId, deletedFeatures);
|
||||||
|
} else {
|
||||||
|
await deleteFeature(deletedFeatures[0]);
|
||||||
|
}
|
||||||
|
|
||||||
await refetch();
|
await refetch();
|
||||||
setToastData({
|
setToastData({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
|
@ -223,6 +223,15 @@ const useProjectApi = () => {
|
|||||||
return makeRequest(req.caller, req.id);
|
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 deleteFeatures = async (projectId: string, featureIds: string[]) => {
|
||||||
const path = `api/admin/projects/${projectId}/delete`;
|
const path = `api/admin/projects/${projectId}/delete`;
|
||||||
const req = createRequest(path, {
|
const req = createRequest(path, {
|
||||||
@ -267,6 +276,7 @@ const useProjectApi = () => {
|
|||||||
archiveFeatures,
|
archiveFeatures,
|
||||||
reviveFeatures,
|
reviveFeatures,
|
||||||
staleFeatures,
|
staleFeatures,
|
||||||
|
deleteFeature,
|
||||||
deleteFeatures,
|
deleteFeatures,
|
||||||
searchProjectUser,
|
searchProjectUser,
|
||||||
errors,
|
errors,
|
||||||
|
Loading…
Reference in New Issue
Block a user