Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2256 Add ability to display text description next to heading label #2263

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6932f32
#2256 Add ability to display text description next to heading label
srikant-ch5 Dec 4, 2024
2666aea
Merge branch 'main' into Action-Image-Align
srikant-ch5 Dec 4, 2024
c3379c6
Merge branch 'main' into Action-Image-Align
srikant-ch5 Dec 6, 2024
54294aa
Include classname change
srikant-ch5 Dec 6, 2024
a0c3e38
Include changes in paramDef
srikant-ch5 Dec 6, 2024
0aebd18
Merge branch 'main' into Action-Image-Align
srikant-ch5 Dec 6, 2024
d97e731
Include description in Form
srikant-ch5 Dec 10, 2024
06f9714
Include description object
srikant-ch5 Dec 18, 2024
e53c03a
Merge branch 'main' into Action-Image-Align
srikant-ch5 Dec 18, 2024
c7beac5
Merge branch 'main' into Action-Image-Align
srikant-ch5 Jan 3, 2025
62cc2e9
Include renderTooltip function to show tooltip with link based on des…
srikant-ch5 Jan 6, 2025
9fc9962
Merge branch 'main' into Action-Image-Align
srikant-ch5 Jan 6, 2025
8214c5f
Merge branch 'main' into Action-Image-Align
srikant-ch5 Jan 7, 2025
a82ebe1
Change renderTootlip as per conditions
srikant-ch5 Jan 8, 2025
e532200
Merge branch 'main' into Action-Image-Align
srikant-ch5 Jan 8, 2025
cff31e2
Refactor title-editor code and include tests and include showHeadingD…
srikant-ch5 Jan 8, 2025
697784a
Update description text in Form
srikant-ch5 Jan 8, 2025
30b7f47
Fix test cases
srikant-ch5 Jan 8, 2025
be033c1
uncomment test cases
srikant-ch5 Jan 8, 2025
762748b
fix test case 2
srikant-ch5 Jan 8, 2025
cc18701
Merge branch 'main' into Action-Image-Align
srikant-ch5 Jan 13, 2025
ef729d2
Fix ui issues
srikant-ch5 Jan 13, 2025
a2b0edb
Update Help button label
srikant-ch5 Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import { MESSAGE_KEYS, CONDITION_MESSAGE_TYPE } from "./../../constants/constant
import * as PropertyUtils from "./../../util/property-utils";
import ActionFactory from "../../actions/action-factory.js";

import Tooltip from "../../../tooltip/tooltip.jsx";
import Icon from "../../../icons/icon.jsx";
import { CARBON_ICONS } from "./../../constants/constants";


