mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-25 02:40:22 -10:00
Since we now have a GridElementWidthResizer element, we can get rid of the SplitBox wrapping the SideBar, and have all major elements as child of the App element, controlled by a CSS Grid. This makes it easy to change the console layout when toggling the editor mode (re-ordering element in JS, changing the CSS grid templates, and placing the element in different areas). This also means we can take advantage of subgrid to align the sidebar toolbar with the filter bar for example. As the part of the stylesheet dedicated to layout grew, it made sense to have it all in a separate stylesheet, App.css, that lives next to the App component. Differential Revision: https://phabricator.services.mozilla.com/D38038
131 lines
3.0 KiB
JavaScript
131 lines
3.0 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
"use strict";
|
|
|
|
const {
|
|
Component,
|
|
createFactory,
|
|
} = require("devtools/client/shared/vendor/react");
|
|
const { connect } = require("devtools/client/shared/vendor/react-redux");
|
|
|
|
const GridElementWidthResizer = createFactory(
|
|
require("devtools/client/shared/components/splitter/GridElementWidthResizer")
|
|
);
|
|
loader.lazyRequireGetter(
|
|
this,
|
|
"dom",
|
|
"devtools/client/shared/vendor/react-dom-factories"
|
|
);
|
|
loader.lazyRequireGetter(
|
|
this,
|
|
"getObjectInspector",
|
|
"devtools/client/webconsole/utils/object-inspector",
|
|
true
|
|
);
|
|
loader.lazyRequireGetter(
|
|
this,
|
|
"actions",
|
|
"devtools/client/webconsole/actions/index"
|
|
);
|
|
loader.lazyRequireGetter(
|
|
this,
|
|
"PropTypes",
|
|
"devtools/client/shared/vendor/react-prop-types"
|
|
);
|
|
loader.lazyRequireGetter(
|
|
this,
|
|
"reps",
|
|
"devtools/client/shared/components/reps/reps"
|
|
);
|
|
loader.lazyRequireGetter(
|
|
this,
|
|
"l10n",
|
|
"devtools/client/webconsole/utils/messages",
|
|
true
|
|
);
|
|
|
|
class SideBar extends Component {
|
|
static get propTypes() {
|
|
return {
|
|
serviceContainer: PropTypes.object,
|
|
dispatch: PropTypes.func.isRequired,
|
|
visible: PropTypes.bool,
|
|
grip: PropTypes.object,
|
|
onResized: PropTypes.func,
|
|
};
|
|
}
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
this.onClickSidebarClose = this.onClickSidebarClose.bind(this);
|
|
}
|
|
|
|
shouldComponentUpdate(nextProps) {
|
|
const { grip, visible } = nextProps;
|
|
|
|
return visible !== this.props.visible || grip !== this.props.grip;
|
|
}
|
|
|
|
onClickSidebarClose() {
|
|
this.props.dispatch(actions.sidebarClose());
|
|
}
|
|
|
|
render() {
|
|
if (!this.props.visible) {
|
|
return null;
|
|
}
|
|
|
|
const { grip, serviceContainer } = this.props;
|
|
|
|
const objectInspector = getObjectInspector(grip, serviceContainer, {
|
|
autoExpandDepth: 1,
|
|
mode: reps.MODE.SHORT,
|
|
autoFocusRoot: true,
|
|
});
|
|
|
|
return [
|
|
dom.aside(
|
|
{
|
|
className: "sidebar",
|
|
key: "sidebar",
|
|
ref: node => {
|
|
this.node = node;
|
|
},
|
|
},
|
|
dom.header(
|
|
{
|
|
className: "devtools-toolbar webconsole-sidebar-toolbar",
|
|
},
|
|
dom.button({
|
|
className: "devtools-button sidebar-close-button",
|
|
title: l10n.getStr("webconsole.closeSidebarButton.tooltip"),
|
|
onClick: this.onClickSidebarClose,
|
|
})
|
|
),
|
|
dom.aside(
|
|
{
|
|
className: "sidebar-contents",
|
|
},
|
|
objectInspector
|
|
)
|
|
),
|
|
GridElementWidthResizer({
|
|
key: "resizer",
|
|
enabled: true,
|
|
position: "start",
|
|
className: "sidebar-resizer",
|
|
getControlledElementNode: () => this.node,
|
|
}),
|
|
];
|
|
}
|
|
}
|
|
|
|
function mapStateToProps(state, props) {
|
|
return {
|
|
grip: state.ui.gripInSidebar,
|
|
};
|
|
}
|
|
|
|
module.exports = connect(mapStateToProps)(SideBar);
|