From 7f13cb935915b158cd1009d7118119f58594729b Mon Sep 17 00:00:00 2001 From: Neha Gokhale Date: Mon, 27 Nov 2023 09:59:53 -0800 Subject: [PATCH] #1629 Added getTopLevelActiveGroupId() method in properties controller Signed-off-by: Neha Gokhale --- .../properties-controller-test.js | 18 ++++++++++++++++++ .../common-properties/properties-controller.js | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/canvas_modules/common-canvas/__tests__/common-properties/properties-controller-test.js b/canvas_modules/common-canvas/__tests__/common-properties/properties-controller-test.js index d691c968ae..f6abedbd7f 100644 --- a/canvas_modules/common-canvas/__tests__/common-properties/properties-controller-test.js +++ b/canvas_modules/common-canvas/__tests__/common-properties/properties-controller-test.js @@ -2294,3 +2294,21 @@ describe("Properties Controller setWideFlyoutPrimaryButtonDisabled", () => { expect(controller.getWideFlyoutPrimaryButtonDisabled(summaryPanelId)).to.be.false; }); }); + +describe("Properties Controller getTopLevelActiveGroupId", () => { + it("should get the top level active group id in properties controller", () => { + reset(); + const renderedObject = testUtils.flyoutEditorForm(checkboxsetParamDef); + controller = renderedObject.controller; + const wrapper = renderedObject.wrapper; + let topLevelActiveGroupId = controller.getTopLevelActiveGroupId(); + expect(topLevelActiveGroupId).to.equal("checkboxset-values"); + + // Select Conditions accordion + const conditionsCategory = wrapper.find("div.properties-category-container").at(1); + conditionsCategory.find("button.properties-category-title").simulate("click"); + topLevelActiveGroupId = controller.getTopLevelActiveGroupId(); + expect(topLevelActiveGroupId).to.equal("checkboxset-conditions"); + + }); +}); diff --git a/canvas_modules/common-canvas/src/common-properties/properties-controller.js b/canvas_modules/common-canvas/src/common-properties/properties-controller.js index 8b0190d4af..121d0f5913 100644 --- a/canvas_modules/common-canvas/src/common-properties/properties-controller.js +++ b/canvas_modules/common-canvas/src/common-properties/properties-controller.js @@ -131,6 +131,11 @@ export default class PropertiesController { return get(this.propertiesConfig, "locale", DEFAULT_LOCALE); } + // Return the id of top-level active tab or accordion + getTopLevelActiveGroupId() { + return this.propertiesStore.getActiveTab(); + } + isTearsheetContainer() { return this.propertiesConfig.containerType === "Tearsheet"; }