1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-27 01:19:00 +02:00

Fix: Conditionally hide Change Requests tab (#2329)

This commit is contained in:
andreas-unleash 2022-11-04 10:17:37 +02:00 committed by GitHub
parent f0a929044d
commit 46076fcbc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,43 +63,53 @@ const Project = () => {
const [showDelDialog, setShowDelDialog] = useState(false); const [showDelDialog, setShowDelDialog] = useState(false);
const tabs = [ const changeRequestsEnabled = uiConfig?.flags?.changeRequests;
{
title: 'Overview', const tabs = useMemo(() => {
path: basePath, const tabArray = [
name: 'overview', {
}, title: 'Overview',
{ path: basePath,
title: 'Health', name: 'overview',
path: `${basePath}/health`, },
name: 'health', {
}, title: 'Health',
{ path: `${basePath}/health`,
title: 'Access', name: 'health',
path: `${basePath}/access`, },
name: 'access', {
}, title: 'Access',
{ path: `${basePath}/access`,
title: 'Environments', name: 'access',
path: `${basePath}/environments`, },
name: 'environments', {
}, title: 'Environments',
{ path: `${basePath}/environments`,
title: 'Archive', name: 'environments',
path: `${basePath}/archive`, },
name: 'archive', {
}, title: 'Archive',
{ path: `${basePath}/archive`,
name: 'archive',
},
{
title: 'Event log',
path: `${basePath}/logs`,
name: 'logs',
},
];
const changeRequestTab = {
title: 'Change requests', title: 'Change requests',
path: `${basePath}/change-requests`, path: `${basePath}/change-requests`,
name: 'change-request' + '', name: 'change-request' + '',
}, };
{
title: 'Event log', if (changeRequestsEnabled) {
path: `${basePath}/logs`, tabArray.splice(tabArray.length - 2, 0, changeRequestTab);
name: 'logs', }
}, return tabArray;
]; }, [changeRequestsEnabled]);
const activeTab = [...tabs] const activeTab = [...tabs]
.reverse() .reverse()