mirror of
https://github.com/Unleash/unleash.git
synced 2025-11-10 01:19:53 +01:00
chore(AI): newUiConfigService flag cleanup (#10910)
This PR cleans up the newUiConfigService flag. These changes were automatically generated by AI and should be reviewed carefully. Fixes #10909 ## 🧹 AI Flag Cleanup Summary This PR removes the `newUiConfigService` feature flag and makes its functionality permanent. The `UiConfigController` now exclusively uses the `UiConfigService` to generate the UI configuration, removing the old, now-dead code path. As a result of this change, several services that were only used in the old implementation have been removed from `UiConfigController`, along with their associated types and imports, simplifying the controller significantly. ### 🚮 Removed - **Flag Definitions** - `newUiConfigService` flag definition from `src/lib/types/experimental.ts`. - Development override for `newUiConfigService` in `src/server-dev.ts`. - **Conditional Logic** - The `if` block checking for `newUiConfigService` in `UiConfigController.getUiConfig`. - **Dead Code** - The legacy implementation of building the UI config object inside `UiConfigController`. - Several unused service dependencies (`VersionService`, `SettingService`, `EmailService`, `SessionService`, `MaintenanceService`) and `IFlagResolver` from `UiConfigController`. ### 🛠 Kept - **New `getUiConfig` implementation** - The `UiConfigController.getUiConfig` method now solely relies on `UiConfigService` to fetch the UI configuration. ### 📝 Why The `newUiConfigService` feature flag was fully rolled out and marked as completed. This cleanup removes the flag and the legacy code path, simplifying the `UiConfigController` and making the new UI config service the standard way of providing UI configuration. Co-authored-by: unleash-bot <194219037+unleash-bot[bot]@users.noreply.github.com>
This commit is contained in:
parent
366827de6f
commit
8d00eea66a
@ -59,7 +59,6 @@ export type IFlagKey =
|
|||||||
| 'optimizeLifecycle'
|
| 'optimizeLifecycle'
|
||||||
| 'newStrategyModal'
|
| 'newStrategyModal'
|
||||||
| 'globalChangeRequestList'
|
| 'globalChangeRequestList'
|
||||||
| 'newUiConfigService'
|
|
||||||
| 'trafficBillingDisplay'
|
| 'trafficBillingDisplay'
|
||||||
| 'milestoneProgression'
|
| 'milestoneProgression'
|
||||||
| 'envAddStrategySuggestion'
|
| 'envAddStrategySuggestion'
|
||||||
@ -274,10 +273,6 @@ const flags: IFlags = {
|
|||||||
process.env.UNLEASH_EXPERIMENTAL_GLOBAL_CHANGE_REQUEST_LIST,
|
process.env.UNLEASH_EXPERIMENTAL_GLOBAL_CHANGE_REQUEST_LIST,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
newUiConfigService: parseEnvVarBoolean(
|
|
||||||
process.env.UNLEASH_EXPERIMENTAL_NEW_UI_CONFIG_SERVICE,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
trafficBillingDisplay: parseEnvVarBoolean(
|
trafficBillingDisplay: parseEnvVarBoolean(
|
||||||
process.env.UNLEASH_EXPERIMENTAL_TRAFFIC_BILLING_DISPLAY,
|
process.env.UNLEASH_EXPERIMENTAL_TRAFFIC_BILLING_DISPLAY,
|
||||||
false,
|
false,
|
||||||
|
|||||||
@ -1,15 +1,8 @@
|
|||||||
import type { Response } from 'express';
|
import type { Response } from 'express';
|
||||||
import type { AuthedRequest } from '../types/core.js';
|
import type { AuthedRequest } from '../types/core.js';
|
||||||
import type { IUnleashServices } from '../services/index.js';
|
import type { IUnleashServices } from '../services/index.js';
|
||||||
import { IAuthType, type IUnleashConfig } from '../types/option.js';
|
import type { IUnleashConfig } from '../types/option.js';
|
||||||
import version from '../util/version.js';
|
|
||||||
import Controller from '../routes/controller.js';
|
import Controller from '../routes/controller.js';
|
||||||
import type VersionService from '../services/version-service.js';
|
|
||||||
import type SettingService from '../services/setting-service.js';
|
|
||||||
import {
|
|
||||||
type SimpleAuthSettings,
|
|
||||||
simpleAuthSettingsKey,
|
|
||||||
} from '../types/settings/simple-auth-settings.js';
|
|
||||||
import { ADMIN, NONE, UPDATE_CORS } from '../types/permissions.js';
|
import { ADMIN, NONE, UPDATE_CORS } from '../types/permissions.js';
|
||||||
import { createResponseSchema } from '../openapi/util/create-response-schema.js';
|
import { createResponseSchema } from '../openapi/util/create-response-schema.js';
|
||||||
import {
|
import {
|
||||||
@ -17,32 +10,17 @@ import {
|
|||||||
type UiConfigSchema,
|
type UiConfigSchema,
|
||||||
} from '../openapi/spec/ui-config-schema.js';
|
} from '../openapi/spec/ui-config-schema.js';
|
||||||
import type { OpenApiService } from '../services/openapi-service.js';
|
import type { OpenApiService } from '../services/openapi-service.js';
|
||||||
import type { EmailService } from '../services/email-service.js';
|
|
||||||
import { emptyResponse } from '../openapi/util/standard-responses.js';
|
import { emptyResponse } from '../openapi/util/standard-responses.js';
|
||||||
import type { IAuthRequest } from '../routes/unleash-types.js';
|
import type { IAuthRequest } from '../routes/unleash-types.js';
|
||||||
import NotFoundError from '../error/notfound-error.js';
|
import NotFoundError from '../error/notfound-error.js';
|
||||||
import type { SetCorsSchema } from '../openapi/spec/set-cors-schema.js';
|
import type { SetCorsSchema } from '../openapi/spec/set-cors-schema.js';
|
||||||
import { createRequestSchema } from '../openapi/util/create-request-schema.js';
|
import { createRequestSchema } from '../openapi/util/create-request-schema.js';
|
||||||
import type { FrontendApiService, SessionService } from '../services/index.js';
|
import type { FrontendApiService } from '../services/index.js';
|
||||||
import type MaintenanceService from '../features/maintenance/maintenance-service.js';
|
|
||||||
import type { IFlagResolver } from '../types/index.js';
|
|
||||||
import type { UiConfigService } from './ui-config-service.js';
|
import type { UiConfigService } from './ui-config-service.js';
|
||||||
|
|
||||||
class UiConfigController extends Controller {
|
class UiConfigController extends Controller {
|
||||||
private versionService: VersionService;
|
|
||||||
|
|
||||||
private settingService: SettingService;
|
|
||||||
|
|
||||||
private frontendApiService: FrontendApiService;
|
private frontendApiService: FrontendApiService;
|
||||||
|
|
||||||
private emailService: EmailService;
|
|
||||||
|
|
||||||
private sessionService: SessionService;
|
|
||||||
|
|
||||||
private maintenanceService: MaintenanceService;
|
|
||||||
|
|
||||||
private flagResolver: IFlagResolver;
|
|
||||||
|
|
||||||
private uiConfigService: UiConfigService;
|
private uiConfigService: UiConfigService;
|
||||||
|
|
||||||
private readonly openApiService: OpenApiService;
|
private readonly openApiService: OpenApiService;
|
||||||
@ -50,37 +28,21 @@ class UiConfigController extends Controller {
|
|||||||
constructor(
|
constructor(
|
||||||
config: IUnleashConfig,
|
config: IUnleashConfig,
|
||||||
{
|
{
|
||||||
versionService,
|
|
||||||
settingService,
|
|
||||||
emailService,
|
|
||||||
openApiService,
|
openApiService,
|
||||||
frontendApiService,
|
frontendApiService,
|
||||||
maintenanceService,
|
|
||||||
sessionService,
|
|
||||||
uiConfigService,
|
uiConfigService,
|
||||||
}: Pick<
|
}: Pick<
|
||||||
IUnleashServices,
|
IUnleashServices,
|
||||||
| 'versionService'
|
|
||||||
| 'settingService'
|
|
||||||
| 'emailService'
|
|
||||||
| 'openApiService'
|
| 'openApiService'
|
||||||
| 'frontendApiService'
|
| 'frontendApiService'
|
||||||
| 'maintenanceService'
|
|
||||||
| 'clientInstanceService'
|
| 'clientInstanceService'
|
||||||
| 'sessionService'
|
|
||||||
| 'uiConfigService'
|
| 'uiConfigService'
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
super(config);
|
super(config);
|
||||||
this.flagResolver = config.flagResolver;
|
|
||||||
this.openApiService = openApiService;
|
this.openApiService = openApiService;
|
||||||
this.uiConfigService = uiConfigService;
|
this.uiConfigService = uiConfigService;
|
||||||
this.versionService = versionService;
|
|
||||||
this.settingService = settingService;
|
|
||||||
this.emailService = emailService;
|
|
||||||
this.frontendApiService = frontendApiService;
|
this.frontendApiService = frontendApiService;
|
||||||
this.maintenanceService = maintenanceService;
|
|
||||||
this.sessionService = sessionService;
|
|
||||||
|
|
||||||
this.route({
|
this.route({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -124,79 +86,13 @@ class UiConfigController extends Controller {
|
|||||||
req: AuthedRequest,
|
req: AuthedRequest,
|
||||||
res: Response<UiConfigSchema>,
|
res: Response<UiConfigSchema>,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (this.flagResolver.isEnabled('newUiConfigService')) {
|
const uiConfig = await this.uiConfigService.getUiConfig(req.user);
|
||||||
const uiConfig = await this.uiConfigService.getUiConfig(req.user);
|
|
||||||
|
|
||||||
return this.openApiService.respondWithValidation(
|
|
||||||
200,
|
|
||||||
res,
|
|
||||||
uiConfigSchema.$id,
|
|
||||||
uiConfig,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const getMaxSessionsCount = async () => {
|
|
||||||
if (this.flagResolver.isEnabled('showUserDeviceCount')) {
|
|
||||||
return this.sessionService.getMaxSessionsCount();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
const [
|
|
||||||
frontendSettings,
|
|
||||||
simpleAuthSettings,
|
|
||||||
maintenanceMode,
|
|
||||||
maxSessionsCount,
|
|
||||||
] = await Promise.all([
|
|
||||||
this.frontendApiService.getFrontendSettings(false),
|
|
||||||
this.settingService.get<SimpleAuthSettings>(simpleAuthSettingsKey),
|
|
||||||
this.maintenanceService.isMaintenanceMode(),
|
|
||||||
getMaxSessionsCount(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const disablePasswordAuth =
|
|
||||||
simpleAuthSettings?.disabled ||
|
|
||||||
this.config.authentication.type === IAuthType.NONE;
|
|
||||||
|
|
||||||
const expFlags = this.config.flagResolver.getAll({
|
|
||||||
email: req.user.email,
|
|
||||||
});
|
|
||||||
|
|
||||||
const flags = {
|
|
||||||
...this.config.ui.flags,
|
|
||||||
...expFlags,
|
|
||||||
};
|
|
||||||
|
|
||||||
const unleashContext = {
|
|
||||||
...this.flagResolver.getStaticContext(), //clientId etc.
|
|
||||||
email: req.user.email,
|
|
||||||
userId: req.user.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
const response: UiConfigSchema = {
|
|
||||||
...this.config.ui,
|
|
||||||
flags,
|
|
||||||
version,
|
|
||||||
emailEnabled: this.emailService.isEnabled(),
|
|
||||||
unleashUrl: this.config.server.unleashUrl,
|
|
||||||
baseUriPath: this.config.server.baseUriPath,
|
|
||||||
authenticationType: this.config.authentication?.type,
|
|
||||||
frontendApiOrigins: frontendSettings.frontendApiOrigins,
|
|
||||||
versionInfo: await this.versionService.getVersionInfo(),
|
|
||||||
prometheusAPIAvailable: this.config.prometheusApi !== undefined,
|
|
||||||
resourceLimits: this.config.resourceLimits,
|
|
||||||
disablePasswordAuth,
|
|
||||||
maintenanceMode,
|
|
||||||
feedbackUriPath: this.config.feedbackUriPath,
|
|
||||||
maxSessionsCount,
|
|
||||||
unleashContext: unleashContext,
|
|
||||||
};
|
|
||||||
|
|
||||||
this.openApiService.respondWithValidation(
|
this.openApiService.respondWithValidation(
|
||||||
200,
|
200,
|
||||||
res,
|
res,
|
||||||
uiConfigSchema.$id,
|
uiConfigSchema.$id,
|
||||||
response,
|
uiConfig,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,6 @@ process.nextTick(async () => {
|
|||||||
lifecycleGraphs: true,
|
lifecycleGraphs: true,
|
||||||
newStrategyModal: true,
|
newStrategyModal: true,
|
||||||
globalChangeRequestList: true,
|
globalChangeRequestList: true,
|
||||||
newUiConfigService: true,
|
|
||||||
trafficBillingDisplay: true,
|
trafficBillingDisplay: true,
|
||||||
milestoneProgression: true,
|
milestoneProgression: true,
|
||||||
featureReleasePlans: true,
|
featureReleasePlans: true,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user