Repository navigation
fix: align admin features with license status and edition - #8284
Conversation
| ) | ||
| const editablePermissionOptions = computed(() => | ||
| permissionOptions.value.filter(({ value }) => !props.isRootFolder || value !== RESOURCE_PERMISSION.NOT_AUTH), | ||
| ) |
There was a problem hiding this comment.
The diff is syntactically valid; the trailing comma is fine with Prettier/TS. The main concern is a semantic behavior change:
// Before
!auth.isCE || value !== ROLE
// Keeps ROLE for every non-CE case
// After
auth.isEE || auth.isPE || value !== ROLE
// Keeps ROLE only when isEE or isPE is truePotential issues
-
Behavior differs if
auth.isEEandauth.isPEare both false whileauth.isCEis also false- Example: auth flags not loaded yet, unauthenticated state, or another edition.
- Before:
ROLEwas included. - After:
ROLEis excluded. - This may be intentional, but it is not equivalent unless the auth state is guaranteed to always be exactly one of CE/EE/PE.
-
Flags are assumed to be mutually exclusive
- If
auth.isCEandauth.isEEcan both be true, the new code includesROLEbecauseauth.isEEis true, whereas the old code excluded it becauseauth.isCEwas true. - If that invariant is not guaranteed, make it explicit:
const canUseRolePermission = computed( () => !auth.isCE && (auth.isEE || auth.isPE), )
- If
-
If the original intent was simply “ROLE is unavailable in CE”, the original condition is clearer and safer:
!auth.isCE || value !== RESOURCE_PERMISSION.ROLE
Suggested optimization
If the intent is “ROLE is only available in EE/PE”:
const canUseRolePermission = computed(() => auth.isEE || auth.isPE)
const permissionOptions = computed(() =>
RESOURCE_PERMISSION_OPTIONS.filter(
({ value }) => canUseRolePermission.value || value !== RESOURCE_PERMISSION.ROLE,
),
)If CE can coexist with EE/PE flags, use:
const canUseRolePermission = computed(
() => !auth.isCE && (auth.isEE || auth.isPE),
)Minor adjacent concern
isFolder assumes props.type is always a string:
props.type.endsWith('_FOLDER')If props.type can be undefined or null, this can throw. Consider:
const isFolder = computed(() =>
Boolean(
folderPermissions.value &&
(props.isFolder ||
props.isRootFolder ||
props.type?.endsWith('_FOLDER')),
),
)Recommendation
Confirm the intended rule for ROLE. If it is “only EE/PE”, extract canUseRolePermission and add tests for CE, EE, PE, loading/unauthenticated state, and any case where multiple auth flags may be true.
| RESOURCE_PERMISSION_OPTIONS.filter(({ value }) => auth.isEE || auth.isPE || value !== RESOURCE_PERMISSION.ROLE).map(({ label, value }) => ({ | ||
| label, | ||
| value, | ||
| })), |
There was a problem hiding this comment.
The main concern is semantic equivalence, not syntax.
Potential issue
Original condition:
!auth.isCE || value !== RESOURCE_PERMISSION.ROLEmeans: hide ROLE only when the edition is CE.
Changed condition:
auth.isEE || auth.isPE || value !== RESOURCE_PERMISSION.ROLEmeans: show ROLE only when the edition is EE or PE.
These are equivalent only if:
- Every non-CE edition is exactly
EEorPE. isCE,isEE, andisPEare mutually exclusive.- These flags are always initialized correctly.
- No new edition will be added later.
If auth flags are still loading/unknown, or if a new edition is introduced, ROLE may be hidden incorrectly. Conversely, if isEE or isPE is accidentally true for a CE environment, ROLE will be shown when the original code would hide it.
Recommendation
Prefer expressing the capability directly instead of duplicating edition checks:
const canSelectRolePermission = computed(
() => auth.isEE || auth.isPE
)
const searchPermissionOptions = computed(() =>
RESOURCE_PERMISSION_OPTIONS
.filter(
({ value }) =>
value !== RESOURCE_PERMISSION.ROLE ||
canSelectRolePermission.value
)
.map(({ label, value }) => ({ label, value }))
)Or, if the intended rule is still “ROLE is unavailable only in CE”, keep the original logic:
const searchPermissionOptions = computed(() =>
RESOURCE_PERMISSION_OPTIONS
.filter(
({ value }) =>
!auth.isCE || value !== RESOURCE_PERMISSION.ROLE
)
.map(({ label, value }) => ({ label, value }))
)Minor notes
- The
filter().map()pattern is fine and readable. - The
map()creates new objects on every auth-flag change, but that is usually acceptable for a small static options list. - Make sure
auth.isEEandauth.isPEare typed and guaranteed to exist. If they can beundefined, the boolean result is still safe, but explicit typing would be clearer. - If options contain extra fields beyond
labelandvalue, themap()will drop them.
Overall: the syntax is valid, but the changed logic is only safe if the edition flags are guaranteed to be mutually exclusive and exhaustive.
| <el-button v-if="!preview && (auth.isCE || auth.isExpire)" class="bg-primary-gradient" round @click="toUrl('https://maxkb.cn/price')"> | ||
| <MkIcon name="icon_launch_outlined" /> | ||
| <span>{{ t('layout.upgrade') }}</span> | ||
| </el-button> |
There was a problem hiding this comment.
Here's my review of the diff:
Summary of Change
The condition for displaying the "Upgrade" button was broadened from auth.isCE (community edition) to auth.isCE || auth.isExpire.
Potential Issues
-
Logic concern — expired paid users vs. CE users
- If
auth.isExpirecan be true for non-CE (i.e., paid/enterprise) subscriptions that have lapsed, this button now links all of them to the same public pricing page (maxkb.cn/price). - Verify this is intended: an expired Enterprise customer may need a renewal flow rather than a generic "upgrade to community" page. Consider routing expired paid users to a renewal/contact-sales URL instead.
- If
-
Possible overlapping states / unclear precedence
- Is
isExpiremutually exclusive withisCE? If a CE license can also be flagged as "expired" (e.g., trial), the two flags may be redundant or semantically confusing. Clarify the flag semantics and whether both should key off the same message/tooltip.
- Is
-
Button label mismatch
- The i18n key is
layout.upgrade. For an expired user, "upgrade" may be misleading — "renew" would be clearer. Consider a different label/copy conditioned onauth.isExpire(e.g.,t(auth.isExpire ? 'layout.renew' : 'layout.upgrade')).
- The i18n key is
-
Readability
- A compound condition inside the template is fine but consider extracting it to a computed property for testability/clarity:
Then
const showUpgrade = computed(() => !props.preview && (auth.isCE || auth.isExpire));
<el-button v-if="showUpgrade" ...>. This is easier to unit-test and keeps the template clean.
- A compound condition inside the template is fine but consider extracting it to a computed property for testability/clarity:
-
Guard against undefined
- Confirm
auth.isExpireis always defined (boolean). If it can beundefined,||still works, but ensure reactivity is set up correctly in the store so the button updates when expiry state changes.
- Confirm
-
No regression on
preview!previewguard is preserved — good. Just confirmpreviewandauthare both reactive sources driving re-render.
Minor Optimization Suggestions
- Extract to a computed for readability/testing (see feat: 添加issues 模版 #4).
- Consider centralizing the target URL (
https://maxkb.cn/price) in a constant/config rather than hardcoding in the template. - Add a tooltip or title distinguishing upgrade vs. renew behavior if labels remain shared.
No functional bugs jump out, but the main thing to validate with product is whether expired non-CE users should be sent to the general pricing page and whether the "Upgrade" copy is appropriate for them.
fix: align admin features with license status and edition