Skip to content

fix: the shared resource menu for the application is not displayed - #8203

Merged
peslyn merged 1 commit into
v3from
pr@v3@fix_the_shared_resource_menu_for_the_application_is_not_displayed
Nov 27, 2026
Merged

peslyn merged 1 commit into
v3from
pr@v3@fix_the_shared_resource_menu_for_the_application_is_not_displayed

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: the shared resource menu for the application is not displayed

:show-shared="auth.isEE || auth.isPE"
:source="RESOURCE_TYPE.TOOL"
@loaded="selectFolder"
@select="selectFolder"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here's my review of the changes:

Potential Issues

  1. auth usage without null-check / reactivity concerns

    • const { auth } = useStore() is fine, but auth.isEE || auth.isPE is used in the template. Verify isEE/isPE are reactive properties (e.g., computed or reactive state) — if they're plain values read once, the show-shared won't update on role/edition change.
  2. isSharedFolder logic duplicate / naming clarity

    • currentFolder.value.id === FOLDER_ENTRY_ID.SHARED combined with isWorkspaceScope.value — consider extracting a helper like isSharedFolderInWorkspace() for readability and reuse. Also confirm currentFolder.value is guaranteed non-null here (if it can be undefined, .id would throw).
  3. API choice precedence when both shared-folder and system scope

    • The ternary chain means isSystemResource() and isSystemSharedResource() take priority over isSharedFolder. Since isSharedFolder requires isWorkspaceScope, these shouldn't overlap, but a comment explaining the precedence would help future maintainers avoid mis-editing.
  4. folder_id omission for shared folder

    • Dropping folder_id when isSharedFolder is true changes the query semantics. Confirm the SharedToolApi endpoint itself scopes to "shared" — otherwise results may leak across folders or return unsorted data.
  5. refreshTool early-return guard not updated

    • Line if (isSystemResource() && !props.workspaceId) return Promise.resolve() — verify this still captures all the new scopes correctly (e.g., isSystemSharedResource might need similar guard). Not a bug per se, but worth double-checking.

Optimization Suggestions

  1. Simplify nested ternaries
    Replace the deeply nested conditional with a small lookup/resolver function:

    function resolveRequestApi() {
      if (isSystemResource()) return SystemToolApi
      if (isSystemSharedResource()) return SystemSharedToolApi
      if (isSharedFolder) return SharedToolApi
      return ToolApi
    }

    This is more readable and easier to unit-test.

  2. Avoid recomputing isSharedFolder
    If currentFolder or isWorkspaceScope change frequently, consider a computed for isSharedFolder instead of a local const inside refreshTool.

  3. show-shared flag coupling
    Using auth.isEE || auth.isPE inline ties UI behavior to feature-flag logic scattered in templates. Consider deriving a single canShowShared computed (e.g., in a composable or store getter) so the rule lives in one place and is testable.

  4. Naming consistency
    SharedToolApi vs SystemSharedToolApi — ensure imports are clearly documented (add a comment) since names are easily confused.

  5. Tests
    Add cases covering: workspace normal folder, workspace shared folder (with/without EE/PE), system resource, system shared resource — to confirm API selection and folder_id presence behave correctly.

Minor

  1. Diff header shows @@ -6,13 +6,16 @@ implying 3 added net lines, but the hunk adds more — confirm import ordering fits lint rules (e.g., alphabetical grouping).
  2. Ensure useStore destructuring matches the repo pattern; some codebases prefer const store = useStore(); const auth = store.auth.

@peslyn
peslyn merged commit 1198c64 into v3 Nov 27, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@fix_the_shared_resource_menu_for_the_application_is_not_displayed branch November 27, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants