Skip to content

Commit 7b652c2

Browse files
committed
clean up some unused logic
1 parent 9b91c18 commit 7b652c2

File tree

1 file changed

+17
-41
lines changed

1 file changed

+17
-41
lines changed

src/components/containers/TraceRequiredPanel.js

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,32 @@ class TraceRequiredPanel extends Component {
1111
render() {
1212
const {localize: _} = this.context;
1313
const {children, ...rest} = this.props;
14-
let showPanel = true;
15-
const emptyPanelMessage = {heading: '', message: ''};
1614

17-
const noTraceMessage = {
18-
heading: _("Looks like there aren't any traces defined yet."),
19-
message: _("Go to the 'Create' tab to define traces."),
20-
};
21-
22-
const conditions = [() => this.hasTrace()].concat(
23-
this.props.extraConditions ? this.props.extraConditions : []
24-
);
15+
if (!this.props.visible) {
16+
return null;
17+
}
2518

26-
const messages = [noTraceMessage].concat(
27-
this.props.extraEmptyPanelMessages
28-
? this.props.extraEmptyPanelMessages
29-
: []
19+
return this.hasTrace() ? (
20+
<LayoutPanel {...rest}>{children}</LayoutPanel>
21+
) : (
22+
<PanelEmpty
23+
heading={_("Looks like there aren't any traces defined yet.")}
24+
>
25+
<p>
26+
{_('Go to the ')}
27+
<a onClick={() => this.context.setPanel('Graph', 'Create')}>
28+
{_('Create')}
29+
</a>
30+
{_(' panel to define traces.')}
31+
</p>
32+
</PanelEmpty>
3033
);
31-
32-
if (this.props.visible) {
33-
conditions.forEach((condition, index) => {
34-
if (!showPanel) {
35-
return;
36-
}
37-
if (!condition()) {
38-
showPanel = false;
39-
emptyPanelMessage.heading = messages[index].heading;
40-
emptyPanelMessage.message = messages[index].message;
41-
}
42-
});
43-
44-
if (showPanel) {
45-
return <LayoutPanel {...rest}>{children}</LayoutPanel>;
46-
}
47-
48-
return (
49-
<PanelEmpty
50-
heading={emptyPanelMessage.heading}
51-
message={emptyPanelMessage.message}
52-
/>
53-
);
54-
}
55-
return null;
5634
}
5735
}
5836

5937
TraceRequiredPanel.propTypes = {
6038
children: PropTypes.node,
6139
visible: PropTypes.bool,
62-
extraConditions: PropTypes.array,
63-
extraEmptyPanelMessages: PropTypes.array,
6440
};
6541

6642
TraceRequiredPanel.defaultProps = {

0 commit comments

Comments
 (0)