mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-20 00:08:02 +01:00
chore: clean up customRootRolesKillSwitch (#6173)
https://linear.app/unleash/issue/2-1308/remove-customrootroleskillswitch-flag Cleans up the `customRootRolesKillSwitch` flag.
This commit is contained in:
parent
13df715bfd
commit
4c1dfbefa7
@ -5,7 +5,6 @@ import { RolesTable } from './RolesTable/RolesTable';
|
||||
import { PageContent } from 'component/common/PageContent/PageContent';
|
||||
import { Tab, Tabs, styled, useMediaQuery } from '@mui/material';
|
||||
import { Route, Routes, useLocation } from 'react-router-dom';
|
||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||
import { PROJECT_ROLE_TYPE, ROOT_ROLE_TYPE } from '@server/util/constants';
|
||||
import { useRoles } from 'hooks/api/getters/useRoles/useRoles';
|
||||
import { Search } from 'component/common/Search/Search';
|
||||
@ -32,7 +31,6 @@ const StyledActions = styled('div')({
|
||||
});
|
||||
|
||||
export const RolesPage = () => {
|
||||
const { uiConfig } = useUiConfig();
|
||||
const { pathname } = useLocation();
|
||||
|
||||
const { roles, projectRoles, loading } = useRoles();
|
||||
@ -41,34 +39,24 @@ export const RolesPage = () => {
|
||||
const [modalOpen, setModalOpen] = useState(false);
|
||||
const [selectedRole, setSelectedRole] = useState<IRole>();
|
||||
|
||||
const tabs = !uiConfig.flags.customRootRolesKillSwitch
|
||||
? [
|
||||
{
|
||||
label: 'Root roles',
|
||||
path: '/admin/roles',
|
||||
total: roles.length,
|
||||
},
|
||||
{
|
||||
label: 'Project roles',
|
||||
path: '/admin/roles/project-roles',
|
||||
total: projectRoles.length,
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
label: 'Project roles',
|
||||
path: '/admin/roles',
|
||||
total: projectRoles.length,
|
||||
},
|
||||
];
|
||||
const tabs = [
|
||||
{
|
||||
label: 'Root roles',
|
||||
path: '/admin/roles',
|
||||
total: roles.length,
|
||||
},
|
||||
{
|
||||
label: 'Project roles',
|
||||
path: '/admin/roles/project-roles',
|
||||
total: projectRoles.length,
|
||||
},
|
||||
];
|
||||
|
||||
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
|
||||
|
||||
const type =
|
||||
uiConfig.flags.customRootRolesKillSwitch ||
|
||||
pathname.includes('project-roles')
|
||||
? PROJECT_ROLE_TYPE
|
||||
: ROOT_ROLE_TYPE;
|
||||
const type = pathname.includes('project-roles')
|
||||
? PROJECT_ROLE_TYPE
|
||||
: ROOT_ROLE_TYPE;
|
||||
|
||||
return (
|
||||
<PageContent
|
||||
@ -156,11 +144,7 @@ export const RolesPage = () => {
|
||||
path='*'
|
||||
element={
|
||||
<RolesTable
|
||||
type={
|
||||
!uiConfig.flags.customRootRolesKillSwitch
|
||||
? ROOT_ROLE_TYPE
|
||||
: PROJECT_ROLE_TYPE
|
||||
}
|
||||
type={ROOT_ROLE_TYPE}
|
||||
searchValue={searchValue}
|
||||
modalOpen={modalOpen}
|
||||
setModalOpen={setModalOpen}
|
||||
|
@ -59,7 +59,6 @@ export type UiFlags = {
|
||||
disableBulkToggle?: boolean;
|
||||
disableNotifications?: boolean;
|
||||
advancedPlayground?: boolean;
|
||||
customRootRolesKillSwitch?: boolean;
|
||||
strategyVariant?: boolean;
|
||||
doraMetrics?: boolean;
|
||||
dependentFeatures?: boolean;
|
||||
|
@ -81,7 +81,6 @@ exports[`should create default config 1`] = `
|
||||
"changeRequestConflictHandling": false,
|
||||
"collectTrafficDataUsage": false,
|
||||
"createdByUserIdDataMigration": false,
|
||||
"customRootRolesKillSwitch": false,
|
||||
"demo": false,
|
||||
"disableBulkToggle": false,
|
||||
"disableMetrics": false,
|
||||
|
@ -19,7 +19,7 @@ export const createAccessService = (
|
||||
db: Db,
|
||||
config: IUnleashConfig,
|
||||
): AccessService => {
|
||||
const { eventBus, getLogger, flagResolver } = config;
|
||||
const { eventBus, getLogger } = config;
|
||||
const groupStore = new GroupStore(db);
|
||||
const accountStore = new AccountStore(db, getLogger);
|
||||
const roleStore = new RoleStore(db, eventBus, getLogger);
|
||||
@ -34,7 +34,7 @@ export const createAccessService = (
|
||||
|
||||
return new AccessService(
|
||||
{ accessStore, accountStore, roleStore, environmentStore },
|
||||
{ getLogger, flagResolver },
|
||||
{ getLogger },
|
||||
groupService,
|
||||
eventService,
|
||||
);
|
||||
@ -63,7 +63,7 @@ export const createFakeAccessService = (
|
||||
|
||||
const accessService = new AccessService(
|
||||
{ accessStore, accountStore, roleStore, environmentStore, groupStore },
|
||||
{ getLogger, flagResolver },
|
||||
{ getLogger },
|
||||
groupService,
|
||||
eventService,
|
||||
);
|
||||
|
@ -108,7 +108,7 @@ export const createFeatureToggleService = (
|
||||
);
|
||||
const accessService = new AccessService(
|
||||
{ accessStore, accountStore, roleStore, environmentStore },
|
||||
{ getLogger, flagResolver },
|
||||
{ getLogger },
|
||||
groupService,
|
||||
eventService,
|
||||
);
|
||||
@ -176,7 +176,7 @@ export const createFakeFeatureToggleService = (
|
||||
);
|
||||
const accessService = new AccessService(
|
||||
{ accessStore, accountStore, roleStore, environmentStore, groupStore },
|
||||
{ getLogger, flagResolver },
|
||||
{ getLogger },
|
||||
groupService,
|
||||
eventService,
|
||||
);
|
||||
|
@ -19,14 +19,9 @@ import { IGroup, ROLE_CREATED, SYSTEM_USER } from '../../lib/types';
|
||||
import BadDataError from '../../lib/error/bad-data-error';
|
||||
import { createFakeEventsService } from '../../lib/features/events/createEventsService';
|
||||
|
||||
function getSetup(customRootRolesKillSwitch: boolean = true) {
|
||||
function getSetup() {
|
||||
const config = createTestConfig({
|
||||
getLogger,
|
||||
experimental: {
|
||||
flags: {
|
||||
customRootRolesKillSwitch,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return createFakeAccessService(config);
|
||||
@ -166,7 +161,7 @@ test('should be able to validate and cleanup with additional properties', async
|
||||
});
|
||||
|
||||
test('user with custom root role should get a user root role', async () => {
|
||||
const { accessService, eventStore } = getSetup(false);
|
||||
const { accessService, eventStore } = getSetup();
|
||||
const createRoleInput: IRoleCreation = {
|
||||
name: 'custom-root-role',
|
||||
description: 'test custom root role',
|
||||
|
@ -40,7 +40,6 @@ import BadDataError from '../error/bad-data-error';
|
||||
import { IGroup } from '../types/group';
|
||||
import { GroupService } from './group-service';
|
||||
import {
|
||||
IFlagResolver,
|
||||
IUnleashConfig,
|
||||
IUserAccessOverview,
|
||||
ROLE_CREATED,
|
||||
@ -114,8 +113,6 @@ export class AccessService {
|
||||
|
||||
private logger: Logger;
|
||||
|
||||
private flagResolver: IFlagResolver;
|
||||
|
||||
private eventService: EventService;
|
||||
|
||||
constructor(
|
||||
@ -128,10 +125,7 @@ export class AccessService {
|
||||
IUnleashStores,
|
||||
'accessStore' | 'accountStore' | 'roleStore' | 'environmentStore'
|
||||
> & { groupStore?: any }, // TODO remove groupStore later, kept for backward compatibility with enterprise
|
||||
{
|
||||
getLogger,
|
||||
flagResolver,
|
||||
}: Pick<IUnleashConfig, 'getLogger' | 'flagResolver'>,
|
||||
{ getLogger }: Pick<IUnleashConfig, 'getLogger'>,
|
||||
groupService: GroupService,
|
||||
eventService: EventService,
|
||||
) {
|
||||
@ -141,7 +135,6 @@ export class AccessService {
|
||||
this.groupService = groupService;
|
||||
this.environmentStore = environmentStore;
|
||||
this.logger = getLogger('/services/access-service.ts');
|
||||
this.flagResolver = flagResolver;
|
||||
this.eventService = eventService;
|
||||
}
|
||||
|
||||
@ -643,15 +636,6 @@ export class AccessService {
|
||||
? CUSTOM_ROOT_ROLE_TYPE
|
||||
: CUSTOM_PROJECT_ROLE_TYPE;
|
||||
|
||||
if (
|
||||
roleType === CUSTOM_ROOT_ROLE_TYPE &&
|
||||
this.flagResolver.isEnabled('customRootRolesKillSwitch')
|
||||
) {
|
||||
throw new InvalidOperationError(
|
||||
'Custom root roles are not enabled.',
|
||||
);
|
||||
}
|
||||
|
||||
const baseRole = {
|
||||
...(await this.validateRole(role)),
|
||||
roleType,
|
||||
@ -695,15 +679,6 @@ export class AccessService {
|
||||
? CUSTOM_ROOT_ROLE_TYPE
|
||||
: CUSTOM_PROJECT_ROLE_TYPE;
|
||||
|
||||
if (
|
||||
roleType === CUSTOM_ROOT_ROLE_TYPE &&
|
||||
this.flagResolver.isEnabled('customRootRolesKillSwitch')
|
||||
) {
|
||||
throw new InvalidOperationError(
|
||||
'Custom root roles are not enabled.',
|
||||
);
|
||||
}
|
||||
|
||||
await this.validateRole(role, role.id);
|
||||
const existingRole = await this.roleStore.get(role.id);
|
||||
const baseRole = {
|
||||
|
@ -25,7 +25,6 @@ export type IFlagKey =
|
||||
| 'disableNotifications'
|
||||
| 'advancedPlayground'
|
||||
| 'filterInvalidClientMetrics'
|
||||
| 'customRootRolesKillSwitch'
|
||||
| 'disableMetrics'
|
||||
| 'scheduledConfigurationChanges'
|
||||
| 'stripClientHeadersOn304'
|
||||
@ -123,10 +122,6 @@ const flags: IFlags = {
|
||||
process.env.FILTER_INVALID_CLIENT_METRICS,
|
||||
false,
|
||||
),
|
||||
customRootRolesKillSwitch: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_CUSTOM_ROOT_ROLES_KILL_SWITCH,
|
||||
false,
|
||||
),
|
||||
disableMetrics: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_DISABLE_METRICS,
|
||||
false,
|
||||
|
2
src/test/fixtures/access-service-mock.ts
vendored
2
src/test/fixtures/access-service-mock.ts
vendored
@ -18,7 +18,7 @@ class AccessServiceMock extends AccessService {
|
||||
roleStore: undefined,
|
||||
environmentStore: undefined,
|
||||
},
|
||||
{ getLogger: noLoggerProvider, flagResolver: undefined },
|
||||
{ getLogger: noLoggerProvider },
|
||||
undefined,
|
||||
undefined,
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user