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.
This commit is contained in:
Roberto Bruggemann
2018-02-15 16:58:04 +00:00
parent e106568dda
commit 72255468c1
5 changed files with 22 additions and 2 deletions

View File

@@ -869,3 +869,10 @@ export function getImagesForService(orgId, serviceId) {
});
};
}
export function setMonitorState(monitor) {
return {
type: ActionTypes.MONITOR_STATE,
monitor
};
}

View File

@@ -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);

View File

@@ -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 (
<CloudLink
@@ -95,6 +95,7 @@ class NodeDetailsHealthLinkItem extends React.Component {
function mapStateToProps(state) {
return {
pausedAt: state.get('pausedAt'),
monitor: state.get('monitor'),
};
}

View File

@@ -32,6 +32,7 @@ const ACTION_TYPES = [
'JUMP_TO_TIME',
'LEAVE_EDGE',
'LEAVE_NODE',
'MONITOR_STATE',
'OPEN_WEBSOCKET',
'PAUSE_TIME_AT_NOW',
'PIN_METRIC',

View File

@@ -768,6 +768,10 @@ export function rootReducer(state = initialState, action) {
});
}
case ActionTypes.MONITOR_STATE: {
return state.set('monitor', action.monitor);
}
default: {
return state;
}