1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-24 01:18:01 +02:00

feat: remove maintenance feature flag (#3199)

This commit is contained in:
Jaanus Sellin 2023-02-27 15:36:56 +02:00 committed by GitHub
parent 2e749a2b3e
commit af82202ada
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 19 additions and 101 deletions

View File

@ -57,12 +57,9 @@ export const App = () => {
elseShow={ elseShow={
<> <>
<ConditionallyRender <ConditionallyRender
condition={ condition={Boolean(
Boolean( uiConfig?.maintenanceMode
uiConfig?.flags?.maintenance )}
) &&
Boolean(uiConfig?.maintenanceMode)
}
show={<MaintenanceBanner />} show={<MaintenanceBanner />}
/> />
<StyledContainer> <StyledContainer>

View File

@ -109,7 +109,7 @@ function AdminMenu() {
} }
/> />
)} )}
{flags.maintenance && (
<Tab <Tab
value="maintenance" value="maintenance"
label={ label={
@ -118,7 +118,6 @@ function AdminMenu() {
</CenteredNavLink> </CenteredNavLink>
} }
/> />
)}
{isBilling && ( {isBilling && (
<Tab <Tab

View File

@ -495,7 +495,6 @@ export const adminMenuRoutes: INavigationMenuItem[] = [
path: '/admin/maintenance', path: '/admin/maintenance',
title: 'Maintenance', title: 'Maintenance',
menu: { adminSettings: true }, menu: { adminSettings: true },
flag: 'maintenance',
}, },
{ {
path: '/admin/cors', path: '/admin/cors',

View File

@ -18,16 +18,11 @@ const getPermissions = (
auth.data && 'permissions' in auth.data auth.data && 'permissions' in auth.data
? auth.data.permissions ? auth.data.permissions
: undefined; : undefined;
if ( if (permissions && uiConfig?.maintenanceMode) {
permissions &&
uiConfig?.flags?.maintenance &&
uiConfig?.flags?.maintenanceMode
) {
permissions = permissions.filter( permissions = permissions.filter(
permission => permission.permission === 'ADMIN' permission => permission.permission === 'ADMIN'
); );
} }
return permissions; return permissions;
}; };

View File

@ -38,7 +38,6 @@ export interface IFlags {
UG?: boolean; UG?: boolean;
ENABLE_DARK_MODE_SUPPORT?: boolean; ENABLE_DARK_MODE_SUPPORT?: boolean;
embedProxyFrontend?: boolean; embedProxyFrontend?: boolean;
maintenance?: boolean;
maintenanceMode?: boolean; maintenanceMode?: boolean;
messageBanner?: boolean; messageBanner?: boolean;
featuresExportImport?: boolean; featuresExportImport?: boolean;

View File

@ -75,7 +75,6 @@ exports[`should create default config 1`] = `
"embedProxyFrontend": true, "embedProxyFrontend": true,
"featuresExportImport": false, "featuresExportImport": false,
"loginEventLog": false, "loginEventLog": false,
"maintenance": false,
"maintenanceMode": false, "maintenanceMode": false,
"messageBanner": false, "messageBanner": false,
"newProjectOverview": false, "newProjectOverview": false,
@ -98,7 +97,6 @@ exports[`should create default config 1`] = `
"embedProxyFrontend": true, "embedProxyFrontend": true,
"featuresExportImport": false, "featuresExportImport": false,
"loginEventLog": false, "loginEventLog": false,
"maintenance": false,
"maintenanceMode": false, "maintenanceMode": false,
"messageBanner": false, "messageBanner": false,
"newProjectOverview": false, "newProjectOverview": false,

View File

@ -158,10 +158,7 @@ export default async function getApp(
app.use( app.use(
`${baseUriPath}/api/admin`, `${baseUriPath}/api/admin`,
conditionalMiddleware(
() => config.flagResolver.isEnabled('maintenance'),
maintenanceMiddleware(config, services.maintenanceService), maintenanceMiddleware(config, services.maintenanceService),
),
); );
if (typeof config.preRouterHook === 'function') { if (typeof config.preRouterHook === 'function') {

View File

@ -15,7 +15,6 @@ import {
maintenanceSchema, maintenanceSchema,
} from '../../openapi/spec/maintenance-schema'; } from '../../openapi/spec/maintenance-schema';
import MaintenanceService from 'lib/services/maintenance-service'; import MaintenanceService from 'lib/services/maintenance-service';
import { InvalidOperationError } from '../../error';
export default class MaintenanceController extends Controller { export default class MaintenanceController extends Controller {
private maintenanceService: MaintenanceService; private maintenanceService: MaintenanceService;
@ -72,7 +71,6 @@ export default class MaintenanceController extends Controller {
req: IAuthRequest<unknown, unknown, MaintenanceSchema>, req: IAuthRequest<unknown, unknown, MaintenanceSchema>,
res: Response, res: Response,
): Promise<void> { ): Promise<void> {
this.verifyMaintenanceEnabled();
await this.maintenanceService.toggleMaintenanceMode( await this.maintenanceService.toggleMaintenanceMode(
req.body, req.body,
extractUsername(req), extractUsername(req),
@ -81,7 +79,6 @@ export default class MaintenanceController extends Controller {
} }
async getMaintenance(req: Request, res: Response): Promise<void> { async getMaintenance(req: Request, res: Response): Promise<void> {
this.verifyMaintenanceEnabled();
const settings = await this.maintenanceService.getMaintenanceSetting(); const settings = await this.maintenanceService.getMaintenanceSetting();
this.openApiService.respondWithValidation( this.openApiService.respondWithValidation(
200, 200,
@ -90,11 +87,5 @@ export default class MaintenanceController extends Controller {
settings, settings,
); );
} }
private verifyMaintenanceEnabled() {
if (!this.config.flagResolver.isEnabled('maintenance')) {
throw new InvalidOperationError('Maintenance is not enabled');
}
}
} }
module.exports = MaintenanceController; module.exports = MaintenanceController;

View File

@ -30,10 +30,6 @@ const flags = {
process.env.UNLEASH_EXPERIMENTAL_PROXY_RETURN_ALL_TOGGLES, process.env.UNLEASH_EXPERIMENTAL_PROXY_RETURN_ALL_TOGGLES,
false, false,
), ),
maintenance: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_MAINTENANCE,
false,
),
maintenanceMode: parseEnvVarBoolean( maintenanceMode: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_MAINTENANCE_MODE, process.env.UNLEASH_EXPERIMENTAL_MAINTENANCE_MODE,
false, false,

View File

@ -38,7 +38,6 @@ process.nextTick(async () => {
embedProxyFrontend: true, embedProxyFrontend: true,
anonymiseEventLog: false, anonymiseEventLog: false,
responseTimeWithAppNameKillSwitch: false, responseTimeWithAppNameKillSwitch: false,
maintenance: true,
featuresExportImport: true, featuresExportImport: true,
newProjectOverview: true, newProjectOverview: true,
projectStatusApi: true, projectStatusApi: true,

View File

@ -1,5 +1,5 @@
import dbInit, { ITestDb } from '../../helpers/database-init'; import dbInit, { ITestDb } from '../../helpers/database-init';
import { setupAppWithCustomConfig } from '../../helpers/test-helper'; import { setupApp, setupAppWithCustomConfig } from '../../helpers/test-helper';
import getLogger from '../../../fixtures/no-logger'; import getLogger from '../../../fixtures/no-logger';
let db: ITestDb; let db: ITestDb;
@ -20,7 +20,6 @@ test('should not allow to create feature toggles in maintenance mode', async ()
const appWithMaintenanceMode = await setupAppWithCustomConfig(db.stores, { const appWithMaintenanceMode = await setupAppWithCustomConfig(db.stores, {
experimental: { experimental: {
flags: { flags: {
maintenance: true,
maintenanceMode: true, maintenanceMode: true,
}, },
}, },
@ -35,33 +34,8 @@ test('should not allow to create feature toggles in maintenance mode', async ()
.expect(503); .expect(503);
}); });
test('should not go into maintenance, when maintenance feature is off', async () => {
const appWithMaintenanceMode = await setupAppWithCustomConfig(db.stores, {
experimental: {
flags: {
maintenance: false,
maintenanceMode: true,
},
},
});
return appWithMaintenanceMode.request
.post('/api/admin/features')
.send({
name: 'maintenance-feature1',
})
.set('Content-Type', 'application/json')
.expect(201);
});
test('maintenance mode is off by default', async () => { test('maintenance mode is off by default', async () => {
const appWithMaintenanceMode = await setupAppWithCustomConfig(db.stores, { const appWithMaintenanceMode = await setupApp(db.stores);
experimental: {
flags: {
maintenance: true,
},
},
});
return appWithMaintenanceMode.request return appWithMaintenanceMode.request
.post('/api/admin/features') .post('/api/admin/features')
@ -73,13 +47,7 @@ test('maintenance mode is off by default', async () => {
}); });
test('should go into maintenance mode, when user has set it', async () => { test('should go into maintenance mode, when user has set it', async () => {
const appWithMaintenanceMode = await setupAppWithCustomConfig(db.stores, { const appWithMaintenanceMode = await setupApp(db.stores);
experimental: {
flags: {
maintenance: true,
},
},
});
await appWithMaintenanceMode.request await appWithMaintenanceMode.request
.post('/api/admin/maintenance') .post('/api/admin/maintenance')
@ -97,30 +65,10 @@ test('should go into maintenance mode, when user has set it', async () => {
.set('Content-Type', 'application/json') .set('Content-Type', 'application/json')
.expect(503); .expect(503);
}); });
test('should 404 on maintenance endpoint, when disabled', async () => {
const appWithMaintenanceMode = await setupAppWithCustomConfig(db.stores, {
experimental: {
flags: {
maintenance: false,
},
},
});
await appWithMaintenanceMode.request
.post('/api/admin/maintenance')
.send({
enabled: true,
})
.set('Content-Type', 'application/json')
.expect(403);
});
test('maintenance mode flag should take precedence over maintenance mode setting', async () => { test('maintenance mode flag should take precedence over maintenance mode setting', async () => {
const appWithMaintenanceMode = await setupAppWithCustomConfig(db.stores, { const appWithMaintenanceMode = await setupAppWithCustomConfig(db.stores, {
experimental: { experimental: {
flags: { flags: {
maintenance: true,
maintenanceMode: true, maintenanceMode: true,
}, },
}, },

View File

@ -4,7 +4,7 @@ title: Maintenance Mode
:::info Availability :::info Availability
Maintenance mode was introduced in Unleash 4.21.0. Maintenance mode was introduced in Unleash 4.22.0.
::: :::