mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	fix: project settings flag limit not properly set (#5317)
https://linear.app/unleash/issue/SR-169/ticket-1107-project-feature-flag-limit-is-not-correctly-updated Fixes #5315, an issue where it would not be possible to set an empty flag limit. This also fixes the UI behavior: Before, when the flag limit field was emptied, it would disappear from the UI. I'm a bit unsure of the original intent of the `(data.defaultStickiness !== undefined || data.featureLimit !== undefined)` condition. We're in an update method, triggered by a PUT endpoint - I think it's safe to assume that we'll always want to set these values to whatever they come as, we just need to convert them to `null` in case they are not present (i.e. `undefined`).
This commit is contained in:
		
							parent
							
								
									180c0dceae
								
							
						
					
					
						commit
						15f77f5b8b
					
				@ -184,8 +184,8 @@ const ProjectForm: React.FC<IProjectForm> = ({
 | 
			
		||||
                }
 | 
			
		||||
            />
 | 
			
		||||
            <ConditionallyRender
 | 
			
		||||
                condition={mode === 'Edit' && Boolean(setFeatureLimit)}
 | 
			
		||||
                show={
 | 
			
		||||
                condition={mode === 'Edit'}
 | 
			
		||||
                show={() => (
 | 
			
		||||
                    <>
 | 
			
		||||
                        <Box
 | 
			
		||||
                            sx={{
 | 
			
		||||
@ -202,17 +202,15 @@ const ProjectForm: React.FC<IProjectForm> = ({
 | 
			
		||||
                            Leave it empty if you don’t want to add a limit
 | 
			
		||||
                        </StyledSubtitle>
 | 
			
		||||
                        <StyledInputContainer>
 | 
			
		||||
                            {featureLimit && setFeatureLimit && (
 | 
			
		||||
                                <StyledInput
 | 
			
		||||
                                    label={'Limit'}
 | 
			
		||||
                                    name='value'
 | 
			
		||||
                                    type={'number'}
 | 
			
		||||
                                    value={featureLimit}
 | 
			
		||||
                                    onChange={(e) =>
 | 
			
		||||
                                        setFeatureLimit(e.target.value)
 | 
			
		||||
                                    }
 | 
			
		||||
                                />
 | 
			
		||||
                            )}
 | 
			
		||||
                            <StyledInput
 | 
			
		||||
                                label={'Limit'}
 | 
			
		||||
                                name='value'
 | 
			
		||||
                                type={'number'}
 | 
			
		||||
                                value={featureLimit!}
 | 
			
		||||
                                onChange={(e) =>
 | 
			
		||||
                                    setFeatureLimit!(e.target.value)
 | 
			
		||||
                                }
 | 
			
		||||
                            />
 | 
			
		||||
                            <ConditionallyRender
 | 
			
		||||
                                condition={
 | 
			
		||||
                                    featureCount !== undefined &&
 | 
			
		||||
@ -226,7 +224,7 @@ const ProjectForm: React.FC<IProjectForm> = ({
 | 
			
		||||
                            />
 | 
			
		||||
                        </StyledInputContainer>
 | 
			
		||||
                    </>
 | 
			
		||||
                }
 | 
			
		||||
                )}
 | 
			
		||||
            />
 | 
			
		||||
            <ConditionallyRender
 | 
			
		||||
                condition={mode === 'Create' && isEnterprise()}
 | 
			
		||||
 | 
			
		||||
@ -82,7 +82,7 @@ const useProjectForm = (
 | 
			
		||||
 | 
			
		||||
    const getFeatureLimitAsNumber = () => {
 | 
			
		||||
        if (featureLimit === '') {
 | 
			
		||||
            return undefined;
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        return Number(featureLimit);
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
@ -244,8 +244,9 @@ class ProjectStore implements IProjectStore {
 | 
			
		||||
        const settingsRow = await this.db(SETTINGS_TABLE)
 | 
			
		||||
            .insert({
 | 
			
		||||
                project: project.id,
 | 
			
		||||
                project_mode: project.mode,
 | 
			
		||||
                default_stickiness: project.defaultStickiness,
 | 
			
		||||
                feature_limit: project.featureLimit,
 | 
			
		||||
                project_mode: project.mode,
 | 
			
		||||
            })
 | 
			
		||||
            .returning('*');
 | 
			
		||||
        return this.mapRow({ ...row[0], ...settingsRow[0] });
 | 
			
		||||
@ -265,6 +266,7 @@ class ProjectStore implements IProjectStore {
 | 
			
		||||
            await this.db(TABLE)
 | 
			
		||||
                .where({ id: data.id })
 | 
			
		||||
                .update(this.fieldToRow(data));
 | 
			
		||||
 | 
			
		||||
            if (
 | 
			
		||||
                data.defaultStickiness !== undefined ||
 | 
			
		||||
                data.featureLimit !== undefined
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user