mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
fix: misc fixes for project archive (#7948)
This commit is contained in:
parent
89f3f09b6e
commit
ee1d8ee8cd
@ -6,7 +6,7 @@ export const ProjectArchived: FC<{ name: string }> = ({ name }) => {
|
||||
<p>
|
||||
The project <strong>{name}</strong> has been archived. You can find
|
||||
it on the{' '}
|
||||
<Link to={`/projects-archive`}>projects archive page</Link>.
|
||||
<Link to={`/projects-archive`}>archive page for projects</Link>.
|
||||
</p>
|
||||
);
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ export const ArchiveProjectForm = ({ featureCount }: IDeleteProjectForm) => {
|
||||
const { uiConfig } = useUiConfig();
|
||||
const { loading } = useProjectApi();
|
||||
const formatProjectArchiveApiCode = () => {
|
||||
return `curl --location --request DELETE '${uiConfig.unleashUrl}/api/admin/projects/${id}/archive' \\
|
||||
return `curl --location --request POST '${uiConfig.unleashUrl}/api/admin/projects/archive/${id}' \\
|
||||
--header 'Authorization: INSERT_API_KEY' '`;
|
||||
};
|
||||
|
||||
|
@ -5,6 +5,7 @@ import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi';
|
||||
import useProjects from 'hooks/api/getters/useProjects/useProjects';
|
||||
import useToast from 'hooks/useToast';
|
||||
import { formatUnknownError } from 'utils/formatUnknownError';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
type ReviveProjectDialogProps = {
|
||||
name: string;
|
||||
@ -27,6 +28,7 @@ export const ReviveProjectDialog = ({
|
||||
const { refetch: refetchProjects } = useProjects();
|
||||
const { refetch: refetchProjectArchive } = useProjects({ archived: true });
|
||||
const { setToastData, setToastApiError } = useToast();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const onClick = async (e: React.SyntheticEvent) => {
|
||||
e.preventDefault();
|
||||
@ -35,6 +37,7 @@ export const ReviveProjectDialog = ({
|
||||
await reviveProject(id);
|
||||
refetchProjects();
|
||||
refetchProjectArchive();
|
||||
navigate(`/projects/${id}`);
|
||||
setToastData({
|
||||
title: 'Revive project',
|
||||
type: 'success',
|
||||
|
@ -9,7 +9,7 @@ const alwaysOnFlagResolver = {
|
||||
},
|
||||
} as unknown as IFlagResolver;
|
||||
|
||||
test('Should not allow to exceed project limit', async () => {
|
||||
test('Should not allow to exceed project limit on create', async () => {
|
||||
const LIMIT = 1;
|
||||
const projectService = createFakeProjectService({
|
||||
...createTestConfig(),
|
||||
@ -31,3 +31,36 @@ test('Should not allow to exceed project limit', async () => {
|
||||
"Failed to create project. You can't create more than the established limit of 1.",
|
||||
);
|
||||
});
|
||||
|
||||
test('Should not allow to exceed project limit on revive', async () => {
|
||||
const LIMIT = 1;
|
||||
const projectService = createFakeProjectService({
|
||||
...createTestConfig(),
|
||||
flagResolver: alwaysOnFlagResolver,
|
||||
resourceLimits: {
|
||||
projects: LIMIT,
|
||||
},
|
||||
eventBus: {
|
||||
emit: () => {},
|
||||
},
|
||||
} as unknown as IUnleashConfig);
|
||||
|
||||
const createProject = (name: string) =>
|
||||
projectService.createProject(
|
||||
{ name, id: name },
|
||||
{} as IUser,
|
||||
{} as IAuditUser,
|
||||
);
|
||||
const archiveProject = (id: string) =>
|
||||
projectService.archiveProject(id, {} as IAuditUser);
|
||||
const reviveProject = (id: string) =>
|
||||
projectService.reviveProject(id, {} as IAuditUser);
|
||||
|
||||
await createProject('projectA');
|
||||
await archiveProject('projectA');
|
||||
await createProject('projectB');
|
||||
|
||||
await expect(() => reviveProject('projectA')).rejects.toThrow(
|
||||
"Failed to create project. You can't create more than the established limit of 1.",
|
||||
);
|
||||
});
|
||||
|
@ -634,6 +634,8 @@ export default class ProjectService {
|
||||
}
|
||||
|
||||
async reviveProject(id: string, auditUser: IAuditUser): Promise<void> {
|
||||
await this.validateProjectLimit();
|
||||
|
||||
await this.projectStore.revive(id);
|
||||
|
||||
await this.eventService.storeEvent(
|
||||
|
Loading…
Reference in New Issue
Block a user