From 8d00eea66a53b13b0023a2ea7db78162c174d64a Mon Sep 17 00:00:00 2001 From: "unleash-bot[bot]" <194219037+unleash-bot[bot]@users.noreply.github.com> Date: Tue, 4 Nov 2025 15:49:44 +0000 Subject: [PATCH] chore(AI): newUiConfigService flag cleanup (#10910) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- src/lib/types/experimental.ts | 5 - src/lib/ui-config/ui-config-controller.ts | 112 +--------------------- src/server-dev.ts | 1 - 3 files changed, 4 insertions(+), 114 deletions(-) diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index f2073598e1..1886239f02 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -59,7 +59,6 @@ export type IFlagKey = | 'optimizeLifecycle' | 'newStrategyModal' | 'globalChangeRequestList' - | 'newUiConfigService' | 'trafficBillingDisplay' | 'milestoneProgression' | 'envAddStrategySuggestion' @@ -274,10 +273,6 @@ const flags: IFlags = { process.env.UNLEASH_EXPERIMENTAL_GLOBAL_CHANGE_REQUEST_LIST, false, ), - newUiConfigService: parseEnvVarBoolean( - process.env.UNLEASH_EXPERIMENTAL_NEW_UI_CONFIG_SERVICE, - false, - ), trafficBillingDisplay: parseEnvVarBoolean( process.env.UNLEASH_EXPERIMENTAL_TRAFFIC_BILLING_DISPLAY, false, diff --git a/src/lib/ui-config/ui-config-controller.ts b/src/lib/ui-config/ui-config-controller.ts index 90ee7204fb..dfab51fd93 100644 --- a/src/lib/ui-config/ui-config-controller.ts +++ b/src/lib/ui-config/ui-config-controller.ts @@ -1,15 +1,8 @@ import type { Response } from 'express'; import type { AuthedRequest } from '../types/core.js'; import type { IUnleashServices } from '../services/index.js'; -import { IAuthType, type IUnleashConfig } from '../types/option.js'; -import version from '../util/version.js'; +import type { IUnleashConfig } from '../types/option.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 { createResponseSchema } from '../openapi/util/create-response-schema.js'; import { @@ -17,32 +10,17 @@ import { type UiConfigSchema, } from '../openapi/spec/ui-config-schema.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 type { IAuthRequest } from '../routes/unleash-types.js'; import NotFoundError from '../error/notfound-error.js'; import type { SetCorsSchema } from '../openapi/spec/set-cors-schema.js'; import { createRequestSchema } from '../openapi/util/create-request-schema.js'; -import type { FrontendApiService, SessionService } from '../services/index.js'; -import type MaintenanceService from '../features/maintenance/maintenance-service.js'; -import type { IFlagResolver } from '../types/index.js'; +import type { FrontendApiService } from '../services/index.js'; import type { UiConfigService } from './ui-config-service.js'; class UiConfigController extends Controller { - private versionService: VersionService; - - private settingService: SettingService; - private frontendApiService: FrontendApiService; - private emailService: EmailService; - - private sessionService: SessionService; - - private maintenanceService: MaintenanceService; - - private flagResolver: IFlagResolver; - private uiConfigService: UiConfigService; private readonly openApiService: OpenApiService; @@ -50,37 +28,21 @@ class UiConfigController extends Controller { constructor( config: IUnleashConfig, { - versionService, - settingService, - emailService, openApiService, frontendApiService, - maintenanceService, - sessionService, uiConfigService, }: Pick< IUnleashServices, - | 'versionService' - | 'settingService' - | 'emailService' | 'openApiService' | 'frontendApiService' - | 'maintenanceService' | 'clientInstanceService' - | 'sessionService' | 'uiConfigService' >, ) { super(config); - this.flagResolver = config.flagResolver; this.openApiService = openApiService; this.uiConfigService = uiConfigService; - this.versionService = versionService; - this.settingService = settingService; - this.emailService = emailService; this.frontendApiService = frontendApiService; - this.maintenanceService = maintenanceService; - this.sessionService = sessionService; this.route({ method: 'get', @@ -124,79 +86,13 @@ class UiConfigController extends Controller { req: AuthedRequest, res: Response, ): Promise { - if (this.flagResolver.isEnabled('newUiConfigService')) { - 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(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, - }; + const uiConfig = await this.uiConfigService.getUiConfig(req.user); this.openApiService.respondWithValidation( 200, res, uiConfigSchema.$id, - response, + uiConfig, ); } diff --git a/src/server-dev.ts b/src/server-dev.ts index 8779f8868a..3c6a9ea453 100644 --- a/src/server-dev.ts +++ b/src/server-dev.ts @@ -54,7 +54,6 @@ process.nextTick(async () => { lifecycleGraphs: true, newStrategyModal: true, globalChangeRequestList: true, - newUiConfigService: true, trafficBillingDisplay: true, milestoneProgression: true, featureReleasePlans: true,