New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permission #1442
Permission #1442
Conversation
|
1 similar comment
|
@@ -9,3 +9,17 @@ export type AuthResponseType = { | |||
appId?: string; | |||
apikey?: string; | |||
}; | |||
|
|||
export type MetaDataType = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
稍微完善下主语
|
||
export type ResourcePermissionType = { | ||
metaData: MetaDataType; | ||
userPermissionTable: Array<{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
统一用[]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment the defaultPermission
}); | ||
|
||
export const MongoUserPermission: Model<SchemaType> = | ||
models['user_permission'] || model('user_permission', UserPermissionSchema); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
复用下面名。
这里是用户的还是团队的?
用 user.xxx 这类命名吧,和其他集合一样。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不用 schema
}, | ||
{ | ||
label: '权限', | ||
value: 'permission' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
创个枚举
@@ -128,7 +123,23 @@ const TeamManageModal = ({ onClose }: { onClose: () => void }) => { | |||
}); | |||
|
|||
return !!userInfo?.team ? ( | |||
<> | |||
<TeamContext.Provider | |||
value={{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有些方法,只有一个地方用到,不需要都塞 context
|
||
export type ResourcePermissionType = { | ||
metaData: MetaDataType; | ||
userPermissionTable: Array<{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment the defaultPermission
export type ResourcePermissionType = { | ||
metaData: MetaDataType; | ||
userPermissionTable: Array<{ | ||
user: UserModelSchema; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user should be string.
user -> memberId.
role: `${TeamMemberRoleEnum}`; | ||
status: `${TeamMemberStatusEnum}`; | ||
permission: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type should be PermissionValueType
} | ||
|
||
// check the permission | ||
export function checkPermission(val: PermissionValueType, perm: PermissionType): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perm: PermissionValueType
export type PermissionValueType = number; | ||
export type PermissionType = [string, PermissionValueType]; | ||
|
||
export const ReadPerm: PermissionType = ['Read', 0b100]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turn the 3 permissions list into a object, which is able to be extended.
|
||
export type UpdateTeamMemberPermissionProps = { | ||
teamId: string; | ||
memberId: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memberIdList
}); | ||
|
||
export const MongoUserPermission: Model<SchemaType> = | ||
models['user_permission'] || model('user_permission', UserPermissionSchema); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不用 schema
@@ -46,6 +47,9 @@ const TeamSchema = new Schema({ | |||
pat: { | |||
type: String | |||
} | |||
}, | |||
resourcePermission: { | |||
type: ResourcePermissonSchema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
写成对象
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this file
29183bb
to
050b981
Compare
- add a new icon
return (await MongoResourcePermission.findOne({ | ||
tmbId, | ||
resourceType | ||
}).exec()) as ResourcePermissionType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前这个查询一直有问题,各种尝试的过程中加上去的 exec 。。功能上没有什么区别,可以删掉,参考:
https://stackoverflow.com/a/68469848/10794921
@@ -0,0 +1 @@ | |||
export const ResourcePermissionCollectionName = 'resource_permission'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个直接放到schema文件里export就ok了
} | ||
|
||
export function constructPermission(permList: PermissionValueType[]) { | ||
return new Permission(0).add(...permList); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0是什么
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那就写一个新的 NullPermission = 0 语义化以下
@@ -13,6 +13,10 @@ const TeamSchema = new Schema({ | |||
type: Schema.Types.ObjectId, | |||
ref: userCollectionName | |||
}, | |||
defaultPermission: { | |||
type: Number, | |||
default: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0能不能找个变量替换,不好理解
* Revert "lafAccount add pat & re request when token invalid (#76)" (#77) This reverts commit 83d85df. * feat: add permission display in the team manager modal * feat: add permission i18n * feat: let team module acquire permission ablity * feat: add ownerPermission property into metaData * feat: team premission system * feat: extract the resourcePermission from resource schemas * fix: move enum definition to constant * feat: auth member permission handler, invite user * feat: permission manage * feat: adjust the style * feat: team card style - add a new icon * feat: team permission in guest mode * chore: change the type * chore: delete useless file * chore: delete useless code * feat: do not show owner in PermissionManage view * chore: fix style * fix: icon remove fill * feat: adjust the codes --------- Co-authored-by: Archer <545436317@qq.com>
* Permission (#1442) * Revert "lafAccount add pat & re request when token invalid (#76)" (#77) This reverts commit 83d85df. * feat: add permission display in the team manager modal * feat: add permission i18n * feat: let team module acquire permission ablity * feat: add ownerPermission property into metaData * feat: team premission system * feat: extract the resourcePermission from resource schemas * fix: move enum definition to constant * feat: auth member permission handler, invite user * feat: permission manage * feat: adjust the style * feat: team card style - add a new icon * feat: team permission in guest mode * chore: change the type * chore: delete useless file * chore: delete useless code * feat: do not show owner in PermissionManage view * chore: fix style * fix: icon remove fill * feat: adjust the codes --------- Co-authored-by: Archer <545436317@qq.com> * perf: permission modal * lock --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com>
No description provided.