mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
refactor: make help tooltip icons focusable (#905)
* refactor: restore rollout slider focus state * refactor: fix disconnected form field labels * refactor: make help tooltip icons focusable
This commit is contained in:
parent
76951f5d98
commit
984e75a03b
22
frontend/src/component/common/HelpIcon/HelpIcon.styles.ts
Normal file
22
frontend/src/component/common/HelpIcon/HelpIcon.styles.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { makeStyles } from '@material-ui/core/styles';
|
||||||
|
|
||||||
|
export const useStyles = makeStyles(theme => ({
|
||||||
|
container: {
|
||||||
|
display: 'inline-grid',
|
||||||
|
alignItems: 'center',
|
||||||
|
outline: 0,
|
||||||
|
|
||||||
|
'&:is(:focus-visible, :active) > *, &:hover > *': {
|
||||||
|
outlineStyle: 'solid',
|
||||||
|
outlineWidth: 2,
|
||||||
|
outlineOffset: 0,
|
||||||
|
outlineColor: theme.palette.primary.main,
|
||||||
|
borderRadius: '100%',
|
||||||
|
color: theme.palette.primary.main,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
fontSize: '1rem',
|
||||||
|
color: theme.palette.grey[600],
|
||||||
|
},
|
||||||
|
}));
|
27
frontend/src/component/common/HelpIcon/HelpIcon.tsx
Normal file
27
frontend/src/component/common/HelpIcon/HelpIcon.tsx
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { Tooltip } from '@material-ui/core';
|
||||||
|
import { Info } from '@material-ui/icons';
|
||||||
|
import { useStyles } from 'component/common/HelpIcon/HelpIcon.styles';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
interface IHelpIconProps {
|
||||||
|
tooltip: string;
|
||||||
|
style?: React.CSSProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const HelpIcon = ({ tooltip, style }: IHelpIconProps) => {
|
||||||
|
const styles = useStyles();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip title={tooltip} arrow>
|
||||||
|
<span
|
||||||
|
className={styles.container}
|
||||||
|
style={style}
|
||||||
|
tabIndex={0}
|
||||||
|
role="tooltip"
|
||||||
|
aria-label="Help"
|
||||||
|
>
|
||||||
|
<Info className={styles.icon} />
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
};
|
@ -16,7 +16,12 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
weightInput: {
|
weightInput: {
|
||||||
marginRight: '0.8rem',
|
marginRight: '0.8rem',
|
||||||
},
|
},
|
||||||
label: { marginBottom: '1rem' },
|
label: {
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: '1ch',
|
||||||
|
marginBottom: '1rem',
|
||||||
|
},
|
||||||
info: {
|
info: {
|
||||||
width: '18.5px',
|
width: '18.5px',
|
||||||
height: '18.5px',
|
height: '18.5px',
|
||||||
|
@ -5,9 +5,7 @@ import {
|
|||||||
FormControlLabel,
|
FormControlLabel,
|
||||||
Grid,
|
Grid,
|
||||||
InputAdornment,
|
InputAdornment,
|
||||||
Tooltip,
|
|
||||||
} from '@material-ui/core';
|
} from '@material-ui/core';
|
||||||
import { Info } from '@material-ui/icons';
|
|
||||||
import { weightTypes } from './enums';
|
import { weightTypes } from './enums';
|
||||||
import { OverrideConfig } from './OverrideConfig/OverrideConfig';
|
import { OverrideConfig } from './OverrideConfig/OverrideConfig';
|
||||||
import ConditionallyRender from 'component/common/ConditionallyRender';
|
import ConditionallyRender from 'component/common/ConditionallyRender';
|
||||||
@ -26,6 +24,7 @@ import { useStyles } from './AddFeatureVariant.styles';
|
|||||||
import Input from 'component/common/Input/Input';
|
import Input from 'component/common/Input/Input';
|
||||||
import { formatUnknownError } from 'utils/formatUnknownError';
|
import { formatUnknownError } from 'utils/formatUnknownError';
|
||||||
import useUnleashContext from 'hooks/api/getters/useUnleashContext/useUnleashContext';
|
import useUnleashContext from 'hooks/api/getters/useUnleashContext/useUnleashContext';
|
||||||
|
import { HelpIcon } from 'component/common/HelpIcon/HelpIcon';
|
||||||
|
|
||||||
const payloadOptions = [
|
const payloadOptions = [
|
||||||
{ key: 'string', label: 'string' },
|
{ key: 'string', label: 'string' },
|
||||||
@ -268,6 +267,7 @@ export const AddVariant = ({
|
|||||||
label="Variant name"
|
label="Variant name"
|
||||||
autoFocus
|
autoFocus
|
||||||
name="name"
|
name="name"
|
||||||
|
id="variant-name"
|
||||||
className={styles.input}
|
className={styles.input}
|
||||||
errorText={error.name}
|
errorText={error.name}
|
||||||
value={data.name || ''}
|
value={data.name || ''}
|
||||||
@ -317,7 +317,7 @@ export const AddVariant = ({
|
|||||||
<Grid item md={4}>
|
<Grid item md={4}>
|
||||||
<Input
|
<Input
|
||||||
id="weight"
|
id="weight"
|
||||||
label="Weight"
|
label="Variant weight"
|
||||||
name="weight"
|
name="weight"
|
||||||
data-testid={'VARIANT_WEIGHT_INPUT'}
|
data-testid={'VARIANT_WEIGHT_INPUT'}
|
||||||
InputProps={{
|
InputProps={{
|
||||||
@ -345,12 +345,7 @@ export const AddVariant = ({
|
|||||||
</Grid>
|
</Grid>
|
||||||
<p className={styles.label}>
|
<p className={styles.label}>
|
||||||
<strong>Payload </strong>
|
<strong>Payload </strong>
|
||||||
<Tooltip
|
<HelpIcon tooltip="Passed along with the the variant object." />
|
||||||
title="Passed to the variant object. Can be anything
|
|
||||||
(json, value, csv)"
|
|
||||||
>
|
|
||||||
<Info className={styles.info} />
|
|
||||||
</Tooltip>
|
|
||||||
</p>
|
</p>
|
||||||
<Grid container>
|
<Grid container>
|
||||||
<Grid item md={2} sm={2} xs={4}>
|
<Grid item md={2} sm={2} xs={4}>
|
||||||
@ -368,7 +363,9 @@ export const AddVariant = ({
|
|||||||
<Input
|
<Input
|
||||||
error={Boolean(error.payload)}
|
error={Boolean(error.payload)}
|
||||||
errorText={error.payload}
|
errorText={error.payload}
|
||||||
name="value"
|
name="variant-payload-value"
|
||||||
|
id="variant-payload-value"
|
||||||
|
label="Value"
|
||||||
className={commonStyles.fullWidth}
|
className={commonStyles.fullWidth}
|
||||||
value={payload.value}
|
value={payload.value}
|
||||||
onChange={e => onPayload('value')(e.target.value)}
|
onChange={e => onPayload('value')(e.target.value)}
|
||||||
@ -376,9 +373,8 @@ export const AddVariant = ({
|
|||||||
placeholder={
|
placeholder={
|
||||||
payload.type === 'json'
|
payload.type === 'json'
|
||||||
? '{ "hello": "world" }'
|
? '{ "hello": "world" }'
|
||||||
: 'value'
|
: ''
|
||||||
}
|
}
|
||||||
label="value"
|
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -387,9 +383,7 @@ export const AddVariant = ({
|
|||||||
show={
|
show={
|
||||||
<p className={styles.label}>
|
<p className={styles.label}>
|
||||||
<strong>Overrides </strong>
|
<strong>Overrides </strong>
|
||||||
<Tooltip title="Here you can specify which users should get this variant.">
|
<HelpIcon tooltip="Here you can specify which users should get this variant." />
|
||||||
<Info className={styles.info} />
|
|
||||||
</Tooltip>
|
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { Tooltip, Typography } from '@material-ui/core';
|
import { Typography } from '@material-ui/core';
|
||||||
import { Info } from '@material-ui/icons';
|
|
||||||
|
|
||||||
import { IParameter } from 'interfaces/strategy';
|
import { IParameter } from 'interfaces/strategy';
|
||||||
import RolloutSlider from '../RolloutSlider/RolloutSlider';
|
import RolloutSlider from '../RolloutSlider/RolloutSlider';
|
||||||
import Select from 'component/common/select';
|
import Select from 'component/common/select';
|
||||||
@ -10,6 +8,7 @@ import {
|
|||||||
FLEXIBLE_STRATEGY_GROUP_ID,
|
FLEXIBLE_STRATEGY_GROUP_ID,
|
||||||
FLEXIBLE_STRATEGY_STICKINESS_ID,
|
FLEXIBLE_STRATEGY_STICKINESS_ID,
|
||||||
} from 'utils/testIds';
|
} from 'utils/testIds';
|
||||||
|
import { HelpIcon } from 'component/common/HelpIcon/HelpIcon';
|
||||||
|
|
||||||
const builtInStickinessOptions = [
|
const builtInStickinessOptions = [
|
||||||
{ key: 'default', label: 'default' },
|
{ key: 'default', label: 'default' },
|
||||||
@ -81,22 +80,14 @@ const FlexibleStrategy = ({
|
|||||||
<Typography
|
<Typography
|
||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
style={{
|
style={{
|
||||||
marginBottom: '0.5rem',
|
marginBottom: '1rem',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
gap: '1ch',
|
||||||
}}
|
}}
|
||||||
component="h2"
|
component="h2"
|
||||||
>
|
>
|
||||||
Stickiness
|
Stickiness
|
||||||
<Tooltip title="Stickiness defines what parameter should be used to ensure that your users get consistency in features. By default unleash will use the first value present in the context in the order of userId, sessionId and random.">
|
<HelpIcon tooltip="Stickiness defines what parameter should be used to ensure that your users get consistency in features. By default unleash will use the first value present in the context in the order of userId, sessionId and random." />
|
||||||
<Info
|
|
||||||
style={{
|
|
||||||
fontSize: '1rem',
|
|
||||||
color: 'gray',
|
|
||||||
marginLeft: '0.2rem',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</Typography>
|
</Typography>
|
||||||
<Select
|
<Select
|
||||||
id="stickiness-select"
|
id="stickiness-select"
|
||||||
@ -116,22 +107,14 @@ const FlexibleStrategy = ({
|
|||||||
<Typography
|
<Typography
|
||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
style={{
|
style={{
|
||||||
marginBottom: '0.5rem',
|
marginBottom: '1rem',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
gap: '1ch',
|
||||||
}}
|
}}
|
||||||
component="h2"
|
component="h2"
|
||||||
>
|
>
|
||||||
GroupId
|
GroupId
|
||||||
<Tooltip title="GroupId is used to ensure that different toggles will hash differently for the same user. The groupId defaults to feature toggle name, but you can override it to correlate rollout of multiple feature toggles.">
|
<HelpIcon tooltip="GroupId is used to ensure that different toggles will hash differently for the same user. The groupId defaults to feature toggle name, but you can override it to correlate rollout of multiple feature toggles." />
|
||||||
<Info
|
|
||||||
style={{
|
|
||||||
fontSize: '1rem',
|
|
||||||
color: 'gray',
|
|
||||||
marginLeft: '0.2rem',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</Typography>
|
</Typography>
|
||||||
<Input
|
<Input
|
||||||
label="groupId"
|
label="groupId"
|
||||||
|
@ -14,9 +14,6 @@ const StyledSlider = withStyles({
|
|||||||
border: '2px solid currentColor',
|
border: '2px solid currentColor',
|
||||||
marginTop: -8,
|
marginTop: -8,
|
||||||
marginLeft: -12,
|
marginLeft: -12,
|
||||||
'&:focus, &:hover, &$active': {
|
|
||||||
boxShadow: 'inherit',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
active: {},
|
active: {},
|
||||||
valueLabel: {
|
valueLabel: {
|
||||||
|
@ -35,13 +35,11 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
marginBottom: '0',
|
marginBottom: '0',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
gap: '1ch',
|
||||||
},
|
},
|
||||||
statusBarSuccess: {
|
statusBarSuccess: {
|
||||||
backgroundColor: theme.palette.primary.main,
|
backgroundColor: theme.palette.primary.main,
|
||||||
},
|
},
|
||||||
helpIcon: {
|
|
||||||
height: '17.5px',
|
|
||||||
},
|
|
||||||
repeatingError: {
|
repeatingError: {
|
||||||
marginTop: '0.5rem',
|
marginTop: '0.5rem',
|
||||||
bottom: '0',
|
bottom: '0',
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { Tooltip, Typography } from '@material-ui/core';
|
import { Typography } from '@material-ui/core';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
|
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
|
||||||
import { BAD_REQUEST, OK } from 'constants/statusCodes';
|
import { BAD_REQUEST, OK } from 'constants/statusCodes';
|
||||||
import { useStyles } from './PasswordChecker.styles';
|
import { useStyles } from './PasswordChecker.styles';
|
||||||
import HelpIcon from '@material-ui/icons/Help';
|
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { formatApiPath } from 'utils/formatPath';
|
import { formatApiPath } from 'utils/formatPath';
|
||||||
import { Alert } from '@material-ui/lab';
|
import { Alert } from '@material-ui/lab';
|
||||||
import ConditionallyRender from 'component/common/ConditionallyRender';
|
import ConditionallyRender from 'component/common/ConditionallyRender';
|
||||||
|
import { HelpIcon } from 'component/common/HelpIcon/HelpIcon';
|
||||||
|
|
||||||
interface IPasswordCheckerProps {
|
interface IPasswordCheckerProps {
|
||||||
password: string;
|
password: string;
|
||||||
@ -157,19 +157,10 @@ const PasswordChecker = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Tooltip
|
<Typography variant="body2" className={styles.title} data-loading>
|
||||||
arrow
|
Please set a strong password
|
||||||
title="Your password needs to be at least ten characters long, and include an uppercase letter, a lowercase letter, a number and a symbol to be a valid OWASP password"
|
<HelpIcon tooltip="Your password needs to be at least ten characters long, and include an uppercase letter, a lowercase letter, a number and a symbol to be a valid OWASP password" />
|
||||||
>
|
</Typography>
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
className={styles.title}
|
|
||||||
data-loading
|
|
||||||
>
|
|
||||||
Please set a strong password
|
|
||||||
<HelpIcon className={styles.helpIcon} />
|
|
||||||
</Typography>
|
|
||||||
</Tooltip>
|
|
||||||
<div
|
<div
|
||||||
className={styles.container}
|
className={styles.container}
|
||||||
style={{
|
style={{
|
||||||
|
Loading…
Reference in New Issue
Block a user