Skip to content

Commit

Permalink
#806 Support bottom panel that appears between the paletter and right… (
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlyn authored Oct 8, 2021
1 parent 23c9447 commit cfc605c
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ export default class CanvasController {
this.objectModel.setRightFlyoutConfig(config);
}

setBottomPanelConfig(config) {
this.logger.log("Setting Bottom Panel Config");
this.objectModel.setBottomPanelConfig(config);
}

setContextMenuConfig(contextMenuConfig) {
this.logger.log("Setting Context Menu Config");
this.contextMenuConfig = Object.assign(this.contextMenuConfig, contextMenuConfig);
Expand Down
100 changes: 100 additions & 0 deletions canvas_modules/common-canvas/src/common-canvas/cc-bottom-panel.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Copyright 2017-2020 Elyra Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* eslint no-shadow: ["error", { "allow": ["Node", "Comment"] }] */

import React from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { injectIntl } from "react-intl";
import Logger from "../logging/canvas-logger.js";

class CanvasBottomPanel extends React.Component {
constructor(props) {
super(props);

this.state = {
panelHeight: 393
};

this.resizing = false;
this.logger = new Logger("CC-Bottom-Panel");

this.startResize = this.startResize.bind(this);
this.stopResize = this.stopResize.bind(this);
this.resize = this.resize.bind(this);
}

componentDidMount() {
// document.addEventListener("mouseup", this.stopResize, true);
}

componentWillUnmount() {
// document.removeEventListener("mouseup", this.stopResize, true);
}

startResize(evt) {
this.resizing = true;
}

stopResize(evt) {
this.resizing = false;
}

resize(evt) {
if (this.resizing) {
this.setState({ "panelHeight": this.state.panelHeight + evt.movementY });
}
}

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

let bottomPanel = null;

const styleObj = {
height: this.state.panelHeight + "px"
// transition: transitionVariable,
};

if (this.props.bottomPanelIsOpen) {
bottomPanel = (
<div className={"bottom-panel"} style={styleObj}>
{this.props.bottomPanelContent}
</div>
);
}

return bottomPanel;
}
}

CanvasBottomPanel.propTypes = {
// Provided by CommonCanvas
intl: PropTypes.object.isRequired,
canvasController: PropTypes.object.isRequired,

// Provided by Redux
bottomPanelIsOpen: PropTypes.bool,
bottomPanelContent: PropTypes.object
};

const mapStateToProps = (state, ownProps) => ({
bottomPanelIsOpen: state.bottompanel.isOpen,
bottomPanelContent: state.bottompanel.content
});

export default connect(mapStateToProps)(injectIntl(CanvasBottomPanel));
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import PropTypes from "prop-types";
import CanvasContents from "./cc-contents.jsx";
import CommonCanvasToolbar from "./cc-toolbar.jsx";
import CommonCanvasRightFlyout from "./cc-right-flyout.jsx";
import CanvasBottomPanel from "./cc-bottom-panel.jsx";
import NotificationPanel from "../notification-panel/notification-panel.jsx";
import Logger from "../logging/canvas-logger.js";

