22import React from 'react' ;
33import { EventBus } from '../actors/eventBus' ;
44
5- interface Key {
5+ export interface Key {
66 subject : string ;
77 action : string ;
88}
99
10- type InvertAction = 'disable' | 'hide' ;
10+ export type InvertAction = 'disable' | 'hide' ;
1111
1212export type MissingPermissionReason = {
1313 type : 'MISSING_PERMISSION' ;
@@ -25,7 +25,7 @@ export type MissingCapabilityReason = {
2525
2626export type ReasonEvent = MissingPermissionReason | MissingCapabilityReason ;
2727
28- interface HasKeyProps < ReasonEvent > {
28+ export interface HasKeyProps < ReasonEvent > {
2929 Key ?: Key ;
3030 predicate ?: ( capabilitiesRegistry : unknown ) => [ boolean , ReasonEvent ] ; // returns a boolean and an event if the user does not have the permission
3131 children : React . ReactNode ;
@@ -48,8 +48,7 @@ export const createCanShow = (
4848 const hasKey = Key ?. subject ? CAN ( Key ?. action , Key ?. subject ) : true ;
4949 const predicateRes = predicate && predicate ( getCapabilitiesRegistry ( ) ) ;
5050
51- //WARNING: remove the false from the below line to enable the feature
52- const can = predicateRes ? predicateRes [ 0 ] && hasKey && false : hasKey && false ;
51+ const can = predicateRes ? predicateRes [ 0 ] && hasKey : hasKey && false ;
5352
5453 const reason = predicateRes ?. [ 1 ] || {
5554 type : 'MISSING_PERMISSION' ,
@@ -71,7 +70,7 @@ export const createCanShow = (
7170
7271 const onClick = isClickable
7372 ? ( ) => {
74- console . log ( 'cant perform action : reason' , reason ) ;
73+ console . log ( 'cant perform action : reason' , reason , eventBus ) ;
7574 const mesheryEventBus = eventBus ( ) ;
7675 mesheryEventBus . publish ( reason ) ;
7776 }
0 commit comments