Repository navigation
fix: use direct user group selection in Professional Edition #8281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
The refactor is conceptually sound (replacing a duplicated
auth.isCEcheck with a singlecomputed), but there are a few behavioural risks and one apparent runtime bug worth checking before merging.🔴 Potential bugs / irregularities
1.
rejectis not defined inloadWorkspaceUserGroupsresolveis a parameter, butrejectis not declared anywhere in scope. If the request fails, this throwsReferenceError: reject is not definedinside the promise chain (unhandled rejection). The cascader'sresolveAPI also has norejectcounterpart — you must always callresolve(...), even on failure:(Pre-existing, but it is in the shown diff and will bite you.)
2.
isPE⇒ "default workspace" is an assumption that needs product confirmationThe whole
v-if/v-elsebranch (multi-select vs. cascader) now hinges on this. If the professional edition can have multiple workspaces, this will:refreshUserGroupOptionsit will doworkspaceUserGroups.flat()over allprops.workspaceIds, mixing groups from different workspaces into one flat multi-select with no provenance.Please verify the PE data model. If PE is not strictly single/default-workspace, the predicate is a misnomer and a logic regression. Consider naming it after the actual condition (
hasSingleWorkspace,isDefaultWorkspaceEdition) so the intent is unambiguous.3. The
elsebranch assigns workspace options touserGroupOptionsuserGroupOptionsis only bound to the<el-select>, which is only rendered whenusesDefaultWorkspaceis true. So in theelsebranch you're populating a user-group list with workspace objects — at best dead code, at worst a wrong-type value that leaks if the edition ever flips at runtime. Pre-existing, but the refactor is a good moment to clean it up (or confirm it feeds the cascader's name-echo path).4. Race condition on rapid prop changes
refreshUserGroupOptionsfires an asyncPromise.all(...).then(...)with no request token / abort. IfworkspaceIdschanges twice quickly (very likely withdeep: true+immediate: trueduring parent mount), a stale response can overwrite the fresh one. Suggest a simple sequence guard:5. Stale
userGroupIdswhen the edition/branch flipsSwitching between
el-selectandel-cascaderunmounts the input, butuserGroupIdsis not reset. Default-workspace group IDs are not valid cascader paths (and vice-versa). Add a reset (or validation) whenusesDefaultWorkspacetransitions.🟡 Optimization suggestions
6.
deep: trueis heavier than needed hereprops.workspaceIdsandprops.workspaceOptionsare replaced wholesale by the parent (typical Vue pattern); you rarely mutate them in place.deep: trueforces a full recursive traversal ofworkspaceOptionson every watch evaluation, for a callback that only needs the array identity andidmembers. Prefer:or, if in-place mutation really happens, use a shallow signature like
() => props.workspaceIds.join(',').Also consider
flush: 'post'so the request isn't fired mid-render during parent mount.7. The preload ternary should be parenthesized
Precedence is correct (
||binds tighter than?:), but the line-break makes it easy to misread. Either extract:or add explicit parens.
8.
userGroupIds.value?.length— optional chain is redundantIf
userGroupIdsisref<string[]>([]),.valueis never nullish; drop the?.(or type it as nullable if it really can be). Minor readability win.9.
Promise.allfans out one request per workspace with no dedupe/batchingFor N workspaces this is N round-trips. If a batch endpoint exists (
getUserGroupsByWorkspaces(ids)), prefer it; otherwise at least dedupeprops.workspaceIds.10.
computedon a store getter — verify reactivityauth.isCE || auth.isPEonly re-evaluates if both flags are reactive (Pinia getters or refs). IfisPEis a plain property set once at bootstrap, the computed is fine but thewatchwill never fire on edition change — in which case it should be aconstoutside the component instead of acomputed. Worth confirming.🟢 Nits
<el-select>to multi-line is fine; no functional change.userGroupIds.value.length > 0in non-edit states; the comment slightly overstates.CascaderPropsis imported but not used anywhere in the shown hunks — confirm it's used further down or drop it (dead import will be flagged by lint ifno-unused-varscovers types).