From 72255468c146ba95b19de786c74e432c1e45c687 Mon Sep 17 00:00:00 2001 From: Roberto Bruggemann Date: Thu, 15 Feb 2018 16:58:04 +0000 Subject: [PATCH] Disable detail panel link The link is disabled if the `monitor` flag is not true. If Weave Cloud runs without Monitor, the link is dead. The flag allows to pass Weave Cloud's Monitor state down to Scope. --- client/app/scripts/actions/app-actions.js | 7 +++++++ client/app/scripts/components/app.js | 7 +++++++ .../node-details/node-details-health-link-item.js | 5 +++-- client/app/scripts/constants/action-types.js | 1 + client/app/scripts/reducers/root.js | 4 ++++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/client/app/scripts/actions/app-actions.js b/client/app/scripts/actions/app-actions.js index 1e06472d77..9c823b70fa 100644 --- a/client/app/scripts/actions/app-actions.js +++ b/client/app/scripts/actions/app-actions.js @@ -869,3 +869,10 @@ export function getImagesForService(orgId, serviceId) { }); }; } + +export function setMonitorState(monitor) { + return { + type: ActionTypes.MONITOR_STATE, + monitor + }; +} diff --git a/client/app/scripts/components/app.js b/client/app/scripts/components/app.js index 20826a6e9c..e48c6c368b 100644 --- a/client/app/scripts/components/app.js +++ b/client/app/scripts/components/app.js @@ -28,6 +28,7 @@ import { unpinMetric, toggleHelp, setGraphView, + setMonitorState, setTableView, setResourceView, shutdown, @@ -63,6 +64,8 @@ class App extends React.Component { constructor(props, context) { super(props, context); + this.props.dispatch(setMonitorState(this.props.monitor)); + this.setViewportDimensions = this.setViewportDimensions.bind(this); this.handleResize = debounce(this.setViewportDimensions, VIEWPORT_RESIZE_DEBOUNCE_INTERVAL); @@ -257,4 +260,8 @@ function mapStateToProps(state) { }; } +App.defaultProps = { + monitor: false +}; + export default connect(mapStateToProps)(App); diff --git a/client/app/scripts/components/node-details/node-details-health-link-item.js b/client/app/scripts/components/node-details/node-details-health-link-item.js index e0c45b47a1..696d26bc50 100644 --- a/client/app/scripts/components/node-details/node-details-health-link-item.js +++ b/client/app/scripts/components/node-details/node-details-health-link-item.js @@ -65,12 +65,12 @@ class NodeDetailsHealthLinkItem extends React.Component { render() { const { - id, url, pausedAt, ...props + id, url, monitor, pausedAt, ...props } = this.props; const metricColor = getMetricColor(id); const labelColor = this.state.hovered && !props.valueEmpty && darkenColor(metricColor); - const timedUrl = appendTime(url, pausedAt); + const timedUrl = monitor === true ? appendTime(url, pausedAt) : ''; return (