import { SPI } from '@oinone/kunlun-spi'; import { Widget } from '@oinone/kunlun-vue-widget'; import { BaseElementWidget } from '../../basic'; import CustomView from './Permission.vue'; import type { IPermissionDslActions } from './types'; @SPI.ClassFactory(BaseElementWidget.Token({ widget: 'permission-view' })) export class PermissionWidget extends BaseElementWidget { public initialize(props) { super.initialize(props); this.setComponent(CustomView); return this; } @Widget.Reactive() protected get dslActions() { const widgets = this.metadataRuntimeContext.viewDsl?.widgets || []; return widgets.find((w) => w.slot === 'actions')?.widgets || []; } @Widget.Reactive() protected get permissionActions(): IPermissionDslActions { return { hasModifyRoleAction: !!this.dslActions.find((a) => a.name === 'modifyRole' && !!a.actionType), hasModifyManagementRoleAction: !!this.dslActions.find((a) => a.name === 'modifyManagementRole' && !!a.actionType), hasPermissionUpdateAction: !!this.dslActions.find((a) => a.name === 'update' && !!a.actionType), hasPermissionCreateAction: !!this.dslActions.find((a) => a.name === 'create' && !!a.actionType), hasPermissionCreateBatchAction: !!this.dslActions.find((a) => a.name === 'authorizes' && !!a.actionType), hasActiveGroupAction: !!this.dslActions.find((a) => a.name === 'active' && !!a.actionType), hasCancelGroupAction: !!this.dslActions.find((a) => a.name === 'disable' && !!a.actionType), hasDeleteGroupAction: !!this.dslActions.find((a) => a.name === 'deleteOne' && !!a.actionType), hasCollectionPermissionItemsAction: !!this.dslActions.find( (a) => a.name === 'collectionPathMappings' && !!a.actionType ), hasAuthGroupSystemPermissionLookupAction: !!this.dslActions.find( (a) => a.name === 'authGroupSystemPermissionLookup' && !!a.actionType ) }; } }