Skip to content

Commit

Permalink
chore: Update tooltips for flag enabled state / value (#3538)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg authored Mar 6, 2024
1 parent 528bcd5 commit c4b5fc5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
42 changes: 30 additions & 12 deletions frontend/web/components/Feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Constants from 'common/constants'
import VariationOptions from './mv/VariationOptions'
import AddVariationButton from './mv/AddVariationButton'
import ErrorMessage from './ErrorMessage'
import Tooltip from './Tooltip'
import Icon from './Icon'

export default class Feature extends PureComponent {
static displayName = 'Feature'
Expand Down Expand Up @@ -49,7 +51,7 @@ export default class Feature extends PureComponent {
? 'User override'
: !!multivariate_options && multivariate_options.length
? `Control Value - ${controlPercentage}%`
: `Value (optional)${' - these can be set per environment'}`
: `Value (optional)`

const showValue = !(
!!identity &&
Expand All @@ -58,16 +60,28 @@ export default class Feature extends PureComponent {
)
return (
<div>
<FormGroup className='mb-4 flex-row'>
<Switch
data-test='toggle-feature-button'
defaultChecked={checked}
disabled={disabled || readOnly}
checked={!disabled && checked}
onChange={onCheckedChange}
className='ml-0'
/>
<div className='label-switch ml-3'>{enabledString || 'Enabled'}</div>
<FormGroup className='mb-4'>
<Tooltip
title={
<div className='flex-row'>
<Switch
data-test='toggle-feature-button'
defaultChecked={checked}
disabled={disabled || readOnly}
checked={!disabled && checked}
onChange={onCheckedChange}
className='ml-0'
/>
<div className='label-switch ml-3 mr-1'>
{enabledString || 'Enabled'}
</div>
{!isEdit && <Icon name='info-outlined' />}
</div>
}
>
{!isEdit &&
'This will determine the initial enabled state for all environments. You can edit the this individually for each environment once the feature is created.'}
</Tooltip>
</FormGroup>

{showValue && (
Expand All @@ -86,7 +100,11 @@ export default class Feature extends PureComponent {
placeholder="e.g. 'big' "
/>
}
tooltip={Constants.strings.REMOTE_CONFIG_DESCRIPTION}
tooltip={`${Constants.strings.REMOTE_CONFIG_DESCRIPTION}${
!isEdit
? '<br/>Setting this when creating a feature will set the value for all environments. You can edit the this individually for each environment once the feature is created.'
: ''
}`}
title={`${valueString}`}
/>
</FormGroup>
Expand Down
4 changes: 4 additions & 0 deletions frontend/web/components/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export type TooltipProps = {
const Tooltip: FC<TooltipProps> = ({ children, place, plainText, title }) => {
const id = Utils.GUID()

if (!children) {
// Skip tooltip by supplying falsy children
return <>{title}</>
}
return (
<>
{title && (
Expand Down

0 comments on commit c4b5fc5

Please sign in to comment.