class TitleEditor extends Component {
constructor(props) {
Expand Down Expand Up @@ -136,20 +140,71 @@ class TitleEditor extends Component {
iconDescription={propertiesTitleEditButtonLabel}
hasIconOnly
/>);
let tooltip = "";
if (this.props.description) {
tooltip = (
<span>{this.props.description.default}</span>
);
}
if (this.props.description?.link) {
this.props.description.link.propertyId = { name: "number" };
}
let helpButton = null;

const helpButton = this.props.help
? (<Button
kind="ghost"
className="properties-title-editor-btn help"
data-id="help"
onClick={this.helpClickHandler}
tooltipPosition="bottom"
renderIcon={Help}
size="sm"
iconDescription={helpButtonLabel}
hasIconOnly
/>)
: null;
// If headingDesc config is enabled show tooltip with link beside heading
const renderTooltip = () => {
if (this.props.showHeadingDesc && this.props.description) {
const { description, controller } = this.props;
const { link } = description;
const tooltipLinkHandler = controller.getHandlers().tooltipLinkHandler;

return (
<span className="properties-heading-icon">
<Tooltip
id={"properties-title-tooltip" + this.id}
tip={tooltip}
link={link || null}
tooltipLinkHandler={tooltipLinkHandler}
direction="bottom"
className="properties-title-tooltip"
showToolTipOnClick
>
<Icon type={CARBON_ICONS.INFORMATION} className="properties-control-description-icon-info" />
</Tooltip>
</span>
);
}

return null;
};

const renderHelpButton = () => {
const { help } = this.props;

if (help) {
return (
<Button
kind="ghost"
className="properties-title-editor-btn help"
data-id="help"
onClick={this.helpClickHandler}
tooltipPosition="bottom"
renderIcon={Help}
size="sm"
iconDescription={helpButtonLabel}
hasIconOnly
/>
);
}

return null;
};

if (this.props.showHeadingDesc) {
helpButton = renderTooltip();
} else {
helpButton = renderHelpButton();
}

const closeButton = this.props.closeHandler
? (<div className="properties-close-button">
Expand Down Expand Up @@ -239,8 +294,10 @@ TitleEditor.propTypes = {
icon: PropTypes.string,
heading: PropTypes.string,
showHeading: PropTypes.bool,
showHeadingDesc: PropTypes.bool,
rightFlyoutTabsView: PropTypes.bool,
titleInfo: PropTypes.object,
description: PropTypes.object,
title: PropTypes.string, // set by redux
setTitle: PropTypes.func // set by redux
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
margin-left: $spacing-02; // spacing between heading label and help button
}
}
.properties-heading-icon {
position: relative;
margin: 0 0 0 $spacing-04;
}
}
.properties-title-editor-input {
width: calc(100% - #{$spacing-03}); // subtract 8px to align with Close icon when applyOnBlur is set
Expand Down Expand Up @@ -152,3 +156,15 @@
justify-content: center;
padding: 0;
}

.properties-heading-icon {
position: absolute;
margin: $spacing-03 0 0 $spacing-03;
}

.properties-title-editor {
.tooltip-container {
height: $spacing-05;
cursor: pointer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ import { UIItem } from "./UIItem";
import { L10nProvider } from "../util/L10nProvider";
import { translateMessages } from "./Conditions";
import { Size } from "../constants/form-constants";
import { ResourceDef } from "../util/L10nProvider";
import { CONTAINER_TYPE } from "../constants/constants";

export default class Form {
constructor(componentId, label, labelEditable, help, editorSize, pixelWidth, uiItems, buttons, data, conditions, resources, icon, heading, title, titleUiItems) {
constructor(componentId, label, labelEditable, help, description, editorSize, pixelWidth, uiItems, buttons, data, conditions, resources, icon, heading, title, titleUiItems) {
this.componentId = componentId;
this.label = label;
this.labelEditable = labelEditable;
this.help = help;
this.description = ResourceDef.make(description);
this.editorSize = editorSize;
this.pixelWidth = pixelWidth;
this.uiItems = uiItems;
Expand Down Expand Up @@ -81,6 +83,7 @@ export default class Form {
propDef.label,
propDef.labelEditable,
propDef.help,
propDef.description,
propDef.editorSizeHint(editorSizeDefault),
propDef.pixelWidth,
[UIItem.makePrimaryTabs(tabs)],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,14 @@ class PropertiesMain extends React.Component {
propertiesTitle = (<TitleEditor
labelEditable={formData.labelEditable}
help={formData.help}
description={formData.description}
controller={this.propertiesController}
helpClickHandler={this.props.callbacks.helpClickHandler}
closeHandler={applyOnBlurEnabled ? this.applyPropertiesEditing.bind(this, true) : null}
icon={formData.icon}
heading={formData.heading}
showHeading={this.props.propertiesConfig.heading}
showHeadingDesc={this.props.propertiesConfig.headingDesc}
srikant-ch5 marked this conversation as resolved.
Show resolved Hide resolved
titleInfo={formData.title}
rightFlyoutTabsView={this.props.propertiesConfig.categoryView === CATEGORY_VIEW.TABS}
/>);
Expand Down Expand Up @@ -666,6 +668,7 @@ PropertiesMain.propTypes = {
conditionReturnValueHandling: PropTypes.string,
returnValueFiltering: PropTypes.array,
heading: PropTypes.bool,
headingDesc: PropTypes.bool,
buttonLabels: PropTypes.shape({
primary: PropTypes.string,
secondary: PropTypes.string
Expand Down
3 changes: 3 additions & 0 deletions canvas_modules/harness/src/client/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class App extends React.Component {
trimSpaces: true,
displayAdditionalComponents: false,
heading: false,
headingDesc: false,
light: true,
lightTheme: false,
showRequiredIndicator: true,
Expand Down Expand Up @@ -2072,6 +2073,7 @@ class App extends React.Component {
disableSaveOnRequiredErrors: this.state.disableSaveOnRequiredErrors,
trimSpaces: this.state.trimSpaces,
heading: this.state.heading,
headingDesc: this.state.headingDesc,
showRequiredIndicator: this.state.showRequiredIndicator,
showAlertsTab: this.state.showAlertsTab,
enableResize: this.state.enableResize,
Expand Down Expand Up @@ -2511,6 +2513,7 @@ class App extends React.Component {
expressionBuilder: this.state.expressionBuilder,
displayAdditionalComponents: this.state.displayAdditionalComponents,
heading: this.state.heading,
headingDesc: this.state.headingDesc,
light: this.state.light,
showRequiredIndicator: this.state.showRequiredIndicator,
showAlertsTab: this.state.showAlertsTab,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"trimSpaces": true,
"displayAdditionalComponents": false,
"heading": false,
"headingDesc": false,
"light": true,
"showRequiredIndicator": true,
"showAlertsTab": true,
Expand Down Expand Up @@ -105,6 +106,11 @@
"default": false,
"type": "boolean"
},
{
"id": "headingDesc",
"default": false,
"type": "boolean"
},
{
"id": "light",
"default": false,
Expand Down Expand Up @@ -340,6 +346,16 @@
},
"control": "toggle"
},
{
"parameter_ref": "headingDesc",
"label": {
"default": "headingDesc"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the label to showHeadingDesc. Label should match with the config option.

},
"description": {
"default": "Show panel heading description"
},
"control": "toggle"
},
{
"parameter_ref": "light",
"label": {
Expand Down Expand Up @@ -713,6 +729,7 @@
"disableSaveOnRequiredErrors",
"trimSpaces",
"heading",
"headingDesc",
"showRequiredIndicator",
"showAlertsTab",
"enableResize",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export default class SidePanelProperties extends React.Component {
"trimSpaces": this.props.propertiesConfig.trimSpaces,
"displayAdditionalComponents": this.props.propertiesConfig.displayAdditionalComponents,
"heading": this.props.propertiesConfig.heading,
"headingDesc": this.props.propertiesConfig.headingDesc,
"light": this.props.propertiesConfig.light,
"showRequiredIndicator": this.props.propertiesConfig.showRequiredIndicator,
"showAlertsTab": this.props.propertiesConfig.showAlertsTab,
Expand Down Expand Up @@ -332,6 +333,7 @@ SidePanelProperties.propTypes = {
expressionBuilder: PropTypes.bool,
displayAdditionalComponents: PropTypes.bool,
heading: PropTypes.bool,
headingDesc: PropTypes.bool,
light: PropTypes.bool,
showRequiredIndicator: PropTypes.bool,
showAlertsTab: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,15 @@
]
}
],
"description": {
"default": "Readonly description",
"link": {
srikant-ch5 marked this conversation as resolved.
Show resolved Hide resolved
"id": "link_for_description",
"data": {
"something": "option data"
}
}
},
"help": {
"data": {
"url": "randomUrl"
Expand Down
Loading