mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
wip
This commit is contained in:
parent
8497c854f6
commit
7161b2dc9b
60
public/app/core/components/Picker/Select.tsx
Normal file
60
public/app/core/components/Picker/Select.tsx
Normal file
@ -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<T> extends PureComponent<Props<T>> {
|
||||||
|
// 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 (
|
||||||
|
// <ReactSelect
|
||||||
|
// classNamePrefix="gf-form-select-box"
|
||||||
|
// className={`gf-form-input gf-form-input--form-dropdown ${widthClass} ${className}`}
|
||||||
|
// components={{
|
||||||
|
// Option: DescriptionOption,
|
||||||
|
// IndicatorsContainer,
|
||||||
|
// }}
|
||||||
|
// defaultValue={defaultValue}
|
||||||
|
// value={value}
|
||||||
|
// getOptionLabel={getOptionLabel}
|
||||||
|
// getOptionValue={getOptionValue}
|
||||||
|
// menuShouldScrollIntoView={false}
|
||||||
|
// isSearchable={false}
|
||||||
|
// onChange={onSelected}
|
||||||
|
// options={options}
|
||||||
|
// placeholder={placeholder || 'Choose'}
|
||||||
|
// styles={ResetStyles}
|
||||||
|
// />
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// export default Select;
|
@ -21,9 +21,23 @@ interface Props {
|
|||||||
onTypeChanged: (newType: PanelPlugin) => void;
|
onTypeChanged: (newType: PanelPlugin) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class VisualizationTab extends PureComponent<Props> {
|
interface State {
|
||||||
|
isVizPickerOpen: boolean;
|
||||||
|
searchQuery: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class VisualizationTab extends PureComponent<Props, State> {
|
||||||
element: HTMLElement;
|
element: HTMLElement;
|
||||||
angularOptions: AngularComponent;
|
angularOptions: AngularComponent;
|
||||||
|
searchInput: HTMLElement;
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
isVizPickerOpen: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
getPanelDefaultOptions = () => {
|
getPanelDefaultOptions = () => {
|
||||||
const { panel, plugin } = this.props;
|
const { panel, plugin } = this.props;
|
||||||
@ -120,18 +134,39 @@ export class VisualizationTab extends PureComponent<Props> {
|
|||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
onOpenVizPicker = () => {
|
||||||
|
this.setState({ isVizPickerOpen: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
renderToolbar = () => {
|
||||||
const { plugin } = this.props;
|
const { plugin } = this.props;
|
||||||
|
|
||||||
const panelSelection = {
|
if (this.state.isVizPickerOpen) {
|
||||||
title: plugin.name,
|
return (
|
||||||
imgSrc: plugin.info.logos.small,
|
<label className="gf-form--has-input-icon">
|
||||||
render: () => {
|
<input
|
||||||
// the needs to be scoped inside this closure
|
type="text"
|
||||||
const { plugin, onTypeChanged } = this.props;
|
className="gf-form-input width-13"
|
||||||
return <VizTypePicker current={plugin} onTypeChanged={onTypeChanged} />;
|
placeholder=""
|
||||||
},
|
ref={elem => (this.searchInput = elem)}
|
||||||
};
|
/>
|
||||||
|
<i className="gf-form-input-icon fa fa-search" />
|
||||||
|
</label>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<div className="toolbar__main" onClick={this.onOpenVizPicker}>
|
||||||
|
<img className="toolbar__main-image" src={plugin.info.logos.small} />
|
||||||
|
<div className="toolbar__main-name">{plugin.name}</div>
|
||||||
|
<i className="fa fa-caret-down" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { plugin, onTypeChanged } = this.props;
|
||||||
|
const { isVizPickerOpen } = this.state;
|
||||||
|
|
||||||
const panelHelp = {
|
const panelHelp = {
|
||||||
title: '',
|
title: '',
|
||||||
@ -140,7 +175,8 @@ export class VisualizationTab extends PureComponent<Props> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EditorTabBody heading="Visualization" main={panelSelection} toolbarItems={[panelHelp]}>
|
<EditorTabBody heading="Visualization" renderToolbar={this.renderToolbar} toolbarItems={[panelHelp]}>
|
||||||
|
{isVizPickerOpen && <VizTypePicker current={plugin} onTypeChanged={onTypeChanged} />}
|
||||||
{this.renderPanelOptions()}
|
{this.renderPanelOptions()}
|
||||||
</EditorTabBody>
|
</EditorTabBody>
|
||||||
);
|
);
|
||||||
|
@ -9,9 +9,6 @@ import KeyboardNavigation, { KeyboardNavigationProps } from './KeyboardNavigatio
|
|||||||
export interface Props {
|
export interface Props {
|
||||||
current: PanelPlugin;
|
current: PanelPlugin;
|
||||||
onTypeChanged: (newType: PanelPlugin) => void;
|
onTypeChanged: (newType: PanelPlugin) => void;
|
||||||
}
|
|
||||||
|
|
||||||
interface State {
|
|
||||||
searchQuery: string;
|
searchQuery: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ $select-input-bg-disabled: $input-bg-disabled;
|
|||||||
|
|
||||||
.gf-form-select-box__menu {
|
.gf-form-select-box__menu {
|
||||||
background: $input-bg;
|
background: $input-bg;
|
||||||
|
box-shadow: $menu-dropdown-shadow;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
min-width: 100%;
|
min-width: 100%;
|
||||||
@ -81,7 +82,7 @@ $select-input-bg-disabled: $input-bg-disabled;
|
|||||||
|
|
||||||
&.gf-form-select-box__option--is-focused {
|
&.gf-form-select-box__option--is-focused {
|
||||||
color: $dropdownLinkColorHover;
|
color: $dropdownLinkColorHover;
|
||||||
background-color: $dropdownLinkBackgroundHover;
|
background: $menu-dropdown-hover-bg;
|
||||||
@include left-brand-border-gradient();
|
@include left-brand-border-gradient();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,9 +97,6 @@ $select-input-bg-disabled: $input-bg-disabled;
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gf-form-select-box__option {
|
|
||||||
}
|
|
||||||
|
|
||||||
.gf-form-select-box__value-container {
|
.gf-form-select-box__value-container {
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
|
Loading…
Reference in New Issue
Block a user