Repository navigation
feat: workspace homepage permission #7866
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /** 工作空间「概览」按钮权限。* */ | ||
|
|
||
| import { can } from '../../policy' | ||
| import { PermissionConstants as P } from '../../core' | ||
|
|
||
| export default { | ||
| /** | ||
| * 工作空间「概览」只读权限 | ||
| */ | ||
| read: () => can(P.HOMEPAGE_READ), | ||
| /** | ||
| * 工作空间「概览」导出权限 | ||
| */ | ||
| edit: () => can(P.HOMEPAGE_EXPORT) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /** 「概览」在各场景下的按钮权限。* */ | ||
|
|
||
| import homepage from './homepage' | ||
|
|
||
| export default { | ||
| /** | ||
| * 工作空间「概览」权限 | ||
| */ | ||
| homepage | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code is syntactically valid JavaScript, but there are a few points to check:
Suggested corrected version if the nested structure is intended: /** Button permissions for "Overview" in each scenario. */
import homepage from './homepage';
export default {
/** Workspace "Overview" permissions. */
homepage,
}; |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import tool from './tool' | |
| import model from './model' | ||
| import system from './system' | ||
| import trigger from './trigger' | ||
| import homepage from './homepage' | ||
|
|
||
| export default { | ||
| /** | ||
|
|
@@ -36,4 +37,9 @@ export default { | |
| /** | ||
| * 「系统全局」按钮权限 | ||
| * */ | ||
| system } | ||
| system, | ||
| /** | ||
| * 工作空间「概览」按钮权限 | ||
| */ | ||
| homepage, | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the review of the provided code snippet: 1. Irregularities & Issues
2. Optimization Suggestions
3. Code Review VerdictThe change is safe and correct assuming:
Recommendation:
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| import perm from '@/permission' | ||
| import type { RouteRecordRaw } from 'vue-router' | ||
|
|
||
| export const homeRoutes: RouteRecordRaw[] = [ | ||
| { | ||
| path: '', | ||
| name: 'workspace-home', | ||
| component: () => import('@/views/home/index.vue'), | ||
| meta: { title: '概览', activeIcon: 'icon_screen_filled', icon: 'icon_screen_outlined', order: 10 }, | ||
| meta: { title: '概览', activeIcon: 'icon_screen_filled', icon: 'icon_screen_outlined', order: 10, permission: () => perm.homepage.homepage.read(), next: 'workspace-application',}, | ||
| }, | ||
| ] |
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.
The code is syntactically fine, but there are a few semantic/style issues:
Likely permission mismatch
editis mapped toP.HOMEPAGE_EXPORT:permissions.edit, they will incorrectly get export permission. If the intent is export, rename the key toexport(orexportPermission) instead ofedit.Naming inconsistency
readandedit, but the second permission is actually export.editis part of an existing public API, keep it only if it really maps to an edit permission, or add an explicit alias with a comment.Malformed/odd JSDoc header
/** 工作空间「概览」按钮权限。* */*before*/. It is harmless, but cleaner is:/** 工作空间「概览」按钮权限。 */Add return types if using TypeScript
Potential circular dependency / barrel import risk
../../policyand../../coremay be fine, but if those are barrel files that re-export this module, watch for circular dependencies. Direct imports can be safer in permission modules.Suggested corrected version:
If
editmust remain for compatibility, then verify whether it should be:rather than
P.HOMEPAGE_EXPORT.