diff --git a/public/app/core/components/CustomScrollbar/CustomScrollbar.tsx b/public/app/core/components/CustomScrollbar/CustomScrollbar.tsx index 9b9a9c4d02a..590c11c0615 100644 --- a/public/app/core/components/CustomScrollbar/CustomScrollbar.tsx +++ b/public/app/core/components/CustomScrollbar/CustomScrollbar.tsx @@ -28,8 +28,8 @@ class CustomScrollbar extends PureComponent {
} renderTrackVertical={props =>
} renderThumbHorizontal={props =>
} diff --git a/public/app/core/components/CustomScrollbar/__snapshots__/CustomScrollbar.test.tsx.snap b/public/app/core/components/CustomScrollbar/__snapshots__/CustomScrollbar.test.tsx.snap index 37d8cea45be..310eb714af9 100644 --- a/public/app/core/components/CustomScrollbar/__snapshots__/CustomScrollbar.test.tsx.snap +++ b/public/app/core/components/CustomScrollbar/__snapshots__/CustomScrollbar.test.tsx.snap @@ -6,8 +6,8 @@ exports[`CustomScrollbar renders correctly 1`] = ` style={ Object { "height": "auto", - "maxHeight": "100%", - "minHeight": "100%", + "maxHeight": "inherit", + "minHeight": "inherit", "overflow": "hidden", "position": "relative", "width": "100%", @@ -23,8 +23,8 @@ exports[`CustomScrollbar renders correctly 1`] = ` "left": undefined, "marginBottom": 0, "marginRight": 0, - "maxHeight": "calc(100% + 0px)", - "minHeight": "calc(100% + 0px)", + "maxHeight": "calc(inherit + 0px)", + "minHeight": "calc(inherit + 0px)", "overflow": "scroll", "position": "relative", "right": undefined, diff --git a/public/app/core/components/PermissionList/AddPermission.tsx b/public/app/core/components/PermissionList/AddPermission.tsx index d6da7c68544..749bef680bf 100644 --- a/public/app/core/components/PermissionList/AddPermission.tsx +++ b/public/app/core/components/PermissionList/AddPermission.tsx @@ -1,7 +1,7 @@ import React, { Component } from 'react'; -import { UserPicker } from 'app/core/components/Picker/UserPicker'; -import { TeamPicker, Team } from 'app/core/components/Picker/TeamPicker'; -import DescriptionPicker, { OptionWithDescription } from 'app/core/components/Picker/DescriptionPicker'; +import { UserPicker } from 'app/core/components/Select/UserPicker'; +import { TeamPicker, Team } from 'app/core/components/Select/TeamPicker'; +import { Select, SelectOptionItem } from 'app/core/components/Select/Select'; import { User } from 'app/types'; import { dashboardPermissionLevels, @@ -61,7 +61,7 @@ class AddPermissions extends Component { this.setState({ teamId: team && !Array.isArray(team) ? team.id : 0 }); }; - onPermissionChanged = (permission: OptionWithDescription) => { + onPermissionChanged = (permission: SelectOptionItem) => { this.setState({ permission: permission.value }); }; @@ -121,11 +121,11 @@ class AddPermissions extends Component { ) : null}
-
diff --git a/public/app/core/components/PermissionList/DisabledPermissionListItem.tsx b/public/app/core/components/PermissionList/DisabledPermissionListItem.tsx index ff679f67ae2..d3f9ddbb1fb 100644 --- a/public/app/core/components/PermissionList/DisabledPermissionListItem.tsx +++ b/public/app/core/components/PermissionList/DisabledPermissionListItem.tsx @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import DescriptionPicker from 'app/core/components/Picker/DescriptionPicker'; +import Select from 'app/core/components/Select/Select'; import { dashboardPermissionLevels } from 'app/types/acl'; export interface Props { @@ -9,6 +9,7 @@ export interface Props { export default class DisabledPermissionListItem extends Component { render() { const { item } = this.props; + const currentPermissionLevel = dashboardPermissionLevels.find(dp => dp.value === item.permission); return ( @@ -23,12 +24,12 @@ export default class DisabledPermissionListItem extends Component { Can
- {}} - disabled={true} - className={'gf-form-select-box__control--menu-right'} - value={item.permission} + i.value} - getOptionLabel={i => i.label} - value={selectedOption} - /> -
- ); - } -} - -export default DescriptionPicker; diff --git a/public/app/core/components/Picker/NoOptionsMessage.tsx b/public/app/core/components/Picker/NoOptionsMessage.tsx deleted file mode 100644 index 1d2ad4a179e..00000000000 --- a/public/app/core/components/Picker/NoOptionsMessage.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import { components } from 'react-select'; -import { OptionProps } from 'react-select/lib/components/Option'; - -export interface Props { - children: Element; -} - -export const PickerOption = (props: OptionProps) => { - const { children, className } = props; - return ( - -
{children}
-
- ); -}; - -export default PickerOption; diff --git a/public/app/core/components/Picker/Select.tsx b/public/app/core/components/Picker/Select.tsx deleted file mode 100644 index b8704893cdb..00000000000 --- a/public/app/core/components/Picker/Select.tsx +++ /dev/null @@ -1,60 +0,0 @@ -// import React, { PureComponent } from 'react'; -// import Select as ReactSelect from 'react-select'; -// import DescriptionOption from './DescriptionOption'; -// import IndicatorsContainer from './IndicatorsContainer'; -// import ResetStyles from './ResetStyles'; -// -// export interface OptionType { -// label: string; -// value: string; -// } -// -// interface Props { -// defaultValue?: any; -// getOptionLabel: (item: T) => string; -// getOptionValue: (item: T) => string; -// onChange: (item: T) => {} | void; -// options: T[]; -// placeholder?: string; -// width?: number; -// value: T; -// className?: string; -// } -// -// export class Select extends PureComponent> { -// static defaultProps = { -// width: null, -// className: '', -// } -// -// render() { -// const { defaultValue, getOptionLabel, getOptionValue, onSelected, options, placeholder, width, value, className } = this.props; -// let widthClass = ''; -// if (width) { -// widthClass = 'width-'+width; -// } -// -// return ( -// -// ); -// } -// } -// -// export default Select; diff --git a/public/app/core/components/Picker/SimplePicker.tsx b/public/app/core/components/Picker/SimplePicker.tsx deleted file mode 100644 index 18b8b4bfc02..00000000000 --- a/public/app/core/components/Picker/SimplePicker.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import React, { SFC } from 'react'; -import Select from 'react-select'; -import DescriptionOption from './DescriptionOption'; -import IndicatorsContainer from './IndicatorsContainer'; -import ResetStyles from './ResetStyles'; - -interface Props { - className?: string; - defaultValue?: any; - getOptionLabel: (item: any) => string; - getOptionValue: (item: any) => string; - onSelected: (item: any) => {} | void; - options: any[]; - placeholder?: string; - width?: number; - value: any; -} - -const SimplePicker: SFC = ({ - className, - defaultValue, - getOptionLabel, - getOptionValue, - onSelected, - options, - placeholder, - width, - value, -}) => { - return ( - - ); - } -} diff --git a/public/app/features/dashboard/dashgrid/DataSourcePicker.tsx b/public/app/core/components/Select/DataSourcePicker.tsx similarity index 64% rename from public/app/features/dashboard/dashgrid/DataSourcePicker.tsx rename to public/app/core/components/Select/DataSourcePicker.tsx index a4368170b12..1a9081038c0 100644 --- a/public/app/features/dashboard/dashgrid/DataSourcePicker.tsx +++ b/public/app/core/components/Select/DataSourcePicker.tsx @@ -3,16 +3,13 @@ import React, { PureComponent } from 'react'; import _ from 'lodash'; // Components -import ResetStyles from 'app/core/components/Picker/ResetStyles'; -import { Option, SingleValue } from 'app/core/components/Picker/PickerOption'; -import IndicatorsContainer from 'app/core/components/Picker/IndicatorsContainer'; -import Select from 'react-select'; +import Select from './Select'; // Types import { DataSourceSelectItem } from 'app/types'; export interface Props { - onChangeDataSource: (ds: DataSourceSelectItem) => void; + onChange: (ds: DataSourceSelectItem) => void; datasources: DataSourceSelectItem[]; current: DataSourceSelectItem; onBlur?: () => void; @@ -32,7 +29,7 @@ export class DataSourcePicker extends PureComponent { onChange = item => { const ds = this.props.datasources.find(ds => ds.name === item.value); - this.props.onChangeDataSource(ds); + this.props.onChange(ds); }; render() { @@ -53,27 +50,19 @@ export class DataSourcePicker extends PureComponent { return (
+ ); + } +} diff --git a/public/app/core/components/Picker/UserPicker.test.tsx b/public/app/core/components/Select/UserPicker.test.tsx similarity index 100% rename from public/app/core/components/Picker/UserPicker.test.tsx rename to public/app/core/components/Select/UserPicker.test.tsx diff --git a/public/app/core/components/Picker/UserPicker.tsx b/public/app/core/components/Select/UserPicker.tsx similarity index 69% rename from public/app/core/components/Picker/UserPicker.tsx rename to public/app/core/components/Select/UserPicker.tsx index 01dbb1fd3ea..976b32e47a9 100644 --- a/public/app/core/components/Picker/UserPicker.tsx +++ b/public/app/core/components/Select/UserPicker.tsx @@ -1,12 +1,15 @@ +// Libraries import React, { Component } from 'react'; -import AsyncSelect from 'react-select/lib/Async'; -import PickerOption from './PickerOption'; + +// Components +import { AsyncSelect } from './Select'; + +// Utils & Services import { debounce } from 'lodash'; import { getBackendSrv } from 'app/core/services/backend_srv'; + +// Types import { User } from 'app/types'; -import ResetStyles from './ResetStyles'; -import IndicatorsContainer from './IndicatorsContainer'; -import NoOptionsMessage from './NoOptionsMessage'; export interface Props { onSelected: (user: User) => void; @@ -40,6 +43,7 @@ export class UserPicker extends Component { .then(result => { return result.map(user => ({ id: user.userId, + value: user.userId, label: user.login === user.email ? user.login : `${user.login} - ${user.email}`, imgUrl: user.avatarUrl, login: user.login, @@ -57,24 +61,13 @@ export class UserPicker extends Component { return (
'Loading...'} noOptionsMessage={() => 'No users found'} - getOptionValue={i => i.id} - getOptionLabel={i => i.label} />
); diff --git a/public/app/core/components/Picker/__snapshots__/PickerOption.test.tsx.snap b/public/app/core/components/Select/__snapshots__/PickerOption.test.tsx.snap similarity index 100% rename from public/app/core/components/Picker/__snapshots__/PickerOption.test.tsx.snap rename to public/app/core/components/Select/__snapshots__/PickerOption.test.tsx.snap diff --git a/public/app/core/components/Picker/__snapshots__/TeamPicker.test.tsx.snap b/public/app/core/components/Select/__snapshots__/TeamPicker.test.tsx.snap similarity index 100% rename from public/app/core/components/Picker/__snapshots__/TeamPicker.test.tsx.snap rename to public/app/core/components/Select/__snapshots__/TeamPicker.test.tsx.snap diff --git a/public/app/core/components/Picker/__snapshots__/UserPicker.test.tsx.snap b/public/app/core/components/Select/__snapshots__/UserPicker.test.tsx.snap similarity index 100% rename from public/app/core/components/Picker/__snapshots__/UserPicker.test.tsx.snap rename to public/app/core/components/Select/__snapshots__/UserPicker.test.tsx.snap diff --git a/public/app/core/components/SharedPreferences/SharedPreferences.tsx b/public/app/core/components/SharedPreferences/SharedPreferences.tsx index 098cbe16ab8..d41626d9a2f 100644 --- a/public/app/core/components/SharedPreferences/SharedPreferences.tsx +++ b/public/app/core/components/SharedPreferences/SharedPreferences.tsx @@ -1,7 +1,7 @@ import React, { PureComponent } from 'react'; import { Label } from 'app/core/components/Label/Label'; -import SimplePicker from 'app/core/components/Picker/SimplePicker'; +import Select from 'app/core/components/Select/Select'; import { getBackendSrv, BackendSrv } from 'app/core/services/backend_srv'; import { DashboardSearchHit } from 'app/types'; @@ -17,12 +17,12 @@ export interface State { dashboards: DashboardSearchHit[]; } -const themes = [{ value: '', text: 'Default' }, { value: 'dark', text: 'Dark' }, { value: 'light', text: 'Light' }]; +const themes = [{ value: '', label: 'Default' }, { value: 'dark', label: 'Dark' }, { value: 'light', label: 'Light' }]; const timezones = [ - { value: '', text: 'Default' }, - { value: 'browser', text: 'Local browser time' }, - { value: 'utc', text: 'UTC' }, + { value: '', label: 'Default' }, + { value: 'browser', label: 'Local browser time' }, + { value: 'utc', label: 'UTC' }, ]; export class SharedPreferences extends PureComponent { @@ -91,12 +91,11 @@ export class SharedPreferences extends PureComponent {

Preferences

UI Theme - item.value === theme)} options={themes} - getOptionValue={i => i.value} - getOptionLabel={i => i.text} - onSelected={theme => this.onThemeChanged(theme.value)} + onChange={theme => this.onThemeChanged(theme.value)} width={20} />
@@ -107,11 +106,11 @@ export class SharedPreferences extends PureComponent { > Home Dashboard - dashboard.id === homeDashboardId)} getOptionValue={i => i.id} getOptionLabel={i => i.title} - onSelected={(dashboard: DashboardSearchHit) => this.onHomeDashboardChanged(dashboard.id)} + onChange={(dashboard: DashboardSearchHit) => this.onHomeDashboardChanged(dashboard.id)} options={dashboards} placeholder="Chose default dashboard" width={20} @@ -119,11 +118,10 @@ export class SharedPreferences extends PureComponent {
- item.value === timezone)} - getOptionValue={i => i.value} - getOptionLabel={i => i.text} - onSelected={timezone => this.onTimeZoneChanged(timezone.value)} + onChange={timezone => this.onTimeZoneChanged(timezone.value)} options={timezones} width={20} /> diff --git a/public/app/core/components/TagFilter/TagFilter.tsx b/public/app/core/components/TagFilter/TagFilter.tsx index 6a4203f8739..8d9cfa6fc6f 100644 --- a/public/app/core/components/TagFilter/TagFilter.tsx +++ b/public/app/core/components/TagFilter/TagFilter.tsx @@ -2,10 +2,10 @@ import React from 'react'; import AsyncSelect from 'react-select/lib/Async'; import { TagOption } from './TagOption'; import { TagBadge } from './TagBadge'; -import IndicatorsContainer from 'app/core/components/Picker/IndicatorsContainer'; -import NoOptionsMessage from 'app/core/components/Picker/NoOptionsMessage'; +import IndicatorsContainer from 'app/core/components/Select/IndicatorsContainer'; +import NoOptionsMessage from 'app/core/components/Select/NoOptionsMessage'; import { components } from 'react-select'; -import ResetStyles from 'app/core/components/Picker/ResetStyles'; +import ResetStyles from 'app/core/components/Select/ResetStyles'; export interface Props { tags: string[]; diff --git a/public/app/core/components/code_editor/code_editor.ts b/public/app/core/components/code_editor/code_editor.ts index 50ff55f3083..20a8384ee33 100644 --- a/public/app/core/components/code_editor/code_editor.ts +++ b/public/app/core/components/code_editor/code_editor.ts @@ -84,7 +84,7 @@ function link(scope, elem, attrs) { // disable depreacation warning codeEditor.$blockScrolling = Infinity; // Padding hacks - (codeEditor.renderer as any).setScrollMargin(15, 15); + (codeEditor.renderer as any).setScrollMargin(10, 10); codeEditor.renderer.setPadding(10); setThemeMode(); diff --git a/public/app/features/dashboard/dashgrid/QueriesTab.tsx b/public/app/features/dashboard/dashgrid/QueriesTab.tsx index cd26defbed3..0f449efdc35 100644 --- a/public/app/features/dashboard/dashgrid/QueriesTab.tsx +++ b/public/app/features/dashboard/dashgrid/QueriesTab.tsx @@ -6,7 +6,7 @@ import _ from 'lodash'; // Components import './../../panel/metrics_tab'; import { EditorTabBody } from './EditorTabBody'; -import { DataSourcePicker } from './DataSourcePicker'; +import { DataSourcePicker } from 'app/core/components/Select/DataSourcePicker'; import { QueryInspector } from './QueryInspector'; import { QueryOptions } from './QueryOptions'; import { AngularQueryComponentScope } from 'app/features/panel/metrics_tab'; @@ -205,20 +205,14 @@ export class QueriesTab extends PureComponent { renderToolbar = () => { const { currentDS } = this.state; - return ( - - ); + return ; }; renderMixedPicker = () => { return ( { if (!datasourceSrv) { throw new Error('No datasource service passed as props.'); } + const datasources = datasourceSrv.getExternal(); const exploreDatasources = datasources.map(ds => ({ value: ds.name, - label: ds.name, + name: ds.name, + meta: ds.meta, })); if (datasources.length > 0) { @@ -885,7 +883,7 @@ export class Explore extends React.PureComponent { } = this.state; const graphHeight = showingGraph && showingTable ? '200px' : '400px'; const exploreClass = split ? 'explore explore-split' : 'explore'; - const selectedDatasource = datasource ? exploreDatasources.find(d => d.label === datasource.name) : undefined; + const selectedDatasource = datasource ? exploreDatasources.find(d => d.name === datasource.name) : undefined; const graphLoading = queryTransactions.some(qt => qt.resultType === 'Graph' && !qt.done); const tableLoading = queryTransactions.some(qt => qt.resultType === 'Table' && !qt.done); const logsLoading = queryTransactions.some(qt => qt.resultType === 'Logs' && !qt.done); @@ -910,26 +908,10 @@ export class Explore extends React.PureComponent { )} {!datasourceMissing ? (
-