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:
parent
2e749a2b3e
commit
af82202ada
@ -57,12 +57,9 @@ export const App = () => {
|
||||
elseShow={
|
||||
<>
|
||||
<ConditionallyRender
|
||||
condition={
|
||||
Boolean(
|
||||
uiConfig?.flags?.maintenance
|
||||
) &&
|
||||
Boolean(uiConfig?.maintenanceMode)
|
||||
}
|
||||
condition={Boolean(
|
||||
uiConfig?.maintenanceMode
|
||||
)}
|
||||
show={<MaintenanceBanner />}
|
||||
/>
|
||||
<StyledContainer>
|
||||
|
@ -109,7 +109,7 @@ function AdminMenu() {
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{flags.maintenance && (
|
||||
|
||||
<Tab
|
||||
value="maintenance"
|
||||
label={
|
||||
@ -118,7 +118,6 @@ function AdminMenu() {
|
||||
</CenteredNavLink>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
{isBilling && (
|
||||
<Tab
|
||||
|
@ -495,7 +495,6 @@ export const adminMenuRoutes: INavigationMenuItem[] = [
|
||||
path: '/admin/maintenance',
|
||||
title: 'Maintenance',
|
||||
menu: { adminSettings: true },
|
||||
flag: 'maintenance',
|
||||
},
|
||||
{
|
||||
path: '/admin/cors',
|
||||
|
@ -18,16 +18,11 @@ const getPermissions = (
|
||||
auth.data && 'permissions' in auth.data
|
||||
? auth.data.permissions
|
||||
: undefined;
|
||||
if (
|
||||
permissions &&
|
||||
uiConfig?.flags?.maintenance &&
|
||||
uiConfig?.flags?.maintenanceMode
|
||||
) {
|
||||
if (permissions && uiConfig?.maintenanceMode) {
|
||||
permissions = permissions.filter(
|
||||
permission => permission.permission === 'ADMIN'
|
||||
);
|
||||
}
|
||||
|
||||
return permissions;
|
||||
};
|
||||
|
||||
|
@ -38,7 +38,6 @@ export interface IFlags {
|
||||
UG?: boolean;
|
||||
ENABLE_DARK_MODE_SUPPORT?: boolean;
|
||||
embedProxyFrontend?: boolean;
|
||||
maintenance?: boolean;
|
||||
maintenanceMode?: boolean;
|
||||
messageBanner?: boolean;
|
||||
featuresExportImport?: boolean;
|
||||
|
@ -75,7 +75,6 @@ exports[`should create default config 1`] = `
|
||||
"embedProxyFrontend": true,
|
||||
"featuresExportImport": false,
|
||||
"loginEventLog": false,
|
||||
"maintenance": false,
|
||||
"maintenanceMode": false,
|
||||
"messageBanner": false,
|
||||
"newProjectOverview": false,
|
||||
@ -98,7 +97,6 @@ exports[`should create default config 1`] = `
|
||||
"embedProxyFrontend": true,
|
||||
"featuresExportImport": false,
|
||||
"loginEventLog": false,
|
||||
"maintenance": false,
|
||||
"maintenanceMode": false,
|
||||
"messageBanner": false,
|
||||
"newProjectOverview": false,
|
||||
|
@ -158,10 +158,7 @@ export default async function getApp(
|
||||
|
||||
app.use(
|
||||
`${baseUriPath}/api/admin`,
|
||||
conditionalMiddleware(
|
||||
() => config.flagResolver.isEnabled('maintenance'),
|
||||
maintenanceMiddleware(config, services.maintenanceService),
|
||||
),
|
||||
);
|
||||
|
||||
if (typeof config.preRouterHook === 'function') {
|
||||
|
@ -15,7 +15,6 @@ import {
|
||||
maintenanceSchema,
|
||||
} from '../../openapi/spec/maintenance-schema';
|
||||
import MaintenanceService from 'lib/services/maintenance-service';
|
||||
import { InvalidOperationError } from '../../error';
|
||||
|
||||
export default class MaintenanceController extends Controller {
|
||||
private maintenanceService: MaintenanceService;
|
||||
@ -72,7 +71,6 @@ export default class MaintenanceController extends Controller {
|
||||
req: IAuthRequest<unknown, unknown, MaintenanceSchema>,
|
||||
res: Response,
|
||||
): Promise<void> {
|
||||
this.verifyMaintenanceEnabled();
|
||||
await this.maintenanceService.toggleMaintenanceMode(
|
||||
req.body,
|
||||
extractUsername(req),
|
||||
@ -81,7 +79,6 @@ export default class MaintenanceController extends Controller {
|
||||
}
|
||||
|
||||
async getMaintenance(req: Request, res: Response): Promise<void> {
|
||||
this.verifyMaintenanceEnabled();
|
||||
const settings = await this.maintenanceService.getMaintenanceSetting();
|
||||
this.openApiService.respondWithValidation(
|
||||
200,
|
||||
@ -90,11 +87,5 @@ export default class MaintenanceController extends Controller {
|
||||
settings,
|
||||
);
|
||||
}
|
||||
|
||||
private verifyMaintenanceEnabled() {
|
||||
if (!this.config.flagResolver.isEnabled('maintenance')) {
|
||||
throw new InvalidOperationError('Maintenance is not enabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = MaintenanceController;
|
||||
|
@ -30,10 +30,6 @@ const flags = {
|
||||
process.env.UNLEASH_EXPERIMENTAL_PROXY_RETURN_ALL_TOGGLES,
|
||||
false,
|
||||
),
|
||||
maintenance: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_MAINTENANCE,
|
||||
false,
|
||||
),
|
||||
maintenanceMode: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_MAINTENANCE_MODE,
|
||||
false,
|
||||
|
@ -38,7 +38,6 @@ process.nextTick(async () => {
|
||||
embedProxyFrontend: true,
|
||||
anonymiseEventLog: false,
|
||||
responseTimeWithAppNameKillSwitch: false,
|
||||
maintenance: true,
|
||||
featuresExportImport: true,
|
||||
newProjectOverview: true,
|
||||
projectStatusApi: true,
|
||||
|
@ -1,5 +1,5 @@
|
||||
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';
|
||||
|
||||
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, {
|
||||
experimental: {
|
||||
flags: {
|
||||
maintenance: true,
|
||||
maintenanceMode: true,
|
||||
},
|
||||
},
|
||||
@ -35,33 +34,8 @@ test('should not allow to create feature toggles in maintenance mode', async ()
|
||||
.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 () => {
|
||||
const appWithMaintenanceMode = await setupAppWithCustomConfig(db.stores, {
|
||||
experimental: {
|
||||
flags: {
|
||||
maintenance: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
const appWithMaintenanceMode = await setupApp(db.stores);
|
||||
|
||||
return appWithMaintenanceMode.request
|
||||
.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 () => {
|
||||
const appWithMaintenanceMode = await setupAppWithCustomConfig(db.stores, {
|
||||
experimental: {
|
||||
flags: {
|
||||
maintenance: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
const appWithMaintenanceMode = await setupApp(db.stores);
|
||||
|
||||
await appWithMaintenanceMode.request
|
||||
.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')
|
||||
.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 () => {
|
||||
const appWithMaintenanceMode = await setupAppWithCustomConfig(db.stores, {
|
||||
experimental: {
|
||||
flags: {
|
||||
maintenance: true,
|
||||
maintenanceMode: true,
|
||||
},
|
||||
},
|
||||
|
@ -4,7 +4,7 @@ title: Maintenance Mode
|
||||
|
||||
:::info Availability
|
||||
|
||||
Maintenance mode was introduced in Unleash 4.21.0.
|
||||
Maintenance mode was introduced in Unleash 4.22.0.
|
||||
|
||||
:::
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user