mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-27 01:19:00 +02:00
feat: prevent revive feature to archived project (#7939)
This commit is contained in:
parent
37dd2ebc4c
commit
51f61d5103
@ -1,7 +1,7 @@
|
|||||||
import { ArchiveTable } from './ArchiveTable';
|
import { ArchiveTable } from './ArchiveTable';
|
||||||
import { render } from 'utils/testRenderer';
|
import { render } from 'utils/testRenderer';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { screen, fireEvent } from '@testing-library/react';
|
import { screen, fireEvent, waitFor } from '@testing-library/react';
|
||||||
import userEvent from '@testing-library/user-event';
|
import userEvent from '@testing-library/user-event';
|
||||||
import {
|
import {
|
||||||
DELETE_FEATURE,
|
DELETE_FEATURE,
|
||||||
@ -63,9 +63,12 @@ const setupApi = () => {
|
|||||||
200,
|
200,
|
||||||
);
|
);
|
||||||
|
|
||||||
testServerRoute(server, '/api/admin/ui-config', {
|
testServerRoute(server, '/api/admin/projects/default/overview', {
|
||||||
environment: 'Open Source',
|
environment: 'Open Source',
|
||||||
});
|
});
|
||||||
|
testServerRoute(server, '/api/admin/ui-config', {
|
||||||
|
archivedAt: null,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
test('should load the table', async () => {
|
test('should load the table', async () => {
|
||||||
@ -95,6 +98,9 @@ test('should show confirm dialog when reviving flag', async () => {
|
|||||||
const reviveFlagsButton = screen.getByRole('button', {
|
const reviveFlagsButton = screen.getByRole('button', {
|
||||||
name: /Revive feature flag/i,
|
name: /Revive feature flag/i,
|
||||||
});
|
});
|
||||||
|
await waitFor(async () => {
|
||||||
|
expect(reviveFlagsButton).toBeEnabled();
|
||||||
|
});
|
||||||
fireEvent.click(reviveFlagsButton);
|
fireEvent.click(reviveFlagsButton);
|
||||||
|
|
||||||
await screen.findByText("And we're back!");
|
await screen.findByText("And we're back!");
|
||||||
|
@ -5,6 +5,7 @@ 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 { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
|
import useProjectOverview from 'hooks/api/getters/useProjectOverview/useProjectOverview';
|
||||||
|
|
||||||
interface IArchivedFeatureReviveConfirmProps {
|
interface IArchivedFeatureReviveConfirmProps {
|
||||||
revivedFeatures: string[];
|
revivedFeatures: string[];
|
||||||
@ -27,6 +28,7 @@ export const ArchivedFeatureReviveConfirm = ({
|
|||||||
}: IArchivedFeatureReviveConfirmProps) => {
|
}: IArchivedFeatureReviveConfirmProps) => {
|
||||||
const { setToastData, setToastApiError } = useToast();
|
const { setToastData, setToastApiError } = useToast();
|
||||||
const { reviveFeatures } = useProjectApi();
|
const { reviveFeatures } = useProjectApi();
|
||||||
|
const { project, loading } = useProjectOverview(projectId);
|
||||||
|
|
||||||
const onReviveFeatureToggle = async () => {
|
const onReviveFeatureToggle = async () => {
|
||||||
try {
|
try {
|
||||||
@ -67,11 +69,23 @@ export const ArchivedFeatureReviveConfirm = ({
|
|||||||
secondaryButtonText='Cancel'
|
secondaryButtonText='Cancel'
|
||||||
onClick={onReviveFeatureToggle}
|
onClick={onReviveFeatureToggle}
|
||||||
onClose={clearModal}
|
onClose={clearModal}
|
||||||
|
disabledPrimaryButton={loading || Boolean(project.archivedAt)}
|
||||||
>
|
>
|
||||||
<Alert severity='info'>
|
<ConditionallyRender
|
||||||
Revived feature flags will be automatically disabled in all
|
condition={Boolean(project.archivedAt)}
|
||||||
environments
|
show={
|
||||||
</Alert>
|
<Alert severity='warning'>
|
||||||
|
Cannot revive feature flag in archived project (Project
|
||||||
|
ID: {projectId})
|
||||||
|
</Alert>
|
||||||
|
}
|
||||||
|
elseShow={
|
||||||
|
<Alert severity='info'>
|
||||||
|
Revived feature flags will be automatically disabled in
|
||||||
|
all environments
|
||||||
|
</Alert>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={revivedFeatures.length > 1}
|
condition={revivedFeatures.length > 1}
|
||||||
|
Loading…
Reference in New Issue
Block a user