Skip to content

fix: align admin features with license status and edition - #8284

Merged
wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@fix_edition
Dec 3, 2026
Merged

wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@fix_edition

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: align admin features with license status and edition

)
const editablePermissionOptions = computed(() =>
permissionOptions.value.filter(({ value }) => !props.isRootFolder || value !== RESOURCE_PERMISSION.NOT_AUTH),
)

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.

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 true

Potential issues

  1. Behavior differs if auth.isEE and auth.isPE are both false while auth.isCE is also false

    • Example: auth flags not loaded yet, unauthenticated state, or another edition.
    • Before: ROLE was included.
    • After: ROLE is 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.
  2. Flags are assumed to be mutually exclusive

    • If auth.isCE and auth.isEE can both be true, the new code includes ROLE because auth.isEE is true, whereas the old code excluded it because auth.isCE was true.
    • If that invariant is not guaranteed, make it explicit:
    const canUseRolePermission = computed(
      () => !auth.isCE && (auth.isEE || auth.isPE),
    )
  3. 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,
})),

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.

The main concern is semantic equivalence, not syntax.

Potential issue

Original condition:

!auth.isCE || value !== RESOURCE_PERMISSION.ROLE

means: hide ROLE only when the edition is CE.

Changed condition:

auth.isEE || auth.isPE || value !== RESOURCE_PERMISSION.ROLE

means: show ROLE only when the edition is EE or PE.

These are equivalent only if:

  1. Every non-CE edition is exactly EE or PE.
  2. isCE, isEE, and isPE are mutually exclusive.
  3. These flags are always initialized correctly.
  4. 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.isEE and auth.isPE are typed and guaranteed to exist. If they can be undefined, the boolean result is still safe, but explicit typing would be clearer.
  • If options contain extra fields beyond label and value, the map() 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.

@wangdan-fit2cloud
wangdan-fit2cloud merged commit a33d614 into v3 Dec 3, 2026
3 of 4 checks passed
@wangdan-fit2cloud
wangdan-fit2cloud deleted the pr@v3@fix_edition branch December 3, 2026 08:36
<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>

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'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

  1. Logic concern — expired paid users vs. CE users

    • If auth.isExpire can 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.
  2. Possible overlapping states / unclear precedence

    • Is isExpire mutually exclusive with isCE? 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.
  3. 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 on auth.isExpire (e.g., t(auth.isExpire ? 'layout.renew' : 'layout.upgrade')).
  4. Readability

    • A compound condition inside the template is fine but consider extracting it to a computed property for testability/clarity:
      const showUpgrade = computed(() => !props.preview && (auth.isCE || auth.isExpire));
      Then <el-button v-if="showUpgrade" ...>. This is easier to unit-test and keeps the template clean.
  5. Guard against undefined

    • Confirm auth.isExpire is always defined (boolean). If it can be undefined, || still works, but ensure reactivity is set up correctly in the store so the button updates when expiry state changes.
  6. No regression on preview

    • !preview guard is preserved — good. Just confirm preview and auth are 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.

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