Commit f5a0b004 by Alexander Zobnin

graph legend: minor refactor

parent 8a292139
import _ from 'lodash'; import _ from 'lodash';
import React from 'react'; import React, { PureComponent } from 'react';
import { TimeSeries } from 'app/core/core'; import { TimeSeries } from 'app/core/core';
import CustomScrollbar from 'app/core/components/CustomScrollbar/CustomScrollbar'; import CustomScrollbar from 'app/core/components/CustomScrollbar/CustomScrollbar';
import { LegendItem, LEGEND_STATS } from './LegendSeriesItem'; import { LegendItem, LEGEND_STATS } from './LegendSeriesItem';
...@@ -61,7 +61,7 @@ interface LegendState { ...@@ -61,7 +61,7 @@ interface LegendState {
hiddenSeries: { [seriesAlias: string]: boolean }; hiddenSeries: { [seriesAlias: string]: boolean };
} }
export class GraphLegend extends React.PureComponent<GraphLegendProps, LegendState> { export class GraphLegend extends PureComponent<GraphLegendProps, LegendState> {
static defaultProps: Partial<GraphLegendProps> = { static defaultProps: Partial<GraphLegendProps> = {
values: false, values: false,
min: false, min: false,
...@@ -205,7 +205,7 @@ export class GraphLegend extends React.PureComponent<GraphLegendProps, LegendSta ...@@ -205,7 +205,7 @@ export class GraphLegend extends React.PureComponent<GraphLegendProps, LegendSta
} }
} }
class LegendSeriesList extends React.PureComponent<LegendComponentProps> { class LegendSeriesList extends PureComponent<LegendComponentProps> {
render() { render() {
const { seriesList, hiddenSeries, values, min, max, avg, current, total } = this.props; const { seriesList, hiddenSeries, values, min, max, avg, current, total } = this.props;
const seriesValuesProps = { values, min, max, avg, current, total }; const seriesValuesProps = { values, min, max, avg, current, total };
...@@ -225,7 +225,7 @@ class LegendSeriesList extends React.PureComponent<LegendComponentProps> { ...@@ -225,7 +225,7 @@ class LegendSeriesList extends React.PureComponent<LegendComponentProps> {
} }
} }
class LegendTable extends React.PureComponent<Partial<LegendComponentProps>> { class LegendTable extends PureComponent<Partial<LegendComponentProps>> {
onToggleSort = stat => { onToggleSort = stat => {
let sortDesc = this.props.sortDesc; let sortDesc = this.props.sortDesc;
let sortBy = this.props.sort; let sortBy = this.props.sort;
...@@ -289,7 +289,7 @@ interface LegendTableHeaderProps { ...@@ -289,7 +289,7 @@ interface LegendTableHeaderProps {
onClick?: (statName: string) => void; onClick?: (statName: string) => void;
} }
class LegendTableHeaderItem extends React.PureComponent<LegendTableHeaderProps & LegendSortProps> { class LegendTableHeaderItem extends PureComponent<LegendTableHeaderProps & LegendSortProps> {
onClick = () => this.props.onClick(this.props.statName); onClick = () => this.props.onClick(this.props.statName);
render() { render() {
...@@ -303,7 +303,7 @@ class LegendTableHeaderItem extends React.PureComponent<LegendTableHeaderProps & ...@@ -303,7 +303,7 @@ class LegendTableHeaderItem extends React.PureComponent<LegendTableHeaderProps &
} }
} }
export class Legend extends React.PureComponent<GraphLegendProps> { export class Legend extends PureComponent<GraphLegendProps> {
render() { render() {
return ( return (
<CustomScrollbar> <CustomScrollbar>
......
import React from 'react'; import React, { PureComponent } from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { TimeSeries } from 'app/core/core'; import { TimeSeries } from 'app/core/core';
import { SeriesColorPicker } from 'app/core/components/colorpicker/SeriesColorPicker'; import { SeriesColorPicker } from 'app/core/components/colorpicker/SeriesColorPicker';
...@@ -29,7 +29,7 @@ interface LegendItemState { ...@@ -29,7 +29,7 @@ interface LegendItemState {
yaxis: number; yaxis: number;
} }
export class LegendItem extends React.PureComponent<LegendItemProps, LegendItemState> { export class LegendItem extends PureComponent<LegendItemProps, LegendItemState> {
static defaultProps = { static defaultProps = {
asTable: false, asTable: false,
hidden: false, hidden: false,
...@@ -119,7 +119,7 @@ interface LegendSeriesLabelProps { ...@@ -119,7 +119,7 @@ interface LegendSeriesLabelProps {
onLabelClick?: (event) => void; onLabelClick?: (event) => void;
} }
class LegendSeriesLabel extends React.PureComponent<LegendSeriesLabelProps & LegendSeriesIconProps> { class LegendSeriesLabel extends PureComponent<LegendSeriesLabelProps & LegendSeriesIconProps> {
static defaultProps = { static defaultProps = {
yaxis: undefined, yaxis: undefined,
onLabelClick: () => {}, onLabelClick: () => {},
...@@ -158,7 +158,7 @@ function SeriesIcon(props) { ...@@ -158,7 +158,7 @@ function SeriesIcon(props) {
return <i className="fa fa-minus pointer" style={{ color: props.color }} />; return <i className="fa fa-minus pointer" style={{ color: props.color }} />;
} }
class LegendSeriesIcon extends React.PureComponent<LegendSeriesIconProps, LegendSeriesIconState> { class LegendSeriesIcon extends PureComponent<LegendSeriesIconProps, LegendSeriesIconState> {
static defaultProps = { static defaultProps = {
yaxis: undefined, yaxis: undefined,
onColorChange: () => {}, onColorChange: () => {},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment