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 useToast from 'hooks/useToast';
|
||||||
import { formatUnknownError } from 'utils/formatUnknownError';
|
import { formatUnknownError } from 'utils/formatUnknownError';
|
||||||
import { ConditionallyRender } from '../ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from '../ConditionallyRender/ConditionallyRender';
|
||||||
|
import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi';
|
||||||
|
|
||||||
interface IFeatureArchiveDialogProps {
|
interface IFeatureArchiveDialogProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@ -21,6 +22,7 @@ export const FeatureArchiveDialog: VFC<IFeatureArchiveDialogProps> = ({
|
|||||||
featureIds,
|
featureIds,
|
||||||
}) => {
|
}) => {
|
||||||
const { archiveFeatureToggle } = useFeatureApi();
|
const { archiveFeatureToggle } = useFeatureApi();
|
||||||
|
const { archiveFeatures } = useProjectApi();
|
||||||
const { setToastData, setToastApiError } = useToast();
|
const { setToastData, setToastApiError } = useToast();
|
||||||
const isBulkArchive = featureIds?.length > 1;
|
const isBulkArchive = featureIds?.length > 1;
|
||||||
|
|
||||||
@ -42,12 +44,7 @@ export const FeatureArchiveDialog: VFC<IFeatureArchiveDialogProps> = ({
|
|||||||
|
|
||||||
const archiveToggles = async () => {
|
const archiveToggles = async () => {
|
||||||
try {
|
try {
|
||||||
// TODO: bulk archive
|
await archiveFeatures(projectId, featureIds);
|
||||||
await Promise.allSettled(
|
|
||||||
featureIds.map(id => {
|
|
||||||
archiveFeatureToggle(projectId, id);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
setToastData({
|
setToastData({
|
||||||
text: 'Selected feature toggles have been archived',
|
text: 'Selected feature toggles have been archived',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
|
@ -202,6 +202,16 @@ const useProjectApi = () => {
|
|||||||
return makeRequest(req.caller, req.id);
|
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 {
|
return {
|
||||||
createProject,
|
createProject,
|
||||||
validateId,
|
validateId,
|
||||||
@ -214,6 +224,7 @@ const useProjectApi = () => {
|
|||||||
removeGroupFromRole,
|
removeGroupFromRole,
|
||||||
changeUserRole,
|
changeUserRole,
|
||||||
changeGroupRole,
|
changeGroupRole,
|
||||||
|
archiveFeatures,
|
||||||
errors,
|
errors,
|
||||||
loading,
|
loading,
|
||||||
searchProjectUser,
|
searchProjectUser,
|
||||||
|
@ -44,7 +44,6 @@ process.nextTick(async () => {
|
|||||||
projectStatusApi: true,
|
projectStatusApi: true,
|
||||||
showProjectApiAccess: true,
|
showProjectApiAccess: true,
|
||||||
projectScopedSegments: true,
|
projectScopedSegments: true,
|
||||||
bulkOperations: true,
|
|
||||||
projectScopedStickiness: true,
|
projectScopedStickiness: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user