Components/PermissionState

PermissionState

Shortcut empty-state component for missing permissions, unauthorized access, and gated workspaces.

VerifiedSince 0.3.4

Usage

PermissionState

Loading demo...

Best Practices

  • Use it only after the host has already determined access is denied; the component does not perform permission checks.
  • Explain which resource is gated and who can grant access.
  • Prefer a request-access primary action when a workflow exists; otherwise point to workspace switching or documentation.
  • Do not reveal sensitive resource details in the title or description when the user is not authorized.

API Reference

Props

TxPermissionState accepts every EmptyStateProps field except variant.

PropTypeDefaultDescription
titlestringpreset titleOverrides the permission-state title.
descriptionstringpreset descriptionExplains the access requirement and next step.
iconTxIconSource | string | nullpreset illustrationCustom icon source/class, or null to hide the icon area.
iconSizenumbersize presetCustom icon size in pixels.
layout'vertical' | 'horizontal''vertical'Empty-state layout.
align'start' | 'center' | 'end''center'Alignment within the wrapper.
size'small' | 'medium' | 'large''medium'Density and illustration scale.
surface'plain' | 'card''plain'Adds card containment when needed.
primaryActionEmptyStateAction-Generated primary action.
secondaryActionEmptyStateAction-Generated secondary action.
actionSizeTxButtonProps['size']'small'Default generated action size.
loadingbooleanfalseUses spinner when no custom icon is supplied.

Events

EventParamsDescription
primary-Forwarded from the generated primary action.
secondary-Forwarded from the generated secondary action.

Slots

SlotPropsDescription
icon-Replaces the preset illustration or custom icon.
title-Replaces resolved title content.
description-Replaces resolved description content.
actions-Replaces generated primary/secondary action buttons.

Overview

  • Always forwards variant="permission" to TxEmptyState.
  • Does not rewrite explicit title, description, surface, layout, align, size, icon, or action props.
  • Forwards icon, title, description, and actions slots unchanged to TxEmptyState.
  • Generated primary / secondary events come from the wrapped TxEmptyState action buttons.

Technologies

  • Wrapper contract: TxPermissionState locks variant="permission" and forwards all other empty-state props and slots without performing access checks.
  • Security note: The host must decide authorization before rendering this component. Keep copy generic enough to avoid disclosing restricted resource details.
  • Verified coverage: permission-state.test.ts verifies variant locking, action prop forwarding, slot forwarding, and install registration.
  • Component source: packages/tuffex/packages/components/src/permission-state/src/TxPermissionState.vue.
  • Base source: packages/tuffex/packages/components/src/empty-state/src/TxEmptyState.vue.
  • Types: packages/tuffex/packages/components/src/permission-state/src/types.ts exports PermissionStateProps = Omit<EmptyStateProps, 'variant'>.
  • Coverage: packages/tuffex/packages/components/src/permission-state/__tests__/permission-state.test.ts verifies wrapper forwarding and install behavior.
查看源码
packages/tuffex/packages/components/src/permission-state/index.ts