|
@@ -3,18 +3,6 @@ import { ExploreId } from 'app/types/explore';
|
|
|
import { DataSourceSelectItem, RawTimeRange, TimeRange } from '@grafana/ui';
|
|
import { DataSourceSelectItem, RawTimeRange, TimeRange } from '@grafana/ui';
|
|
|
import { DataSourcePicker } from 'app/core/components/Select/DataSourcePicker';
|
|
import { DataSourcePicker } from 'app/core/components/Select/DataSourcePicker';
|
|
|
|
|
|
|
|
-const createDatasourcePicker = (props: Props) => {
|
|
|
|
|
- const { exploreDatasources, selectedDatasource } = props;
|
|
|
|
|
-
|
|
|
|
|
- return (
|
|
|
|
|
- <DataSourcePicker
|
|
|
|
|
- onChange={props.onChangeDatasource}
|
|
|
|
|
- datasources={exploreDatasources}
|
|
|
|
|
- current={selectedDatasource}
|
|
|
|
|
- />
|
|
|
|
|
- );
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
const createResponsiveButton = (options: {
|
|
const createResponsiveButton = (options: {
|
|
|
splitted: boolean;
|
|
splitted: boolean;
|
|
|
title: string;
|
|
title: string;
|
|
@@ -32,12 +20,6 @@ const createResponsiveButton = (options: {
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const createSplittedClassName = (options: { splitted: boolean; className: string }) => {
|
|
|
|
|
- const { className, splitted } = options;
|
|
|
|
|
-
|
|
|
|
|
- return splitted ? `${className}-splitted` : className;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
interface Props {
|
|
interface Props {
|
|
|
datasourceMissing: boolean;
|
|
datasourceMissing: boolean;
|
|
|
exploreDatasources: DataSourceSelectItem[];
|
|
exploreDatasources: DataSourceSelectItem[];
|
|
@@ -61,18 +43,20 @@ export class ExploreToolbar extends PureComponent<Props, {}> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
- const { datasourceMissing, exploreId, loading, splitted, timepicker } = this.props;
|
|
|
|
|
- const toolbar = createSplittedClassName({ splitted, className: 'toolbar' });
|
|
|
|
|
- const toolbarItem = createSplittedClassName({ splitted, className: 'toolbar-item' });
|
|
|
|
|
- const toolbarHeader = createSplittedClassName({ splitted, className: 'toolbar-header' });
|
|
|
|
|
- const toolbarContent = createSplittedClassName({ splitted, className: 'toolbar-content' });
|
|
|
|
|
- const toolbarContentItem = createSplittedClassName({ splitted, className: 'toolbar-content-item' });
|
|
|
|
|
- const timepickerClasses = createSplittedClassName({ splitted, className: 'timepicker toolbar-content-item' });
|
|
|
|
|
|
|
+ const {
|
|
|
|
|
+ datasourceMissing,
|
|
|
|
|
+ exploreDatasources,
|
|
|
|
|
+ exploreId,
|
|
|
|
|
+ loading,
|
|
|
|
|
+ selectedDatasource,
|
|
|
|
|
+ splitted,
|
|
|
|
|
+ timepicker,
|
|
|
|
|
+ } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <div className={toolbar}>
|
|
|
|
|
- <div className={toolbarItem}>
|
|
|
|
|
- <div className={toolbarHeader}>
|
|
|
|
|
|
|
+ <div className={splitted ? 'toolbar splitted' : 'toolbar'}>
|
|
|
|
|
+ <div className="toolbar-item">
|
|
|
|
|
+ <div className="toolbar-header">
|
|
|
<div className="toolbar-header-title">
|
|
<div className="toolbar-header-title">
|
|
|
{exploreId === 'left' && (
|
|
{exploreId === 'left' && (
|
|
|
<a className="navbar-page-btn">
|
|
<a className="navbar-page-btn">
|
|
@@ -90,15 +74,21 @@ export class ExploreToolbar extends PureComponent<Props, {}> {
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- <div className={toolbarItem}>
|
|
|
|
|
- <div className={toolbarContent}>
|
|
|
|
|
|
|
+ <div className="toolbar-item">
|
|
|
|
|
+ <div className="toolbar-content">
|
|
|
{!datasourceMissing ? (
|
|
{!datasourceMissing ? (
|
|
|
- <div className={toolbarContentItem}>
|
|
|
|
|
- <div className="datasource-picker">{createDatasourcePicker(this.props)}</div>
|
|
|
|
|
|
|
+ <div className="toolbar-content-item">
|
|
|
|
|
+ <div className="datasource-picker">
|
|
|
|
|
+ <DataSourcePicker
|
|
|
|
|
+ onChange={this.props.onChangeDatasource}
|
|
|
|
|
+ datasources={exploreDatasources}
|
|
|
|
|
+ current={selectedDatasource}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
) : null}
|
|
) : null}
|
|
|
{exploreId === 'left' && !splitted ? (
|
|
{exploreId === 'left' && !splitted ? (
|
|
|
- <div className={toolbarContentItem}>
|
|
|
|
|
|
|
+ <div className="toolbar-content-item">
|
|
|
{createResponsiveButton({
|
|
{createResponsiveButton({
|
|
|
splitted,
|
|
splitted,
|
|
|
title: 'Split',
|
|
title: 'Split',
|
|
@@ -107,13 +97,13 @@ export class ExploreToolbar extends PureComponent<Props, {}> {
|
|
|
})}
|
|
})}
|
|
|
</div>
|
|
</div>
|
|
|
) : null}
|
|
) : null}
|
|
|
- <div className={timepickerClasses}>{timepicker}</div>
|
|
|
|
|
- <div className={toolbarContentItem}>
|
|
|
|
|
|
|
+ <div className="toolbar-content-item timepicker">{timepicker}</div>
|
|
|
|
|
+ <div className="toolbar-content-item">
|
|
|
<button className="btn navbar-button navbar-button--no-icon" onClick={this.props.onClearAll}>
|
|
<button className="btn navbar-button navbar-button--no-icon" onClick={this.props.onClearAll}>
|
|
|
Clear All
|
|
Clear All
|
|
|
</button>
|
|
</button>
|
|
|
</div>
|
|
</div>
|
|
|
- <div className={toolbarContentItem}>
|
|
|
|
|
|
|
+ <div className="toolbar-content-item">
|
|
|
{createResponsiveButton({
|
|
{createResponsiveButton({
|
|
|
splitted,
|
|
splitted,
|
|
|
title: 'Run Query',
|
|
title: 'Run Query',
|