Skip to content

Commit 9d9f0cc

Browse files
feat: add custom property to Action
1 parent ed190af commit 9d9f0cc

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

src/backend/actions/action.interface.ts

+9
Original file line numberDiff line numberDiff line change
@@ -624,12 +624,21 @@ export interface Action <T extends ActionResponse> {
624624

625625
/**
626626
* Defines the variant of the action. based on that it will receive given color.
627+
* @new in version v3.3
627628
*/
628629
variant?: VariantType;
629630

630631
/**
631632
* Action can be nested. If you give here another action name - it will be nested under it.
632633
* If parent action doesn't exists - it will be nested under name in the parent.
634+
* @deprecated in version v3.3
633635
*/
634636
parent?: string;
637+
638+
/**
639+
* Any custom properties you want to pass down to {@link ActionJSON}. They have to
640+
* be stringified.
641+
* @new in version v3.3
642+
*/
643+
custom?: Record<string, any>;
635644
}

src/backend/decorators/action/action-decorator.ts

+5
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,10 @@ class ActionDecorator {
318318
return this.action.parent || null
319319
}
320320

321+
custom(): Record<string, any> {
322+
return this.action.custom || {}
323+
}
324+
321325
hasHandler(): boolean {
322326
return !!this.action.handler
323327
}
@@ -347,6 +351,7 @@ class ActionDecorator {
347351
variant: this.variant(),
348352
parent: this.parent(),
349353
hasHandler: this.hasHandler(),
354+
custom: this.custom(),
350355
}
351356
}
352357
}

src/frontend/components/spec/action-json.factory.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ factory.define<ActionJSON>('ActionJSON', Object, {
1414
variant: 'default',
1515
parent: null,
1616
hasHandler: true,
17+
custom: {},
1718
})

src/frontend/interfaces/action/action-json.interface.ts

+6
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,10 @@ export interface ActionJSON {
7575
* @new in version 3.3
7676
*/
7777
hasHandler: boolean;
78+
79+
/**
80+
* Any custom options passed from the {@link Action} configuration.
81+
* @new in version 3.3
82+
*/
83+
custom: Record<string, any>;
7884
}

0 commit comments

Comments
 (0)