Skip to content

Commit 0b80126

Browse files
fix: restore Prevent Flag Defaults UI enforcement in create feature modal (#6931)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ddbf8bd commit 0b80126

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

frontend/web/components/modals/create-feature/FeatureUpdateSummary.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import React, { FC } from 'react'
22
import InfoMessage from 'components/InfoMessage'
33
import Button from 'components/base/forms/Button'
44
import ModalHR from 'components/modals/ModalHR'
5+
import { useGetProjectQuery } from 'common/services/useProject'
56

67
type FeatureUpdateSummaryProps = {
78
identity?: string
9+
projectId: number | string
810
onCreateFeature: () => void
911
isSaving: boolean
1012
name: string
@@ -22,18 +24,24 @@ const FeatureUpdateSummary: FC<FeatureUpdateSummaryProps> = ({
2224
isSaving,
2325
name,
2426
onCreateFeature,
27+
projectId,
2528
regexValid,
2629
}) => {
30+
const { data: project } = useGetProjectQuery({ id: projectId })
31+
const preventFlagDefaults = !!project?.prevent_flag_defaults
32+
2733
return (
2834
<>
2935
<ModalHR className={`my-4 ${identity ? 'mx-3' : ''}`} />
3036
{!identity && (
3137
<div className='text-right mb-3'>
32-
<InfoMessage collapseId={'create-flag'}>
33-
This will create the feature for <strong>all environments</strong>,
34-
you can edit this feature per environment once the feature is
35-
created.
36-
</InfoMessage>
38+
{!preventFlagDefaults && (
39+
<InfoMessage collapseId={'create-flag'}>
40+
This will create the feature for <strong>all environments</strong>
41+
, you can edit this feature per environment once the feature is
42+
created.
43+
</InfoMessage>
44+
)}
3745

3846
<Button
3947
onClick={onCreateFeature}

frontend/web/components/modals/create-feature/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,7 @@ const Index = class extends Component {
18431843
/>
18441844
<FeatureUpdateSummary
18451845
identity={identity}
1846+
projectId={this.props.projectId}
18461847
onCreateFeature={onCreateFeature}
18471848
isSaving={isSaving}
18481849
name={projectFlag.name}

frontend/web/components/modals/create-feature/tabs/CreateFeature.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { useHasPermission } from 'common/providers/Permission'
88
import Switch from 'components/Switch'
99
import Tooltip from 'components/Tooltip'
1010
import Icon from 'components/Icon'
11+
import InfoMessage from 'components/InfoMessage'
12+
import { useGetProjectQuery } from 'common/services/useProject'
1113
import { useCreateTagMutation, useGetTagsQuery } from 'common/services/useTag'
1214

1315
type CreateFeatureTabProps = {
@@ -55,6 +57,9 @@ const CreateFeature: FC<CreateFeatureTabProps> = ({
5557
permission: 'ADMIN',
5658
})
5759

60+
const { data: project } = useGetProjectQuery({ id: projectId })
61+
const preventFlagDefaults = !!project?.prevent_flag_defaults && !identity
62+
5863
const noPermissions = !createFeature && !projectAdmin
5964

6065
const showExperimentToggle =
@@ -134,10 +139,17 @@ const CreateFeature: FC<CreateFeatureTabProps> = ({
134139
<WarningMessage warningMessage={featureWarning} />
135140
{!!projectFlag && (
136141
<>
142+
{preventFlagDefaults && (
143+
<InfoMessage collapseId='create-flag'>
144+
This will create the feature for <strong>all environments</strong>
145+
, you can edit the feature's enabled state and value per
146+
environment once the feature is created.
147+
</InfoMessage>
148+
)}
137149
<FeatureValue
138150
error={error}
139151
createFeature={createFeature}
140-
hideValue={false}
152+
hideValue={preventFlagDefaults}
141153
isEdit={!!identity}
142154
identity={identity}
143155
noPermissions={noPermissions}

0 commit comments

Comments
 (0)