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

#2137 Enable right flyout resize using drag #2138

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
555828c
#2137 Increase View Size of Modeler Node Panel
srikant-ch5 Sep 3, 2024
1f5d309
Fix eslint build issue in properties-main.scss
srikant-ch5 Sep 3, 2024
b5fa39a
Include resizeComp inplace of resizeBtn
srikant-ch5 Sep 3, 2024
1149c5b
Remove editorSize test case in common-properties-test
srikant-ch5 Sep 3, 2024
71920eb
Include border-interactive on side panel drag hover
srikant-ch5 Sep 3, 2024
ecf21ef
Increase side border in accordion panels
srikant-ch5 Sep 3, 2024
d6b4035
Merge main
srikant-ch5 Sep 4, 2024
34ffea7
Implement Resizing in CC Right Flyout
srikant-ch5 Sep 5, 2024
af19cf5
Revert common properties test case changes
srikant-ch5 Sep 5, 2024
55d5765
Resolve Conflicts
srikant-ch5 Sep 11, 2024
66b4818
add limitWidth to CC Right Flyout
srikant-ch5 Sep 12, 2024
0baa3c0
Merge main
srikant-ch5 Sep 12, 2024
ddc8c53
Restore properties width
srikant-ch5 Sep 12, 2024
a195f49
Merge branch 'main' into 15709_DraggableFlyout
srikant-ch5 Sep 19, 2024
a1e70c1
Revert changes in cc for properties widths
srikant-ch5 Sep 20, 2024
5d042a2
Set min-width in properties-right-flyout to expand as per drag
srikant-ch5 Sep 20, 2024
242455d
Use the width scss variables in properties-main
srikant-ch5 Sep 23, 2024
23f3ec0
Merge branch 'main' into 15709_DraggableFlyout
srikant-ch5 Sep 26, 2024
fbc7d51
Merge branch 'main' into 15709_DraggableFlyout
tomlyn Sep 26, 2024
dd1e426
#2180 Upgrade to react-redux@8 (#2183)
tomlyn Sep 26, 2024
2f3f8b3
#2184 Add JSX decoration example to Stages sample application (#2185)
tomlyn Sep 26, 2024
3e87904
Merge branch 'main' into 15709_DraggableFlyout
srikant-ch5 Oct 1, 2024
99cb677
Merge branch 'main' into 15709_DraggableFlyout
srikant-ch5 Oct 7, 2024
7bb0db7
Merge branch 'main' into 15709_DraggableFlyout
matthoward366 Oct 8, 2024
c26142d
Include right flyout inside a container
srikant-ch5 Oct 9, 2024
b182f52
remove hardcoded color for test
srikant-ch5 Oct 9, 2024
40c14f5
Make Resize button appear over flyout drag
srikant-ch5 Oct 9, 2024
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 @@ -1618,6 +1618,10 @@ export default class CanvasController {
this.objectModel.setBottomPanelHeight(ht);
}

setRightPanelWidth(wdth) {
this.objectModel.setRightPanelWidth(wdth);
}

