1
0
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:
Tymoteusz Czech 2023-03-14 10:12:41 +01:00
parent abe19d3040
commit a8f66dc772
No known key found for this signature in database
GPG Key ID: 133555230D88D75F
3 changed files with 14 additions and 7 deletions

View File

@ -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',

View File

@ -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,

View File

@ -44,7 +44,6 @@ process.nextTick(async () => {
projectStatusApi: true,
showProjectApiAccess: true,
projectScopedSegments: true,
bulkOperations: true,
projectScopedStickiness: true,
},
},