mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: keep parent selection in edit dependency dialogue (#6727)
This commit is contained in:
		
							parent
							
								
									089bc4851e
								
							
						
					
					
						commit
						99935fec94
					
				@ -81,13 +81,14 @@ test('Delete dependency', async () => {
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test('Add dependency', async () => {
 | 
			
		||||
test('Edit dependency', async () => {
 | 
			
		||||
    let closed = false;
 | 
			
		||||
    setupApi();
 | 
			
		||||
    render(
 | 
			
		||||
        <AddDependencyDialogue
 | 
			
		||||
            project='default'
 | 
			
		||||
            featureId='child'
 | 
			
		||||
            parentFeatureId='parentB'
 | 
			
		||||
            showDependencyDialogue={true}
 | 
			
		||||
            onClose={() => {
 | 
			
		||||
                closed = true;
 | 
			
		||||
@ -95,7 +96,7 @@ test('Add dependency', async () => {
 | 
			
		||||
        />,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    const removeDependency = await screen.findByText('Remove');
 | 
			
		||||
    const removeDependency = await screen.findByText('Add');
 | 
			
		||||
 | 
			
		||||
    await waitFor(() => {
 | 
			
		||||
        expect(removeDependency).not.toBeDisabled();
 | 
			
		||||
@ -103,6 +104,7 @@ test('Add dependency', async () => {
 | 
			
		||||
 | 
			
		||||
    // Open the dropdown by selecting the role.
 | 
			
		||||
    const dropdown = screen.queryAllByRole('combobox')[0];
 | 
			
		||||
    expect(dropdown.innerHTML).toBe('parentB');
 | 
			
		||||
    userEvent.click(dropdown);
 | 
			
		||||
 | 
			
		||||
    const parentAOption = await screen.findByText('parentA');
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,7 @@ import { DependenciesUpgradeAlert } from './DependenciesUpgradeAlert';
 | 
			
		||||
interface IAddDependencyDialogueProps {
 | 
			
		||||
    project: string;
 | 
			
		||||
    featureId: string;
 | 
			
		||||
    parentFeatureId?: string;
 | 
			
		||||
    showDependencyDialogue: boolean;
 | 
			
		||||
    onClose: () => void;
 | 
			
		||||
}
 | 
			
		||||
@ -161,10 +162,13 @@ const useManageDependency = (
 | 
			
		||||
export const AddDependencyDialogue = ({
 | 
			
		||||
    project,
 | 
			
		||||
    featureId,
 | 
			
		||||
    parentFeatureId,
 | 
			
		||||
    showDependencyDialogue,
 | 
			
		||||
    onClose,
 | 
			
		||||
}: IAddDependencyDialogueProps) => {
 | 
			
		||||
    const [parent, setParent] = useState(REMOVE_DEPENDENCY_OPTION.key);
 | 
			
		||||
    const [parent, setParent] = useState(
 | 
			
		||||
        parentFeatureId || REMOVE_DEPENDENCY_OPTION.key,
 | 
			
		||||
    );
 | 
			
		||||
    const handleClick = useManageDependency(
 | 
			
		||||
        project,
 | 
			
		||||
        featureId,
 | 
			
		||||
 | 
			
		||||
@ -164,6 +164,7 @@ export const DependencyRow: FC<{ feature: IFeatureToggle }> = ({ feature }) => {
 | 
			
		||||
                    <AddDependencyDialogue
 | 
			
		||||
                        project={feature.project}
 | 
			
		||||
                        featureId={feature.name}
 | 
			
		||||
                        parentFeatureId={feature.dependencies[0]?.feature}
 | 
			
		||||
                        onClose={() => setShowDependencyDialogue(false)}
 | 
			
		||||
                        showDependencyDialogue={showDependencyDialogue}
 | 
			
		||||
                    />
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,7 @@ const setupApi = () => {
 | 
			
		||||
    testServerRoute(
 | 
			
		||||
        server,
 | 
			
		||||
        '/api/admin/projects/default/features/feature/parents',
 | 
			
		||||
        [],
 | 
			
		||||
        ['some_parent'],
 | 
			
		||||
    );
 | 
			
		||||
    testServerRoute(
 | 
			
		||||
        server,
 | 
			
		||||
@ -243,6 +243,7 @@ test('delete dependency with change request', async () => {
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test('edit dependency', async () => {
 | 
			
		||||
    setupChangeRequestApi();
 | 
			
		||||
    render(
 | 
			
		||||
        <FeatureOverviewSidePanelDetails
 | 
			
		||||
            feature={
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user