2
2
import React from 'react' ;
3
3
import { EventBus } from '../actors/eventBus' ;
4
4
5
- interface Key {
5
+ export interface Key {
6
6
subject : string ;
7
7
action : string ;
8
8
}
9
9
10
- type InvertAction = 'disable' | 'hide' ;
10
+ export type InvertAction = 'disable' | 'hide' ;
11
11
12
12
export type MissingPermissionReason = {
13
13
type : 'MISSING_PERMISSION' ;
@@ -25,7 +25,7 @@ export type MissingCapabilityReason = {
25
25
26
26
export type ReasonEvent = MissingPermissionReason | MissingCapabilityReason ;
27
27
28
- interface HasKeyProps < ReasonEvent > {
28
+ export interface HasKeyProps < ReasonEvent > {
29
29
Key ?: Key ;
30
30
predicate ?: ( capabilitiesRegistry : unknown ) => [ boolean , ReasonEvent ] ; // returns a boolean and an event if the user does not have the permission
31
31
children : React . ReactNode ;
@@ -48,8 +48,7 @@ export const createCanShow = (
48
48
const hasKey = Key ?. subject ? CAN ( Key ?. action , Key ?. subject ) : true ;
49
49
const predicateRes = predicate && predicate ( getCapabilitiesRegistry ( ) ) ;
50
50
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 ;
53
52
54
53
const reason = predicateRes ?. [ 1 ] || {
55
54
type : 'MISSING_PERMISSION' ,
@@ -71,7 +70,7 @@ export const createCanShow = (
71
70
72
71
const onClick = isClickable
73
72
? ( ) => {
74
- console . log ( 'cant perform action : reason' , reason ) ;
73
+ console . log ( 'cant perform action : reason' , reason , eventBus ) ;
75
74
const mesheryEventBus = eventBus ( ) ;
76
75
mesheryEventBus . publish ( reason ) ;
77
76
}
0 commit comments