diff --git a/client/shared/index.tsx b/client/shared/index.tsx index 611c0301..18bd97f5 100644 --- a/client/shared/index.tsx +++ b/client/shared/index.tsx @@ -254,7 +254,7 @@ export { isValidJson } from './utils/json-helper'; export { MessageHelper } from './utils/message-helper'; export { PERMISSION, - AllPermission, + ALL_PERMISSION, getPermissionList, getDefaultPermissionList, applyDefaultFallbackGroupPermission, diff --git a/client/shared/utils/role-helper.ts b/client/shared/utils/role-helper.ts index c3321a4c..92688ac9 100644 --- a/client/shared/utils/role-helper.ts +++ b/client/shared/utils/role-helper.ts @@ -4,7 +4,7 @@ import { model, t } from '..'; * 所有人权限 * 群组最低权限标识 */ -export const AllPermission = Symbol('AllPermission'); +export const ALL_PERMISSION = Symbol('AllPermission'); export interface PermissionItemType { /** diff --git a/client/web/src/components/modals/GroupDetail/Role/index.tsx b/client/web/src/components/modals/GroupDetail/Role/index.tsx index ae5dffb1..a58fd7b9 100644 --- a/client/web/src/components/modals/GroupDetail/Role/index.tsx +++ b/client/web/src/components/modals/GroupDetail/Role/index.tsx @@ -1,6 +1,6 @@ import { Loading } from '@/components/Loading'; import { PillTabs } from '@/components/PillTabs'; -import { AllPermission } from 'tailchat-shared'; +import { ALL_PERMISSION } from 'tailchat-shared'; import React, { useMemo, useState } from 'react'; import { t, useGroupInfo } from 'tailchat-shared'; import { RoleItem } from './RoleItem'; @@ -14,8 +14,8 @@ interface GroupPermissionProps { } export const GroupRole: React.FC = React.memo((props) => { const { groupId } = props; - const [roleId, setRoleId] = useState( - AllPermission + const [roleId, setRoleId] = useState( + ALL_PERMISSION ); const groupInfo = useGroupInfo(groupId); const roles = groupInfo?.roles ?? []; @@ -39,8 +39,8 @@ export const GroupRole: React.FC = React.memo((props) => {
{/* 角色列表 */} setRoleId(AllPermission)} + active={roleId === ALL_PERMISSION} + onClick={() => setRoleId(ALL_PERMISSION)} > {t('所有人')} @@ -67,7 +67,7 @@ export const GroupRole: React.FC = React.memo((props) => { { key: 'summary', label: t('概述'), - disabled: roleId === AllPermission, + disabled: roleId === ALL_PERMISSION, children: ( <> {currentRoleInfo && ( @@ -76,7 +76,7 @@ export const GroupRole: React.FC = React.memo((props) => { onChangeRoleName={handleChangeRoleName} onDeleteRole={async () => { await handleDeleteRole(); - setRoleId(AllPermission); // 删除身份组后切换到所有人 + setRoleId(ALL_PERMISSION); // 删除身份组后切换到所有人 }} /> )} @@ -98,7 +98,7 @@ export const GroupRole: React.FC = React.memo((props) => { { key: 'member', label: t('管理成员'), - disabled: roleId === AllPermission, + disabled: roleId === ALL_PERMISSION, children: ( <> {currentRoleInfo && ( diff --git a/client/web/src/components/modals/GroupDetail/Role/tabs/permission.tsx b/client/web/src/components/modals/GroupDetail/Role/tabs/permission.tsx index 38096170..bf942ddd 100644 --- a/client/web/src/components/modals/GroupDetail/Role/tabs/permission.tsx +++ b/client/web/src/components/modals/GroupDetail/Role/tabs/permission.tsx @@ -1,4 +1,4 @@ -import { AllPermission, getPermissionList } from 'tailchat-shared'; +import { ALL_PERMISSION, getPermissionList } from 'tailchat-shared'; import { Button } from 'antd'; import React, { useCallback, useMemo } from 'react'; import { model, t } from 'tailchat-shared'; @@ -6,7 +6,7 @@ import { useModifyPermission } from '../useModifyPermission'; import { PermissionList } from '@/components/PermissionList'; interface RolePermissionProps { - roleId: typeof AllPermission | string; + roleId: typeof ALL_PERMISSION | string; currentRoleInfo?: model.group.GroupRole; fallbackPermissions: string[]; onSavePermission: (permissions: string[]) => Promise; @@ -14,7 +14,7 @@ interface RolePermissionProps { export const RolePermission: React.FC = React.memo( (props) => { const currentRolePermissions: string[] = useMemo(() => { - if (props.roleId === AllPermission) { + if (props.roleId === ALL_PERMISSION) { return props.fallbackPermissions; } diff --git a/client/web/src/components/modals/GroupDetail/Role/useRoleActions.ts b/client/web/src/components/modals/GroupDetail/Role/useRoleActions.ts index 7c19d1b8..b201339e 100644 --- a/client/web/src/components/modals/GroupDetail/Role/useRoleActions.ts +++ b/client/web/src/components/modals/GroupDetail/Role/useRoleActions.ts @@ -1,5 +1,5 @@ import { - AllPermission, + ALL_PERMISSION, getDefaultPermissionList, showSuccessToasts, } from 'tailchat-shared'; @@ -7,7 +7,7 @@ import { model, t, useAsyncRequest } from 'tailchat-shared'; export function useRoleActions( groupId: string, - roleId: typeof AllPermission | string + roleId: typeof ALL_PERMISSION | string ) { const [{ loading: loading1 }, handleCreateRole] = useAsyncRequest(async () => { @@ -21,7 +21,7 @@ export function useRoleActions( const [{ loading: loading2 }, handleSavePermission] = useAsyncRequest( async (permissions: string[]) => { - if (roleId === AllPermission) { + if (roleId === ALL_PERMISSION) { // 所有人权限 await model.group.modifyGroupField( groupId, @@ -44,7 +44,7 @@ export function useRoleActions( const [{ loading: loading3 }, handleChangeRoleName] = useAsyncRequest( async (newRoleName: string) => { - if (roleId === AllPermission) { + if (roleId === ALL_PERMISSION) { throw new Error(t('无法修改所有人权限组的显示名称')); } await model.group.updateGroupRoleName(groupId, roleId, newRoleName); @@ -55,7 +55,7 @@ export function useRoleActions( const [{ loading: loading4 }, handleDeleteRole] = useAsyncRequest(async () => { - if (roleId === AllPermission) { + if (roleId === ALL_PERMISSION) { throw new Error(t('无法删除所有人权限')); }