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

[explore] add collapsible Control sections #3354

Merged
merged 1 commit into from
Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -6,25 +6,38 @@ import InfoTooltipWithTrigger from '../../components/InfoTooltipWithTrigger';
const propTypes = {
label: PropTypes.string,
description: PropTypes.string,
tooltip: PropTypes.string,
children: PropTypes.node.isRequired,
startExpanded: PropTypes.bool,
};

const defaultProps = {
label: null,
description: null,
tooltip: null,
startExpanded: false,
};

export default class ControlPanelSection extends React.Component {
constructor(props) {
super(props);
this.state = { expanded: this.props.startExpanded };
}
toggleExpand() {
this.setState({ expanded: !this.state.expanded });
}
renderHeader() {
const { label, tooltip } = this.props;
const { label, description } = this.props;
let header;
if (label) {
header = (
<div>
{label} &nbsp;
{tooltip && <InfoTooltipWithTrigger label={label} tooltip={tooltip} />}
<i
className={`text-primary expander fa fa-caret-${this.state.expanded ? 'down' : 'right'}`}
onClick={this.toggleExpand.bind(this)}
/>
{' '}
<span onClick={this.toggleExpand.bind(this)}>{label}</span>
{' '}
{description && <InfoTooltipWithTrigger label={label} tooltip={description} />}
</div>
);
}
Expand All @@ -35,6 +48,8 @@ export default class ControlPanelSection extends React.Component {
return (
<Panel
className="control-panel-section"
collapsible
expanded={this.state.expanded}
header={this.renderHeader()}
>
{this.props.children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ class ControlPanelsContainer extends React.Component {
<ControlPanelSection
key={section.label}
label={section.label}
tooltip={section.description}
startExpanded={section.expanded}
description={section.description}
>
{section.controlSetRows.map((controlSets, i) => (
<ControlRow
key={`controlsetrow-${i}`}
className="control-row"
controls={controlSets.map(controlName => (
controlName &&
this.props.controls[controlName] &&
Expand Down
13 changes: 13 additions & 0 deletions superset/assets/javascripts/explore/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,16 @@
height: 10px;
margin: 9px 1px;
}
.control-panel-section .panel-body {
margin-left: 15px;
padding-bottom: 0px;
}
.control-panel-section .control-label {
margin-bottom: 0px;
}
.fa.expander {
width: 15px;
}
.control-panel-section span.label {
display: inline-block;
}
Loading