From d08f359542230962ce6da0dad7b8bb7f17188703 Mon Sep 17 00:00:00 2001 From: Carita Date: Thu, 8 Aug 2024 08:59:44 -0700 Subject: [PATCH] #2088 Render actions in title outside of groups (#2097) Signed-off-by: Carita Ou --- .../components/title-editor-test.js | 2 +- .../paramDefs/action_paramDef.json | 26 ++++++++++++------- .../src/common-properties/form/EditorForm.js | 4 +-- .../src/common-properties/form/Form.js | 10 ++++--- .../parameterDefs/action_paramDef.json | 26 ++++++++++++------- 5 files changed, 42 insertions(+), 26 deletions(-) diff --git a/canvas_modules/common-canvas/__tests__/common-properties/components/title-editor-test.js b/canvas_modules/common-canvas/__tests__/common-properties/components/title-editor-test.js index 8857e4d0ba..053de78ee4 100644 --- a/canvas_modules/common-canvas/__tests__/common-properties/components/title-editor-test.js +++ b/canvas_modules/common-canvas/__tests__/common-properties/components/title-editor-test.js @@ -420,7 +420,7 @@ describe("Title editor actions", () => { expect(buttons.length).to.equal(2); expect(buttons[0].textContent).to.equal("Increment"); - expect(buttons[1].textContent).to.equal("Decrement"); + expect(buttons[1].textContent).to.equal("Run"); fireEvent.click(buttons[0]); diff --git a/canvas_modules/common-canvas/__tests__/test_resources/paramDefs/action_paramDef.json b/canvas_modules/common-canvas/__tests__/test_resources/paramDefs/action_paramDef.json index d6934ecbae..99dd092380 100644 --- a/canvas_modules/common-canvas/__tests__/test_resources/paramDefs/action_paramDef.json +++ b/canvas_modules/common-canvas/__tests__/test_resources/paramDefs/action_paramDef.json @@ -158,7 +158,7 @@ "title_info": { "action_refs": [ "increment", - "decrement" + "run_action" ] }, "parameter_info": [ @@ -716,6 +716,14 @@ "width": 25 } } + }, + { + "id": "run_action", + "label": { + "resource_key": "run_action" + }, + "control": "button", + "data": {} } ], "group_info": [ @@ -918,7 +926,6 @@ "disable_image_text" ] } - ] }, { @@ -1010,8 +1017,6 @@ } } } - - ], "dataset_metadata": [ { @@ -1085,13 +1090,14 @@ "resources": { "increment": "Increment", "decrement": "Decrement", + "run_action": "Run", "dm-update": "Add Field", - "winter": "Winter", - "summer": "Summer", - "fall": "Fall", - "spring": "Spring", - "moon": "Moon", - "meteor": "Meteor", + "winter": "Winter", + "summer": "Summer", + "fall": "Fall", + "spring": "Spring", + "moon": "Moon", + "meteor": "Meteor", "weather.action.panel.label": "Weather action panel label", "weather.action.panel.desc": "Weather action panel description" } diff --git a/canvas_modules/common-canvas/src/common-properties/form/EditorForm.js b/canvas_modules/common-canvas/src/common-properties/form/EditorForm.js index 0161dffa36..67d3fd3f31 100644 --- a/canvas_modules/common-canvas/src/common-properties/form/EditorForm.js +++ b/canvas_modules/common-canvas/src/common-properties/form/EditorForm.js @@ -1,5 +1,5 @@ /* - * Copyright 2017-2023 Elyra Authors + * Copyright 2017-2024 Elyra Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -856,5 +856,5 @@ function _parameterValueDescription(parameter, l10nProvider) { export { - makePrimaryTab, _makeControl as makeControl + makePrimaryTab, _makeControl as makeControl, _makeActions as makeActions }; diff --git a/canvas_modules/common-canvas/src/common-properties/form/Form.js b/canvas_modules/common-canvas/src/common-properties/form/Form.js index 639915b3d6..d1e1db1fcd 100644 --- a/canvas_modules/common-canvas/src/common-properties/form/Form.js +++ b/canvas_modules/common-canvas/src/common-properties/form/Form.js @@ -1,5 +1,5 @@ /* - * Copyright 2017-2023 Elyra Authors + * Copyright 2017-2024 Elyra Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ import { PropertyDef } from "./PropertyDef"; import { propertyOf } from "lodash"; -import { makePrimaryTab } from "./EditorForm"; +import { makePrimaryTab, makeActions } from "./EditorForm"; import { UIItem } from "./UIItem"; import { L10nProvider } from "../util/L10nProvider"; import { translateMessages } from "./Conditions"; @@ -61,6 +61,10 @@ export default class Form { tabs.push(makePrimaryTab(propDef, group, l10nProvider, containerType)); } } + let titleActions = []; + if (propDef.titleMetadata && propDef.actionMetadata) { + titleActions = makeActions(null, propDef.actionMetadata, propDef.titleMetadata.Title, null, l10nProvider); + } const currentParameters = propertyOf(paramDef)("current_parameters"); const data = { @@ -76,7 +80,7 @@ export default class Form { propDef.help, propDef.editorSizeHint(editorSizeDefault), propDef.pixelWidth, - [UIItem.makePrimaryTabs(tabs)], + [UIItem.makePrimaryTabs(tabs)].concat(titleActions), _defaultButtons(), data, translateMessages(conditions, l10nProvider), diff --git a/canvas_modules/harness/test_resources/parameterDefs/action_paramDef.json b/canvas_modules/harness/test_resources/parameterDefs/action_paramDef.json index d6934ecbae..99dd092380 100644 --- a/canvas_modules/harness/test_resources/parameterDefs/action_paramDef.json +++ b/canvas_modules/harness/test_resources/parameterDefs/action_paramDef.json @@ -158,7 +158,7 @@ "title_info": { "action_refs": [ "increment", - "decrement" + "run_action" ] }, "parameter_info": [ @@ -716,6 +716,14 @@ "width": 25 } } + }, + { + "id": "run_action", + "label": { + "resource_key": "run_action" + }, + "control": "button", + "data": {} } ], "group_info": [ @@ -918,7 +926,6 @@ "disable_image_text" ] } - ] }, { @@ -1010,8 +1017,6 @@ } } } - - ], "dataset_metadata": [ { @@ -1085,13 +1090,14 @@ "resources": { "increment": "Increment", "decrement": "Decrement", + "run_action": "Run", "dm-update": "Add Field", - "winter": "Winter", - "summer": "Summer", - "fall": "Fall", - "spring": "Spring", - "moon": "Moon", - "meteor": "Meteor", + "winter": "Winter", + "summer": "Summer", + "fall": "Fall", + "spring": "Spring", + "moon": "Moon", + "meteor": "Meteor", "weather.action.panel.label": "Weather action panel label", "weather.action.panel.desc": "Weather action panel description" }