From 7161b2dc9bc1a76dc1fe2b4b2c05ea2139b2b1f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 12 Dec 2018 09:51:17 +0100 Subject: [PATCH] wip --- public/app/core/components/Picker/Select.tsx | 60 +++++++++++++++++++ .../dashboard/dashgrid/VisualizationTab.tsx | 60 +++++++++++++++---- .../dashboard/dashgrid/VizTypePicker.tsx | 3 - public/sass/components/_form_select_box.scss | 6 +- 4 files changed, 110 insertions(+), 19 deletions(-) create mode 100644 public/app/core/components/Picker/Select.tsx diff --git a/public/app/core/components/Picker/Select.tsx b/public/app/core/components/Picker/Select.tsx new file mode 100644 index 00000000000..b8704893cdb --- /dev/null +++ b/public/app/core/components/Picker/Select.tsx @@ -0,0 +1,60 @@ +// 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/features/dashboard/dashgrid/VisualizationTab.tsx b/public/app/features/dashboard/dashgrid/VisualizationTab.tsx index 19026754f83..7411c59a91e 100644 --- a/public/app/features/dashboard/dashgrid/VisualizationTab.tsx +++ b/public/app/features/dashboard/dashgrid/VisualizationTab.tsx @@ -21,9 +21,23 @@ interface Props { onTypeChanged: (newType: PanelPlugin) => void; } -export class VisualizationTab extends PureComponent { +interface State { + isVizPickerOpen: boolean; + searchQuery: string; +} + +export class VisualizationTab extends PureComponent { element: HTMLElement; angularOptions: AngularComponent; + searchInput: HTMLElement; + + constructor(props) { + super(props); + + this.state = { + isVizPickerOpen: false, + }; + } getPanelDefaultOptions = () => { const { panel, plugin } = this.props; @@ -120,18 +134,39 @@ export class VisualizationTab extends PureComponent { this.forceUpdate(); }; - render() { + onOpenVizPicker = () => { + this.setState({ isVizPickerOpen: true }); + }; + + renderToolbar = () => { const { plugin } = this.props; - const panelSelection = { - title: plugin.name, - imgSrc: plugin.info.logos.small, - render: () => { - // the needs to be scoped inside this closure - const { plugin, onTypeChanged } = this.props; - return ; - }, - }; + if (this.state.isVizPickerOpen) { + return ( + + ); + } else { + return ( +
+ +
{plugin.name}
+ +
+ ); + } + }; + + render() { + const { plugin, onTypeChanged } = this.props; + const { isVizPickerOpen } = this.state; const panelHelp = { title: '', @@ -140,7 +175,8 @@ export class VisualizationTab extends PureComponent { }; return ( - + + {isVizPickerOpen && } {this.renderPanelOptions()} ); diff --git a/public/app/features/dashboard/dashgrid/VizTypePicker.tsx b/public/app/features/dashboard/dashgrid/VizTypePicker.tsx index 939fa79c289..d246c069f22 100644 --- a/public/app/features/dashboard/dashgrid/VizTypePicker.tsx +++ b/public/app/features/dashboard/dashgrid/VizTypePicker.tsx @@ -9,9 +9,6 @@ import KeyboardNavigation, { KeyboardNavigationProps } from './KeyboardNavigatio export interface Props { current: PanelPlugin; onTypeChanged: (newType: PanelPlugin) => void; -} - -interface State { searchQuery: string; } diff --git a/public/sass/components/_form_select_box.scss b/public/sass/components/_form_select_box.scss index 3b36df5048e..337145f88dc 100644 --- a/public/sass/components/_form_select_box.scss +++ b/public/sass/components/_form_select_box.scss @@ -54,6 +54,7 @@ $select-input-bg-disabled: $input-bg-disabled; .gf-form-select-box__menu { background: $input-bg; + box-shadow: $menu-dropdown-shadow; position: absolute; z-index: 2; min-width: 100%; @@ -81,7 +82,7 @@ $select-input-bg-disabled: $input-bg-disabled; &.gf-form-select-box__option--is-focused { color: $dropdownLinkColorHover; - background-color: $dropdownLinkBackgroundHover; + background: $menu-dropdown-hover-bg; @include left-brand-border-gradient(); } @@ -96,9 +97,6 @@ $select-input-bg-disabled: $input-bg-disabled; display: none; } -.gf-form-select-box__option { -} - .gf-form-select-box__value-container { display: table-cell; padding: 8px 10px;