diff --git a/packages/grafana-ui/src/components/Cascader/Cascader.tsx b/packages/grafana-ui/src/components/Cascader/Cascader.tsx index 3fbd8afc56d..31671b60785 100644 --- a/packages/grafana-ui/src/components/Cascader/Cascader.tsx +++ b/packages/grafana-ui/src/components/Cascader/Cascader.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Icon } from '../Icon/Icon'; import RCCascader from 'rc-cascader'; -import { Select } from '../Forms/Select/Select'; +import { Select } from '../Select/Select'; import { FormInputSize } from '../Forms/types'; import { Input } from '../Forms/Input/Input'; import { SelectableValue } from '@grafana/data'; diff --git a/packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx b/packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx index 27e02d65065..2bc668c2348 100644 --- a/packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx +++ b/packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx @@ -8,7 +8,7 @@ import { TLSAuthSettings } from './TLSAuthSettings'; import { DataSourceSettings } from '@grafana/data'; import { HttpSettingsProps } from './types'; import { CustomHeadersSettings } from './CustomHeadersSettings'; -import { Select } from '../Select/Select'; +import { Select } from '../Forms/Legacy/Select/Select'; import { Input } from '../Input/Input'; import { FormField } from '../FormField/FormField'; import { FormLabel } from '../FormLabel/FormLabel'; diff --git a/packages/grafana-ui/src/components/Forms/Form.story.tsx b/packages/grafana-ui/src/components/Forms/Form.story.tsx index ed0cfb73f52..82f72c22ebe 100644 --- a/packages/grafana-ui/src/components/Forms/Form.story.tsx +++ b/packages/grafana-ui/src/components/Forms/Form.story.tsx @@ -11,7 +11,7 @@ import { Switch } from './Switch'; import { Checkbox } from './Checkbox'; import { RadioButtonGroup } from './RadioButtonGroup/RadioButtonGroup'; -import { Select } from './Select/Select'; +import { Select } from '../Select/Select'; import Forms from './index'; import mdx from './Form.mdx'; import { ValidateResult } from 'react-hook-form'; diff --git a/packages/grafana-ui/src/components/Select/ButtonSelect.story.tsx b/packages/grafana-ui/src/components/Forms/Legacy/Select/ButtonSelect.story.tsx similarity index 89% rename from packages/grafana-ui/src/components/Select/ButtonSelect.story.tsx rename to packages/grafana-ui/src/components/Forms/Legacy/Select/ButtonSelect.story.tsx index af306fb8cde..9dff759ed59 100644 --- a/packages/grafana-ui/src/components/Select/ButtonSelect.story.tsx +++ b/packages/grafana-ui/src/components/Forms/Legacy/Select/ButtonSelect.story.tsx @@ -2,8 +2,8 @@ import React from 'react'; import { storiesOf } from '@storybook/react'; import { action } from '@storybook/addon-actions'; import { withKnobs, object, text } from '@storybook/addon-knobs'; -import { withCenteredStory } from '../../utils/storybook/withCenteredStory'; -import { UseState } from '../../utils/storybook/UseState'; +import { withCenteredStory } from '../../../../utils/storybook/withCenteredStory'; +import { UseState } from '../../../../utils/storybook/UseState'; import { SelectableValue } from '@grafana/data'; import { ButtonSelect } from './ButtonSelect'; diff --git a/packages/grafana-ui/src/components/Forms/Legacy/Select/ButtonSelect.tsx b/packages/grafana-ui/src/components/Forms/Legacy/Select/ButtonSelect.tsx new file mode 100644 index 00000000000..5ad3a55d866 --- /dev/null +++ b/packages/grafana-ui/src/components/Forms/Legacy/Select/ButtonSelect.tsx @@ -0,0 +1,97 @@ +import React, { PureComponent, ReactElement } from 'react'; +import Select from './Select'; +import { PopoverContent } from '../../../Tooltip/Tooltip'; +import { SelectableValue } from '@grafana/data'; + +interface ButtonComponentProps { + label: ReactElement | string | undefined; + className: string | undefined; + iconClass?: string; +} + +const ButtonComponent = (buttonProps: ButtonComponentProps) => (props: any) => { + const { label, className, iconClass } = buttonProps; + + return ( +
+
+ {iconClass && } + {label ? label : ''} + {!props.menuIsOpen && } + {props.menuIsOpen && } +
+
+ ); +}; + +export interface Props { + className: string | undefined; + options: Array>; + value?: SelectableValue; + label?: ReactElement | string; + iconClass?: string; + components?: any; + maxMenuHeight?: number; + onChange: (item: SelectableValue) => void; + tooltipContent?: PopoverContent; + isMenuOpen?: boolean; + onOpenMenu?: () => void; + onCloseMenu?: () => void; + tabSelectsValue?: boolean; + autoFocus?: boolean; +} + +export class ButtonSelect extends PureComponent> { + onChange = (item: SelectableValue) => { + const { onChange } = this.props; + onChange(item); + }; + + render() { + const { + className, + options, + value, + label, + iconClass, + components, + maxMenuHeight, + tooltipContent, + isMenuOpen, + onOpenMenu, + onCloseMenu, + tabSelectsValue, + autoFocus = true, + } = this.props; + const combinedComponents = { + ...components, + Control: ButtonComponent({ label, className, iconClass }), + }; + + return ( + { + action('onChanged fired')(value); + updateValue(value); + }} + /> + ); + }} + + ); +}; + +export const withAllowCustomValue = () => { + // @ts-ignore + const value = object>('Selected Value:', null); + + return ( + + {(value, updateValue) => { + return ( + { - setValue(v); - }} - size="md" - {...getDynamicProps()} - /> - - ); -}; - -/** - * Uses plain values instead of SelectableValue - */ -export const basicSelectPlainValue = () => { - const [value, setValue] = useState(); - return ( - <> - { - setValue(v.value); - }} - size="md" - {...getDynamicProps()} - /> - - ); -}; - -/** - * Uses plain values instead of SelectableValue - */ -export const multiPlainValue = () => { - const [value, setValue] = useState(); - - return ( - <> - { - setValue(v.map((v: any) => v.value)); - }} - size="md" - {...getDynamicProps()} - /> - - ); -}; - -export const multiSelect = () => { - const [value, setValue] = useState>>([]); - - return ( - <> - { - setValue(v); - }} - size="md" - {...getDynamicProps()} - /> - - ); -}; - -export const multiSelectAsync = () => { - const [value, setValue] = useState>>(); - - return ( - { - setValue(v); - }} - size="md" - allowCustomValue - {...getDynamicProps()} - /> - ); -}; -export const buttonSelect = () => { - const [value, setValue] = useState>(); - const icon = getIconKnob(); - return ( - { - setValue(v); - }} - size="md" - allowCustomValue - icon={icon} - {...getDynamicProps()} - /> - ); -}; - -export const basicSelectAsync = () => { - const [value, setValue] = useState>(); - - return ( - { - setValue(v); - }} - size="md" - {...getDynamicProps()} - /> - ); -}; - -export const customizedControl = () => { - const [value, setValue] = useState>(); - - return ( - { - setValue(v); - }} - size="md" - {...getDynamicProps()} - /> - - - ); -}; - -export const customValueCreation = () => { - const [value, setValue] = useState>(); - const [customOptions, setCustomOptions] = useState>>([]); - const options = generateOptions(); - return ( - <> - onChange(o.value!)} /> ); } } diff --git a/packages/grafana-ui/src/components/OptionsUI/select.tsx b/packages/grafana-ui/src/components/OptionsUI/select.tsx index 5ca25dc85f8..b14572ee726 100644 --- a/packages/grafana-ui/src/components/OptionsUI/select.tsx +++ b/packages/grafana-ui/src/components/OptionsUI/select.tsx @@ -1,11 +1,11 @@ import React from 'react'; import { FieldConfigEditorProps, SelectFieldConfigSettings } from '@grafana/data'; -import Forms from '../Forms'; +import { Select } from '../Select/Select'; export function SelectValueEditor({ value, onChange, item, }: FieldConfigEditorProps>) { - return defaultValue={value} onChange={e => onChange(e.value)} options={item.settings?.options} />; + return defaultValue={value} onChange={e => onChange(e.value)} options={item.settings?.options} />; } diff --git a/packages/grafana-ui/src/components/RefreshPicker/RefreshPicker.tsx b/packages/grafana-ui/src/components/RefreshPicker/RefreshPicker.tsx index 649054c19e2..9ff215d24f9 100644 --- a/packages/grafana-ui/src/components/RefreshPicker/RefreshPicker.tsx +++ b/packages/grafana-ui/src/components/RefreshPicker/RefreshPicker.tsx @@ -3,7 +3,7 @@ import classNames from 'classnames'; import { SelectableValue } from '@grafana/data'; import { css } from 'emotion'; import { Tooltip } from '../Tooltip/Tooltip'; -import { ButtonSelect } from '../Select/ButtonSelect'; +import { ButtonSelect } from '../Forms/Legacy/Select/ButtonSelect'; import memoizeOne from 'memoize-one'; import { GrafanaTheme } from '@grafana/data'; import { withTheme } from '../../themes'; diff --git a/packages/grafana-ui/src/components/Segment/SegmentSelect.tsx b/packages/grafana-ui/src/components/Segment/SegmentSelect.tsx index 1f4fc462530..bb0c7d236a4 100644 --- a/packages/grafana-ui/src/components/Segment/SegmentSelect.tsx +++ b/packages/grafana-ui/src/components/Segment/SegmentSelect.tsx @@ -2,7 +2,7 @@ import React, { useRef } from 'react'; import { css, cx } from 'emotion'; import useClickAway from 'react-use/lib/useClickAway'; import { SelectableValue } from '@grafana/data'; -import { Select } from '../Select/Select'; +import { Select } from '../Forms/Legacy/Select/Select'; export interface Props { value?: SelectableValue; diff --git a/packages/grafana-ui/src/components/Select/ButtonSelect.tsx b/packages/grafana-ui/src/components/Select/ButtonSelect.tsx index fe4e7ef2a57..f98eddd5cc8 100644 --- a/packages/grafana-ui/src/components/Select/ButtonSelect.tsx +++ b/packages/grafana-ui/src/components/Select/ButtonSelect.tsx @@ -1,97 +1,89 @@ -import React, { PureComponent, ReactElement } from 'react'; -import Select from './Select'; -import { PopoverContent } from '../Tooltip/Tooltip'; -import { SelectableValue } from '@grafana/data'; +import React from 'react'; +import { css } from 'emotion'; +import { GrafanaTheme } from '@grafana/data'; -interface ButtonComponentProps { - label: ReactElement | string | undefined; - className: string | undefined; - iconClass?: string; -} - -const ButtonComponent = (buttonProps: ButtonComponentProps) => (props: any) => { - const { label, className, iconClass } = buttonProps; +import { Button, ButtonVariant, ButtonProps } from '../Button'; +import { ComponentSize } from '../../types/size'; +import { SelectCommonProps, CustomControlProps } from './types'; +import { SelectBase } from './SelectBase'; +import { stylesFactory, useTheme } from '../../themes'; +import { Icon } from '../Icon/Icon'; +import { IconType } from '../Icon/types'; - return ( -
-
- {iconClass && } - {label ? label : ''} - {!props.menuIsOpen && } - {props.menuIsOpen && } -
-
- ); -}; - -export interface Props { - className: string | undefined; - options: Array>; - value?: SelectableValue; - label?: ReactElement | string; - iconClass?: string; - components?: any; - maxMenuHeight?: number; - onChange: (item: SelectableValue) => void; - tooltipContent?: PopoverContent; - isMenuOpen?: boolean; - onOpenMenu?: () => void; - onCloseMenu?: () => void; - tabSelectsValue?: boolean; - autoFocus?: boolean; +interface ButtonSelectProps extends Omit, 'renderControl' | 'size' | 'prefix'> { + icon?: IconType; + variant?: ButtonVariant; + size?: ComponentSize; } -export class ButtonSelect extends PureComponent> { - onChange = (item: SelectableValue) => { - const { onChange } = this.props; - onChange(item); - }; - - render() { - const { - className, - options, - value, - label, - iconClass, - components, - maxMenuHeight, - tooltipContent, - isMenuOpen, - onOpenMenu, - onCloseMenu, - tabSelectsValue, - autoFocus = true, - } = this.props; - const combinedComponents = { - ...components, - Control: ButtonComponent({ label, className, iconClass }), - }; +interface SelectButtonProps extends Omit { + icon?: IconType; + isOpen?: boolean; +} +const SelectButton = React.forwardRef( + ({ icon, children, isOpen, ...buttonProps }, ref) => { + const getStyles = stylesFactory((theme: GrafanaTheme) => ({ + wrapper: css` + display: flex; + align-items: center; + justify-content: space-between; + max-width: 200px; + text-overflow: ellipsis; + `, + iconWrap: css` + padding: 0 15px 0 0; + `, + caretWrap: css` + padding-left: ${theme.spacing.sm}; + margin-left: ${theme.spacing.sm}; + margin-right: -${theme.spacing.sm}; + height: 100%; + `, + })); + const styles = getStyles(useTheme()); + const buttonIcon = `fa fa-${icon}`; + const caretIcon = isOpen ? 'caret-up' : 'caret-down'; return ( - { - action('onChanged fired')(value); - updateValue(value); - }} - /> - ); - }} -
+ <> + { - action('onChanged fired')(value); - updateValue(value); - }} - /> - ); - }} - + <> + { + setValue(v.value); + }} + size="md" + {...getDynamicProps()} + /> + + ); +}; + +/** + * Uses plain values instead of SelectableValue + */ +export const multiPlainValue = () => { + const [value, setValue] = useState(); + + return ( + <> + { + setValue(v.map((v: any) => v.value)); + }} + size="md" + {...getDynamicProps()} + /> + ); +}; + +export const multiSelect = () => { + const [value, setValue] = useState>>([]); + return ( - + { + setValue(v); + }} + size="md" + {...getDynamicProps()} + /> + + ); +}; + +export const multiSelectAsync = () => { + const [value, setValue] = useState>>(); + + return ( + { + setValue(v); + }} + size="md" + allowCustomValue + {...getDynamicProps()} + /> + ); +}; +export const buttonSelect = () => { + const [value, setValue] = useState>(); + const icon = getIconKnob(); + return ( + { + setValue(v); + }} + size="md" + allowCustomValue + icon={icon} + {...getDynamicProps()} + /> + ); +}; + +export const basicSelectAsync = () => { + const [value, setValue] = useState>(); + + return ( + { - action('onChange')(value); - setValue(value); + defaultOptions + value={value} + onChange={v => { + setValue(v); + }} + size="md" + {...getDynamicProps()} + /> + ); +}; + +export const customizedControl = () => { + const [value, setValue] = useState>(); + + return ( + { + setValue(v); + }} + size="md" + {...getDynamicProps()} + /> + + + ); +}; + +export const customValueCreation = () => { + const [value, setValue] = useState>(); + const [customOptions, setCustomOptions] = useState>>([]); + const options = generateOptions(); + return ( + <> + props.onChange(e.value)} options={props.item.settings?.options} /> ), }; diff --git a/public/app/core/components/PermissionList/AddPermission.tsx b/public/app/core/components/PermissionList/AddPermission.tsx index a661a85db9b..99733d4373a 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/Select/UserPicker'; import { TeamPicker, Team } from 'app/core/components/Select/TeamPicker'; -import { Select } from '@grafana/ui'; +import { LegacyForms } from '@grafana/ui'; import { SelectableValue } from '@grafana/data'; import { User } from 'app/types'; import { @@ -12,6 +12,7 @@ import { NewDashboardAclItem, OrgRole, } from 'app/types/acl'; +const { Select } = LegacyForms; export interface Props { onAddPermission: (item: NewDashboardAclItem) => void; diff --git a/public/app/core/components/PermissionList/DisabledPermissionListItem.tsx b/public/app/core/components/PermissionList/DisabledPermissionListItem.tsx index ebf3cbad1bc..2bb61bf60b1 100644 --- a/public/app/core/components/PermissionList/DisabledPermissionListItem.tsx +++ b/public/app/core/components/PermissionList/DisabledPermissionListItem.tsx @@ -1,6 +1,7 @@ import React, { Component } from 'react'; -import { Select } from '@grafana/ui'; +import { LegacyForms } from '@grafana/ui'; import { dashboardPermissionLevels } from 'app/types/acl'; +const { Select } = LegacyForms; export interface Props { item: any; diff --git a/public/app/core/components/PermissionList/PermissionListItem.tsx b/public/app/core/components/PermissionList/PermissionListItem.tsx index 3f56799ab19..0579a2667a2 100644 --- a/public/app/core/components/PermissionList/PermissionListItem.tsx +++ b/public/app/core/components/PermissionList/PermissionListItem.tsx @@ -1,8 +1,9 @@ import React, { PureComponent } from 'react'; -import { Select } from '@grafana/ui'; +import { LegacyForms } from '@grafana/ui'; import { SelectableValue } from '@grafana/data'; import { dashboardPermissionLevels, DashboardAcl, PermissionLevel } from 'app/types/acl'; import { FolderInfo } from 'app/types'; +const { Select } = LegacyForms; const setClassNameHelper = (inherited: boolean) => { return inherited ? 'gf-form-disabled' : ''; diff --git a/public/app/core/components/Select/DashboardPicker.tsx b/public/app/core/components/Select/DashboardPicker.tsx index bbcd57ce319..3e69b57b67a 100644 --- a/public/app/core/components/Select/DashboardPicker.tsx +++ b/public/app/core/components/Select/DashboardPicker.tsx @@ -2,7 +2,7 @@ import React, { FC } from 'react'; import { debounce } from 'lodash'; import { useAsyncFn } from 'react-use'; import { SelectableValue } from '@grafana/data'; -import { Forms } from '@grafana/ui'; +import { AsyncSelect } from '@grafana/ui'; import { FormInputSize } from '@grafana/ui/src/components/Forms/types'; import { backendSrv } from 'app/core/services/backend_srv'; import { DashboardSearchHit, DashboardDTO } from 'app/types'; @@ -42,7 +42,7 @@ export const DashboardPicker: FC = ({ const [state, searchDashboards] = useAsyncFn(debouncedSearch, []); return ( - void; diff --git a/public/app/core/components/Select/FolderPicker.tsx b/public/app/core/components/Select/FolderPicker.tsx index ff3a3decb64..20899e345b7 100644 --- a/public/app/core/components/Select/FolderPicker.tsx +++ b/public/app/core/components/Select/FolderPicker.tsx @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import { Forms } from '@grafana/ui'; +import { AsyncSelect } from '@grafana/ui'; import { AppEvents, SelectableValue } from '@grafana/data'; import { debounce } from 'lodash'; import appEvents from '../../app_events'; @@ -150,7 +150,7 @@ export class FolderPicker extends PureComponent { return ( <> {useNewForms && ( - {
- void; diff --git a/public/app/core/components/Select/OrgPicker.tsx b/public/app/core/components/Select/OrgPicker.tsx index 544488e4be0..c74de40e7c3 100644 --- a/public/app/core/components/Select/OrgPicker.tsx +++ b/public/app/core/components/Select/OrgPicker.tsx @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import { Forms } from '@grafana/ui'; +import { AsyncSelect } from '@grafana/ui'; import { getBackendSrv } from 'app/core/services/backend_srv'; import { Organization } from 'app/types'; import { SelectableValue } from '@grafana/data'; @@ -54,7 +54,7 @@ export class OrgPicker extends PureComponent { const { isLoading } = this.state; return ( - - onPanelConfigChange('repeat', value.value)} options={variableOptions} @@ -72,7 +72,7 @@ export const GeneralPanelOptions: FC<{ {panel.repeat && panel.repeatDirection === 'h' && ( - onPanelConfigChange('maxPerRow', value.value)} diff --git a/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx b/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx index 5b041daa1df..6e2f21f55ac 100644 --- a/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx +++ b/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx @@ -1,6 +1,6 @@ import React, { PureComponent } from 'react'; import { FieldConfigSource, GrafanaTheme, PanelData, PanelPlugin, SelectableValue } from '@grafana/data'; -import { Forms, stylesFactory, Icon } from '@grafana/ui'; +import { Select, stylesFactory, Icon } from '@grafana/ui'; import { css, cx } from 'emotion'; import config from 'app/core/config'; import AutoSizer from 'react-virtualized-auto-sizer'; @@ -205,7 +205,7 @@ export class PanelEditorUnconnected extends PureComponent {
- v.value === uiState.mode)} options={displayModes} onChange={this.onDiplayModeChange} diff --git a/public/app/features/dashboard/components/ShareModal/ShareEmbed.tsx b/public/app/features/dashboard/components/ShareModal/ShareEmbed.tsx index c8d9c97fb5d..2d0928b7f70 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareEmbed.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareEmbed.tsx @@ -1,5 +1,6 @@ import React, { PureComponent } from 'react'; -import { Switch, Select } from '@grafana/ui'; +import { Switch, LegacyForms } from '@grafana/ui'; +const { Select } = LegacyForms; import { SelectableValue } from '@grafana/data'; import { DashboardModel, PanelModel } from 'app/features/dashboard/state'; import { buildIframeHtml } from './utils'; diff --git a/public/app/features/dashboard/components/ShareModal/ShareLink.tsx b/public/app/features/dashboard/components/ShareModal/ShareLink.tsx index 2e9ea52c2bd..cb5f2c143f7 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareLink.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareLink.tsx @@ -1,6 +1,7 @@ import React, { PureComponent } from 'react'; import { e2e } from '@grafana/e2e'; -import { Switch, Select, ClipboardButton } from '@grafana/ui'; +import { Switch, LegacyForms, ClipboardButton } from '@grafana/ui'; +const { Select } = LegacyForms; import { SelectableValue, PanelModel, AppEvents } from '@grafana/data'; import { DashboardModel } from 'app/features/dashboard/state'; import { buildImageUrl, buildShareUrl } from './utils'; diff --git a/public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx b/public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx index 5467bfb8fb4..91e41bcb035 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx @@ -1,5 +1,6 @@ import React, { PureComponent } from 'react'; -import { Button, ClipboardButton, Input, LinkButton, Select } from '@grafana/ui'; +import { Button, ClipboardButton, Input, LinkButton, LegacyForms } from '@grafana/ui'; +const { Select } = LegacyForms; import { AppEvents, SelectableValue } from '@grafana/data'; import { getBackendSrv } from '@grafana/runtime'; import { DashboardModel, PanelModel } from 'app/features/dashboard/state'; diff --git a/public/app/features/explore/AdHocFilter.tsx b/public/app/features/explore/AdHocFilter.tsx index 2edeb97d7c7..876ac4fe079 100644 --- a/public/app/features/explore/AdHocFilter.tsx +++ b/public/app/features/explore/AdHocFilter.tsx @@ -1,5 +1,6 @@ import React, { useContext } from 'react'; -import { Select, ThemeContext } from '@grafana/ui'; +import { LegacyForms, ThemeContext } from '@grafana/ui'; +const { Select } = LegacyForms; import { css, cx } from 'emotion'; import { GrafanaTheme, SelectableValue } from '@grafana/data'; diff --git a/public/app/features/explore/ExploreToolbar.tsx b/public/app/features/explore/ExploreToolbar.tsx index a2b17d4205c..29da103daac 100644 --- a/public/app/features/explore/ExploreToolbar.tsx +++ b/public/app/features/explore/ExploreToolbar.tsx @@ -7,7 +7,8 @@ import classNames from 'classnames'; import { css } from 'emotion'; import { ExploreId, ExploreItemState } from 'app/types/explore'; -import { ToggleButtonGroup, ToggleButton, Tooltip, ButtonSelect, SetInterval } from '@grafana/ui'; +import { ToggleButtonGroup, ToggleButton, Tooltip, LegacyForms, SetInterval } from '@grafana/ui'; +const { ButtonSelect } = LegacyForms; import { RawTimeRange, TimeZone, TimeRange, DataQuery, ExploreMode } from '@grafana/data'; import { DataSourcePicker } from 'app/core/components/Select/DataSourcePicker'; import { StoreState } from 'app/types/store'; diff --git a/public/app/features/explore/RichHistory/RichHistoryQueriesTab.tsx b/public/app/features/explore/RichHistory/RichHistoryQueriesTab.tsx index 322b7b135d9..d6f20d80b16 100644 --- a/public/app/features/explore/RichHistory/RichHistoryQueriesTab.tsx +++ b/public/app/features/explore/RichHistory/RichHistoryQueriesTab.tsx @@ -21,7 +21,8 @@ import { // Components import RichHistoryCard from './RichHistoryCard'; import { sortOrderOptions } from './RichHistory'; -import { Select, Slider } from '@grafana/ui'; +import { LegacyForms, Slider } from '@grafana/ui'; +const { Select } = LegacyForms; export interface Props { queries: RichHistoryQuery[]; diff --git a/public/app/features/explore/RichHistory/RichHistorySettings.test.tsx b/public/app/features/explore/RichHistory/RichHistorySettings.test.tsx index 1e1257d11ae..85b8f38cb80 100644 --- a/public/app/features/explore/RichHistory/RichHistorySettings.test.tsx +++ b/public/app/features/explore/RichHistory/RichHistorySettings.test.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { mount } from 'enzyme'; import { RichHistorySettings, RichHistorySettingsProps } from './RichHistorySettings'; -import { Forms } from '@grafana/ui'; +import { Forms, Select } from '@grafana/ui'; const setup = (propOverrides?: Partial) => { const props: RichHistorySettingsProps = { @@ -23,7 +23,7 @@ const setup = (propOverrides?: Partial) => { describe('RichHistorySettings', () => { it('should render component with correct retention period', () => { const wrapper = setup(); - expect(wrapper.find(Forms.Select).text()).toEqual('2 weeks'); + expect(wrapper.find(Select).text()).toEqual('2 weeks'); }); it('should render component with correctly checked starredTabAsFirstTab settings', () => { const wrapper = setup(); diff --git a/public/app/features/explore/RichHistory/RichHistorySettings.tsx b/public/app/features/explore/RichHistory/RichHistorySettings.tsx index a3911e91a8b..501ee8d3205 100644 --- a/public/app/features/explore/RichHistory/RichHistorySettings.tsx +++ b/public/app/features/explore/RichHistory/RichHistorySettings.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { css } from 'emotion'; -import { stylesFactory, useTheme, Forms, Button } from '@grafana/ui'; +import { stylesFactory, useTheme, Forms, Select, Button } from '@grafana/ui'; import { GrafanaTheme, AppEvents } from '@grafana/data'; import appEvents from 'app/core/app_events'; import { CoreEvents } from 'app/types'; @@ -79,11 +79,7 @@ export function RichHistorySettings(props: RichHistorySettingsProps) { className="space-between" >
- +
diff --git a/public/app/features/explore/RichHistory/RichHistoryStarredTab.tsx b/public/app/features/explore/RichHistory/RichHistoryStarredTab.tsx index 0610143466a..57b644fb16d 100644 --- a/public/app/features/explore/RichHistory/RichHistoryStarredTab.tsx +++ b/public/app/features/explore/RichHistory/RichHistoryStarredTab.tsx @@ -15,7 +15,8 @@ import { sortQueries, createDatasourcesList } from '../../../core/utils/richHist // Components import RichHistoryCard from './RichHistoryCard'; import { sortOrderOptions } from './RichHistory'; -import { Select } from '@grafana/ui'; +import { LegacyForms } from '@grafana/ui'; +const { Select } = LegacyForms; export interface Props { queries: RichHistoryQuery[]; diff --git a/public/app/features/expressions/ExpressionQueryEditor.tsx b/public/app/features/expressions/ExpressionQueryEditor.tsx index 0799c4edc22..054c135912b 100644 --- a/public/app/features/expressions/ExpressionQueryEditor.tsx +++ b/public/app/features/expressions/ExpressionQueryEditor.tsx @@ -1,7 +1,8 @@ // Libraries import React, { PureComponent, ChangeEvent } from 'react'; -import { FormLabel, Select, FormField } from '@grafana/ui'; +import { FormLabel, LegacyForms, FormField } from '@grafana/ui'; +const { Select } = LegacyForms; import { SelectableValue, ReducerID, QueryEditorProps } from '@grafana/data'; // Types diff --git a/public/app/features/teams/TeamMemberRow.tsx b/public/app/features/teams/TeamMemberRow.tsx index 4b866ed2e41..243dda9b833 100644 --- a/public/app/features/teams/TeamMemberRow.tsx +++ b/public/app/features/teams/TeamMemberRow.tsx @@ -1,6 +1,7 @@ import React, { PureComponent } from 'react'; import { connect } from 'react-redux'; -import { Select, DeleteButton } from '@grafana/ui'; +import { LegacyForms, DeleteButton } from '@grafana/ui'; +const { Select } = LegacyForms; import { SelectableValue } from '@grafana/data'; import { TeamMember, teamsPermissionLevels, TeamPermissionLevel } from 'app/types'; diff --git a/public/app/plugins/datasource/cloudwatch/components/ConfigEditor.tsx b/public/app/plugins/datasource/cloudwatch/components/ConfigEditor.tsx index cc621107712..afad8a79585 100644 --- a/public/app/plugins/datasource/cloudwatch/components/ConfigEditor.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/ConfigEditor.tsx @@ -1,5 +1,6 @@ import React, { PureComponent } from 'react'; -import { FormLabel, Select, Input, Button } from '@grafana/ui'; +import { FormLabel, LegacyForms, Input, Button } from '@grafana/ui'; +const { Select } = LegacyForms; import { DataSourcePluginOptionsEditorProps, onUpdateDatasourceJsonDataOptionSelect, diff --git a/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx b/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx index 6edfbea75ba..c82f79ed183 100644 --- a/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx +++ b/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx @@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'; // Types -import { Select } from '@grafana/ui'; +import { LegacyForms } from '@grafana/ui'; import { DataQuery, DataQueryError, PanelData, DataFrame, SelectableValue } from '@grafana/data'; import { DashboardQuery } from './types'; import config from 'app/core/config'; @@ -12,6 +12,7 @@ import { PanelModel } from 'app/features/dashboard/state'; import { SHARED_DASHBODARD_QUERY } from './types'; import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv'; import { filterPanelDataToQuery } from 'app/features/dashboard/panel_editor/QueryEditorRow'; +const { Select } = LegacyForms; type ResultInfo = { img: string; // The Datasource diff --git a/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.test.tsx b/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.test.tsx index 1dcc1347228..c752e1a75e9 100644 --- a/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.test.tsx +++ b/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.test.tsx @@ -3,7 +3,8 @@ import { last } from 'lodash'; import { mount } from 'enzyme'; import { ElasticDetails } from './ElasticDetails'; import { createDefaultConfigOptions } from './mocks'; -import { Select } from '@grafana/ui'; +import { LegacyForms } from '@grafana/ui'; +const { Select } = LegacyForms; describe('ElasticDetails', () => { it('should render without error', () => { diff --git a/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx b/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx index 043ec15c2e1..5127bd500d1 100644 --- a/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx +++ b/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx @@ -1,5 +1,6 @@ import React from 'react'; -import { EventsWithValidation, FormField, Input, regexValidation, Select } from '@grafana/ui'; +import { EventsWithValidation, FormField, Input, regexValidation, LegacyForms } from '@grafana/ui'; +const { Select } = LegacyForms; import { ElasticsearchOptions } from '../types'; import { DataSourceSettings, SelectableValue } from '@grafana/data'; diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AnalyticsConfig.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AnalyticsConfig.tsx index 9e2b97fd524..efc612af5fd 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AnalyticsConfig.tsx +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AnalyticsConfig.tsx @@ -1,7 +1,8 @@ import React, { PureComponent, ChangeEvent } from 'react'; import { SelectableValue } from '@grafana/data'; import { AzureCredentialsForm } from './AzureCredentialsForm'; -import { Switch, FormLabel, Select, Button } from '@grafana/ui'; +import { Switch, FormLabel, LegacyForms, Button } from '@grafana/ui'; +const { Select } = LegacyForms; import { AzureDataSourceSettings } from '../types'; export interface State { diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.tsx index c999032fb87..0926fd0c25a 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.tsx +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.tsx @@ -1,6 +1,7 @@ import React, { ChangeEvent, PureComponent } from 'react'; import { SelectableValue } from '@grafana/data'; -import { Input, FormLabel, Select, Button } from '@grafana/ui'; +import { Input, FormLabel, LegacyForms, Button } from '@grafana/ui'; +const { Select } = LegacyForms; export interface Props { selectedAzureCloud?: string; diff --git a/public/app/plugins/datasource/graphite/configuration/ConfigEditor.tsx b/public/app/plugins/datasource/graphite/configuration/ConfigEditor.tsx index c04a990475e..b3903bc70ba 100644 --- a/public/app/plugins/datasource/graphite/configuration/ConfigEditor.tsx +++ b/public/app/plugins/datasource/graphite/configuration/ConfigEditor.tsx @@ -1,5 +1,6 @@ import React, { PureComponent } from 'react'; -import { DataSourceHttpSettings, FormLabel, Select, Switch } from '@grafana/ui'; +import { DataSourceHttpSettings, FormLabel, LegacyForms, Switch } from '@grafana/ui'; +const { Select } = LegacyForms; import { DataSourcePluginOptionsEditorProps, onUpdateDatasourceJsonDataOptionSelect, diff --git a/public/app/plugins/datasource/influxdb/components/ConfigEditor.tsx b/public/app/plugins/datasource/influxdb/components/ConfigEditor.tsx index 6ed7510b49f..66b06e45bd1 100644 --- a/public/app/plugins/datasource/influxdb/components/ConfigEditor.tsx +++ b/public/app/plugins/datasource/influxdb/components/ConfigEditor.tsx @@ -8,7 +8,8 @@ import { onUpdateDatasourceJsonDataOptionSelect, onUpdateDatasourceSecureJsonDataOption, } from '@grafana/data'; -import { DataSourceHttpSettings, FormLabel, Input, SecretFormField, Select } from '@grafana/ui'; +import { DataSourceHttpSettings, FormLabel, Input, SecretFormField, LegacyForms } from '@grafana/ui'; +const { Select } = LegacyForms; import { InfluxOptions, InfluxSecureJsonData } from '../types'; const httpModes = [ diff --git a/public/app/plugins/datasource/input/InputQueryEditor.tsx b/public/app/plugins/datasource/input/InputQueryEditor.tsx index 53700f09f71..20a9a741566 100644 --- a/public/app/plugins/datasource/input/InputQueryEditor.tsx +++ b/public/app/plugins/datasource/input/InputQueryEditor.tsx @@ -5,7 +5,8 @@ import React, { PureComponent } from 'react'; import { InputDatasource, describeDataFrame } from './InputDatasource'; import { InputQuery, InputOptions } from './types'; -import { FormLabel, Select, TableInputCSV } from '@grafana/ui'; +import { FormLabel, LegacyForms, TableInputCSV } from '@grafana/ui'; +const { Select } = LegacyForms; import { DataFrame, toCSV, SelectableValue, MutableDataFrame, QueryEditorProps } from '@grafana/data'; import { dataFrameToCSV } from './utils'; diff --git a/public/app/plugins/datasource/opentsdb/components/OpenTsdbDetails.tsx b/public/app/plugins/datasource/opentsdb/components/OpenTsdbDetails.tsx index 12c07bdcf44..ed7bfbc5150 100644 --- a/public/app/plugins/datasource/opentsdb/components/OpenTsdbDetails.tsx +++ b/public/app/plugins/datasource/opentsdb/components/OpenTsdbDetails.tsx @@ -1,5 +1,6 @@ import React, { SyntheticEvent } from 'react'; -import { FormLabel, Select, Input } from '@grafana/ui'; +import { FormLabel, LegacyForms, Input } from '@grafana/ui'; +const { Select } = LegacyForms; import { DataSourceSettings, SelectableValue } from '@grafana/data'; import { OpenTsdbOptions } from '../types'; diff --git a/public/app/plugins/datasource/prometheus/components/PromQueryEditor.tsx b/public/app/plugins/datasource/prometheus/components/PromQueryEditor.tsx index c2a614a3552..c7a5b26097f 100644 --- a/public/app/plugins/datasource/prometheus/components/PromQueryEditor.tsx +++ b/public/app/plugins/datasource/prometheus/components/PromQueryEditor.tsx @@ -2,9 +2,11 @@ import _ from 'lodash'; import React, { PureComponent } from 'react'; // Types -import { FormLabel, Select, Switch } from '@grafana/ui'; +import { FormLabel, LegacyForms, Switch } from '@grafana/ui'; import { SelectableValue, QueryEditorProps } from '@grafana/data'; +const { Select } = LegacyForms; + import { PrometheusDatasource } from '../datasource'; import { PromQuery, PromOptions } from '../types'; diff --git a/public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx b/public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx index d56f226dc8e..4436362c0a3 100644 --- a/public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx +++ b/public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx @@ -1,5 +1,6 @@ import React, { SyntheticEvent } from 'react'; -import { EventsWithValidation, FormField, FormLabel, Input, regexValidation, Select } from '@grafana/ui'; +import { EventsWithValidation, FormField, FormLabel, Input, regexValidation, LegacyForms } from '@grafana/ui'; +const { Select } = LegacyForms; import { DataSourceSettings, SelectableValue } from '@grafana/data'; import { PromOptions } from '../types'; diff --git a/public/app/plugins/datasource/testdata/QueryEditor.tsx b/public/app/plugins/datasource/testdata/QueryEditor.tsx index 709ff79fe9b..71d7dd674f7 100644 --- a/public/app/plugins/datasource/testdata/QueryEditor.tsx +++ b/public/app/plugins/datasource/testdata/QueryEditor.tsx @@ -6,7 +6,8 @@ import _ from 'lodash'; import { getBackendSrv } from '@grafana/runtime'; // Components -import { FormLabel, Select } from '@grafana/ui'; +import { FormLabel, LegacyForms } from '@grafana/ui'; +const { Select } = LegacyForms; import { QueryEditorProps, SelectableValue } from '@grafana/data'; // Types diff --git a/public/app/plugins/panel/bargauge/BarGaugePanelEditor.tsx b/public/app/plugins/panel/bargauge/BarGaugePanelEditor.tsx index ce1154a6c37..8a9daea9d1f 100644 --- a/public/app/plugins/panel/bargauge/BarGaugePanelEditor.tsx +++ b/public/app/plugins/panel/bargauge/BarGaugePanelEditor.tsx @@ -6,13 +6,14 @@ import { FieldDisplayEditor, PanelOptionsGroup, FormLabel, - Select, + LegacyForms, Switch, FieldPropertiesEditor, ThresholdsEditor, LegacyValueMappingsEditor, DataLinksEditor, } from '@grafana/ui'; +const { Select } = LegacyForms; import { DataLink, FieldConfig, diff --git a/public/app/plugins/panel/graph2/GraphPanelEditor.tsx b/public/app/plugins/panel/graph2/GraphPanelEditor.tsx index ced2543fbf1..370ac06154d 100644 --- a/public/app/plugins/panel/graph2/GraphPanelEditor.tsx +++ b/public/app/plugins/panel/graph2/GraphPanelEditor.tsx @@ -10,9 +10,10 @@ import { GraphTooltipOptions, PanelOptionsGrid, PanelOptionsGroup, - Select, + LegacyForms, FieldPropertiesEditor, } from '@grafana/ui'; +const { Select } = LegacyForms; import { Options, GraphOptions } from './types'; import { GraphLegendEditor } from './GraphLegendEditor'; import { NewPanelEditorContext } from 'app/features/dashboard/components/PanelEditor/PanelEditor'; diff --git a/public/app/plugins/panel/logs/LogsPanelEditor.tsx b/public/app/plugins/panel/logs/LogsPanelEditor.tsx index 4bf3278e446..8118a887cdd 100644 --- a/public/app/plugins/panel/logs/LogsPanelEditor.tsx +++ b/public/app/plugins/panel/logs/LogsPanelEditor.tsx @@ -1,6 +1,7 @@ // Libraries import React, { PureComponent } from 'react'; -import { Switch, PanelOptionsGrid, PanelOptionsGroup, FormLabel, Select } from '@grafana/ui'; +import { Switch, PanelOptionsGrid, PanelOptionsGroup, FormLabel, LegacyForms } from '@grafana/ui'; +const { Select } = LegacyForms; // Types import { Options } from './types'; diff --git a/public/app/plugins/panel/piechart/PieChartOptionsBox.tsx b/public/app/plugins/panel/piechart/PieChartOptionsBox.tsx index 86b2360ff5c..e1b5774142f 100644 --- a/public/app/plugins/panel/piechart/PieChartOptionsBox.tsx +++ b/public/app/plugins/panel/piechart/PieChartOptionsBox.tsx @@ -2,7 +2,8 @@ import React, { PureComponent } from 'react'; // Components -import { Select, FormLabel, PanelOptionsGroup } from '@grafana/ui'; +import { LegacyForms, FormLabel, PanelOptionsGroup } from '@grafana/ui'; +const { Select } = LegacyForms; // Types import { PanelEditorProps } from '@grafana/data'; diff --git a/public/app/plugins/panel/stat/StatPanelEditor.tsx b/public/app/plugins/panel/stat/StatPanelEditor.tsx index fc0bf92fa51..cf9a4040796 100644 --- a/public/app/plugins/panel/stat/StatPanelEditor.tsx +++ b/public/app/plugins/panel/stat/StatPanelEditor.tsx @@ -6,13 +6,15 @@ import { FieldDisplayEditor, PanelOptionsGroup, FormLabel, - Select, + LegacyForms, FieldPropertiesEditor, ThresholdsEditor, LegacyValueMappingsEditor, DataLinksEditor, } from '@grafana/ui'; +const { Select } = LegacyForms; + import { PanelEditorProps, ReduceDataOptions, diff --git a/public/app/plugins/panel/text2/TextPanelEditor.tsx b/public/app/plugins/panel/text2/TextPanelEditor.tsx index 62ecf2c104f..e9351188dd2 100644 --- a/public/app/plugins/panel/text2/TextPanelEditor.tsx +++ b/public/app/plugins/panel/text2/TextPanelEditor.tsx @@ -2,7 +2,8 @@ import React, { PureComponent, ChangeEvent } from 'react'; // Components -import { PanelOptionsGroup, Select } from '@grafana/ui'; +import { PanelOptionsGroup, LegacyForms } from '@grafana/ui'; +const { Select } = LegacyForms; import { PanelEditorProps, SelectableValue } from '@grafana/data'; // Types