Skip to content

Commit eb4c754

Browse files
committed
fix: remove hardcoded false
Signed-off-by: codeSafari10 <[email protected]>
1 parent 9044d57 commit eb4c754

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

package-lock.json

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/custom/permissions.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import React from 'react';
33
import { 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

1212
export type MissingPermissionReason = {
1313
type: 'MISSING_PERMISSION';
@@ -25,7 +25,7 @@ export type MissingCapabilityReason = {
2525

2626
export 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

Comments
 (0)