Skip to content

fix: role no permission disbaled check - #7873

Merged
fit2cloudwxx merged 1 commit into
v3from
pr@v3@fix_roleNoPermissionDisabledCheck
Nov 12, 2026
Merged

fit2cloudwxx merged 1 commit into
v3from
pr@v3@fix_roleNoPermissionDisabledCheck

Conversation

@shaohuzhang1

@shaohuzhang1 shaohuzhang1 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

ใ€ใ€่ง’่‰ฒใ€‘ไผ˜ๅŒ–-่ง’่‰ฒๆ— ใ€Œ่ง’่‰ฒ็ฎก็†-็ผ–่พ‘ใ€ๆƒ้™ๆ—ถ๏ผŒๆƒ้™็Ÿฉ้˜ตๅค้€‰ๆก†ๅบ”ไธๅฏ็‚นๅ‡ปๅ‹พ้€‰ใ€‘
https://www.tapd.cn/tapd_fe/45245355/bug/detail/1145245355001079354

const disabled = computed(() => props.currentRole.internal || !perm.system.role.edit())
const permissionTableKey = computed(() => `${props.currentRole.id}:${disabled.value ? 'readonly' : 'editable'}`)

function loadPermissions() {

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.

Code Review

1. perm.system.role.edit() called inside a computed

const disabled = computed(() => props.currentRole.internal || !perm.system.role.edit())

Issues:

  • If perm.system.role.edit() is a function returning a plain boolean (not reading reactive state), this is fine โ€” but the ! negation combined with short-circuit means it's only evaluated when internal === false. Not a bug, just noted.
  • If perm.system.role.edit() internally reads reactive state, the computed will track it correctly. โœ” Good.

Potential concern: If perm.system.role.edit() reads from a store/composable that may not be initialized yet at setup time, and the permission resolves asynchronously later, make sure the underlying source is reactive so the computed re-evaluates. If permissions are fetched via an async call into a non-reactive variable, disabled will be stale.

2. permissionTableKey tied to disabled

const permissionTableKey = computed(() => `${props.currentRole.id}:${disabled.value ? 'readonly' : 'editable'}`)

This forces a remount of the table whenever disabled flips โ€” reasonable if the child really needs remount (e.g., different internal state), but if the only difference is read-only behavior, a plain prop would suffice and avoid a full teardown/re-render cost. Optimization suggestion: prefer passing disabled down as a prop unless there's a concrete reason for a key-based reset.

3. showCategory declared but unused in diff

const showCategory = ref(true) โ€” verify it's still used elsewhere; otherwise dead code.

4. Minor style / consistency

  • Inline Chinese comment is helpful but mixing languages in one file may violate team convention โ€” confirm it matches the rest of the file.
  • Naming: disabled is generic; isReadonly or isPermissionMatrixDisabled conveys intent better.

5. Logic check

For a built-in role (internal === true), the second operand isn't evaluated โ€” good for performance and avoids unnecessary permission-store access. For non-internal roles, edit permission is required to allow editing โ€” matches the comment. โœ”

Summary

  • No functional bugs in the snippet.
  • Main thing to verify: perm.system.role.edit() reads reactive state (so disabled updates on permission changes).
  • Consider whether permissionTableKey remount is truly needed vs. a prop.

@fit2cloudwxx
fit2cloudwxx merged commit 1e93d93 into v3 Nov 12, 2026
3 of 4 checks passed
@fit2cloudwxx
fit2cloudwxx deleted the pr@v3@fix_roleNoPermissionDisabledCheck branch November 12, 2026 09:52
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