Skip to content

Commit

Permalink
#1181 Allow primary panels to be hidden (#1182)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthoward366 authored Sep 16, 2022
1 parent 9d4d72e commit 91e9a1b
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1113,3 +1113,28 @@ describe("complex nested panels visible and enabled conditions work correctly",
expect(controller.getPanelState({ name: "init1level3control" })).to.equal("enabled");
});
});


describe("Primary panel conditions work correctly", () => {
let wrapper;
let controller;
beforeEach(() => {
const renderedObject = propertyUtils.flyoutEditorForm(panelConditionsParamDef);
wrapper = renderedObject.wrapper;
controller = renderedObject.controller;
});

afterEach(() => {
wrapper.unmount();
});

it("Primary panel can be hidden", () => {
let textPanel = wrapper.find("div[data-id='properties-text-panels']");
expect(textPanel).to.have.length(1);
controller.updatePropertyValue({ name: "hideTextPanels" }, true);
wrapper.update();
textPanel = wrapper.find("div[data-id='properties-text-panels']");
expect(textPanel).to.have.length(0);
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe("text panel visible and enabled conditions work correctly", () => {
beforeEach(() => {
const renderedObject = propertyUtils.flyoutEditorForm(panelConditionsParamDef);
wrapper = renderedObject.wrapper;
const textPanelcategory = wrapper.find("div.properties-category-container").at(1); // TEXT PANEL category
const textPanelcategory = wrapper.find("div.properties-category-container").at(2); // TEXT PANEL category
panels = textPanelcategory.find("div.properties-text-panel");
controller = renderedObject.controller;
});
Expand All @@ -89,7 +89,8 @@ describe("text panel visible and enabled conditions work correctly", () => {

it("text panel should be disabled", () => {
expect(panels).to.have.length(2);
expect(controller.getPanelState({ name: "orange-panel" })).to.equal("enabled");
// initially set to visible since there is a primary panel hidden condition
expect(controller.getPanelState({ name: "orange-panel" })).to.equal("visible");
controller.updatePropertyValue({ name: "disableTextPanel" }, true);
expect(controller.getPanelState({ name: "orange-panel" })).to.equal("disabled");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe("twisty panel classNames applied correctly", () => {
});

it("text panel should have custom classname defined", () => {
const twistyPanelcategory = wrapper.find("div.properties-category-container").at(5); // TWISTY PANEL category
const twistyPanelcategory = wrapper.find("div.properties-category-container").at(6); // TWISTY PANEL category
expect(twistyPanelcategory.find(".twisty-panel1-group-twistypanel-class")).to.have.length(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"current_parameters": {
"disableTextPanel": false,
"hideTextPanel": false,
"hideTextPanels": false,
"disablePanelSelector": true,
"fruit-color1": "red1",
"hidePanelSelector": true,
Expand Down Expand Up @@ -92,6 +93,10 @@
"id": "hideTextPanel",
"type": "boolean"
},
{
"id": "hideTextPanels",
"type": "boolean"
},
{
"id": "disablePanelSelector",
"type": "boolean"
Expand Down Expand Up @@ -401,6 +406,15 @@
"default": "Hide Apples text panel"
}
},
{
"parameter_ref": "hideTextPanels",
"label": {
"default": "Hide Text Panels"
},
"description": {
"default": "Hides Text Panels primary panel"
}
},
{
"parameter_ref": "disablePanelSelector",
"label": {
Expand Down Expand Up @@ -953,6 +967,15 @@
}
],
"group_info": [
{
"id": "primary-panel-condition",
"label": {
"default": "Primary Panel Condition"
},
"parameter_refs": [
"hideTextPanels"
]
},
{
"id": "text-panels",
"label": {
Expand Down Expand Up @@ -1629,6 +1652,20 @@
}
}
},
{
"visible": {
"group_refs": [
"text-panels"
],
"evaluate": {
"condition": {
"parameter_ref": "hideTextPanels",
"op": "equals",
"value": false
}
}
}
},
{
"enabled": {
"parameter_refs": [
Expand Down
2 changes: 1 addition & 1 deletion canvas_modules/common-canvas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"eslint-config-canvas": "file:../eslint-config-canvas",
"eslint-plugin-import": "2.25.3",
"eslint-plugin-react": "7.21.2",
"grunt": "1.3.0",
"grunt": "1.5.3",
"grunt-contrib-clean": "2.0.0",
"grunt-contrib-sass": "2.0.0",
"grunt-env": "1.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { connect } from "react-redux";
import { setActiveTab } from "./../../actions";
import { Tab, Tabs } from "carbon-components-react";
import * as PropertyUtil from "./../../util/property-utils";
import { MESSAGE_KEYS, CARBON_ICONS, CONDITION_MESSAGE_TYPE } from "./../../constants/constants";
import { MESSAGE_KEYS, CARBON_ICONS, CONDITION_MESSAGE_TYPE, STATES } from "./../../constants/constants";
import { cloneDeep, isEmpty, sortBy, get } from "lodash";
import logger from "./../../../../utils/logger";
import classNames from "classnames";
Expand All @@ -39,7 +39,7 @@ import TextPanel from "./../../panels/text-panel";
import ActionPanel from "./../../panels/action-panel";

import ActionFactory from "./../../actions/action-factory";
import Icon from "./../../../icons/icon.jsx";
import Icon from "./../../../icons/icon";

const ALERT_TAB_GROUP = "alertMsgs";

Expand Down Expand Up @@ -128,8 +128,13 @@ class EditorForm extends React.Component {
const tabContent = [];
let hasAlertsTab = false;
let modalSelected = 0;
for (var i = 0; i < tabs.length; i++) {

for (let i = 0; i < tabs.length; i++) {
const tab = tabs[i];
const tabState = this.props.controller.getPanelState({ name: tab.group });
if (tabState === STATES.HIDDEN) {
continue;
}
if (i === 0 && tab.group === ALERT_TAB_GROUP) {
hasAlertsTab = true;
}
Expand Down
4 changes: 2 additions & 2 deletions canvas_modules/harness/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"js-file-download": "0.4.12",
"lodash": "4.17.21",
"log4js": "6.4.1",
"nconf": "0.10.0"
"nconf": "0.12.0"
},
"devDependencies": {
"@babel/core": "7.11.6",
Expand Down Expand Up @@ -52,7 +52,7 @@
"eslint-plugin-cypress": "2.11.1",
"eslint-plugin-react": "7.21.2",
"file-loader": "6.1.0",
"grunt": "1.3.0",
"grunt": "1.5.3",
"grunt-contrib-clean": "2.0.0",
"grunt-contrib-copy": "1.0.0",
"grunt-env": "1.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"current_parameters": {
"disableTextPanel": false,
"hideTextPanel": false,
"hideTextPanels": false,
"disablePanelSelector": true,
"fruit-color1": "red1",
"hidePanelSelector": true,
Expand Down Expand Up @@ -92,6 +93,10 @@
"id": "hideTextPanel",
"type": "boolean"
},
{
"id": "hideTextPanels",
"type": "boolean"
},
{
"id": "disablePanelSelector",
"type": "boolean"
Expand Down Expand Up @@ -401,6 +406,15 @@
"default": "Hide Apples text panel"
}
},
{
"parameter_ref": "hideTextPanels",
"label": {
"default": "Hide Text Panels"
},
"description": {
"default": "Hides Text Panels primary panel"
}
},
{
"parameter_ref": "disablePanelSelector",
"label": {
Expand Down Expand Up @@ -953,6 +967,15 @@
}
],
"group_info": [
{
"id": "primary-panel-condition",
"label": {
"default": "Primary Panel Condition"
},
"parameter_refs": [
"hideTextPanels"
]
},
{
"id": "text-panels",
"label": {
Expand Down Expand Up @@ -1629,6 +1652,20 @@
}
}
},
{
"visible": {
"group_refs": [
"text-panels"
],
"evaluate": {
"condition": {
"parameter_ref": "hideTextPanels",
"op": "equals",
"value": false
}
}
}
},
{
"enabled": {
"parameter_refs": [
Expand Down

0 comments on commit 91e9a1b

Please sign in to comment.