mirror of
https://github.com/weaveworks/scope.git
synced 2026-05-03 07:49:10 +00:00
* Added resource view selector button * Showing resource boxes in the resource view * Crude CPU resource view prototype * Improved the viewMode state logic * Extracted zooming into a separate wrapper component * Split the layout selectors between graph-view and resource-view * Proper zooming logic for the resource view * Moved all node networks utils to selectors * Improved the zoom caching logic * Further refactoring of selectors * Added sticky labels to the resource boxes * Added panning translation limits in the resource view * Renamed GridModeSelector -> ViewModeSelector * Polished the topology resource view selection logic * Search bar hidden in the resource view * Added per-layer topology names to the resource view * Made metric selectors work for the resource view * Adjusted the viewport selectors * Renamed viewport selector to canvas (+ maximal zoom fix) * Showing more useful metric info in the resource box labels * Fetching only necessary nodes for the resource view * Refactored the resource view layer component * Addressed first batch UI comments (from the Scope meeting) * Switch to deep zooming transform in the resource view to avoid SVG precision errors * Renamed and moved resource view components * Polished all the resource view components * Changing the available metrics selection * Improved and polished the state transition logic for the resource view * Separated zoom limits from the zoom active state * Renaming and bunch of comments * Addressed all the UI comments (@davkal + @fons) * Made graph view selectors independent from resource view selectors
66 lines
1.6 KiB
JavaScript
66 lines
1.6 KiB
JavaScript
import React from 'react';
|
|
import classNames from 'classnames';
|
|
import { connect } from 'react-redux';
|
|
|
|
import { selectMetric, pinMetric, unpinMetric } from '../actions/app-actions';
|
|
import { pinnedMetricSelector } from '../selectors/node-metric';
|
|
|
|
class MetricSelectorItem extends React.Component {
|
|
|
|
constructor(props, context) {
|
|
super(props, context);
|
|
|
|
this.onMouseOver = this.onMouseOver.bind(this);
|
|
this.onMouseClick = this.onMouseClick.bind(this);
|
|
}
|
|
|
|
onMouseOver() {
|
|
const k = this.props.metric.get('id');
|
|
this.props.selectMetric(k);
|
|
}
|
|
|
|
onMouseClick() {
|
|
const k = this.props.metric.get('id');
|
|
const pinnedMetric = this.props.pinnedMetric;
|
|
|
|
if (k !== pinnedMetric) {
|
|
this.props.pinMetric(k);
|
|
} else if (!this.props.alwaysPinned) {
|
|
this.props.unpinMetric(k);
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const { metric, selectedMetric, pinnedMetric } = this.props;
|
|
const id = metric.get('id');
|
|
const isPinned = (id === pinnedMetric);
|
|
const isSelected = (id === selectedMetric);
|
|
const className = classNames('metric-selector-action', {
|
|
'metric-selector-action-selected': isSelected
|
|
});
|
|
|
|
return (
|
|
<div
|
|
key={id}
|
|
className={className}
|
|
onMouseOver={this.onMouseOver}
|
|
onClick={this.onMouseClick}>
|
|
{metric.get('label')}
|
|
{isPinned && <span className="fa fa-thumb-tack" />}
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
function mapStateToProps(state) {
|
|
return {
|
|
selectedMetric: state.get('selectedMetric'),
|
|
pinnedMetric: pinnedMetricSelector(state),
|
|
};
|
|
}
|
|
|
|
export default connect(
|
|
mapStateToProps,
|
|
{ selectMetric, pinMetric, unpinMetric }
|
|
)(MetricSelectorItem);
|