Skip to content

fix: application workflow permission error - #7962

Merged
peslyn merged 1 commit into
v3from
pr@v3@fix_application_workflow_permission_error
Nov 17, 2026
Merged

peslyn merged 1 commit into
v3from
pr@v3@fix_application_workflow_permission_error

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: application workflow permission error

@peslyn
peslyn merged commit 7fc746c into v3 Nov 17, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@fix_application_workflow_permission_error branch November 17, 2026 03:17
<MkTooltip content="保存" placement="bottom" v-if="applicationWorkflowPermission('edit')">
<el-button plain :disabled="loading" @click="handleSave()" class="w-8! min-w-8!">
<MkIcon name="icon_save_outlined" />
</el-button>

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 are my observations on the diff:

Potential issues

  1. v-if on <MkTooltip> rather than the button itself — if MkTooltip uses a slot/teleport or Popper internally, hiding it may leave unintended behavior (e.g., an empty wrapper in DOM). It's usually safer to apply v-if directly on the interactive element:

    <el-button v-if="applicationWorkflowPermission('edit')" ...>

    Or wrap both in a <template v-if>.

  2. Permission check called on every render — applicationWorkflowPermission('edit') runs inside the template, so it will be re-evaluated on every reactivity-triggered re-render (and this looks like a toolbar item that likely re-renders frequently). Consider moving it into a computed:

    const canEdit = computed(() => applicationWorkflowPermission('edit'))

    Especially important because isSystemResource() and perm.application.* calls inside the helper could have non-trivial cost or side effects.

  3. Consistency of permission gating — the handleSave() handler itself is not guarded by the new 'edit' permission. If the button is ever reachable via other paths (keyboard shortcut, programmatic call, stale reactive state before re-render), users without edit permission could still trigger save. Prefer also guarding inside handleSave():

    function handleSave() {
      if (!applicationWorkflowPermission('edit')) return
      ...
    }
  4. Naming / semantics — adding 'edit' to ApplicationWorkflowPermissionMethod alongside 'publish' broadens the type, but the existing permission tables (perm.application.system[...], perm.application.workspace[...]) must actually expose an edit method; otherwise TypeScript will complain, or worse, silently allow runtime undefined() errors. Double-check that perm.application.{system,workspace}.edit exists and returns a boolean.

  5. No tooltip when hidden — using placement="bottom" with a conditional on the tooltip means keyboard-only or screen-reader users get no affordance change; if you want better UX for permission denial, consider rendering disabled + tooltip "no permission" instead of hiding entirely (product decision, but worth noting).

Minor / style

  1. Attribute order — place v-if first for readability: <MkTooltip v-if="..." content="保存" placement="bottom">.
  2. The diff context has an unrelated-looking .ts extension on imports (@/utils/resource-context.ts, @/permission/index.ts) — verify your bundler/TS config supports explicit extensions where required (Vite/ESM ok; some loaders not).
  3. Nothing wrong with widening the union type per se, but consider whether 'edit' should map to an existing 'write'/'update' perm key for consistency across the codebase.

Suggested refactor

<!-- 保存 -->
<MkTooltip v-if="canEdit" content="保存" placement="bottom">
  <el-button plain :disabled="loading || !canEdit" @click="handleSave()" class="w-8! min-w-8!">
    <MkIcon name="icon_save_outlined" />
  </el-button>
</MkTooltip>
const canEdit = computed(() => applicationWorkflowPermission('edit'))

function handleSave() {
  if (!canEdit.value) return
  // ...
}

No functional bugs visible in the snippet itself, but points 2 and 3 (computed caching + handler-level guard) are the most important corrections.

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