Skip to content

Commit

Permalink
TSVB Inaccurate Group By (#73683) (#73776)
Browse files Browse the repository at this point in the history
Closes: #62081
  • Loading branch information
alexwizp authored Jul 30, 2020
1 parent 3fc6d84 commit e5823ec
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/plugins/vis_type_timeseries/common/ui_restrictions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

import { PANEL_TYPES } from './panel_types';

/**
* UI Restrictions keys
* @constant
Expand Down Expand Up @@ -56,3 +58,12 @@ export type TimeseriesUIRestrictions = {
export const DEFAULT_UI_RESTRICTION: UIRestrictions = {
'*': true,
};

/** limit on the number of series for the panel
* @constant
* @public
*/
export const limitOfSeries = {
[PANEL_TYPES.GAUGE]: 1,
[PANEL_TYPES.METRIC]: 2,
};
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
import { QueryBarWrapper } from '../query_bar_wrapper';
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';

import { limitOfSeries } from '../../../../common/ui_restrictions';
import { PANEL_TYPES } from '../../../../common/panel_types';

class GaugePanelConfigUi extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -110,7 +113,7 @@ class GaugePanelConfigUi extends Component {
<SeriesEditor
colorPicker={true}
fields={this.props.fields}
limit={1}
limit={limitOfSeries[PANEL_TYPES.GAUGE]}
model={this.props.model}
name={this.props.name}
onChange={this.props.onChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import { FormattedMessage } from '@kbn/i18n/react';

import { QueryBarWrapper } from '../query_bar_wrapper';
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
import { limitOfSeries } from '../../../../common/ui_restrictions';
import { PANEL_TYPES } from '../../../../common/panel_types';

export class MetricPanelConfig extends Component {
constructor(props) {
Expand Down Expand Up @@ -75,7 +77,7 @@ export class MetricPanelConfig extends Component {
<SeriesEditor
colorPicker={false}
fields={this.props.fields}
limit={2}
limit={limitOfSeries[PANEL_TYPES.METRIC]}
model={this.props.model}
name={this.props.name}
onChange={this.props.onChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,20 @@
* specific language governing permissions and limitations
* under the License.
*/
export const getActiveSeries = (panel) => {
const shouldNotApplyFilter = ['gauge', 'markdown'].includes(panel.type);

return (panel.series || []).filter((series) => !series.hidden || shouldNotApplyFilter);
import { PanelSchema } from '../../../../common/types';
import { PANEL_TYPES } from '../../../../common/panel_types';
import { limitOfSeries } from '../../../../common/ui_restrictions';

export const getActiveSeries = (panel: PanelSchema) => {
let visibleSeries = panel.series || [];

if (panel.type in limitOfSeries) {
visibleSeries = visibleSeries.slice(0, limitOfSeries[panel.type]);
}

// Toogle visibility functionality for 'gauge', 'markdown' is not accessible
const shouldNotApplyFilter = [PANEL_TYPES.GAUGE, PANEL_TYPES.MARKDOWN].includes(panel.type);

return visibleSeries.filter((series) => !series.hidden || shouldNotApplyFilter);
};

0 comments on commit e5823ec

Please sign in to comment.