Registry: add a reusable function registry (#17047)

This commit is contained in:
Ryan McKinley
2019-07-16 11:40:23 -07:00
committed by GitHub
parent 5151b8ce07
commit c194ae1ba5
35 changed files with 406 additions and 283 deletions

View File

@@ -2,7 +2,8 @@
import React, { PureComponent } from 'react';
// Components
import { Select, SelectOptionItem } from '@grafana/ui';
import { Select } from '@grafana/ui';
import { SelectableValue } from '@grafana/data';
// Types
import { DataSourceSelectItem } from '@grafana/ui';
@@ -28,7 +29,7 @@ export class DataSourcePicker extends PureComponent<Props> {
super(props);
}
onChange = (item: SelectOptionItem<string>) => {
onChange = (item: SelectableValue<string>) => {
const ds = this.props.datasources.find(ds => ds.name === item.value);
this.props.onChange(ds);
};

View File

@@ -1,12 +1,13 @@
import React from 'react';
import _ from 'lodash';
import { Select, SelectOptionItem } from '@grafana/ui';
import { Select } from '@grafana/ui';
import { SelectableValue } from '@grafana/data';
import { Variable } from 'app/types/templates';
export interface Props {
onChange: (value: string) => void;
options: Array<SelectOptionItem<string>>;
options: Array<SelectableValue<string>>;
isSearchable: boolean;
value: string;
placeholder?: string;
@@ -15,7 +16,7 @@ export interface Props {
}
interface State {
options: Array<SelectOptionItem<string>>;
options: Array<SelectableValue<string>>;
}
export class MetricSelect extends React.Component<Props, State> {