Merge pull request #2947 from spotify/alund/settings

UX improvements to Settings
This commit is contained in:
Fredrik Adelöw
2020-10-19 22:57:46 +02:00
committed by GitHub
8 changed files with 38 additions and 46 deletions
@@ -37,7 +37,7 @@ export const AuthProviders = ({ providerSettings }: Props) => {
}
return (
<InfoCard>
<InfoCard title="Available Providers">
<List dense>{providers}</List>
</InfoCard>
);
@@ -22,14 +22,13 @@ import {
SessionState,
} from '@backstage/core';
import {
Button,
ListItem,
ListItemIcon,
ListItemSecondaryAction,
ListItemText,
Tooltip,
} from '@material-ui/core';
import PowerButton from '@material-ui/icons/PowerSettingsNew';
import { ToggleButton } from '@material-ui/lab';
type Props = {
title: string;
@@ -84,14 +83,13 @@ export const ProviderSettingsItem = ({
arrow
title={signedIn ? `Sign out from ${title}` : `Sign in to ${title}`}
>
<ToggleButton
size="small"
value={title}
selected={signedIn}
onChange={() => (signedIn ? api.signOut() : api.signIn())}
<Button
variant="outlined"
color="primary"
onClick={() => (signedIn ? api.signOut() : api.signIn())}
>
<PowerButton color={signedIn ? 'primary' : undefined} />
</ToggleButton>
{signedIn ? `Sign out` : `Sign in`}
</Button>
</Tooltip>
</ListItemSecondaryAction>
</ListItem>
@@ -62,7 +62,7 @@ export const FeatureFlags = () => {
}
return (
<InfoCard>
<InfoCard title="Feature Flags">
<List dense>
{featureFlags.map(featureFlag => {
const enabled = Boolean(state[featureFlag.name]);
@@ -19,10 +19,9 @@ import {
ListItem,
ListItemSecondaryAction,
ListItemText,
Switch,
Tooltip,
} from '@material-ui/core';
import CheckIcon from '@material-ui/icons/CheckCircle';
import { ToggleButton } from '@material-ui/lab';
import { FeatureFlagsRegistryItem } from '@backstage/core';
type Props = {
@@ -39,14 +38,12 @@ export const FlagItem = ({ flag, enabled, toggleHandler }: Props) => (
/>
<ListItemSecondaryAction>
<Tooltip placement="top" arrow title={enabled ? 'Disable' : 'Enable'}>
<ToggleButton
size="small"
value="flag"
selected={enabled}
<Switch
color="primary"
checked={enabled}
onChange={() => toggleHandler(flag.name)}
>
<CheckIcon color={enabled ? 'primary' : undefined} />
</ToggleButton>
name={flag.name}
/>
</Tooltip>
</ListItemSecondaryAction>
</ListItem>
@@ -21,12 +21,12 @@ import { Profile } from './Profile';
import { ThemeToggle } from './ThemeToggle';
export const General = () => (
<Grid container spacing={3}>
<Grid item md={12}>
<Grid container direction="row" spacing={3}>
<Grid item sm={12} md={6}>
<Profile />
</Grid>
<Grid item md={12}>
<InfoCard>
<Grid item sm={12} md={6}>
<InfoCard title="Appearance">
<List dense>
<ThemeToggle />
<PinButton />
@@ -32,10 +32,9 @@ describe('<PinButton />', () => {
</SidebarPinStateContext.Provider>,
),
);
expect(rendered.getByText('Pin Sidebar')).toBeInTheDocument();
const pinButton = rendered.getByTitle('Pin Sidebar');
const pinButton = rendered.getByLabelText('Pin Sidebar Switch');
fireEvent.click(pinButton);
expect(mockToggleFn).toHaveBeenCalled();
});
@@ -19,18 +19,11 @@ import {
ListItem,
ListItemSecondaryAction,
ListItemText,
Switch,
Tooltip,
} from '@material-ui/core';
import LockIcon from '@material-ui/icons/Lock';
import LockOpenIcon from '@material-ui/icons/LockOpen';
import { ToggleButton } from '@material-ui/lab';
import { SidebarPinStateContext } from '@backstage/core';
type PinIconProps = { isPinned: boolean };
const PinIcon = ({ isPinned }: PinIconProps) =>
isPinned ? <LockIcon color="primary" /> : <LockOpenIcon />;
export const PinButton = () => {
const { isPinned, toggleSidebarPinState } = useContext(
SidebarPinStateContext,
@@ -48,16 +41,13 @@ export const PinButton = () => {
arrow
title={`${isPinned ? 'Unpin' : 'Pin'} Sidebar`}
>
<ToggleButton
size="small"
value="pin"
selected={isPinned}
onChange={() => {
toggleSidebarPinState();
}}
>
<PinIcon isPinned={isPinned} />
</ToggleButton>
<Switch
color="primary"
checked={isPinned}
onChange={() => toggleSidebarPinState()}
name="pin"
inputProps={{ 'aria-label': 'Pin Sidebar Switch' }}
/>
</Tooltip>
</ListItemSecondaryAction>
</ListItem>
@@ -102,12 +102,20 @@ export const ThemeToggle = () => {
title={`Select ${theme.title}`}
value={theme.variant}
>
<ThemeIcon id={theme.id} icon={themeIcon} activeId={themeId} />
<>
{theme.variant}&nbsp;
<ThemeIcon
id={theme.id}
icon={themeIcon}
activeId={themeId}
/>
</>
</TooltipToggleButton>
);
})}
<Tooltip placement="top" arrow title="Select auto theme">
<ToggleButton value="auto">
<ToggleButton value="auto" selected={themeId === undefined}>
Auto&nbsp;
<AutoIcon color={themeId === undefined ? 'primary' : undefined} />
</ToggleButton>
</Tooltip>