Skip to content

perf(ui): cache permission lookups and fix batch selection - #8231

Closed
2710165659 wants to merge 1 commit into
1Panel-dev:v2from
2710165659:v2
Closed

2710165659 wants to merge 1 commit into
1Panel-dev:v2from
2710165659:v2

Conversation

@2710165659

Copy link
Copy Markdown

What this PR does / why we need it?

Permission strings are generated per resource, so the array returned by the profile API grows with the number of resources a user owns. Every permission check scanned that array linearly, and each list page evaluated more than ten such checks per card. The cost therefore grew quadratically with the resource count, and because every batch-selection click re-rendered the whole list, each click repeated that work — on older machines the page froze on nearly every click.

Batch selection had a second problem: the checkbox both updated the group model and ran a manual push/splice handler, so a click could register twice or fail to deselect.

Summary of your change

  • Added a memoized permission index on the user store (permission list, permission set, role set), invalidated by user info or edition changes. Permission and role checks are now O(1) lookups; existing return values and semantics are unchanged.
  • The application / knowledge / tool list pages now compute permission flags once per list and reuse them, so the "more" menu and its items share the same result.
  • Switched v-for keys from array index to resource id, fixing card state sticking to the wrong row after paging or deletion.
  • Removed the duplicated manual checkbox handler and let el-checkbox-group own the selection state; the checkbox no longer bubbles its click into the card action.
  • No backend or API changes. Type check passes.

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

@shaohuzhang1

Copy link
Copy Markdown
Contributor

V3 no longer has this issue

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