-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: Application detail #3798
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
fix: Application detail #3798
Conversation
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -171,7 +171,7 @@ const ApplicationDetailRouter = { | |||
() => { | |||
const to: any = get_next_route() | |||
if (to.params.from == 'resource-management') { } else { | |||
return new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole], [PermissionConst.APPLICATION_CHAT_USER_READ.getWorkspacePermissionWorkspaceManageRole], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR') | |||
return new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole()], [PermissionConst.APPLICATION_CHAT_USER_READ.getWorkspacePermissionWorkspaceManageRole()], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR') | |||
} | |||
}, | |||
() => { |
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.
The provided code seems to have formatting issues with unnecessary parentheses around function calls, which can make it harder to read and potentially cause errors due to incorrect syntax. Here are some improvements:
-
Remove unnecessary parentheses:
const ApplicationDetailRouter = { checkAppAccessRead(...args) { const to = get_next_route(); if (to.params.from !== 'resource-management' && args.includes(RoleConst.WORKSPACE_MANAGE)) { return new ComplexPermission(args); } }, // Similar methods for other access checks... };
-
Consider extracting common logic into separate helper functions or variables if applicable:
- For example, extract
getComplexPermission
that takes the role and permission arrays as arguments.
- For example, extract
-
Ensure consistent usage of arrow functions without unnecessary parameters:
- This can help avoid confusion about implicit this behavior:
const appRouterHelper = {};
appRouterHelper.getComplexPermission = (roleArray, permArray, editionArray, operator) => {
return new ComplexPermission(roleArray, permArray, editionArray, operator);
};
const AppDetailRouter = {
checkAppAccessRead(roleConst, permConst, editionConst) {
const to = get_next_route();
if (to.params.from !== 'resource-management') {
appRouterHelper.getComplexPermission([roleConst], [permConst], [editionConst], OR);
}
},
// Similar methods for other access checks using the same helper
};
- Add type annotations where appropriate to improve readability and maintainability:
const appRouterHelper = {}; interface RoleConstant { manageWorkspace(): string; } interface PermissionConstant { applicationAccessRead(workspaceManageRole: string): string; } interface EditionConstant { isEE() boolean; isPE() boolean; } class ComplexPermission { constructor( roles: readonly string[], permissions: readonly string[], editions: readonly string[], operator: "AND" | "OR" ) {} } const appRouterHelper = { getComplexPermission: ( rolesArray: readonly string[], permArray: readonly string[], editionArray: readonly string[], operator: "AND" | "OR" ): ComplexPermission => { return new ComplexPermission(rolesArray, permArray, editionArray, operator); }, }; const AppDetailRouter = { checkAppAccessRead(roleConst: Pick<RoleConstant, 'manageWorkspace'>, permConst: Pick<PermissionConstant, 'applicationAccessRead'>, editionConst: Pick<EditionConstant, 'isEE'|'isPE'>) { const to = get_next_route(); if (to.params.from !== 'resource-management' && appRouterHelper.isWorkSpaceManageRoleUsed(to, roleConst)) { appRouterHelper.getComplexPermission([roleConst.manageWorkspace()], [permConst.applicationAccessRead(roleConst.manageWorkspace())), [editionConst.isEE(), editionConst.isPE()], "OR"); } }, // Similar methods using the same structure... private isWorkSpaceManageRoleUsed(route: any, roleConst: Pick<RoleConstant, 'manageWorkspace'>) { return Object.getOwnPropertyNames(route).includes('from', route['from'] === 'resource-management'); } };
These changes should improve readability, reduce potential parsing issues, simplify method signatures, and add more clarity to the codebase.
What this PR does / why we need it?
Summary of your change
Please indicate you've done the following: