mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-27 00:19:39 +01:00
remove change request flag (#2703)
This commit is contained in:
parent
97cf3cd418
commit
f4480d516b
frontend/src
component
hooks
@ -5,10 +5,6 @@ import useProjectRolePermissions from 'hooks/api/getters/useProjectRolePermissio
|
||||
import useProjectRolesApi from 'hooks/api/actions/useProjectRolesApi/useProjectRolesApi';
|
||||
import { formatUnknownError } from 'utils/formatUnknownError';
|
||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||
import {
|
||||
APPLY_CHANGE_REQUEST,
|
||||
APPROVE_CHANGE_REQUEST,
|
||||
} from 'component/providers/AccessProvider/permissions';
|
||||
|
||||
export interface ICheckedPermission {
|
||||
[key: string]: IPermission;
|
||||
@ -170,35 +166,12 @@ const useProjectRoleForm = (
|
||||
setErrors({});
|
||||
};
|
||||
|
||||
// TODO: Clean up when feature is complete - changeRequests
|
||||
let filteredPermissions = cloneDeep(permissions);
|
||||
|
||||
if (!uiConfig?.flags.changeRequests) {
|
||||
filteredPermissions.environments = filteredPermissions.environments.map(
|
||||
env => {
|
||||
env.permissions = env.permissions.filter(permission => {
|
||||
if (!uiConfig?.flags.changeRequests) {
|
||||
if (
|
||||
permission.name === APPLY_CHANGE_REQUEST ||
|
||||
permission.name === APPROVE_CHANGE_REQUEST
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
return env;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
roleName,
|
||||
roleDesc,
|
||||
errors,
|
||||
checkedPermissions,
|
||||
permissions: filteredPermissions,
|
||||
permissions,
|
||||
setRoleName,
|
||||
setRoleDesc,
|
||||
handlePermissionChange,
|
||||
|
@ -7,7 +7,7 @@ import { styled, Tab, Tabs } from '@mui/material';
|
||||
import { Delete, Edit } from '@mui/icons-material';
|
||||
import useToast from 'hooks/useToast';
|
||||
import useQueryParams from 'hooks/useQueryParams';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import ProjectEnvironment from '../ProjectEnvironment/ProjectEnvironment';
|
||||
import { ProjectFeaturesArchive } from './ProjectFeaturesArchive/ProjectFeaturesArchive';
|
||||
import ProjectOverview from './ProjectOverview';
|
||||
@ -77,51 +77,44 @@ const Project = () => {
|
||||
const { isOss, uiConfig } = useUiConfig();
|
||||
const basePath = `/projects/${projectId}`;
|
||||
const projectName = project?.name || projectId;
|
||||
const { isChangeRequestConfiguredInAnyEnv, isChangeRequestFlagEnabled } =
|
||||
const { isChangeRequestConfiguredInAnyEnv } =
|
||||
useChangeRequestsEnabled(projectId);
|
||||
const { favorite, unfavorite } = useFavoriteProjectsApi();
|
||||
|
||||
const [showDelDialog, setShowDelDialog] = useState(false);
|
||||
|
||||
const tabs = useMemo(() => {
|
||||
const tabArray = [
|
||||
{
|
||||
title: 'Overview',
|
||||
path: basePath,
|
||||
name: 'overview',
|
||||
},
|
||||
{
|
||||
title: 'Health',
|
||||
path: `${basePath}/health`,
|
||||
name: 'health',
|
||||
},
|
||||
{
|
||||
title: 'Archive',
|
||||
path: `${basePath}/archive`,
|
||||
name: 'archive',
|
||||
},
|
||||
...(isChangeRequestFlagEnabled
|
||||
? [
|
||||
{
|
||||
title: 'Change requests',
|
||||
path: `${basePath}/change-requests`,
|
||||
name: 'change-request',
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
title: 'Project settings',
|
||||
path: `${basePath}/settings`,
|
||||
name: 'settings',
|
||||
},
|
||||
{
|
||||
title: 'Event log',
|
||||
path: `${basePath}/logs`,
|
||||
name: 'logs',
|
||||
},
|
||||
];
|
||||
return tabArray;
|
||||
}, [isChangeRequestFlagEnabled]);
|
||||
const tabs = [
|
||||
{
|
||||
title: 'Overview',
|
||||
path: basePath,
|
||||
name: 'overview',
|
||||
},
|
||||
{
|
||||
title: 'Health',
|
||||
path: `${basePath}/health`,
|
||||
name: 'health',
|
||||
},
|
||||
{
|
||||
title: 'Archive',
|
||||
path: `${basePath}/archive`,
|
||||
name: 'archive',
|
||||
},
|
||||
{
|
||||
title: 'Change requests',
|
||||
path: `${basePath}/change-requests`,
|
||||
name: 'change-request',
|
||||
},
|
||||
{
|
||||
title: 'Project settings',
|
||||
path: `${basePath}/settings`,
|
||||
name: 'settings',
|
||||
},
|
||||
{
|
||||
title: 'Event log',
|
||||
path: `${basePath}/logs`,
|
||||
name: 'logs',
|
||||
},
|
||||
];
|
||||
|
||||
const activeTab = [...tabs]
|
||||
.reverse()
|
||||
@ -285,21 +278,11 @@ const Project = () => {
|
||||
<Route path="logs" element={<ProjectLog />} />
|
||||
<Route
|
||||
path="change-requests"
|
||||
element={
|
||||
<ConditionallyRender
|
||||
condition={isChangeRequestFlagEnabled}
|
||||
show={<ProjectChangeRequests />}
|
||||
/>
|
||||
}
|
||||
element={<ProjectChangeRequests />}
|
||||
/>
|
||||
<Route
|
||||
path="change-requests/:id"
|
||||
element={
|
||||
<ConditionallyRender
|
||||
condition={isChangeRequestFlagEnabled}
|
||||
show={<ChangeRequestOverview />}
|
||||
/>
|
||||
}
|
||||
element={<ChangeRequestOverview />}
|
||||
/>
|
||||
<Route path="settings/*" element={<ProjectSettings />} />
|
||||
<Route path="*" element={<ProjectOverview />} />
|
||||
|
@ -1,34 +1,26 @@
|
||||
import React from 'react';
|
||||
import useUiConfig from './api/getters/useUiConfig/useUiConfig';
|
||||
import { useChangeRequestConfig } from './api/getters/useChangeRequestConfig/useChangeRequestConfig';
|
||||
|
||||
export const useChangeRequestsEnabled = (projectId: string) => {
|
||||
const { uiConfig } = useUiConfig();
|
||||
const { data } = useChangeRequestConfig(projectId);
|
||||
|
||||
const isChangeRequestConfigured = React.useCallback(
|
||||
(environment: string): boolean => {
|
||||
const enabled = data.some(draft => {
|
||||
return data.some(draft => {
|
||||
return (
|
||||
draft.environment === environment &&
|
||||
draft.changeRequestEnabled
|
||||
);
|
||||
});
|
||||
|
||||
return Boolean(uiConfig?.flags.changeRequests) && enabled;
|
||||
},
|
||||
[JSON.stringify(data)]
|
||||
);
|
||||
|
||||
const isChangeRequestConfiguredInAnyEnv = React.useCallback((): boolean => {
|
||||
return (
|
||||
Boolean(uiConfig?.flags.changeRequests) &&
|
||||
data.some(draft => draft.changeRequestEnabled)
|
||||
);
|
||||
return data.some(draft => draft.changeRequestEnabled);
|
||||
}, [JSON.stringify(data)]);
|
||||
|
||||
return {
|
||||
isChangeRequestFlagEnabled: Boolean(uiConfig?.flags.changeRequests),
|
||||
isChangeRequestConfigured,
|
||||
isChangeRequestConfiguredInAnyEnv,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user