mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	chore: stop using deprecated properties and lean on resourceLimits cfg (#9994)
This removes segmentValuesLimit and strategySegmentsLimit from ui-config-schema, deprecated in 5.11.0
This commit is contained in:
		
							parent
							
								
									b681702b77
								
							
						
					
					
						commit
						beb29f5b5b
					
				@ -1,16 +1,13 @@
 | 
			
		||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
 | 
			
		||||
import type { IUiConfig } from 'interfaces/uiConfig';
 | 
			
		||||
 | 
			
		||||
type IUseSegmentLimits = Pick<
 | 
			
		||||
    IUiConfig,
 | 
			
		||||
    'segmentValuesLimit' | 'strategySegmentsLimit'
 | 
			
		||||
>;
 | 
			
		||||
 | 
			
		||||
export const useSegmentLimits = (): IUseSegmentLimits => {
 | 
			
		||||
export const useSegmentLimits = (): {
 | 
			
		||||
    segmentValuesLimit: number;
 | 
			
		||||
    strategySegmentsLimit: number;
 | 
			
		||||
} => {
 | 
			
		||||
    const { uiConfig } = useUiConfig();
 | 
			
		||||
 | 
			
		||||
    return {
 | 
			
		||||
        segmentValuesLimit: uiConfig.segmentValuesLimit,
 | 
			
		||||
        strategySegmentsLimit: uiConfig.strategySegmentsLimit,
 | 
			
		||||
        segmentValuesLimit: uiConfig.resourceLimits.segmentValues,
 | 
			
		||||
        strategySegmentsLimit: uiConfig.resourceLimits.strategySegments,
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -29,8 +29,6 @@ export interface IUiConfig {
 | 
			
		||||
    prometheusAPIAvailable: boolean;
 | 
			
		||||
    maintenanceMode?: boolean;
 | 
			
		||||
    toast?: IProclamationToast;
 | 
			
		||||
    segmentValuesLimit?: number;
 | 
			
		||||
    strategySegmentsLimit?: number;
 | 
			
		||||
    frontendApiOrigins?: string[];
 | 
			
		||||
    resourceLimits: ResourceLimitsSchema;
 | 
			
		||||
    oidcConfiguredThroughEnv?: boolean;
 | 
			
		||||
 | 
			
		||||
@ -9,8 +9,24 @@ test('uiConfigSchema', () => {
 | 
			
		||||
        baseUriPath: 'a',
 | 
			
		||||
        environment: 'a',
 | 
			
		||||
        disablePasswordAuth: false,
 | 
			
		||||
        segmentValuesLimit: 0,
 | 
			
		||||
        strategySegmentsLimit: 0,
 | 
			
		||||
        resourceLimits: {
 | 
			
		||||
            segmentValues: 0,
 | 
			
		||||
            strategySegments: 0,
 | 
			
		||||
            actionSetActions: 0,
 | 
			
		||||
            actionSetsPerProject: 0,
 | 
			
		||||
            actionSetFilters: 0,
 | 
			
		||||
            actionSetFilterValues: 0,
 | 
			
		||||
            signalEndpoints: 0,
 | 
			
		||||
            signalTokensPerEndpoint: 0,
 | 
			
		||||
            featureEnvironmentStrategies: 0,
 | 
			
		||||
            constraintValues: 0,
 | 
			
		||||
            environments: 1,
 | 
			
		||||
            projects: 1,
 | 
			
		||||
            apiTokens: 0,
 | 
			
		||||
            segments: 0,
 | 
			
		||||
            featureFlags: 1,
 | 
			
		||||
            constraints: 0,
 | 
			
		||||
        },
 | 
			
		||||
        versionInfo: {
 | 
			
		||||
            current: {},
 | 
			
		||||
            latest: {},
 | 
			
		||||
 | 
			
		||||
@ -72,20 +72,6 @@ export const uiConfigSchema = {
 | 
			
		||||
            description: 'Whether maintenance mode is currently active or not.',
 | 
			
		||||
            example: false,
 | 
			
		||||
        },
 | 
			
		||||
        segmentValuesLimit: {
 | 
			
		||||
            type: 'number',
 | 
			
		||||
            description:
 | 
			
		||||
                'The maximum number of values that can be used in a single segment.',
 | 
			
		||||
            example: 1000,
 | 
			
		||||
            deprecated: true,
 | 
			
		||||
        },
 | 
			
		||||
        strategySegmentsLimit: {
 | 
			
		||||
            type: 'number',
 | 
			
		||||
            description:
 | 
			
		||||
                'The maximum number of segments that can be applied to a single strategy.',
 | 
			
		||||
            example: 5,
 | 
			
		||||
            deprecated: true,
 | 
			
		||||
        },
 | 
			
		||||
        resourceLimits: {
 | 
			
		||||
            $ref: resourceLimitsSchema.$id,
 | 
			
		||||
            description: resourceLimitsSchema.description,
 | 
			
		||||
 | 
			
		||||
@ -53,8 +53,12 @@ test('should get ui config', async () => {
 | 
			
		||||
 | 
			
		||||
    expect(body.slogan).toEqual('hello');
 | 
			
		||||
    expect(body.headerBackground).toEqual('red');
 | 
			
		||||
    expect(body.segmentValuesLimit).toEqual(DEFAULT_SEGMENT_VALUES_LIMIT);
 | 
			
		||||
    expect(body.strategySegmentsLimit).toEqual(DEFAULT_STRATEGY_SEGMENTS_LIMIT);
 | 
			
		||||
    expect(body.resourceLimits!.segmentValues).toEqual(
 | 
			
		||||
        DEFAULT_SEGMENT_VALUES_LIMIT,
 | 
			
		||||
    );
 | 
			
		||||
    expect(body.resourceLimits!.strategySegments).toEqual(
 | 
			
		||||
        DEFAULT_STRATEGY_SEGMENTS_LIMIT,
 | 
			
		||||
    );
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test('should update CORS settings', async () => {
 | 
			
		||||
 | 
			
		||||
@ -191,8 +191,6 @@ class ConfigController extends Controller {
 | 
			
		||||
            unleashUrl: this.config.server.unleashUrl,
 | 
			
		||||
            baseUriPath: this.config.server.baseUriPath,
 | 
			
		||||
            authenticationType: this.config.authentication?.type,
 | 
			
		||||
            segmentValuesLimit: this.config.resourceLimits.segmentValues,
 | 
			
		||||
            strategySegmentsLimit: this.config.resourceLimits.strategySegments,
 | 
			
		||||
            frontendApiOrigins: frontendSettings.frontendApiOrigins,
 | 
			
		||||
            versionInfo: await this.versionService.getVersionInfo(),
 | 
			
		||||
            prometheusAPIAvailable: this.config.prometheusApi !== undefined,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user