| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  | import omitBy from 'lodash/omitBy'; | 
					
						
							| 
									
										
										
										
											2019-01-22 14:50:19 +01:00
										 |  |  | import React, { PureComponent } from 'react'; | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  | import { connect } from 'react-redux'; | 
					
						
							|  |  |  | import { hot } from 'react-hot-loader'; | 
					
						
							| 
									
										
										
										
											2019-08-29 13:41:45 +02:00
										 |  |  | import memoizeOne from 'memoize-one'; | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  | import classNames from 'classnames'; | 
					
						
							| 
									
										
										
										
											2019-09-20 13:00:11 +02:00
										 |  |  | import { css } from 'emotion'; | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-17 11:25:12 +02:00
										 |  |  | import { ExploreId, ExploreItemState, ExploreMode } from 'app/types/explore'; | 
					
						
							| 
									
										
										
										
											2019-10-31 10:48:05 +01:00
										 |  |  | import { ToggleButtonGroup, ToggleButton, Tooltip, ButtonSelect, SetInterval } from '@grafana/ui'; | 
					
						
							|  |  |  | import { RawTimeRange, TimeZone, TimeRange, DataSourceSelectItem, DataQuery } from '@grafana/data'; | 
					
						
							| 
									
										
										
										
											2019-01-23 15:57:24 +01:00
										 |  |  | import { DataSourcePicker } from 'app/core/components/Select/DataSourcePicker'; | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  | import { StoreState } from 'app/types/store'; | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  | import { | 
					
						
							|  |  |  |   changeDatasource, | 
					
						
							|  |  |  |   clearQueries, | 
					
						
							|  |  |  |   splitClose, | 
					
						
							|  |  |  |   runQueries, | 
					
						
							|  |  |  |   splitOpen, | 
					
						
							| 
									
										
										
										
											2019-10-08 18:55:53 +02:00
										 |  |  |   syncTimes, | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  |   changeRefreshInterval, | 
					
						
							| 
									
										
										
										
											2019-05-16 09:52:22 +02:00
										 |  |  |   changeMode, | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  |   clearOrigin, | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  | } from './state/actions'; | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  | import { updateLocation } from 'app/core/actions'; | 
					
						
							| 
									
										
										
										
											2019-04-29 18:28:41 +02:00
										 |  |  | import { getTimeZone } from '../profile/state/selectors'; | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  | import { getDashboardSrv } from '../dashboard/services/DashboardSrv'; | 
					
						
							|  |  |  | import kbn from '../../core/utils/kbn'; | 
					
						
							| 
									
										
										
										
											2019-06-28 12:07:55 +02:00
										 |  |  | import { ExploreTimeControls } from './ExploreTimeControls'; | 
					
						
							| 
									
										
										
										
											2019-09-17 11:25:12 +02:00
										 |  |  | import { LiveTailButton } from './LiveTailButton'; | 
					
						
							|  |  |  | import { ResponsiveButton } from './ResponsiveButton'; | 
					
						
							|  |  |  | import { RunButton } from './RunButton'; | 
					
						
							| 
									
										
										
										
											2019-09-24 10:18:34 +02:00
										 |  |  | import { LiveTailControls } from './useLiveTailControls'; | 
					
						
							| 
									
										
										
										
											2019-01-24 07:23:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-20 13:00:11 +02:00
										 |  |  | const getStyles = memoizeOne(() => { | 
					
						
							|  |  |  |   return { | 
					
						
							|  |  |  |     liveTailButtons: css`
 | 
					
						
							|  |  |  |       margin-left: 10px; | 
					
						
							| 
									
										
										
										
											2019-10-07 23:28:16 +02:00
										 |  |  |       @media (max-width: 1110px) { | 
					
						
							|  |  |  |         margin-left: 4px; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2019-09-20 13:00:11 +02:00
										 |  |  |     `,
 | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  | interface OwnProps { | 
					
						
							|  |  |  |   exploreId: ExploreId; | 
					
						
							| 
									
										
										
										
											2019-04-29 18:28:41 +02:00
										 |  |  |   onChangeTime: (range: RawTimeRange, changedByScanner?: boolean) => void; | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | interface StateProps { | 
					
						
							| 
									
										
										
										
											2019-01-24 09:26:48 +01:00
										 |  |  |   datasourceMissing: boolean; | 
					
						
							|  |  |  |   exploreDatasources: DataSourceSelectItem[]; | 
					
						
							|  |  |  |   loading: boolean; | 
					
						
							| 
									
										
										
										
											2019-04-29 18:28:41 +02:00
										 |  |  |   range: TimeRange; | 
					
						
							|  |  |  |   timeZone: TimeZone; | 
					
						
							| 
									
										
										
										
											2019-11-26 09:01:32 +00:00
										 |  |  |   selectedDatasource?: DataSourceSelectItem; | 
					
						
							| 
									
										
										
										
											2019-01-24 09:26:48 +01:00
										 |  |  |   splitted: boolean; | 
					
						
							| 
									
										
										
										
											2019-10-08 18:55:53 +02:00
										 |  |  |   syncedTimes: boolean; | 
					
						
							| 
									
										
										
										
											2019-11-26 09:01:32 +00:00
										 |  |  |   refreshInterval?: string; | 
					
						
							| 
									
										
										
										
											2019-09-24 12:19:48 +02:00
										 |  |  |   supportedModes: ExploreMode[]; | 
					
						
							|  |  |  |   selectedMode: ExploreMode; | 
					
						
							| 
									
										
										
										
											2019-05-20 13:28:23 +02:00
										 |  |  |   hasLiveOption: boolean; | 
					
						
							|  |  |  |   isLive: boolean; | 
					
						
							| 
									
										
										
										
											2019-09-17 11:25:12 +02:00
										 |  |  |   isPaused: boolean; | 
					
						
							| 
									
										
										
										
											2019-11-26 09:01:32 +00:00
										 |  |  |   originPanelId?: number; | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  |   queries: DataQuery[]; | 
					
						
							| 
									
										
										
										
											2019-11-26 09:01:32 +00:00
										 |  |  |   datasourceLoading?: boolean; | 
					
						
							| 
									
										
										
										
											2019-11-06 20:19:50 +01:00
										 |  |  |   containerWidth: number; | 
					
						
							| 
									
										
										
										
											2019-01-24 09:26:48 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  | interface DispatchProps { | 
					
						
							|  |  |  |   changeDatasource: typeof changeDatasource; | 
					
						
							|  |  |  |   clearAll: typeof clearQueries; | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  |   runQueries: typeof runQueries; | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  |   closeSplit: typeof splitClose; | 
					
						
							|  |  |  |   split: typeof splitOpen; | 
					
						
							| 
									
										
										
										
											2019-10-08 18:55:53 +02:00
										 |  |  |   syncTimes: typeof syncTimes; | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  |   changeRefreshInterval: typeof changeRefreshInterval; | 
					
						
							| 
									
										
										
										
											2019-05-16 09:52:22 +02:00
										 |  |  |   changeMode: typeof changeMode; | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  |   clearOrigin: typeof clearOrigin; | 
					
						
							|  |  |  |   updateLocation: typeof updateLocation; | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type Props = StateProps & DispatchProps & OwnProps; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-06 20:19:50 +01:00
										 |  |  | export class UnConnectedExploreToolbar extends PureComponent<Props> { | 
					
						
							| 
									
										
										
										
											2019-07-30 15:49:32 +02:00
										 |  |  |   onChangeDatasource = async (option: { value: any }) => { | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  |     this.props.changeDatasource(this.props.exploreId, option.value); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   onClearAll = () => { | 
					
						
							|  |  |  |     this.props.clearAll(this.props.exploreId); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   onRunQuery = () => { | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  |     return this.props.runQueries(this.props.exploreId); | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  |   onChangeRefreshInterval = (item: string) => { | 
					
						
							|  |  |  |     const { changeRefreshInterval, exploreId } = this.props; | 
					
						
							|  |  |  |     changeRefreshInterval(exploreId, item); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-16 09:52:22 +02:00
										 |  |  |   onModeChange = (mode: ExploreMode) => { | 
					
						
							|  |  |  |     const { changeMode, exploreId } = this.props; | 
					
						
							|  |  |  |     changeMode(exploreId, mode); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-08 18:55:53 +02:00
										 |  |  |   onChangeTimeSync = () => { | 
					
						
							|  |  |  |     const { syncTimes, exploreId } = this.props; | 
					
						
							|  |  |  |     syncTimes(exploreId); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  |   returnToPanel = async ({ withChanges = false } = {}) => { | 
					
						
							|  |  |  |     const { originPanelId } = this.props; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const dashboardSrv = getDashboardSrv(); | 
					
						
							|  |  |  |     const dash = dashboardSrv.getCurrent(); | 
					
						
							|  |  |  |     const titleSlug = kbn.slugifyForUrl(dash.title); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!withChanges) { | 
					
						
							|  |  |  |       this.props.clearOrigin(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const dashViewOptions = { | 
					
						
							|  |  |  |       fullscreen: withChanges || dash.meta.fullscreen, | 
					
						
							|  |  |  |       edit: withChanges || dash.meta.isEditing, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     this.props.updateLocation({ | 
					
						
							|  |  |  |       path: `/d/${dash.uid}/:${titleSlug}`, | 
					
						
							|  |  |  |       query: { | 
					
						
							|  |  |  |         ...omitBy(dashViewOptions, v => !v), | 
					
						
							|  |  |  |         panelId: originPanelId, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-22 14:50:19 +01:00
										 |  |  |   render() { | 
					
						
							| 
									
										
										
										
											2019-01-24 12:00:10 +01:00
										 |  |  |     const { | 
					
						
							|  |  |  |       datasourceMissing, | 
					
						
							|  |  |  |       exploreDatasources, | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  |       closeSplit, | 
					
						
							| 
									
										
										
										
											2019-01-24 12:00:10 +01:00
										 |  |  |       exploreId, | 
					
						
							|  |  |  |       loading, | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  |       range, | 
					
						
							| 
									
										
										
										
											2019-04-29 18:28:41 +02:00
										 |  |  |       timeZone, | 
					
						
							| 
									
										
										
										
											2019-01-24 12:00:10 +01:00
										 |  |  |       selectedDatasource, | 
					
						
							|  |  |  |       splitted, | 
					
						
							| 
									
										
										
										
											2019-10-08 18:55:53 +02:00
										 |  |  |       syncedTimes, | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  |       refreshInterval, | 
					
						
							|  |  |  |       onChangeTime, | 
					
						
							|  |  |  |       split, | 
					
						
							| 
									
										
										
										
											2019-09-24 12:19:48 +02:00
										 |  |  |       supportedModes, | 
					
						
							|  |  |  |       selectedMode, | 
					
						
							| 
									
										
										
										
											2019-05-20 13:28:23 +02:00
										 |  |  |       hasLiveOption, | 
					
						
							|  |  |  |       isLive, | 
					
						
							| 
									
										
										
										
											2019-09-17 11:25:12 +02:00
										 |  |  |       isPaused, | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  |       originPanelId, | 
					
						
							| 
									
										
										
										
											2019-10-02 10:15:06 +02:00
										 |  |  |       datasourceLoading, | 
					
						
							| 
									
										
										
										
											2019-11-06 20:19:50 +01:00
										 |  |  |       containerWidth, | 
					
						
							| 
									
										
										
										
											2019-01-24 12:00:10 +01:00
										 |  |  |     } = this.props; | 
					
						
							| 
									
										
										
										
											2019-01-22 14:50:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-20 13:00:11 +02:00
										 |  |  |     const styles = getStyles(); | 
					
						
							| 
									
										
										
										
											2019-11-26 09:01:32 +00:00
										 |  |  |     const originDashboardIsEditable = originPanelId && Number.isInteger(originPanelId); | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  |     const panelReturnClasses = classNames('btn', 'navbar-button', { | 
					
						
							|  |  |  |       'btn--radius-right-0': originDashboardIsEditable, | 
					
						
							|  |  |  |       'navbar-button navbar-button--border-right-0': originDashboardIsEditable, | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-13 01:01:32 +01:00
										 |  |  |     const showSmallDataSourcePicker = (splitted ? containerWidth < 700 : containerWidth < 800) || false; | 
					
						
							| 
									
										
										
										
											2019-11-06 20:19:50 +01:00
										 |  |  |     const showSmallTimePicker = splitted || containerWidth < 1210; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-22 14:50:19 +01:00
										 |  |  |     return ( | 
					
						
							| 
									
										
										
										
											2019-01-28 12:21:04 +01:00
										 |  |  |       <div className={splitted ? 'explore-toolbar splitted' : 'explore-toolbar'}> | 
					
						
							|  |  |  |         <div className="explore-toolbar-item"> | 
					
						
							|  |  |  |           <div className="explore-toolbar-header"> | 
					
						
							|  |  |  |             <div className="explore-toolbar-header-title"> | 
					
						
							| 
									
										
										
										
											2019-01-23 15:57:24 +01:00
										 |  |  |               {exploreId === 'left' && ( | 
					
						
							| 
									
										
										
										
											2019-02-04 11:19:45 +01:00
										 |  |  |                 <span className="navbar-page-btn"> | 
					
						
							| 
									
										
										
										
											2019-02-18 15:04:26 +01:00
										 |  |  |                   <i className="gicon gicon-explore" /> | 
					
						
							| 
									
										
										
										
											2019-01-23 15:57:24 +01:00
										 |  |  |                   Explore | 
					
						
							| 
									
										
										
										
											2019-02-04 11:19:45 +01:00
										 |  |  |                 </span> | 
					
						
							| 
									
										
										
										
											2019-01-23 15:57:24 +01:00
										 |  |  |               )} | 
					
						
							|  |  |  |             </div> | 
					
						
							| 
									
										
										
										
											2019-03-25 16:44:09 +01:00
										 |  |  |             {splitted && ( | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  |               <a className="explore-toolbar-header-close" onClick={() => closeSplit(exploreId)}> | 
					
						
							| 
									
										
										
										
											2019-03-25 16:44:09 +01:00
										 |  |  |                 <i className="fa fa-times fa-fw" /> | 
					
						
							|  |  |  |               </a> | 
					
						
							|  |  |  |             )} | 
					
						
							| 
									
										
										
										
											2019-01-22 14:50:19 +01:00
										 |  |  |           </div> | 
					
						
							| 
									
										
										
										
											2019-01-23 15:57:24 +01:00
										 |  |  |         </div> | 
					
						
							| 
									
										
										
										
											2019-01-28 12:21:04 +01:00
										 |  |  |         <div className="explore-toolbar-item"> | 
					
						
							|  |  |  |           <div className="explore-toolbar-content"> | 
					
						
							| 
									
										
										
										
											2019-01-24 11:27:48 +01:00
										 |  |  |             {!datasourceMissing ? ( | 
					
						
							| 
									
										
										
										
											2019-01-28 12:21:04 +01:00
										 |  |  |               <div className="explore-toolbar-content-item"> | 
					
						
							| 
									
										
										
										
											2019-11-06 20:19:50 +01:00
										 |  |  |                 <div | 
					
						
							|  |  |  |                   className={classNames( | 
					
						
							|  |  |  |                     'explore-ds-picker', | 
					
						
							|  |  |  |                     showSmallDataSourcePicker ? 'explore-ds-picker--small' : '' | 
					
						
							|  |  |  |                   )} | 
					
						
							|  |  |  |                 > | 
					
						
							| 
									
										
										
										
											2019-01-24 12:00:10 +01:00
										 |  |  |                   <DataSourcePicker | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  |                     onChange={this.onChangeDatasource} | 
					
						
							| 
									
										
										
										
											2019-01-24 12:00:10 +01:00
										 |  |  |                     datasources={exploreDatasources} | 
					
						
							|  |  |  |                     current={selectedDatasource} | 
					
						
							| 
									
										
										
										
											2019-10-02 10:15:06 +02:00
										 |  |  |                     showLoading={datasourceLoading} | 
					
						
							| 
									
										
										
										
											2019-11-06 20:19:50 +01:00
										 |  |  |                     hideTextValue={showSmallDataSourcePicker} | 
					
						
							| 
									
										
										
										
											2019-01-24 12:00:10 +01:00
										 |  |  |                   /> | 
					
						
							|  |  |  |                 </div> | 
					
						
							| 
									
										
										
										
											2019-09-24 12:19:48 +02:00
										 |  |  |                 {supportedModes.length > 1 ? ( | 
					
						
							| 
									
										
										
										
											2019-05-16 09:52:22 +02:00
										 |  |  |                   <div className="query-type-toggle"> | 
					
						
							|  |  |  |                     <ToggleButtonGroup label="" transparent={true}> | 
					
						
							|  |  |  |                       <ToggleButton | 
					
						
							|  |  |  |                         key={ExploreMode.Metrics} | 
					
						
							|  |  |  |                         value={ExploreMode.Metrics} | 
					
						
							|  |  |  |                         onChange={this.onModeChange} | 
					
						
							| 
									
										
										
										
											2019-09-24 12:19:48 +02:00
										 |  |  |                         selected={selectedMode === ExploreMode.Metrics} | 
					
						
							| 
									
										
										
										
											2019-05-16 09:52:22 +02:00
										 |  |  |                       > | 
					
						
							|  |  |  |                         {'Metrics'} | 
					
						
							|  |  |  |                       </ToggleButton> | 
					
						
							|  |  |  |                       <ToggleButton | 
					
						
							|  |  |  |                         key={ExploreMode.Logs} | 
					
						
							|  |  |  |                         value={ExploreMode.Logs} | 
					
						
							|  |  |  |                         onChange={this.onModeChange} | 
					
						
							| 
									
										
										
										
											2019-09-24 12:19:48 +02:00
										 |  |  |                         selected={selectedMode === ExploreMode.Logs} | 
					
						
							| 
									
										
										
										
											2019-05-16 09:52:22 +02:00
										 |  |  |                       > | 
					
						
							|  |  |  |                         {'Logs'} | 
					
						
							|  |  |  |                       </ToggleButton> | 
					
						
							|  |  |  |                     </ToggleButtonGroup> | 
					
						
							|  |  |  |                   </div> | 
					
						
							|  |  |  |                 ) : null} | 
					
						
							| 
									
										
										
										
											2019-01-23 15:57:24 +01:00
										 |  |  |               </div> | 
					
						
							|  |  |  |             ) : null} | 
					
						
							| 
									
										
										
										
											2019-05-16 09:52:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-26 09:01:32 +00:00
										 |  |  |             {originPanelId && Number.isInteger(originPanelId) && !splitted && ( | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  |               <div className="explore-toolbar-content-item"> | 
					
						
							|  |  |  |                 <Tooltip content={'Return to panel'} placement="bottom"> | 
					
						
							|  |  |  |                   <button className={panelReturnClasses} onClick={() => this.returnToPanel()}> | 
					
						
							|  |  |  |                     <i className="fa fa-arrow-left" /> | 
					
						
							|  |  |  |                   </button> | 
					
						
							|  |  |  |                 </Tooltip> | 
					
						
							|  |  |  |                 {originDashboardIsEditable && ( | 
					
						
							|  |  |  |                   <ButtonSelect | 
					
						
							|  |  |  |                     className="navbar-button--attached btn--radius-left-0$" | 
					
						
							|  |  |  |                     options={[{ label: 'Return to panel with changes', value: '' }]} | 
					
						
							|  |  |  |                     onChange={() => this.returnToPanel({ withChanges: true })} | 
					
						
							|  |  |  |                     maxMenuHeight={380} | 
					
						
							|  |  |  |                   /> | 
					
						
							|  |  |  |                 )} | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  |             )} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-23 15:57:24 +01:00
										 |  |  |             {exploreId === 'left' && !splitted ? ( | 
					
						
							| 
									
										
										
										
											2019-10-10 21:53:02 +02:00
										 |  |  |               <div className="explore-toolbar-content-item explore-icon-align"> | 
					
						
							| 
									
										
										
										
											2019-09-17 11:25:12 +02:00
										 |  |  |                 <ResponsiveButton | 
					
						
							|  |  |  |                   splitted={splitted} | 
					
						
							|  |  |  |                   title="Split" | 
					
						
							|  |  |  |                   onClick={split} | 
					
						
							|  |  |  |                   iconClassName="fa fa-fw fa-columns icon-margin-right" | 
					
						
							|  |  |  |                   disabled={isLive} | 
					
						
							|  |  |  |                 /> | 
					
						
							| 
									
										
										
										
											2019-01-23 15:57:24 +01:00
										 |  |  |               </div> | 
					
						
							|  |  |  |             ) : null} | 
					
						
							| 
									
										
										
										
											2019-09-17 11:25:12 +02:00
										 |  |  |             {!isLive && ( | 
					
						
							|  |  |  |               <div className="explore-toolbar-content-item"> | 
					
						
							|  |  |  |                 <ExploreTimeControls | 
					
						
							|  |  |  |                   exploreId={exploreId} | 
					
						
							|  |  |  |                   range={range} | 
					
						
							|  |  |  |                   timeZone={timeZone} | 
					
						
							|  |  |  |                   onChangeTime={onChangeTime} | 
					
						
							| 
									
										
										
										
											2019-10-08 18:55:53 +02:00
										 |  |  |                   splitted={splitted} | 
					
						
							|  |  |  |                   syncedTimes={syncedTimes} | 
					
						
							|  |  |  |                   onChangeTimeSync={this.onChangeTimeSync} | 
					
						
							| 
									
										
										
										
											2019-11-06 20:19:50 +01:00
										 |  |  |                   hideText={showSmallTimePicker} | 
					
						
							| 
									
										
										
										
											2019-09-17 11:25:12 +02:00
										 |  |  |                 /> | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  |             )} | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-22 12:26:14 +01:00
										 |  |  |             {!isLive && ( | 
					
						
							|  |  |  |               <div className="explore-toolbar-content-item explore-icon-align"> | 
					
						
							|  |  |  |                 <ResponsiveButton | 
					
						
							|  |  |  |                   splitted={splitted} | 
					
						
							|  |  |  |                   title="Clear All" | 
					
						
							|  |  |  |                   onClick={this.onClearAll} | 
					
						
							|  |  |  |                   iconClassName="fa fa-fw fa-trash icon-margin-right" | 
					
						
							|  |  |  |                 /> | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  |             )} | 
					
						
							| 
									
										
										
										
											2019-01-28 12:21:04 +01:00
										 |  |  |             <div className="explore-toolbar-content-item"> | 
					
						
							| 
									
										
										
										
											2019-09-17 11:25:12 +02:00
										 |  |  |               <RunButton | 
					
						
							|  |  |  |                 refreshInterval={refreshInterval} | 
					
						
							|  |  |  |                 onChangeRefreshInterval={this.onChangeRefreshInterval} | 
					
						
							|  |  |  |                 splitted={splitted} | 
					
						
							|  |  |  |                 loading={loading || (isLive && !isPaused)} | 
					
						
							|  |  |  |                 onRun={this.onRunQuery} | 
					
						
							|  |  |  |                 showDropdown={!isLive} | 
					
						
							|  |  |  |               /> | 
					
						
							|  |  |  |               {refreshInterval && <SetInterval func={this.onRunQuery} interval={refreshInterval} loading={loading} />} | 
					
						
							| 
									
										
										
										
											2019-01-23 15:57:24 +01:00
										 |  |  |             </div> | 
					
						
							| 
									
										
										
										
											2019-09-17 11:25:12 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             {hasLiveOption && ( | 
					
						
							| 
									
										
										
										
											2019-09-20 13:00:11 +02:00
										 |  |  |               <div className={`explore-toolbar-content-item ${styles.liveTailButtons}`}> | 
					
						
							| 
									
										
										
										
											2019-09-24 10:18:34 +02:00
										 |  |  |                 <LiveTailControls exploreId={exploreId}> | 
					
						
							|  |  |  |                   {controls => ( | 
					
						
							|  |  |  |                     <LiveTailButton | 
					
						
							| 
									
										
										
										
											2019-10-10 22:16:04 +02:00
										 |  |  |                       splitted={splitted} | 
					
						
							| 
									
										
										
										
											2019-09-24 10:18:34 +02:00
										 |  |  |                       isLive={isLive} | 
					
						
							|  |  |  |                       isPaused={isPaused} | 
					
						
							|  |  |  |                       start={controls.start} | 
					
						
							|  |  |  |                       pause={controls.pause} | 
					
						
							|  |  |  |                       resume={controls.resume} | 
					
						
							|  |  |  |                       stop={controls.stop} | 
					
						
							|  |  |  |                     /> | 
					
						
							|  |  |  |                   )} | 
					
						
							|  |  |  |                 </LiveTailControls> | 
					
						
							| 
									
										
										
										
											2019-09-20 13:00:11 +02:00
										 |  |  |               </div> | 
					
						
							| 
									
										
										
										
											2019-09-17 11:25:12 +02:00
										 |  |  |             )} | 
					
						
							| 
									
										
										
										
											2019-01-22 14:50:19 +01:00
										 |  |  |           </div> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | const mapStateToProps = (state: StoreState, { exploreId }: OwnProps): StateProps => { | 
					
						
							|  |  |  |   const splitted = state.explore.split; | 
					
						
							| 
									
										
										
										
											2019-10-08 18:55:53 +02:00
										 |  |  |   const syncedTimes = state.explore.syncedTimes; | 
					
						
							| 
									
										
										
										
											2019-09-17 11:25:12 +02:00
										 |  |  |   const exploreItem: ExploreItemState = state.explore[exploreId]; | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  |   const { | 
					
						
							|  |  |  |     datasourceInstance, | 
					
						
							|  |  |  |     datasourceMissing, | 
					
						
							|  |  |  |     exploreDatasources, | 
					
						
							|  |  |  |     range, | 
					
						
							|  |  |  |     refreshInterval, | 
					
						
							| 
									
										
										
										
											2019-09-03 09:55:20 +02:00
										 |  |  |     loading, | 
					
						
							| 
									
										
										
										
											2019-05-16 09:52:22 +02:00
										 |  |  |     supportedModes, | 
					
						
							|  |  |  |     mode, | 
					
						
							| 
									
										
										
										
											2019-05-20 13:28:23 +02:00
										 |  |  |     isLive, | 
					
						
							| 
									
										
										
										
											2019-09-17 11:25:12 +02:00
										 |  |  |     isPaused, | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  |     originPanelId, | 
					
						
							|  |  |  |     queries, | 
					
						
							| 
									
										
										
										
											2019-10-02 10:15:06 +02:00
										 |  |  |     datasourceLoading, | 
					
						
							| 
									
										
										
										
											2019-11-06 20:19:50 +01:00
										 |  |  |     containerWidth, | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  |   } = exploreItem; | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  |   const selectedDatasource = datasourceInstance | 
					
						
							|  |  |  |     ? exploreDatasources.find(datasource => datasource.name === datasourceInstance.name) | 
					
						
							|  |  |  |     : undefined; | 
					
						
							| 
									
										
										
										
											2019-06-03 14:54:32 +02:00
										 |  |  |   const hasLiveOption = | 
					
						
							| 
									
										
										
										
											2019-11-15 15:38:25 +00:00
										 |  |  |     datasourceInstance && datasourceInstance.meta && datasourceInstance.meta.streaming && mode === ExploreMode.Logs | 
					
						
							|  |  |  |       ? true | 
					
						
							|  |  |  |       : false; | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return { | 
					
						
							|  |  |  |     datasourceMissing, | 
					
						
							|  |  |  |     exploreDatasources, | 
					
						
							|  |  |  |     loading, | 
					
						
							|  |  |  |     range, | 
					
						
							| 
									
										
										
										
											2019-04-29 18:28:41 +02:00
										 |  |  |     timeZone: getTimeZone(state.user), | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  |     selectedDatasource, | 
					
						
							|  |  |  |     splitted, | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  |     refreshInterval, | 
					
						
							| 
									
										
										
										
											2019-09-24 12:19:48 +02:00
										 |  |  |     supportedModes, | 
					
						
							|  |  |  |     selectedMode: supportedModes.includes(mode) ? mode : supportedModes[0], | 
					
						
							| 
									
										
										
										
											2019-05-20 13:28:23 +02:00
										 |  |  |     hasLiveOption, | 
					
						
							|  |  |  |     isLive, | 
					
						
							| 
									
										
										
										
											2019-09-17 11:25:12 +02:00
										 |  |  |     isPaused, | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  |     originPanelId, | 
					
						
							|  |  |  |     queries, | 
					
						
							| 
									
										
										
										
											2019-10-08 18:55:53 +02:00
										 |  |  |     syncedTimes, | 
					
						
							| 
									
										
										
										
											2019-10-02 10:15:06 +02:00
										 |  |  |     datasourceLoading, | 
					
						
							| 
									
										
										
										
											2019-11-06 20:19:50 +01:00
										 |  |  |     containerWidth, | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  |   }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const mapDispatchToProps: DispatchProps = { | 
					
						
							|  |  |  |   changeDatasource, | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  |   updateLocation, | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  |   changeRefreshInterval, | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  |   clearAll: clearQueries, | 
					
						
							| 
									
										
										
										
											2019-04-16 09:15:23 +02:00
										 |  |  |   runQueries, | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  |   closeSplit: splitClose, | 
					
						
							|  |  |  |   split: splitOpen, | 
					
						
							| 
									
										
										
										
											2019-10-08 18:55:53 +02:00
										 |  |  |   syncTimes, | 
					
						
							| 
									
										
										
										
											2019-05-16 09:52:22 +02:00
										 |  |  |   changeMode: changeMode, | 
					
						
							| 
									
										
										
										
											2019-09-05 13:44:37 +01:00
										 |  |  |   clearOrigin, | 
					
						
							| 
									
										
										
										
											2019-01-24 13:19:33 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-19 13:59:39 +00:00
										 |  |  | export const ExploreToolbar = hot(module)(connect(mapStateToProps, mapDispatchToProps)(UnConnectedExploreToolbar)); |