Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

feat: Permission front

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Aug 26, 2025

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.

Details

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.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Aug 26, 2025

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

RESOURCE_TOOL_AUTH: new Permission('SYSTEM_RESOURCE_TOOL:READ+AUTH'),

APPEARANCE_SETTINGS_READ: new Permission('APPEARANCE_SETTINGS:READ'),
APPEARANCE_SETTINGS_EDIT: new Permission('APPEARANCE_SETTINGS:READ+EDIT'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code snippet looks generally clean, but there are a few suggestions to improve it:

  1. Consistent Property Naming: Ensure that all permission keys use consistent naming conventions (e.g., RESOURCE_MODEL_READ, RESOURC_AUTH).

  2. Optional Properties: Since permissions might not always require certain parts of them, consider creating optional properties for components like read/edit/delete.

  3. Security Measures: Include comments explaining the reasons behind each permission level.

Here is a more optimized version with these considerations in mind:

const PermissionConst = {
  // Base permission levels
  READ: 'READ',
  WRITE: 'WRITE',

  // Resource model-related permissions
  RESOURCE_MODEL_BASIC: [Permission.READ],
  RESOURCE_MODEL_EXTENDED: [...PermissionBase, ..., Permission.WRITE], // Example extend base

  // Application-specific permissions
  RESOURCE_APPLICATION_READ: PermissionConst.READ,
  RESOURCE_APPLICATION_WRITE: PermissionConst.WRITE,

  // Knowledge hub permissions
  RESOURCE_KNOWLEDGE_READ: PermissionConst.READ,
  RESOURCE_KNOWLEDGE_WRITE: PermissionConst.WRITE,

  // Tool functionality permissions
  RESOURCE_TOOL_READ: PermissionConst.READ,
  RESOURCE_TOOL_WRITE: PermissionConst.WRITE,

  // Settings permissions
  APPEARANCE_SETTINGS_READ: PermissionConst.READ,
  APPEARANCE_SETTINGS_WRITE: PermissionConst.WRITE,
};

// Helper function to combine multiple permissions into one array
function combinePermissions(...permissions) {
  return Array.from(new Set(permissions));
}

console.log(Object.keys(PermissionConst)).map(key => console.log(`${key}: ${typeof PermissionConst[key]}`));

Explanation:

  • Consistently Named Permissions: The property names now follow a consistent pattern, making it easier to understand their purpose.

  • Optional Properties: Added helper functions or object destructuring to handle case where some permissions might be omitted.

  • Security Comments: Left commented out for clarity, if you need to ensure specific security rules align with business needs.

These changes will make the configuration more maintainable and scalable. Make sure to adjust according to project requirements and team processes.

@zhanweizhang7 zhanweizhang7 merged commit 39fd66e into v2 Aug 26, 2025
3 of 5 checks passed
@zhanweizhang7 zhanweizhang7 deleted the pr@v2@feat_front_permission branch August 26, 2025 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants