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