mirror of
https://github.com/logto-io/logto.git
synced 2025-03-31 22:51:25 -05:00
fix(console): remove role edit from user details (#1173)
This commit is contained in:
parent
d2bf19b12d
commit
520f66cf3c
4 changed files with 1 additions and 68 deletions
|
@ -1,44 +0,0 @@
|
|||
import React, { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import Select from '@/components/Select';
|
||||
|
||||
type Props = {
|
||||
value?: string[];
|
||||
onChange?: (value: string[]) => void;
|
||||
};
|
||||
|
||||
const roleDefault = 'default';
|
||||
const roleAdmin = 'admin';
|
||||
|
||||
const RoleSelect = ({ value, onChange }: Props) => {
|
||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||
|
||||
const options = useMemo(
|
||||
() => [
|
||||
{ value: roleDefault, title: t('user_details.roles.default') },
|
||||
{ value: roleAdmin, title: t('user_details.roles.admin') },
|
||||
],
|
||||
[t]
|
||||
);
|
||||
|
||||
const selectValue = useMemo(() => {
|
||||
if (!value?.length) {
|
||||
return roleDefault;
|
||||
}
|
||||
|
||||
if (value.length === 1 && value[0] === 'admin') {
|
||||
return roleAdmin;
|
||||
}
|
||||
|
||||
throw new Error('Unsupported user role value');
|
||||
}, [value]);
|
||||
|
||||
const handleChange = (value?: string) => {
|
||||
onChange?.(value === roleAdmin ? ['admin'] : []);
|
||||
};
|
||||
|
||||
return <Select options={options} value={selectValue} onChange={handleChange} />;
|
||||
};
|
||||
|
||||
export default RoleSelect;
|
|
@ -2,7 +2,7 @@ import { User } from '@logto/schemas';
|
|||
import { Nullable } from '@silverhand/essentials';
|
||||
import classNames from 'classnames';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Controller, useController, useForm } from 'react-hook-form';
|
||||
import { useController, useForm } from 'react-hook-form';
|
||||
import { toast } from 'react-hot-toast';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import ReactModal from 'react-modal';
|
||||
|
@ -34,7 +34,6 @@ import { uriValidator } from '@/utilities/validator';
|
|||
import CreateSuccess from './components/CreateSuccess';
|
||||
import DeleteForm from './components/DeleteForm';
|
||||
import ResetPasswordForm from './components/ResetPasswordForm';
|
||||
import RoleSelect from './components/RoleSelect';
|
||||
import UserConnectors from './components/UserConnectors';
|
||||
import * as styles from './index.module.scss';
|
||||
|
||||
|
@ -240,18 +239,6 @@ const UserDetails = () => {
|
|||
errorMessage={errors.avatar?.message}
|
||||
/>
|
||||
</FormField>
|
||||
<FormField
|
||||
title="admin_console.user_details.field_roles"
|
||||
className={styles.textField}
|
||||
>
|
||||
<Controller
|
||||
name="roleNames"
|
||||
control={control}
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<RoleSelect value={value} onChange={onChange} />
|
||||
)}
|
||||
/>
|
||||
</FormField>
|
||||
<FormField
|
||||
title="admin_console.user_details.field_connectors"
|
||||
className={styles.textField}
|
||||
|
|
|
@ -363,7 +363,6 @@ const translation = {
|
|||
field_username: 'Username',
|
||||
field_name: 'Name',
|
||||
field_avatar: 'Avatar image URL',
|
||||
field_roles: 'Roles',
|
||||
field_custom_data: 'Custom data',
|
||||
field_connectors: 'Social connectors',
|
||||
custom_data_invalid: 'Custom data must be a valid JSON',
|
||||
|
@ -377,10 +376,6 @@ const translation = {
|
|||
deletion_confirmation:
|
||||
'You are removing the existing <name/> identity. Are you want to do that?',
|
||||
},
|
||||
roles: {
|
||||
default: 'Default',
|
||||
admin: 'Admin',
|
||||
},
|
||||
},
|
||||
contact: {
|
||||
title: 'Contact Us',
|
||||
|
|
|
@ -354,7 +354,6 @@ const translation = {
|
|||
field_username: '用户名',
|
||||
field_name: '名称',
|
||||
field_avatar: '头像图片链接',
|
||||
field_roles: '角色',
|
||||
field_custom_data: '自定义数据',
|
||||
field_connectors: '社交账号',
|
||||
custom_data_invalid: '自定义数据必须是有效的 JSON',
|
||||
|
@ -367,10 +366,6 @@ const translation = {
|
|||
not_connected: '该用户还没有绑定社交账号。',
|
||||
deletion_confirmation: '您在正要删除现有的 <name /> 身份,是否确认?',
|
||||
},
|
||||
roles: {
|
||||
default: '默认',
|
||||
admin: '管理员',
|
||||
},
|
||||
},
|
||||
contact: {
|
||||
title: '联系我们',
|
||||
|
|
Loading…
Add table
Reference in a new issue