Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

feat: Knowledge workflow permission

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Nov 11, 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 Nov 11, 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

}),
},
redirect: (menu: any) => {
const from = 'workspace'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some potential issues with the provided React component code:

  1. The permission array is unnecessarily complex and verbose.
  2. There are duplicated checks and permissions in different parts of the array.
  3. Some route parameters are incorrectly written (folderId should be type, extensionId seems misplaced).

Optimization suggestions:

  1. Combine similar conditions and roles into fewer function calls and simpler logic.
  2. Simplify repeated permission calculations.
  3. Correct inconsistencies such as "shared" vs. 'shared'.

Here's an optimized version:

const DocumentRouter = {
  permission: [
    (to) => {
      if (to.params.type === '4') {
        if (to.params.folderId === 'workspace-management') {
          return new ComplexPermission([RoleConst.ADMIN], [], [], 'AND');
        } else {
          return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole();
        }
      }
      // Handle other types or folderIds appropriately
    },
    (to) => {
      if (to.params.type === '4') {
        return PermissionConst.KNOWLEDGE_WORKFLOW_READ.getKnowledgeWorkspaceResourcePermission(to.params.id);
      }
<|fim_suffix|>n to.params.type.includes('document') && !to.params.extensionId;
};

DocumentRouter.redirect = ({ type }) => {
  if (!['admin', 'editor'].includes(type)) return '/login';
};

These improvements enhance readability, reduce redundancy, and handle various scenarios more efficiently.

)
RESOURCE_KNOWLEDGE_DOCUMENT_READ = Permission(
group=Group.SYSTEM_RES_KNOWLEDGE_DOCUMENT, operate=Operate.READ, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE_KNOWLEDGE], is_ee=settings.edition == "EE"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are no apparent issues with the provided code snippet. It seems to be correctly defining enumerations and permission constants based on different groups and their associated operations, roles, and resource permissions. A few notes:

  1. The new KNOWLEDGE_WORKFLOW group is added along with its respective permissions (READ, EDIT) for both workspace and system-level access.

  2. Similar additional entries have been created for workflow-related permissions in system-level knowledge resources and user/shared workspaces.

  3. There might be redundancy in the list of resource_permission_group_list since some names like "KNOWLEDGE_MANGE" and "KNOWLEDGE_VIEW" are repeated, but this doesn't affect the functionality unless those specific values need customization.

Overall, the structure looks clean and follows good naming conventions. If there's any further modification needed beyond these entries, please specify!

IS_CE: new Edition('X-PACK-CE'),
}
export {PermissionConst, RoleConst, EditionConst}

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 current code appears to be adding two new permissions for knowledge workflow access: KNOWLEDGE_WORKFLOW_READ and KNOWLEDGE_WORKFLOW_EDIT. These additions could potentially improve the functionality of systems that work with advanced workflows related to knowledge management.

Here are a few points:

  1. Functionality Enhancement: Adding these permissions would allow users with these capabilities to view or edit knowledge workflows, which can be useful in scenarios such as managing processes or approvals associated with knowledge items.

  2. Clarity and Organization: Organizing permissions into separate groups like KNOWLEDGE_, SHARED_KNOWLEDGE_, and RESOURCE_KNOWLDGE_ helps in clearly delineating areas where permission sets differ based on data scope (knowledge, shared knowledge, resources).

  3. Future Proofing: If more complex permission requirements emerge for workflow-related actions, having these distinct sections makes it easier to scale and maintain the system's permission structure.

Overall, the addition of these permissions aligns with best practices for implementing robust access control mechanisms tailored to specific functionalities within an application.

@zhanweizhang7 zhanweizhang7 merged commit b82e12a into knowledge_workflow Nov 11, 2025
3 of 6 checks passed
@zhanweizhang7 zhanweizhang7 deleted the pr@knowledge_workflow@feat_permission branch November 11, 2025 08:17
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