mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	Fix: Conditionally hide Change Requests tab (#2329)
(cherry picked from commit 46076fcbc8)
			
			
This commit is contained in:
		
							parent
							
								
									1061991ebb
								
							
						
					
					
						commit
						47cc168020
					
				@ -8,7 +8,7 @@ import { styled, Tab, Tabs } from '@mui/material';
 | 
				
			|||||||
import { Delete, Edit } from '@mui/icons-material';
 | 
					import { Delete, Edit } from '@mui/icons-material';
 | 
				
			||||||
import useToast from 'hooks/useToast';
 | 
					import useToast from 'hooks/useToast';
 | 
				
			||||||
import useQueryParams from 'hooks/useQueryParams';
 | 
					import useQueryParams from 'hooks/useQueryParams';
 | 
				
			||||||
import { useEffect, useState } from 'react';
 | 
					import { useEffect, useMemo, useState } from 'react';
 | 
				
			||||||
import { ProjectAccess } from '../ProjectAccess/ProjectAccess';
 | 
					import { ProjectAccess } from '../ProjectAccess/ProjectAccess';
 | 
				
			||||||
import ProjectEnvironment from '../ProjectEnvironment/ProjectEnvironment';
 | 
					import ProjectEnvironment from '../ProjectEnvironment/ProjectEnvironment';
 | 
				
			||||||
import { ProjectFeaturesArchive } from './ProjectFeaturesArchive/ProjectFeaturesArchive';
 | 
					import { ProjectFeaturesArchive } from './ProjectFeaturesArchive/ProjectFeaturesArchive';
 | 
				
			||||||
@ -63,7 +63,10 @@ const Project = () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    const [showDelDialog, setShowDelDialog] = useState(false);
 | 
					    const [showDelDialog, setShowDelDialog] = useState(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const tabs = [
 | 
					    const changeRequestsEnabled = uiConfig?.flags?.changeRequests;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const tabs = useMemo(() => {
 | 
				
			||||||
 | 
					        const tabArray = [
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                title: 'Overview',
 | 
					                title: 'Overview',
 | 
				
			||||||
                path: basePath,
 | 
					                path: basePath,
 | 
				
			||||||
@ -89,11 +92,6 @@ const Project = () => {
 | 
				
			|||||||
                path: `${basePath}/archive`,
 | 
					                path: `${basePath}/archive`,
 | 
				
			||||||
                name: 'archive',
 | 
					                name: 'archive',
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            title: 'Change requests',
 | 
					 | 
				
			||||||
            path: `${basePath}/change-requests`,
 | 
					 | 
				
			||||||
            name: 'change-request' + '',
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                title: 'Event log',
 | 
					                title: 'Event log',
 | 
				
			||||||
                path: `${basePath}/logs`,
 | 
					                path: `${basePath}/logs`,
 | 
				
			||||||
@ -101,6 +99,18 @@ const Project = () => {
 | 
				
			|||||||
            },
 | 
					            },
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const changeRequestTab = {
 | 
				
			||||||
 | 
					            title: 'Change requests',
 | 
				
			||||||
 | 
					            path: `${basePath}/change-requests`,
 | 
				
			||||||
 | 
					            name: 'change-request' + '',
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (changeRequestsEnabled) {
 | 
				
			||||||
 | 
					            tabArray.splice(tabArray.length - 2, 0, changeRequestTab);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return tabArray;
 | 
				
			||||||
 | 
					    }, [changeRequestsEnabled]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const activeTab = [...tabs]
 | 
					    const activeTab = [...tabs]
 | 
				
			||||||
        .reverse()
 | 
					        .reverse()
 | 
				
			||||||
        .find(tab => pathname.startsWith(tab.path));
 | 
					        .find(tab => pathname.startsWith(tab.path));
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user