From 9d9f0cc4668fcea089fc19576ad6d6b1e93ff883 Mon Sep 17 00:00:00 2001 From: Wojciech Date: Sat, 17 Oct 2020 07:48:20 +0200 Subject: [PATCH] feat: add custom property to Action --- src/backend/actions/action.interface.ts | 9 +++++++++ src/backend/decorators/action/action-decorator.ts | 5 +++++ src/frontend/components/spec/action-json.factory.ts | 1 + src/frontend/interfaces/action/action-json.interface.ts | 6 ++++++ 4 files changed, 21 insertions(+) diff --git a/src/backend/actions/action.interface.ts b/src/backend/actions/action.interface.ts index 4cd164671..f5e898a0e 100644 --- a/src/backend/actions/action.interface.ts +++ b/src/backend/actions/action.interface.ts @@ -624,12 +624,21 @@ export interface Action { /** * Defines the variant of the action. based on that it will receive given color. + * @new in version v3.3 */ variant?: VariantType; /** * Action can be nested. If you give here another action name - it will be nested under it. * If parent action doesn't exists - it will be nested under name in the parent. + * @deprecated in version v3.3 */ parent?: string; + + /** + * Any custom properties you want to pass down to {@link ActionJSON}. They have to + * be stringified. + * @new in version v3.3 + */ + custom?: Record; } diff --git a/src/backend/decorators/action/action-decorator.ts b/src/backend/decorators/action/action-decorator.ts index 8d764f0d7..e147a15ed 100644 --- a/src/backend/decorators/action/action-decorator.ts +++ b/src/backend/decorators/action/action-decorator.ts @@ -318,6 +318,10 @@ class ActionDecorator { return this.action.parent || null } + custom(): Record { + return this.action.custom || {} + } + hasHandler(): boolean { return !!this.action.handler } @@ -347,6 +351,7 @@ class ActionDecorator { variant: this.variant(), parent: this.parent(), hasHandler: this.hasHandler(), + custom: this.custom(), } } } diff --git a/src/frontend/components/spec/action-json.factory.ts b/src/frontend/components/spec/action-json.factory.ts index 43154453f..0c428306f 100644 --- a/src/frontend/components/spec/action-json.factory.ts +++ b/src/frontend/components/spec/action-json.factory.ts @@ -14,4 +14,5 @@ factory.define('ActionJSON', Object, { variant: 'default', parent: null, hasHandler: true, + custom: {}, }) diff --git a/src/frontend/interfaces/action/action-json.interface.ts b/src/frontend/interfaces/action/action-json.interface.ts index cb52b9b27..063c975b7 100644 --- a/src/frontend/interfaces/action/action-json.interface.ts +++ b/src/frontend/interfaces/action/action-json.interface.ts @@ -75,4 +75,10 @@ export interface ActionJSON { * @new in version 3.3 */ hasHandler: boolean; + + /** + * Any custom options passed from the {@link Action} configuration. + * @new in version 3.3 + */ + custom: Record; }