Skip to content
Merged
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
33 changes: 22 additions & 11 deletions web/src/pages/desktop/menu/settings/account/users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Alert,
Button,
Checkbox,
ConfigProvider,
Form,
Input,
message,
Expand All @@ -13,6 +14,7 @@ import {
Switch,
Tooltip
} from 'antd';
import type { ThemeConfig } from 'antd';
import { KeyRoundIcon, ShieldCheckIcon, Trash2Icon } from 'lucide-react';
import { useTranslation } from 'react-i18next';

Expand Down Expand Up @@ -50,6 +52,15 @@ function reachesMcp(user: Pick<User, 'role' | 'enabled' | 'permissions'> | null)
// the administrator can act on (an invalid role, the last administrator, ...).
class AccountRefused extends Error {}

// The row's icon buttons are 24px tall (antd's small control height) while the
// default switch track is 22px, so the enable switch would sit a pixel short of
// their edges. This one-off theme raises the track to 24px; the knob must grow
// with it (handleSize = trackHeight - 2 * padding) because it is pinned to the
// track padding, not centered, and would otherwise hang off-center.
const buttonHeightSwitchTheme: ThemeConfig = {
components: { Switch: { trackHeight: 24, handleSize: 20 } }
};

export const Users = () => {
const { t } = useTranslation();
const { account } = useAuth();
Expand Down Expand Up @@ -394,17 +405,6 @@ export const Users = () => {
onClick={() => openPermissionEditor(user)}
/>
</Tooltip>
<Switch
checked={user.enabled}
disabled={isLoading || isProtected}
checkedChildren={t('settings.account.users.enabled')}
unCheckedChildren={t('settings.account.users.disabled')}
onChange={(enabled) =>
guardMcpLoss(user, { ...user, enabled }, (rotate) =>
updateUser(user, { enabled }, rotate)
)
}
/>
<Tooltip title={t('settings.account.users.resetPassword')}>
<Button
size="small"
Expand Down Expand Up @@ -433,6 +433,17 @@ export const Users = () => {
/>
</Tooltip>
</Popconfirm>
<ConfigProvider theme={buttonHeightSwitchTheme}>
<Switch
checked={user.enabled}
disabled={isLoading || isProtected}
onChange={(enabled) =>
guardMcpLoss(user, { ...user, enabled }, (rotate) =>
updateUser(user, { enabled }, rotate)
)
}
/>
</ConfigProvider>
</div>
</div>
);
Expand Down