From 3c5f8325f55292c5cc85e8f3ffbd111fcdd4d062 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Wed, 31 Oct 2018 11:16:49 +0100 Subject: [PATCH] stackdriver: refactor dropdown component --- .../stackdriver/components/SimpleDropdown.tsx | 28 ++++--------------- .../components/TemplateQueryComponent.tsx | 18 ++++++------ 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/public/app/plugins/datasource/stackdriver/components/SimpleDropdown.tsx b/public/app/plugins/datasource/stackdriver/components/SimpleDropdown.tsx index ff08229c07a..b701924333f 100644 --- a/public/app/plugins/datasource/stackdriver/components/SimpleDropdown.tsx +++ b/public/app/plugins/datasource/stackdriver/components/SimpleDropdown.tsx @@ -8,31 +8,15 @@ interface Props { } const SimpleDropdown: SFC = props => { + const { label, onValueChange, value, options } = props; return (
- {props.label} + {label}
- -
-
- ); -}; - -export const KeyValueDropdown: SFC = props => { - return ( -
- {props.label} -
- + {options.map(({ value, name }, i) => ( + ))} diff --git a/public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx b/public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx index 311c4c9a149..1f31b4aafc5 100644 --- a/public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx +++ b/public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import SimpleDropdown, { KeyValueDropdown } from './SimpleDropdown'; +import SimpleDropdown from './SimpleDropdown'; import { TemplateQueryProps } from 'app/types/plugins'; import { getMetricTypesByService, extractServicesFromMetricDescriptors } from '../functions'; import defaultsDeep from 'lodash/defaultsDeep'; @@ -113,7 +113,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent ({ value: l, name: l }))} onValueChange={this.onLabelKeyChange} label="Resource Labels" /> @@ -122,7 +122,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent ({ value: l, name: l }))} onValueChange={this.onLabelKeyChange} label="Metric Labels" /> @@ -136,7 +136,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent {this.state.labels.join(',')} - - - - -