Repository navigation
Conversation
| :show-shared="auth.isEE || auth.isPE" | ||
| :source="RESOURCE_TYPE.TOOL" | ||
| @loaded="selectFolder" | ||
| @select="selectFolder" |
There was a problem hiding this comment.
Here's my review of the changes:
Potential Issues
-
authusage without null-check / reactivity concernsconst { auth } = useStore()is fine, butauth.isEE || auth.isPEis used in the template. VerifyisEE/isPEare reactive properties (e.g., computed or reactive state) — if they're plain values read once, theshow-sharedwon't update on role/edition change.
-
isSharedFolderlogic duplicate / naming claritycurrentFolder.value.id === FOLDER_ENTRY_ID.SHAREDcombined withisWorkspaceScope.value— consider extracting a helper likeisSharedFolderInWorkspace()for readability and reuse. Also confirmcurrentFolder.valueis guaranteed non-null here (if it can beundefined,.idwould throw).
-
API choice precedence when both shared-folder and system scope
- The ternary chain means
isSystemResource()andisSystemSharedResource()take priority overisSharedFolder. SinceisSharedFolderrequiresisWorkspaceScope, these shouldn't overlap, but a comment explaining the precedence would help future maintainers avoid mis-editing.
- The ternary chain means
-
folder_idomission for shared folder- Dropping
folder_idwhenisSharedFolderis true changes the query semantics. Confirm theSharedToolApiendpoint itself scopes to "shared" — otherwise results may leak across folders or return unsorted data.
- Dropping
-
refreshToolearly-return guard not updated- Line
if (isSystemResource() && !props.workspaceId) return Promise.resolve()— verify this still captures all the new scopes correctly (e.g.,isSystemSharedResourcemight need similar guard). Not a bug per se, but worth double-checking.
- Line
Optimization Suggestions
-
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.
-
Avoid recomputing
isSharedFolder
IfcurrentFolderorisWorkspaceScopechange frequently, consider acomputedforisSharedFolderinstead of a local const insiderefreshTool. -
show-sharedflag coupling
Usingauth.isEE || auth.isPEinline ties UI behavior to feature-flag logic scattered in templates. Consider deriving a singlecanShowSharedcomputed (e.g., in a composable or store getter) so the rule lives in one place and is testable. -
Naming consistency
SharedToolApivsSystemSharedToolApi— ensure imports are clearly documented (add a comment) since names are easily confused. -
Tests
Add cases covering: workspace normal folder, workspace shared folder (with/without EE/PE), system resource, system shared resource — to confirm API selection andfolder_idpresence behave correctly.
Minor
- 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). - Ensure
useStoredestructuring matches the repo pattern; some codebases preferconst store = useStore(); const auth = store.auth.
fix: the shared resource menu for the application is not displayed