Expand All @@ -36,15 +37,21 @@ class CommonCanvasCentralItems extends React.Component {
const canvasToolbar = (<CommonCanvasToolbar canvasController={this.props.canvasController} />);
const notificationPanel = (<NotificationPanel canvasController={this.props.canvasController} />);
const canvasContents = (<CanvasContents canvasController={this.props.canvasController} containingDivId={this.props.containingDivId} />);
const bottomPanel = (<CanvasBottomPanel canvasController={this.props.canvasController} />);

let centralItems = null;
if (this.props.enableRightFlyoutUnderToolbar) {
centralItems = (
<div className="common-canvas-right-side-items-under-toolbar">
{canvasToolbar}
<div id={this.props.containingDivId} className="common-canvas-items-container-under-toolbar">
{canvasContents}
{rightFlyout}
<div className="common-canvas-with-bottom-panel">
{canvasContents}
{bottomPanel}
</div>
<div>
{rightFlyout}
</div>
{notificationPanel}
</div>
</div>
Expand All @@ -56,6 +63,7 @@ class CommonCanvasCentralItems extends React.Component {
<div id={this.props.containingDivId} className="common-canvas-items-container">
{canvasToolbar}
{canvasContents}
{bottomPanel}
{notificationPanel}
</div>
{rightFlyout}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ class CanvasContents extends React.Component {
? dropDivClassName + " common-canvas-toolbar-none"
: dropDivClassName;

dropDivClassName = this.props.bottomPanelIsOpen
? dropDivClassName + " common-canvas-bottom-panel-is-open"
: dropDivClassName;

return (
<main aria-label={this.getLabel("canvas.label")} role="main" className={mainClassName}>
<ReactResizeDetector handleWidth handleHeight onResize={this.refreshOnSizeChange}>
Expand Down Expand Up @@ -398,12 +402,14 @@ CanvasContents.propTypes = {

// Provided by Redux
canvasConfig: PropTypes.object.isRequired,
canvasInfo: PropTypes.object
canvasInfo: PropTypes.object,
bottomPanelIsOpen: PropTypes.bool
};

const mapStateToProps = (state, ownProps) => ({
canvasInfo: state.canvasinfo,
canvasConfig: state.canvasconfig,
bottomPanelIsOpen: state.bottompanel.isOpen,
// These two fields are included here so they will trigger a render.
// The renderer will retrieve the data for them by calling the canvas controller.
selectionInfo: state.selectioninfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class CommonCanvas extends React.Component {
props.canvasController.setNotificationPanelConfig(props.notificationConfig);
props.canvasController.setRightFlyoutConfig(
{ content: props.rightFlyoutContent, isOpen: props.showRightFlyout });
props.canvasController.setBottomPanelConfig(
{ content: props.bottomPanelContent, isOpen: props.showBottomPanel });

props.canvasController.setHandlers({
contextMenuHandler: props.contextMenuHandler,
Expand Down Expand Up @@ -127,7 +129,9 @@ CommonCanvas.propTypes = {
idGeneratorHandler: PropTypes.func,
selectionChangeHandler: PropTypes.func,
rightFlyoutContent: PropTypes.object,
showRightFlyout: PropTypes.bool
showRightFlyout: PropTypes.bool,
bottomPanelContent: PropTypes.object,
showBottomPanel: PropTypes.bool
};

export default injectIntl(CommonCanvas);
35 changes: 31 additions & 4 deletions canvas_modules/common-canvas/src/common-canvas/common-canvas.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

@import "carbon-components/scss/globals/scss/_vars";
$toolbar-button-height: 41px; // Allow one extra pixel for the toolbar border
$bottom-panel-height: 393px;

/* Default layout for common-canvas components where the canvas appears below
* the toolbar and right-side flyout appears to the right of the toolbar and
Expand Down Expand Up @@ -50,6 +51,11 @@ $toolbar-button-height: 41px; // Allow one extra pixel for the toolbar border
height: 100%;
}

.common-canvas-with-bottom-panel {
width: 100%;
position: relative;
}

.common-canvas-drop-div {
height: calc(100% - #{$toolbar-button-height});
width: 100%;
Expand All @@ -58,17 +64,37 @@ $toolbar-button-height: 41px; // Allow one extra pixel for the toolbar border
cursor: default;
top: $toolbar-button-height;
overflow: hidden;
}

.common-canvas-drop-div.common-canvas-toolbar-none {
height: 100%;
top: 0;
&.common-canvas-bottom-panel-is-open {
height: calc(100% - #{$toolbar-button-height} - #{$bottom-panel-height});
}

&.common-canvas-toolbar-none {
height: 100%;
top: 0;
}

&.common-canvas-toolbar-none.common-canvas-bottom-panel-is-open {
height: calc(100% - #{$toolbar-button-height} - #{$bottom-panel-height});
top: 0;
}
}

.right-flyout-panel {
height: 100%;
position: relative;
user-select: none; /* Prevent elements from being selectable */
background-color: $ui-01;
}

.bottom-panel {
position: absolute;
bottom: 0;
width: 100%;
height: $bottom-panel-height;
user-select: none; /* Prevent elements from being selectable */
background-color: $ui-01;
border-top: $palette-border-width solid $palette-border-color;
}

/* Alternative layout for common-canvas components where canvas and right-side
Expand Down Expand Up @@ -173,4 +199,5 @@ $toolbar-button-height: 41px; // Allow one extra pixel for the toolbar border
&.info > svg > .dot {
fill: $support-04;
}

}
12 changes: 12 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 @@ -1399,6 +1399,18 @@ export default class ObjectModel {
return this.store.isRightFlyoutOpen();
}

// ---------------------------------------------------------------------------
// Bottom panel methods
// ---------------------------------------------------------------------------

setBottomPanelConfig(config) {
this.store.dispatch({ type: "SET_BOTTOM_PANEL_CONFIG", data: { config: config } });
}

isBottomPanelOpen() {
return this.store.isBottomPanelOpen();
}

// ---------------------------------------------------------------------------
// Selection methods
// ---------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import palette from "./reducers/palette.js";
import canvasinfo from "./reducers/canvasinfo.js";
import contextmenu from "./reducers/contextmenu.js";
import rightflyout from "./reducers/rightflyout.js";
import bottompanel from "./reducers/bottompanel.js";
import breadcrumbs from "./reducers/breadcrumbs.js";
import canvasconfig from "./reducers/canvasconfig.js";
import canvastoolbar from "./reducers/canvastoolbar.js";
Expand All @@ -50,7 +51,8 @@ export default class CanavasStore {
tooltip,
canvastoolbar,
contextmenu,
rightflyout
rightflyout,
bottompanel
});

const initialState = {
Expand All @@ -65,7 +67,8 @@ export default class CanavasStore {
tooltip: {},
canvastoolbar: {},
contextmenu: { menuDef: [] },
rightflyout: {}
rightflyout: {},
bottompanel: {}
};

let enableDevTools = false;
Expand Down Expand Up @@ -132,6 +135,10 @@ export default class CanavasStore {
return this.store.getState().rightflyout.isOpen;
}

isBottomPanelOpen() {
return this.store.getState().bottompanel.isOpen;
}

getNotificationPanel() {
return this.copyData(this.store.getState().notificationpanel);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2021 Elyra Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export default (state = {}, action) => {
switch (action.type) {
case "SET_BOTTOM_PANEL_CONFIG": {
if (action.data.config) {
return {
content: action.data.config.content,
isOpen: action.data.config.isOpen };
}
return state;
}

default:
return state;
}
};
Loading

0 comments on commit cfc605c

Please sign in to comment.