isTopPanelOpen() {
return this.getObjectModel().isTopPanelOpen();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class CommonCanvasPanels extends React.Component {
containingDivId={this.props.containingDivId}
/>
);
const rightFlyout = (<CommonCanvasRightFlyout />);
const rightFlyout = (<CommonCanvasRightFlyout containingDivId={this.props.containingDivId} canvasController={this.props.canvasController} />);
const leftFlyoutIsOpen = this.isLeftPanelOpen();
const leftFlyout = leftFlyoutIsOpen ? this.generateLeftFlyout() : null;

Expand Down
63 changes: 58 additions & 5 deletions canvas_modules/common-canvas/src/common-canvas/cc-right-flyout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,71 @@ import { connect } from "react-redux";
import PropTypes from "prop-types";
import Logger from "../logging/canvas-logger.js";

const MIN_WIDTH = 300;
const MAX_WIDTH_EXTEND_PERCENT = 0.7; // Should cover atmost 70% of available width
class CommonCanvasRightFlyout extends React.Component {
constructor(props) {
super(props);

this.logger = new Logger("CC-RightFlyout");

this.onMouseDown = this.onMouseDown.bind(this);
this.onMouseMoveX = this.onMouseMoveX.bind(this);
this.onMouseUp = this.onMouseUp.bind(this);
}

onMouseDown(e) {
if (e.button === 0) {
document.addEventListener("mousemove", this.onMouseMoveX, true);
document.addEventListener("mouseup", this.onMouseUp, true);
this.posX = e.clientX;
this.startWidth = this.commonCanvasRightFlyout.offsetWidth;

e.preventDefault();
}
}

onMouseUp() {
document.removeEventListener("mousemove", this.onMouseMoveX, true);
document.removeEventListener("mouseup", this.onMouseUp, true);
}

onMouseMoveX(e) {
if (e.clientX) {
const newWidth = this.startWidth + (this.posX - e.clientX);
this.commonCanvasRightFlyout.style.width = `${this.limitWidth(newWidth)}px`;
this.props.canvasController.setRightPanelWidth(newWidth);
}
}

limitWidth(wth) {
const canvasContainer = document.getElementById(this.props.containingDivId);
let width = wth;

if (canvasContainer) {
// Max Width should be 70% of the total available width (canvas + rightflyout)
const totalAvialableWidth = canvasContainer.getBoundingClientRect().width + this.commonCanvasRightFlyout.offsetWidth;
const maxWidth = MAX_WIDTH_EXTEND_PERCENT * totalAvialableWidth;
width = Math.min(Math.max(width, MIN_WIDTH), maxWidth);
}

return width;
}

render() {
this.logger.log("render");

let rightFlyout = <div />; // For no content, return empty <div> so grid siziing for parent <div> work correctly.

if (this.props.content && this.props.isOpen) {
const rfClass = this.props.enableRightFlyoutUnderToolbar
? "right-flyout-panel under-toolbar"
: "right-flyout-panel";
rightFlyout = (
<div className={rfClass}>
{this.props.content}
<div className="right-flyout-container" ref={ (ref) => (this.commonCanvasRightFlyout = ref) } >
<div className="right-flyout-resize-handle" onMouseDown={this.onMouseDown} />
<div className={rfClass}>
{this.props.content}
</div>
</div>
);
}
Expand All @@ -46,16 +93,22 @@ class CommonCanvasRightFlyout extends React.Component {
}

CommonCanvasRightFlyout.propTypes = {
// Provided by Common Canvas
canvasController: PropTypes.object,
containingDivId: PropTypes.string,

// Provided by Redux
isOpen: PropTypes.bool,
content: PropTypes.object,
enableRightFlyoutUnderToolbar: PropTypes.bool
enableRightFlyoutUnderToolbar: PropTypes.bool,
panelWidth: PropTypes.number
};

const mapStateToProps = (state, ownProps) => ({
isOpen: state.rightflyout.isOpen,
content: state.rightflyout.content,
enableRightFlyoutUnderToolbar: state.canvasconfig.enableRightFlyoutUnderToolbar
enableRightFlyoutUnderToolbar: state.canvasconfig.enableRightFlyoutUnderToolbar,
panelWidth: state.rightflyout.panelWidth
});

export default connect(mapStateToProps)(CommonCanvasRightFlyout);
21 changes: 21 additions & 0 deletions canvas_modules/common-canvas/src/common-canvas/common-canvas.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,39 @@ $panel-border-color: $border-subtle-01;
position: relative; // This allows the State Tag to have positio: absolute
}

.right-flyout-container {
display: flex;
border-left: $panel-border-width solid $panel-border-color;
:hover {
border-left: 0px;
}
}

.left-flyout-panel,
.right-flyout-panel {
// This combination of height and min-height enable scrolling in the child panel,
// I believe this is because it sets a specific height on the CSS grid cell,
// so the contents of the panel can adjust themselves to the height accordingly.
height: 0;
min-height: 100%;
min-width: 100%;

user-select: none; /* Prevent elements from being selectable */
background-color: $layer-01;
}

.right-flyout-resize-handle {
cursor: ew-resize;
flex: 0 0 $spacing-01;
border: $panel-border-color;
border-width: 1px;
background: $layer-01;
transition: all 0.2s ease-in;
&:hover {
background: $button-tertiary;
}
}

.bottom-panel {
display: flex;
flex-direction: column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import TitleEditor from "./../components/title-editor";
import classNames from "classnames";

import { injectIntl } from "react-intl";
import styles from "./properties-main-widths.scss";
import styles from "./properties-main-widths.module.scss";

const FLYOUT_WIDTH_SMALL = parseInt(styles.flyoutWidthSmall, 10);
const FLYOUT_WIDTH_MEDIUM = parseInt(styles.flyoutWidthMedium, 10);
Expand Down Expand Up @@ -88,6 +88,12 @@ class PropertiesMain extends React.Component {
showPropertiesButtons: true,
editorSize: editorSize
};
this.flyoutWidth = {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not seeing this being used. Am I missing something?

Copy link
Contributor Author

@srikant-ch5 srikant-ch5 Sep 23, 2024

Choose a reason for hiding this comment

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

This is being used in updateRightFlyoutWidth to enforce right-flyout-panel width.

small: FLYOUT_WIDTH_SMALL,
medium: FLYOUT_WIDTH_MEDIUM,
large: FLYOUT_WIDTH_LARGE,
max: FLYOUT_WIDTH_MAX
};
this.applyPropertiesEditing = this.applyPropertiesEditing.bind(this);
this.showPropertiesButtons = this.showPropertiesButtons.bind(this);
this.updateEditorSize = this.updateEditorSize.bind(this);
Expand All @@ -96,6 +102,7 @@ class PropertiesMain extends React.Component {
this._getResizeButton = this._getResizeButton.bind(this);
this._isResizeButtonRequired = this._isResizeButtonRequired.bind(this);
this.onBlur = this.onBlur.bind(this);
this.updateRightFlyoutWidth = this.updateRightFlyoutWidth.bind(this);
}

componentDidMount() {
Expand Down Expand Up @@ -420,11 +427,19 @@ class PropertiesMain extends React.Component {
this.setState({ showPropertiesButtons: state });
}

updateRightFlyoutWidth(size) {
Copy link
Member

Choose a reason for hiding this comment

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

This seems like the wrong place for setting this. Why is this needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we are trying to implement resize in cc-right-flyout which will resize right-flyout-panel as per drag width. So when we click on panel resize it will only resize the common properties content and will not expand/shrink the right-flyout-panel so to enforce width on CC right-flyout I have included this. Please let me know if you can suggest another way of doing this.

Without enforcing width to right-flyout in properties it will look something like below, where the properties content width is set as per custom classnames but flyout width is not reset.

Screenshot 2024-09-23 at 12 19 42 PM

Also could you please where can I find any reference to feature flag in the code ?

const element = document.querySelector(".right-flyout-container");
if (element) {
element.style.width = `${this.flyoutWidth[size]}px`;
}
}

updateEditorSize(newEditorSize) {
this.setState({
editorSize: newEditorSize
});
this.propertiesController.setEditorSize(newEditorSize);
this.updateRightFlyoutWidth(newEditorSize);
}

resize() {
Expand Down Expand Up @@ -493,6 +508,7 @@ class PropertiesMain extends React.Component {
showPropertiesButtons={this.state.showPropertiesButtons}
disableSaveOnRequiredErrors={this.props.propertiesConfig.disableSaveOnRequiredErrors}
/>);

if (this._isResizeButtonRequired()) {
const resizeIcon = this._getResizeButton();
// Resize button label can be "Expand" or "Contract"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
* limitations under the License.
*/

@import "./properties-main-widths.scss";
@import "./properties-main-widths.module.scss";
$properties-modal-buttons-height: $spacing-10;
$properties-resize-button-size: $spacing-06;

.properties-right-flyout {
// Set the font explicitly to 14px to shrink them across the entire properties editor
font-size: 14px;
width: 0;
min-width: 100%;
height: 100%;
overflow: hidden;
border-left: 1px solid $layer-accent-01;
outline: none;
display: flex;
flex-direction: column;
position: relative;
transition: motion(entrance, expressive) $duration-moderate-01;

&.properties-small {
Expand Down
4 changes: 4 additions & 0 deletions canvas_modules/common-canvas/src/object-model/object-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,10 @@ export default class ObjectModel {
this.store.dispatch({ type: "SET_BOTTOM_PANEL_CONFIG", data: { config: { panelHeight: ht } } });
}

setRightPanelWidth(wdth) {
this.store.dispatch({ type: "SET_RIGHT_FLYOUT_WIDTH", data: { config: { panelWidth: wdth } } });
}

// ---------------------------------------------------------------------------
// Top panel methods
// ---------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ export default (state = {}, action) => {
return state;
}

case "SET_RIGHT_FLYOUT_WIDTH": {
if (action.data.config.panelWidth) {
return {
...state,
panelWidth: action.data.config.panelWidth
};
}
return state;
}

default:
return state;
}
Expand Down
Loading