mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-05 17:53:12 +02:00
bulk feature archive api
This commit is contained in:
parent
abe19d3040
commit
a8f66dc772
@ -4,6 +4,7 @@ import useFeatureApi from 'hooks/api/actions/useFeatureApi/useFeatureApi';
|
||||
import useToast from 'hooks/useToast';
|
||||
import { formatUnknownError } from 'utils/formatUnknownError';
|
||||
import { ConditionallyRender } from '../ConditionallyRender/ConditionallyRender';
|
||||
import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi';
|
||||
|
||||
interface IFeatureArchiveDialogProps {
|
||||
isOpen: boolean;
|
||||
@ -21,6 +22,7 @@ export const FeatureArchiveDialog: VFC<IFeatureArchiveDialogProps> = ({
|
||||
featureIds,
|
||||
}) => {
|
||||
const { archiveFeatureToggle } = useFeatureApi();
|
||||
const { archiveFeatures } = useProjectApi();
|
||||
const { setToastData, setToastApiError } = useToast();
|
||||
const isBulkArchive = featureIds?.length > 1;
|
||||
|
||||
@ -42,12 +44,7 @@ export const FeatureArchiveDialog: VFC<IFeatureArchiveDialogProps> = ({
|
||||
|
||||
const archiveToggles = async () => {
|
||||
try {
|
||||
// TODO: bulk archive
|
||||
await Promise.allSettled(
|
||||
featureIds.map(id => {
|
||||
archiveFeatureToggle(projectId, id);
|
||||
})
|
||||
);
|
||||
await archiveFeatures(projectId, featureIds);
|
||||
setToastData({
|
||||
text: 'Selected feature toggles have been archived',
|
||||
type: 'success',
|
||||
|
@ -202,6 +202,16 @@ const useProjectApi = () => {
|
||||
return makeRequest(req.caller, req.id);
|
||||
};
|
||||
|
||||
const archiveFeatures = async (projectId: string, featureIds: string[]) => {
|
||||
const path = `api/admin/projects/${projectId}/archive`;
|
||||
const req = createRequest(path, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ features: featureIds }),
|
||||
});
|
||||
|
||||
return makeRequest(req.caller, req.id);
|
||||
};
|
||||
|
||||
return {
|
||||
createProject,
|
||||
validateId,
|
||||
@ -214,6 +224,7 @@ const useProjectApi = () => {
|
||||
removeGroupFromRole,
|
||||
changeUserRole,
|
||||
changeGroupRole,
|
||||
archiveFeatures,
|
||||
errors,
|
||||
loading,
|
||||
searchProjectUser,
|
||||
|
@ -44,7 +44,6 @@ process.nextTick(async () => {
|
||||
projectStatusApi: true,
|
||||
showProjectApiAccess: true,
|
||||
projectScopedSegments: true,
|
||||
bulkOperations: true,
|
||||
projectScopedStickiness: true,
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user