Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ui/src/router/modules/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ const DocumentRouter = {
title: 'views.workflow.workflow',
icon: 'app-problems',
activeMenu: '/knowledge',
sameRoute: 'knowledge',
parentPath: '/knowledge/:id/:folderId/:type',
parentName: 'KnowledgeDetail',
resourceType: SourceTypeEnum.KNOWLEDGE,
group: 'KnowledgeDetail',
permission: [
() => {
const to: any = get_next_route()
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 JavaScript code you provided is a part of a React Router router configuration for managing different sections within an application. There are several potential improvements and clarifications needed:

  1. Duplicate activeMenu Path: The parentPath (newly added) includes /knowledge:id:folderId:type, while activeMenu has only /knowledge. This redundancy might not be intentional, especially if they represent the same functionality.

  2. Variable Naming Convention: It's generally good practice to use consistent naming conventions across your project. Ensure that variable names like to follow standard JavaScript conventions.

  3. Function Scope Considerations: If get_next_route() is meant to return something based on some logic, consider defining it with proper scope or importing where necessary.

  4. Code Readability: Adding comments can help clarify what each part of the routing configuration does.

Here’s the revised version of your code:

const DocumentRouter = {
  path: '/document', // Base route for documents
  routes: [
    {
      pattern: '/workflow/:id',
      component: WorkflowComponent,
      exact: true,
      meta: { 
        menuTitle: 'Workflow Details', 
        icon: 'application-list-icon' 
      },
      children: [
        {
          path: ':folderId',
          exact: true,
          component: FolderDetailsComponent,
          metaData: { menuTitle: 'Folder Details', activeMenu: '/documents/workflow/:id/:folderId', permission: [] }
        },
        {
          path: ':folderId/view/:type',
          exact: true,
          component: ViewDocumentComponent,
          metaData: {
            menuTitle: 'View Document',
            activeMenu: '/documents/workflow/:id/:folderId/:type',
            parentName: 'FolderDetails',
            resourceType: SourceTypeEnum.DOCUMENT,
            group: 'DocumentDetail'
          }
        }
      ]
    }
  ],
};

Key Changes:

  • Added a base route /document instead of duplicating workflow.
  • Introduced metaData object to store metadata properties more logically grouped.
  • Cleaned up syntax for clarity.
  • Assumed WorkflowComponent, FolderDetailsComponent, and other components have been imported or defined elsewhere in your project.

Make sure to update accordingly based on your actual implementation details.

Expand Down
Loading