fix: ux
This commit is contained in:
parent
ded0383ac4
commit
e59816aba4
@ -37,13 +37,13 @@ export const AppPermissionList: PermissionListType<AppPermissionKeyEnum> = {
|
|||||||
name: '门户快捷应用权限',
|
name: '门户快捷应用权限',
|
||||||
description: '',
|
description: '',
|
||||||
value: GateQuickAppPermission,
|
value: GateQuickAppPermission,
|
||||||
checkBoxType: 'multiple' // TODO: 加个隐藏选项
|
checkBoxType: 'hiden'
|
||||||
},
|
},
|
||||||
[AppPermissionKeyEnum.featuredGate]: {
|
[AppPermissionKeyEnum.featuredGate]: {
|
||||||
name: '门户推荐应用权限',
|
name: '门户推荐应用权限',
|
||||||
description: '',
|
description: '',
|
||||||
value: GateFeaturedAppPermission,
|
value: GateFeaturedAppPermission,
|
||||||
checkBoxType: 'multiple' // TODO: 加个隐藏选项
|
checkBoxType: 'hiden'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ export class AppPermission extends Permission {
|
|||||||
} else if (!props?.per) {
|
} else if (!props?.per) {
|
||||||
props.per = AppDefaultPermissionVal;
|
props.per = AppDefaultPermissionVal;
|
||||||
}
|
}
|
||||||
|
props.permissionList = AppPermissionList;
|
||||||
super(props);
|
super(props);
|
||||||
this.setUpdatePermissionCallback(() => {
|
this.setUpdatePermissionCallback(() => {
|
||||||
this.hasReadPer = this.checkPer(AppPermissionList.read.value);
|
this.hasReadPer = this.checkPer(AppPermissionList.read.value);
|
||||||
|
|||||||
@ -1,5 +1,10 @@
|
|||||||
import { type PermissionListType, type PermissionValueType } from './type';
|
import { type PermissionListType, type PermissionValueType } from './type';
|
||||||
import { PermissionList, NullPermission, OwnerPermissionVal } from './constant';
|
import {
|
||||||
|
PermissionList,
|
||||||
|
NullPermission,
|
||||||
|
OwnerPermissionVal,
|
||||||
|
ManagePermissionVal
|
||||||
|
} from './constant';
|
||||||
|
|
||||||
export type PerConstructPros = {
|
export type PerConstructPros = {
|
||||||
per?: PermissionValueType;
|
per?: PermissionValueType;
|
||||||
@ -63,6 +68,12 @@ export class Permission {
|
|||||||
if (perm === OwnerPermissionVal) {
|
if (perm === OwnerPermissionVal) {
|
||||||
return this.value === OwnerPermissionVal;
|
return this.value === OwnerPermissionVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 管理员
|
||||||
|
if ((this.value & ManagePermissionVal) === ManagePermissionVal) {
|
||||||
|
return (this._permissionList.manage.value & perm) === perm;
|
||||||
|
}
|
||||||
|
|
||||||
return (this.value & perm) === perm;
|
return (this.value & perm) === perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
packages/global/support/permission/type.d.ts
vendored
2
packages/global/support/permission/type.d.ts
vendored
@ -18,7 +18,7 @@ export type PermissionListType<T = {}> = Record<
|
|||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
value: PermissionValueType;
|
value: PermissionValueType;
|
||||||
checkBoxType: 'single' | 'multiple';
|
checkBoxType: 'single' | 'multiple' | 'hiden';
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
|||||||
@ -137,7 +137,7 @@ export const authApp = async ({
|
|||||||
appId: ParentIdType;
|
appId: ParentIdType;
|
||||||
per: PermissionValueType;
|
per: PermissionValueType;
|
||||||
}): Promise<
|
}): Promise<
|
||||||
AuthResponseType & {
|
AuthResponseType<AppPermission> & {
|
||||||
app: AppDetailType;
|
app: AppDetailType;
|
||||||
}
|
}
|
||||||
> => {
|
> => {
|
||||||
|
|||||||
@ -83,7 +83,7 @@ function PermissionSelect({
|
|||||||
const selectedSingleValue = useMemo(() => {
|
const selectedSingleValue = useMemo(() => {
|
||||||
if (!permissionList) return undefined;
|
if (!permissionList) return undefined;
|
||||||
|
|
||||||
const per = new Permission({ per: value });
|
const per = new Permission({ per: value, permissionList });
|
||||||
|
|
||||||
if (per.hasManagePer) return permissionList['manage'].value;
|
if (per.hasManagePer) return permissionList['manage'].value;
|
||||||
if (per.hasWritePer) return permissionList['write'].value;
|
if (per.hasWritePer) return permissionList['write'].value;
|
||||||
@ -91,18 +91,18 @@ function PermissionSelect({
|
|||||||
return permissionList['read'].value;
|
return permissionList['read'].value;
|
||||||
}, [permissionList, value]);
|
}, [permissionList, value]);
|
||||||
const selectedMultipleValues = useMemo(() => {
|
const selectedMultipleValues = useMemo(() => {
|
||||||
const per = new Permission({ per: value });
|
const per = new Permission({ per: value, permissionList });
|
||||||
|
|
||||||
return permissionSelectList.multipleCheckBoxList
|
return permissionSelectList.multipleCheckBoxList
|
||||||
.filter((item) => {
|
.filter((item) => {
|
||||||
return per.checkPer(item.value);
|
return per.checkPer(item.value);
|
||||||
})
|
})
|
||||||
.map((item) => item.value);
|
.map((item) => item.value);
|
||||||
}, [permissionSelectList.multipleCheckBoxList, value]);
|
}, [permissionList, permissionSelectList.multipleCheckBoxList, value]);
|
||||||
|
|
||||||
const onSelectPer = (perValue: PermissionValueType) => {
|
const onSelectPer = (perValue: PermissionValueType) => {
|
||||||
if (perValue === value) return;
|
if (perValue === value) return;
|
||||||
const per = new Permission({ per: perValue });
|
const per = new Permission({ per: perValue, permissionList });
|
||||||
per.addPer(...selectedMultipleValues);
|
per.addPer(...selectedMultipleValues);
|
||||||
onChange(per.value);
|
onChange(per.value);
|
||||||
};
|
};
|
||||||
@ -157,7 +157,7 @@ function PermissionSelect({
|
|||||||
{/* The list of single select permissions */}
|
{/* The list of single select permissions */}
|
||||||
{permissionSelectList.singleCheckBoxList.map((item) => {
|
{permissionSelectList.singleCheckBoxList.map((item) => {
|
||||||
const change = () => {
|
const change = () => {
|
||||||
const per = new Permission({ per: value });
|
const per = new Permission({ per: value, permissionList });
|
||||||
per.removePer(selectedSingleValue);
|
per.removePer(selectedSingleValue);
|
||||||
per.addPer(item.value);
|
per.addPer(item.value);
|
||||||
onSelectPer(per.value);
|
onSelectPer(per.value);
|
||||||
@ -191,12 +191,13 @@ function PermissionSelect({
|
|||||||
<MyDivider my={2} />
|
<MyDivider my={2} />
|
||||||
{permissionSelectList.multipleCheckBoxList.map((item) => {
|
{permissionSelectList.multipleCheckBoxList.map((item) => {
|
||||||
const isChecked = selectedMultipleValues.includes(item.value);
|
const isChecked = selectedMultipleValues.includes(item.value);
|
||||||
const isDisabled = new Permission({ per: selectedSingleValue }).checkPer(
|
const isDisabled = new Permission({
|
||||||
item.value
|
per: selectedSingleValue,
|
||||||
);
|
permissionList
|
||||||
|
}).checkPer(item.value);
|
||||||
const change = () => {
|
const change = () => {
|
||||||
if (isDisabled) return;
|
if (isDisabled) return;
|
||||||
const per = new Permission({ per: value });
|
const per = new Permission({ per: value, permissionList });
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
per.removePer(item.value);
|
per.removePer(item.value);
|
||||||
} else {
|
} else {
|
||||||
@ -221,14 +222,18 @@ function PermissionSelect({
|
|||||||
: {
|
: {
|
||||||
cursor: 'pointer'
|
cursor: 'pointer'
|
||||||
})}
|
})}
|
||||||
|
onClick={change}
|
||||||
>
|
>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
size="lg"
|
size="lg"
|
||||||
isChecked={isChecked}
|
isChecked={isChecked}
|
||||||
onChange={change}
|
// onChange={(e) => {
|
||||||
|
// e.stopPropagation();
|
||||||
|
// e.preventDefault();
|
||||||
|
// }}
|
||||||
isDisabled={isDisabled}
|
isDisabled={isDisabled}
|
||||||
/>
|
/>
|
||||||
<Box ml={4} onClick={change}>
|
<Box ml={4}>
|
||||||
<Box>{t(item.name as any)}</Box>
|
<Box>{t(item.name as any)}</Box>
|
||||||
<Box color={'myGray.500'} fontSize={'mini'}>
|
<Box color={'myGray.500'} fontSize={'mini'}>
|
||||||
{t(item.description as any)}
|
{t(item.description as any)}
|
||||||
|
|||||||
@ -38,7 +38,7 @@ async function handler(
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// auth chat permission
|
// auth chat permission
|
||||||
if (chat && !app.permission.hasManagePer && String(tmbId) !== String(chat?.tmbId)) {
|
if (chat && !app.permission.hasLogPer && String(tmbId) !== String(chat?.tmbId)) {
|
||||||
return Promise.reject(ChatErrEnum.unAuthChat);
|
return Promise.reject(ChatErrEnum.unAuthChat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -170,7 +170,7 @@ export async function authChatCrud({
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (String(teamId) !== String(chat.teamId)) return Promise.reject(ChatErrEnum.unAuthChat);
|
if (String(teamId) !== String(chat.teamId)) return Promise.reject(ChatErrEnum.unAuthChat);
|
||||||
if (permission.hasManagePer)
|
if (permission.hasLogPer)
|
||||||
return {
|
return {
|
||||||
teamId,
|
teamId,
|
||||||
tmbId,
|
tmbId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user