Skip to content

feat: application publish permission - #7728

Merged
peslyn merged 1 commit into
v3from
pr@v3@feat_application_publish_permission
Nov 6, 2026
Merged

peslyn merged 1 commit into
v3from
pr@v3@feat_application_publish_permission

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

feat: application publish permission

@peslyn
peslyn merged commit 33d5cc2 into v3 Nov 6, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@feat_application_publish_permission branch November 6, 2026 09:45
<el-button v-if="applicationWorkflowPermission('publish')" type="primary" :disabled="loading" @click="handleOpenPublish">发布</el-button>
<!-- 更多操作 -->
<MkDropdown trigger="click" placement="bottom-end" class="ml-2" persistent>
<el-button text class="h-7! w-7! px-0!">

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

Issues / Irregularities

  1. applicationId dependency risk – applicationWorkflowPermission references applicationId from the outer scope. Make sure it's declared before this function in <script setup> order, otherwise you'll get a temporal dead zone (ReferenceError) at init. Also consider passing it explicitly as a parameter for clarity/testability:

    function applicationWorkflowPermission(method: ..., id: string): boolean
  2. Function called in template – re-evaluated on every render. Since permissions rarely change reactively (and perm.application.system[method]() looks like a non-reactive call), wrap it in a computed:

    const canPublish = computed(() => applicationWorkflowPermission('publish'))

    Then use v-if="canPublish".

  3. Inconsistent meaning of the API – perm.application.system[method]() is called as a function, while perm.application.workspace[method](applicationId) takes an argument. Verify both are actually functions (the type is only a string union; TS can't check these dynamic accesses). If perm has typed methods, prefer direct calls: perm.application.system.publish() — safer and no string indexing.

  4. Import style inconsistency – elsewhere imports drop the .ts extension ('@/utils/resource-context.ts' also has it, but './navigation' doesn't). Standardize — typically omit extensions for module resolution consistency and bundler compatibility.

  5. Redundant Boolean() – if the permission functions already return booleans, Boolean(...) wrapping is unnecessary noise. If they may return undefined/truthy values, the cast is fine — but note it explicitly in the permission module's typing instead.

Optimization Suggestions

  • UX consideration: hiding the button with v-if vs. disabling with :disabled + tooltip ("no permission"). Hiding is cleaner security-wise, but confirm designers intend hidden (some teams prefer disabled-with-reason).
  • Naming: ApplicationWorkflowPermissionMethod is verbose; something like type WorkflowAction = 'publish' is clearer.
  • Generalization: if more buttons will need checks (dropdown "more actions" menu likely), export a small composable, e.g. useApplicationWorkflowPermission(applicationId) returning { canPublish, canDelete, ... }, to avoid repeating helper calls in the template.

Overall the change is functionally sound; the main real risks are #1 (declaration order) and #3 (unverified dynamic method existence).

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