Skip to content

Commit

Permalink
fix: hide view features from associated segment overrides (#4786)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg authored Oct 30, 2024
1 parent f72c764 commit 49ff569
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 5 additions & 3 deletions frontend/web/components/SegmentOverrideActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ interface SegmentOverrideActionProps {
canRemove: boolean
onRemove: () => void
onEdit: () => void
hideViewSegment?: void
onCopyValue: () => void
canEdit: boolean
canCopyValue: boolean
}

type ActionType = 'edit' | 'remove'
type ActionType = 'edit' | 'remove' | 'copy'

function calculateListPosition(
btnEl: HTMLElement,
Expand All @@ -33,6 +34,7 @@ export const SegmentOverrideAction: FC<SegmentOverrideActionProps> = ({
canCopyValue,
canEdit,
canRemove,
hideViewSegment,
onCopyValue,
onEdit,
onRemove,
Expand Down Expand Up @@ -80,7 +82,7 @@ export const SegmentOverrideAction: FC<SegmentOverrideActionProps> = ({
)
}

if (!!canEdit && !canRemove) {
if (!!canEdit && !canRemove && !hideViewSegment) {
return (
<Button onClick={() => handleActionClick('edit')} size='small'>
View Segment
Expand Down Expand Up @@ -111,7 +113,7 @@ export const SegmentOverrideAction: FC<SegmentOverrideActionProps> = ({
ref={listRef}
className='feature-action__list'
>
{!!canEdit && (
{!!canEdit && !hideViewSegment && (
<div
className='feature-action__item'
onClick={(e) => {
Expand Down
5 changes: 5 additions & 0 deletions frontend/web/components/SegmentOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const SegmentOverrideInner = class Override extends React.Component {
confirmRemove,
controlValue,
disabled,
hideViewSegment,
index,
multivariateOptions,
name,
Expand Down Expand Up @@ -185,6 +186,7 @@ const SegmentOverrideInner = class Override extends React.Component {
Constants.projectPermissions('Manage Segments'),
<>
<SegmentOverrideActions
hideViewSegment={hideViewSegment}
onCopyValue={() => {
this.setState({ changed: true })
setValue(
Expand Down Expand Up @@ -346,6 +348,7 @@ const SegmentOverrideListInner = ({
controlValue,
disabled,
environmentId,
hideViewSegment,
id,
items,
multivariateOptions,
Expand All @@ -370,6 +373,7 @@ const SegmentOverrideListInner = ({
id={id}
name={name}
segment={value.segment}
hideViewSegment={hideViewSegment}
onSortEnd={onSortEnd}
disabled={disabled}
showEditSegment={showEditSegment}
Expand Down Expand Up @@ -705,6 +709,7 @@ class TheComponent extends Component {
setSegmentEditId={this.setSegmentEditId}
onSortEnd={this.onSortEnd}
projectFlag={this.props.projectFlag}
hideViewSegment={this.props.hideViewSegment}
/>
<div className='text-left mt-4'>
<JSONReference
Expand Down
2 changes: 2 additions & 0 deletions frontend/web/components/modals/AssociatedSegmentOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export default class SegmentOverridesInner extends Component {
<UncontrolledSegmentOverrides
feature={projectFlag.id}
readOnly
hideViewSegment
projectId={projectId}
multivariateOptions={_.cloneDeep(projectFlag.multivariate_options)}
environmentId={environmentId}
Expand Down Expand Up @@ -397,6 +398,7 @@ export default class SegmentOverridesInner extends Component {
name=' '
disableCreate
projectId={projectId}
hideViewSegment
onRemove={this.props.onRemove}
multivariateOptions={_.cloneDeep(
projectFlag.multivariate_options,
Expand Down

0 comments on commit 49ff569

Please sign in to comment.