-
Notifications
You must be signed in to change notification settings - Fork 465
chore: permission types #6417
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
base: feat/edit-versioned-change-request
Are you sure you want to change the base?
chore: permission types #6417
Conversation
…on-types # Conflicts: # frontend/common/providers/Permission.tsx # frontend/web/components/modals/create-feature/index.js
…on-types # Conflicts: # frontend/web/components/modals/create-feature/index.js
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Docker builds report
|
Zaimwa9
left a comment
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.
Looks neat. There are just 2 conditions that got truncated somehow and a couple of NITs
| permissions[EnvironmentPermission.VIEW_IDENTITIES] | ||
| permissions.ADMIN |
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.
| permissions[EnvironmentPermission.VIEW_IDENTITIES] | |
| permissions.ADMIN | |
| permissions[EnvironmentPermission.VIEW_IDENTITIES] || | |
| permissions.ADMIN |
| (!savePermission, | ||
| isSaving || | ||
| !projectFlag.name || | ||
| invalid) |
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.
| (!savePermission, | |
| isSaving || | |
| !projectFlag.name || | |
| invalid) | |
| (!savePermission || | |
| isSaving || | |
| !projectFlag.name || | |
| invalid) |
| }, | ||
| organisationPermissions: (perm: string) => | ||
| organisationPermissions: (perm: OrganisationPermissionDescription) => | ||
| `To manage this feature you need the <i>${perm}</i> permission for this organisastion.<br/>Please contact a member of this organisation who has administrator privileges.`, |
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.
| `To manage this feature you need the <i>${perm}</i> permission for this organisastion.<br/>Please contact a member of this organisation who has administrator privileges.`, | |
| `To manage this feature you need the <i>${perm}</i> permission for this organisation.<br/>Please contact a member of this organisation who has administrator privileges.`, |
|
|
||
| const finalPermission = hasPermission || AccountStore.isAdmin() | ||
|
|
||
| let permissionDescriptionFunc: (perm: any) => any = |
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.
What do you think about renaming to something like getPermissionDescription?
| permissionName || | ||
| permissionDescriptionFunc( | ||
| PermissionDescriptions[permission as ProjectPermission], | ||
| ), |
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.
Can we put this into a variable and re-use it in the 2 places?
| '#F57C78', | ||
| ], | ||
| projectPermissions: (perm: string) => | ||
| projectPermissions: (perm: ProjectPermissionDescription) => |
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.
Actually, can't we use directly the enum here and get the description within this function ?
const description = ProjectPermissionDescriptions[perm];
| type PermissionType = { | ||
| id: number | string | ||
| permission: string | ||
| permission: PermissionEnum |
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.
NIT:
Here we could use a union type like:
type OrganisationLevelProps = BasePermissionProps & {
level: 'organisation';
permission: OrganisationPermission;
};
same with env and project and then
export type PermissionType =
| ProjectLevelProps
| EnvironmentLevelProps
| OrganisationLevelProps;
so the permission would directly be inferred and we can get invalid combinations directly
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature!Changes
How did you test this code?
E2E, checking each usage of permission
Note: due to amount of refactoring I've done, I've pointed this to the latest branch I've been working on