Skip to content

Commit

Permalink
fix: Logic in segment overrides readonly with the manage_segment_over…
Browse files Browse the repository at this point in the history
…rides permission (#2973)
  • Loading branch information
novakzaballa authored Nov 14, 2023
1 parent 3993823 commit 37879b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions frontend/web/components/SegmentOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ class TheComponent extends Component {
const isLimitReached =
segmentOverrideLimitAlert.percentage &&
segmentOverrideLimitAlert.percentage >= 100
const manageSegmentsEnabled = Utils.getFlagsmithHasFeature(
const manageSegmentOverridesEnabled = Utils.getFlagsmithHasFeature(
'manage_segment_overrides_env_role',
)
return (
Expand Down Expand Up @@ -603,7 +603,7 @@ class TheComponent extends Component {
theme='outline'
disabled={
!!isLimitReached ||
(manageSegmentsEnabled && !manageSegments)
(manageSegmentOverridesEnabled && !manageSegments)
}
>
Create Feature-Specific Segment
Expand Down
8 changes: 4 additions & 4 deletions frontend/web/components/modals/CreateFlag.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ const CreateFlag = class extends Component {
const existingChangeRequest = this.props.changeRequest
const hideIdentityOverridesTab = Utils.getShouldHideIdentityOverridesTab()
const noPermissions = this.props.noPermissions
const manageSegmentsEnabled = Utils.getFlagsmithHasFeature(
const manageSegmentOverridesEnabled = Utils.getFlagsmithHasFeature(
'manage_segment_overrides_env_role',
)
let regexValid = true
Expand Down Expand Up @@ -1141,8 +1141,8 @@ const CreateFlag = class extends Component {
manageSegmentOverrides,
}) => {
const isReadOnly =
manageSegmentsEnabled
? manageSegmentOverrides
manageSegmentOverridesEnabled
? !manageSegmentOverrides
: noPermissions
return (
<SegmentOverrides
Expand Down Expand Up @@ -1261,7 +1261,7 @@ const CreateFlag = class extends Component {
!name ||
invalid ||
!savePermission ||
(manageSegmentsEnabled &&
(manageSegmentOverridesEnabled &&
!manageSegmentsOverrides)
}
>
Expand Down
11 changes: 7 additions & 4 deletions frontend/web/components/modals/CreateSegment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -509,16 +509,19 @@ const CreateSegment: FC<CreateSegmentType> = ({
id={environmentId}
>
{({ permission: manageSegmentOverrides }) => {
const manageSegmentsEnabled = Utils.getFlagsmithHasFeature(
'manage_segment_overrides_env_role',
)
const manageSegmentOverridesEnabled =
Utils.getFlagsmithHasFeature(
'manage_segment_overrides_env_role',
)
const isReadOnly = !manageSegmentOverrides
return (
<AssociatedSegmentOverrides
feature={segment.feature}
projectId={projectId}
id={segment.id}
readOnly={manageSegmentsEnabled ? isReadOnly : false}
readOnly={
manageSegmentOverridesEnabled ? isReadOnly : false
}
/>
)
}}
Expand Down

3 comments on commit 37879b2

@vercel
Copy link

@vercel vercel bot commented on 37879b2 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 37879b2 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 37879b2 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./docs

docs-flagsmith.vercel.app
docs-git-main-flagsmith.vercel.app
docs.bullet-train.io
docs.flagsmith.com

Please sign in to comment.