Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hide view features from associated segment overrides #4786

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,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 @@ -364,6 +365,7 @@ export default class SegmentOverridesInner extends Component {
name=' '
disableCreate
projectId={projectId}
hideViewSegment
onRemove={this.props.onRemove}
multivariateOptions={_.cloneDeep(
projectFlag.multivariate_options,
Expand Down
Loading