-
-
Notifications
You must be signed in to change notification settings - Fork 112
Empty panels #692
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
Empty panels #692
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,56 +11,32 @@ class TraceRequiredPanel extends Component { | |
render() { | ||
const {localize: _} = this.context; | ||
const {children, ...rest} = this.props; | ||
let showPanel = true; | ||
const emptyPanelMessage = {heading: '', message: ''}; | ||
|
||
const noTraceMessage = { | ||
heading: _("Looks like there aren't any traces defined yet."), | ||
message: _("Go to the 'Create' tab to define traces."), | ||
}; | ||
|
||
const conditions = [() => this.hasTrace()].concat( | ||
this.props.extraConditions ? this.props.extraConditions : [] | ||
); | ||
if (!this.props.visible) { | ||
return null; | ||
} | ||
|
||
const messages = [noTraceMessage].concat( | ||
this.props.extraEmptyPanelMessages | ||
? this.props.extraEmptyPanelMessages | ||
: [] | ||
return this.hasTrace() ? ( | ||
<LayoutPanel {...rest}>{children}</LayoutPanel> | ||
) : ( | ||
<PanelEmpty | ||
heading={_("Looks like there aren't any traces defined yet.")} | ||
> | ||
<p> | ||
{_('Go to the ')} | ||
<a onClick={() => this.context.setPanel('Graph', 'Create')}> | ||
{_('Create')} | ||
</a> | ||
{_(' panel to define traces.')} | ||
</p> | ||
</PanelEmpty> | ||
); | ||
|
||
if (this.props.visible) { | ||
conditions.forEach((condition, index) => { | ||
if (!showPanel) { | ||
return; | ||
} | ||
if (!condition()) { | ||
showPanel = false; | ||
emptyPanelMessage.heading = messages[index].heading; | ||
emptyPanelMessage.message = messages[index].message; | ||
} | ||
}); | ||
|
||
if (showPanel) { | ||
return <LayoutPanel {...rest}>{children}</LayoutPanel>; | ||
} | ||
|
||
return ( | ||
<PanelEmpty | ||
heading={emptyPanelMessage.heading} | ||
message={emptyPanelMessage.message} | ||
/> | ||
); | ||
} | ||
return null; | ||
} | ||
} | ||
|
||
TraceRequiredPanel.propTypes = { | ||
children: PropTypes.node, | ||
visible: PropTypes.bool, | ||
extraConditions: PropTypes.array, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah nice. |
||
extraEmptyPanelMessages: PropTypes.array, | ||
}; | ||
|
||
TraceRequiredPanel.defaultProps = { | ||
|
@@ -70,6 +46,7 @@ TraceRequiredPanel.defaultProps = { | |
TraceRequiredPanel.contextTypes = { | ||
fullData: PropTypes.array, | ||
localize: PropTypes.func, | ||
setPanel: PropTypes.func, | ||
}; | ||
|
||
export default TraceRequiredPanel; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,19 +38,7 @@ class UpdateMenuAccordion extends Component { | |
); | ||
}); | ||
|
||
return ( | ||
<TraceRequiredPanel | ||
extraConditions={[() => updatemenus.length > 0]} | ||
extraEmptyPanelMessages={[ | ||
{ | ||
heading: _('There are no update menus to style in your plot'), | ||
message: '', | ||
}, | ||
]} | ||
> | ||
{content ? content : null} | ||
</TraceRequiredPanel> | ||
); | ||
return <TraceRequiredPanel>{content ? content : null}</TraceRequiredPanel>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm ok once we tackle #562 this can just be a Panel :) |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,33 +22,10 @@ import { | |
} from '../components'; | ||
|
||
class StyleAxesPanel extends Component { | ||
constructor(props, context) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very nice |
||
super(props, context); | ||
this.hasAxes = this.hasAxes.bind(this); | ||
} | ||
|
||
hasAxes() { | ||
return ( | ||
Object.keys(this.context.fullLayout._subplots).filter( | ||
type => | ||
!['cartesian', 'mapbox'].includes(type) && | ||
this.context.fullLayout._subplots[type].length > 0 | ||
).length > 0 | ||
); | ||
} | ||
|
||
render() { | ||
const {localize: _} = this.context; | ||
return ( | ||
<TraceRequiredPanel | ||
extraConditions={[this.hasAxes]} | ||
extraEmptyPanelMessages={[ | ||
{ | ||
heading: _('Your plot does not have any axes to style.'), | ||
message: '', | ||
}, | ||
]} | ||
> | ||
<TraceRequiredPanel> | ||
<AxesFold | ||
name={_('Titles')} | ||
axisFilter={axis => | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good. I know the panel still appears even when all traces are in constant-color mode, but that's ok. at least this panel never appears when there's nothing you can do in it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once you saw that panel appear, you don't wanna loose it again right? :)