2019-12-05 04:22:46 -06:00
|
|
|
import React from 'react';
|
2021-04-01 07:15:23 -05:00
|
|
|
import { css, cx } from '@emotion/css';
|
2020-04-27 02:09:05 -05:00
|
|
|
import { compose } from 'redux';
|
2021-06-22 04:43:13 -05:00
|
|
|
import { connect, ConnectedProps } from 'react-redux';
|
2020-01-16 04:11:33 -06:00
|
|
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
2019-08-29 06:41:45 -05:00
|
|
|
import memoizeOne from 'memoize-one';
|
2020-04-27 02:09:05 -05:00
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
2021-08-23 15:03:41 -05:00
|
|
|
import { TooltipDisplayMode } from '@grafana/schema';
|
|
|
|
import { ErrorBoundaryAlert, CustomScrollbar, Collapse, withTheme2, Themeable2 } from '@grafana/ui';
|
2021-08-13 01:02:49 -05:00
|
|
|
import { AbsoluteTimeRange, DataQuery, LoadingState, RawTimeRange, DataFrame, GrafanaTheme2 } from '@grafana/data';
|
2018-07-13 02:09:36 -05:00
|
|
|
|
2019-01-17 10:59:47 -06:00
|
|
|
import LogsContainer from './LogsContainer';
|
|
|
|
import QueryRows from './QueryRows';
|
|
|
|
import TableContainer from './TableContainer';
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
import RichHistoryContainer from './RichHistory/RichHistoryContainer';
|
2020-08-06 10:22:54 -05:00
|
|
|
import ExploreQueryInspector from './ExploreQueryInspector';
|
2020-11-09 07:48:24 -06:00
|
|
|
import { splitOpen } from './state/main';
|
2021-02-12 14:33:26 -06:00
|
|
|
import { changeSize } from './state/explorePane';
|
2020-11-09 07:48:24 -06:00
|
|
|
import { updateTimeRange } from './state/time';
|
|
|
|
import { scanStopAction, addQueryRow, modifyQueries, setQueries, scanStart } from './state/query';
|
2021-02-12 14:33:26 -06:00
|
|
|
import { ExploreId, ExploreItemState } from 'app/types/explore';
|
2019-01-17 10:59:47 -06:00
|
|
|
import { StoreState } from 'app/types';
|
2019-01-22 07:50:19 -06:00
|
|
|
import { ExploreToolbar } from './ExploreToolbar';
|
2019-03-28 11:17:01 -05:00
|
|
|
import { NoDataSourceCallToAction } from './NoDataSourceCallToAction';
|
2019-04-29 11:28:41 -05:00
|
|
|
import { getTimeZone } from '../profile/state/selectors';
|
2020-04-02 06:34:16 -05:00
|
|
|
import { SecondaryActions } from './SecondaryActions';
|
2020-06-10 00:09:02 -05:00
|
|
|
import { FILTER_FOR_OPERATOR, FILTER_OUT_OPERATOR, FilterItem } from '@grafana/ui/src/components/Table/types';
|
2021-01-15 09:20:20 -06:00
|
|
|
import { ExploreGraphNGPanel } from './ExploreGraphNGPanel';
|
2021-01-19 09:34:43 -06:00
|
|
|
import { NodeGraphContainer } from './NodeGraphContainer';
|
2021-03-23 05:58:09 -05:00
|
|
|
import { ResponseErrorContainer } from './ResponseErrorContainer';
|
2021-05-19 12:41:54 -05:00
|
|
|
import { TraceViewContainer } from './TraceView/TraceViewContainer';
|
2018-12-31 12:30:32 -06:00
|
|
|
|
2021-08-13 01:02:49 -05:00
|
|
|
const getStyles = (theme: GrafanaTheme2) => {
|
2019-09-20 06:00:11 -05:00
|
|
|
return {
|
2020-12-15 08:18:12 -06:00
|
|
|
exploreMain: css`
|
|
|
|
label: exploreMain;
|
2019-09-20 06:00:11 -05:00
|
|
|
// Is needed for some transition animations to work.
|
|
|
|
position: relative;
|
2020-03-26 07:24:58 -05:00
|
|
|
margin-top: 21px;
|
2019-09-20 06:00:11 -05:00
|
|
|
`,
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
button: css`
|
2020-04-16 07:28:46 -05:00
|
|
|
label: button;
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
margin: 1em 4px 0 0;
|
2019-12-23 05:29:00 -06:00
|
|
|
`,
|
2020-04-16 07:28:46 -05:00
|
|
|
queryContainer: css`
|
|
|
|
label: queryContainer;
|
|
|
|
// Need to override normal css class and don't want to count on ordering of the classes in html.
|
|
|
|
height: auto !important;
|
2020-04-27 16:53:15 -05:00
|
|
|
flex: unset !important;
|
2021-08-03 05:32:53 -05:00
|
|
|
display: unset !important;
|
2021-08-13 01:02:49 -05:00
|
|
|
padding: ${theme.spacing(1)};
|
2020-04-16 07:28:46 -05:00
|
|
|
`,
|
2019-09-20 06:00:11 -05:00
|
|
|
};
|
2021-08-13 01:02:49 -05:00
|
|
|
};
|
2019-09-20 06:00:11 -05:00
|
|
|
|
2021-08-13 01:02:49 -05:00
|
|
|
export interface ExploreProps extends Themeable2 {
|
2019-01-11 11:26:56 -06:00
|
|
|
exploreId: ExploreId;
|
2021-08-13 01:02:49 -05:00
|
|
|
theme: GrafanaTheme2;
|
2018-04-27 11:21:20 -05:00
|
|
|
}
|
|
|
|
|
2020-08-06 10:22:54 -05:00
|
|
|
enum ExploreDrawer {
|
|
|
|
RichHistory,
|
|
|
|
QueryInspector,
|
|
|
|
}
|
|
|
|
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
interface ExploreState {
|
2020-08-06 10:22:54 -05:00
|
|
|
openDrawer?: ExploreDrawer;
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
2021-06-22 04:43:13 -05:00
|
|
|
export type Props = ExploreProps & ConnectedProps<typeof connector>;
|
|
|
|
|
2018-11-21 07:45:57 -06:00
|
|
|
/**
|
|
|
|
* Explore provides an area for quick query iteration for a given datasource.
|
|
|
|
* Once a datasource is selected it populates the query section at the top.
|
|
|
|
* When queries are run, their results are being displayed in the main section.
|
|
|
|
* The datasource determines what kind of query editor it brings, and what kind
|
2019-01-12 16:44:24 -06:00
|
|
|
* of results viewers it supports. The state is managed entirely in Redux.
|
2018-11-22 05:00:41 -06:00
|
|
|
*
|
2019-01-12 16:44:24 -06:00
|
|
|
* SPLIT VIEW
|
2018-11-22 05:00:41 -06:00
|
|
|
*
|
2019-01-12 16:44:24 -06:00
|
|
|
* Explore can have two Explore areas side-by-side. This is handled in `Wrapper.tsx`.
|
|
|
|
* Since there can be multiple Explores (e.g., left and right) each action needs
|
|
|
|
* the `exploreId` as first parameter so that the reducer knows which Explore state
|
|
|
|
* is affected.
|
2018-11-22 05:00:41 -06:00
|
|
|
*
|
|
|
|
* DATASOURCE REQUESTS
|
|
|
|
*
|
|
|
|
* A click on Run Query creates transactions for all DataQueries for all expanded
|
|
|
|
* result viewers. New runs are discarding previous runs. Upon completion a transaction
|
|
|
|
* saves the result. The result viewers construct their data from the currently existing
|
|
|
|
* transactions.
|
|
|
|
*
|
|
|
|
* The result viewers determine some of the query options sent to the datasource, e.g.,
|
|
|
|
* `format`, to indicate eventual transformations by the datasources' result transformers.
|
2018-11-21 07:45:57 -06:00
|
|
|
*/
|
2021-06-22 04:43:13 -05:00
|
|
|
export class Explore extends React.PureComponent<Props, ExploreState> {
|
|
|
|
constructor(props: Props) {
|
2018-04-26 04:58:42 -05:00
|
|
|
super(props);
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
this.state = {
|
2020-08-06 10:22:54 -05:00
|
|
|
openDrawer: undefined,
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
};
|
2018-04-26 04:58:42 -05:00
|
|
|
}
|
|
|
|
|
2019-06-28 05:07:55 -05:00
|
|
|
onChangeTime = (rawRange: RawTimeRange) => {
|
|
|
|
const { updateTimeRange, exploreId } = this.props;
|
2019-06-25 07:44:19 -05:00
|
|
|
updateTimeRange({ exploreId, rawRange });
|
2018-04-30 10:25:25 -05:00
|
|
|
};
|
|
|
|
|
2018-10-09 12:46:31 -05:00
|
|
|
// Use this in help pages to set page to a single query
|
2018-11-21 09:28:30 -06:00
|
|
|
onClickExample = (query: DataQuery) => {
|
2019-01-15 12:52:53 -06:00
|
|
|
this.props.setQueries(this.props.exploreId, [query]);
|
2018-10-09 12:46:31 -05:00
|
|
|
};
|
|
|
|
|
2020-06-10 00:09:02 -05:00
|
|
|
onCellFilterAdded = (filter: FilterItem) => {
|
|
|
|
const { value, key, operator } = filter;
|
|
|
|
if (operator === FILTER_FOR_OPERATOR) {
|
|
|
|
this.onClickFilterLabel(key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (operator === FILTER_OUT_OPERATOR) {
|
|
|
|
this.onClickFilterOutLabel(key, value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-11-01 04:01:00 -05:00
|
|
|
onClickFilterLabel = (key: string, value: string) => {
|
2018-11-28 03:46:35 -06:00
|
|
|
this.onModifyQueries({ type: 'ADD_FILTER', key, value });
|
2018-08-08 09:50:30 -05:00
|
|
|
};
|
|
|
|
|
2019-11-01 04:01:00 -05:00
|
|
|
onClickFilterOutLabel = (key: string, value: string) => {
|
|
|
|
this.onModifyQueries({ type: 'ADD_FILTER_OUT', key, value });
|
|
|
|
};
|
|
|
|
|
2019-12-23 05:29:00 -06:00
|
|
|
onClickAddQueryRowButton = () => {
|
|
|
|
const { exploreId, queryKeys } = this.props;
|
|
|
|
this.props.addQueryRow(exploreId, queryKeys.length);
|
|
|
|
};
|
|
|
|
|
2019-03-22 09:24:30 -05:00
|
|
|
onModifyQueries = (action: any, index?: number) => {
|
2019-01-10 07:24:31 -06:00
|
|
|
const { datasourceInstance } = this.props;
|
2019-11-26 03:01:32 -06:00
|
|
|
if (datasourceInstance?.modifyQuery) {
|
|
|
|
const modifier = (queries: DataQuery, modification: any) =>
|
|
|
|
datasourceInstance.modifyQuery!(queries, modification);
|
|
|
|
this.props.modifyQueries(this.props.exploreId, action, modifier, index);
|
2018-08-04 04:58:54 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-11 11:26:56 -06:00
|
|
|
onResize = (size: { height: number; width: number }) => {
|
|
|
|
this.props.changeSize(this.props.exploreId, size);
|
2018-04-26 04:58:42 -05:00
|
|
|
};
|
|
|
|
|
2018-11-27 09:35:37 -06:00
|
|
|
onStartScanning = () => {
|
2019-01-10 07:24:31 -06:00
|
|
|
// Scanner will trigger a query
|
2019-06-28 05:07:55 -05:00
|
|
|
this.props.scanStart(this.props.exploreId);
|
2018-11-23 10:53:16 -06:00
|
|
|
};
|
|
|
|
|
2018-11-27 09:35:37 -06:00
|
|
|
onStopScanning = () => {
|
2019-02-04 00:47:10 -06:00
|
|
|
this.props.scanStopAction({ exploreId: this.props.exploreId });
|
2018-11-23 10:53:16 -06:00
|
|
|
};
|
|
|
|
|
2019-08-26 01:11:07 -05:00
|
|
|
onUpdateTimeRange = (absoluteRange: AbsoluteTimeRange) => {
|
2019-10-08 11:55:53 -05:00
|
|
|
const { exploreId, updateTimeRange } = this.props;
|
2019-08-26 01:11:07 -05:00
|
|
|
updateTimeRange({ exploreId, absoluteRange });
|
|
|
|
};
|
|
|
|
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
toggleShowRichHistory = () => {
|
2021-01-20 00:59:48 -06:00
|
|
|
this.setState((state) => {
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
return {
|
2020-08-06 10:22:54 -05:00
|
|
|
openDrawer: state.openDrawer === ExploreDrawer.RichHistory ? undefined : ExploreDrawer.RichHistory,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
toggleShowQueryInspector = () => {
|
2021-01-20 00:59:48 -06:00
|
|
|
this.setState((state) => {
|
2020-08-06 10:22:54 -05:00
|
|
|
return {
|
|
|
|
openDrawer: state.openDrawer === ExploreDrawer.QueryInspector ? undefined : ExploreDrawer.QueryInspector,
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-01-19 09:34:43 -06:00
|
|
|
renderEmptyState() {
|
2019-03-28 11:17:01 -05:00
|
|
|
return (
|
|
|
|
<div className="explore-container">
|
|
|
|
<NoDataSourceCallToAction />
|
|
|
|
</div>
|
|
|
|
);
|
2021-01-19 09:34:43 -06:00
|
|
|
}
|
|
|
|
|
2021-06-18 07:21:54 -05:00
|
|
|
renderGraphPanel(width: number) {
|
|
|
|
const { graphResult, absoluteRange, timeZone, splitOpen, queryResponse, loading, theme } = this.props;
|
2021-08-13 01:02:49 -05:00
|
|
|
const spacing = parseInt(theme.spacing(2).slice(0, -2), 10);
|
2021-01-19 09:34:43 -06:00
|
|
|
return (
|
2021-06-01 02:28:25 -05:00
|
|
|
<Collapse label="Graph" loading={loading} isOpen>
|
|
|
|
<ExploreGraphNGPanel
|
|
|
|
data={graphResult!}
|
|
|
|
height={400}
|
2021-08-13 01:02:49 -05:00
|
|
|
width={width - spacing}
|
2021-06-01 02:28:25 -05:00
|
|
|
tooltipDisplayMode={TooltipDisplayMode.Single}
|
|
|
|
absoluteRange={absoluteRange}
|
|
|
|
timeZone={timeZone}
|
|
|
|
onUpdateTimeRange={this.onUpdateTimeRange}
|
|
|
|
annotations={queryResponse.annotations}
|
|
|
|
splitOpenFn={splitOpen}
|
|
|
|
/>
|
|
|
|
</Collapse>
|
2021-01-19 09:34:43 -06:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderTablePanel(width: number) {
|
|
|
|
const { exploreId, datasourceInstance } = this.props;
|
|
|
|
return (
|
|
|
|
<TableContainer
|
|
|
|
ariaLabel={selectors.pages.Explore.General.table}
|
|
|
|
width={width}
|
|
|
|
exploreId={exploreId}
|
|
|
|
onCellFilterAdded={datasourceInstance?.modifyQuery ? this.onCellFilterAdded : undefined}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-06-18 07:21:54 -05:00
|
|
|
renderLogsPanel(width: number) {
|
|
|
|
const { exploreId, syncedTimes, theme } = this.props;
|
2021-08-13 01:02:49 -05:00
|
|
|
const spacing = parseInt(theme.spacing(2).slice(0, -2), 10);
|
2021-01-19 09:34:43 -06:00
|
|
|
return (
|
|
|
|
<LogsContainer
|
|
|
|
exploreId={exploreId}
|
|
|
|
syncedTimes={syncedTimes}
|
2021-08-13 01:02:49 -05:00
|
|
|
width={width - spacing}
|
2021-01-19 09:34:43 -06:00
|
|
|
onClickFilterLabel={this.onClickFilterLabel}
|
|
|
|
onClickFilterOutLabel={this.onClickFilterOutLabel}
|
|
|
|
onStartScanning={this.onStartScanning}
|
|
|
|
onStopScanning={this.onStopScanning}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderNodeGraphPanel() {
|
|
|
|
const { exploreId, showTrace, queryResponse } = this.props;
|
|
|
|
return (
|
|
|
|
<NodeGraphContainer
|
|
|
|
dataFrames={this.getNodeGraphDataFrames(queryResponse.series)}
|
|
|
|
exploreId={exploreId}
|
2021-05-26 08:11:47 -05:00
|
|
|
withTraceView={showTrace}
|
2021-01-19 09:34:43 -06:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
getNodeGraphDataFrames = memoizeOne((frames: DataFrame[]) => {
|
|
|
|
// TODO: this not in sync with how other types of responses are handled. Other types have a query response
|
|
|
|
// processing pipeline which ends up populating redux state with proper data. As we move towards more dataFrame
|
|
|
|
// oriented API it seems like a better direction to move such processing into to visualisations and do minimal
|
|
|
|
// and lazy processing here. Needs bigger refactor so keeping nodeGraph and Traces as they are for now.
|
2021-01-20 00:59:48 -06:00
|
|
|
return frames.filter((frame) => frame.meta?.preferredVisualisationType === 'nodeGraph');
|
2021-01-19 09:34:43 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
renderTraceViewPanel() {
|
2021-02-23 12:44:31 -06:00
|
|
|
const { queryResponse, splitOpen, exploreId } = this.props;
|
2021-01-20 00:59:48 -06:00
|
|
|
const dataFrames = queryResponse.series.filter((series) => series.meta?.preferredVisualisationType === 'trace');
|
2021-01-19 09:34:43 -06:00
|
|
|
|
|
|
|
return (
|
|
|
|
// If there is no data (like 404) we show a separate error so no need to show anything here
|
2021-05-19 12:41:54 -05:00
|
|
|
dataFrames.length && <TraceViewContainer exploreId={exploreId} dataFrames={dataFrames} splitOpenFn={splitOpen} />
|
2021-01-19 09:34:43 -06:00
|
|
|
);
|
|
|
|
}
|
2019-03-28 11:17:01 -05:00
|
|
|
|
2018-04-26 04:58:42 -05:00
|
|
|
render() {
|
|
|
|
const {
|
2019-01-10 07:24:31 -06:00
|
|
|
datasourceInstance,
|
2018-07-13 02:09:36 -05:00
|
|
|
datasourceMissing,
|
2019-01-11 11:26:56 -06:00
|
|
|
exploreId,
|
2019-02-04 06:41:29 -06:00
|
|
|
queryKeys,
|
2019-08-13 00:32:43 -05:00
|
|
|
graphResult,
|
2019-09-03 02:55:20 -05:00
|
|
|
queryResponse,
|
2019-12-23 05:29:00 -06:00
|
|
|
isLive,
|
2020-04-16 07:28:46 -05:00
|
|
|
theme,
|
2020-07-09 09:14:55 -05:00
|
|
|
showMetrics,
|
|
|
|
showTable,
|
|
|
|
showLogs,
|
|
|
|
showTrace,
|
2021-01-19 09:34:43 -06:00
|
|
|
showNodeGraph,
|
2019-01-10 07:24:31 -06:00
|
|
|
} = this.props;
|
2020-08-06 10:22:54 -05:00
|
|
|
const { openDrawer } = this.state;
|
2020-04-16 07:28:46 -05:00
|
|
|
const styles = getStyles(theme);
|
2021-01-19 16:52:09 -06:00
|
|
|
const showPanels = queryResponse && queryResponse.state !== LoadingState.NotStarted;
|
2020-08-06 10:22:54 -05:00
|
|
|
const showRichHistory = openDrawer === ExploreDrawer.RichHistory;
|
|
|
|
const showQueryInspector = openDrawer === ExploreDrawer.QueryInspector;
|
|
|
|
|
2018-04-26 04:58:42 -05:00
|
|
|
return (
|
2021-04-15 03:44:25 -05:00
|
|
|
<CustomScrollbar autoHeightMin={'100%'}>
|
2019-06-28 05:07:55 -05:00
|
|
|
<ExploreToolbar exploreId={exploreId} onChangeTime={this.onChangeTime} />
|
2019-03-28 11:17:01 -05:00
|
|
|
{datasourceMissing ? this.renderEmptyState() : null}
|
2019-04-01 00:38:00 -05:00
|
|
|
{datasourceInstance && (
|
2019-02-19 08:41:35 -06:00
|
|
|
<div className="explore-container">
|
2020-04-16 07:28:46 -05:00
|
|
|
<div className={cx('panel-container', styles.queryContainer)}>
|
2021-02-12 14:33:26 -06:00
|
|
|
<QueryRows exploreId={exploreId} queryKeys={queryKeys} />
|
2020-04-16 07:28:46 -05:00
|
|
|
<SecondaryActions
|
|
|
|
addQueryRowButtonDisabled={isLive}
|
|
|
|
// We cannot show multiple traces at the same time right now so we do not show add query button.
|
2020-07-09 09:14:55 -05:00
|
|
|
//TODO:unification
|
|
|
|
addQueryRowButtonHidden={false}
|
2020-04-16 07:28:46 -05:00
|
|
|
richHistoryButtonActive={showRichHistory}
|
2020-08-06 10:22:54 -05:00
|
|
|
queryInspectorButtonActive={showQueryInspector}
|
2020-04-16 07:28:46 -05:00
|
|
|
onClickAddQueryRowButton={this.onClickAddQueryRowButton}
|
|
|
|
onClickRichHistoryButton={this.toggleShowRichHistory}
|
2020-08-06 10:22:54 -05:00
|
|
|
onClickQueryInspectorButton={this.toggleShowQueryInspector}
|
2020-04-16 07:28:46 -05:00
|
|
|
/>
|
2021-04-27 08:13:08 -05:00
|
|
|
<ResponseErrorContainer exploreId={exploreId} />
|
2020-04-14 04:32:14 -05:00
|
|
|
</div>
|
2020-04-08 10:16:22 -05:00
|
|
|
<AutoSizer onResize={this.onResize} disableHeight>
|
2019-02-19 08:41:35 -06:00
|
|
|
{({ width }) => {
|
|
|
|
if (width === 0) {
|
|
|
|
return null;
|
|
|
|
}
|
2019-02-07 11:20:16 -06:00
|
|
|
|
2019-02-19 08:41:35 -06:00
|
|
|
return (
|
2020-12-15 08:18:12 -06:00
|
|
|
<main className={cx(styles.exploreMain)} style={{ width }}>
|
2019-09-04 06:59:30 -05:00
|
|
|
<ErrorBoundaryAlert>
|
2021-01-19 16:52:09 -06:00
|
|
|
{showPanels && (
|
2019-02-19 08:41:35 -06:00
|
|
|
<>
|
2021-05-10 13:25:30 -05:00
|
|
|
{showMetrics && graphResult && (
|
2021-06-18 07:21:54 -05:00
|
|
|
<ErrorBoundaryAlert>{this.renderGraphPanel(width)}</ErrorBoundaryAlert>
|
2021-05-10 13:25:30 -05:00
|
|
|
)}
|
|
|
|
{showTable && <ErrorBoundaryAlert>{this.renderTablePanel(width)}</ErrorBoundaryAlert>}
|
2021-06-18 07:21:54 -05:00
|
|
|
{showLogs && <ErrorBoundaryAlert>{this.renderLogsPanel(width)}</ErrorBoundaryAlert>}
|
2021-05-10 13:25:30 -05:00
|
|
|
{showNodeGraph && <ErrorBoundaryAlert>{this.renderNodeGraphPanel()}</ErrorBoundaryAlert>}
|
|
|
|
{showTrace && <ErrorBoundaryAlert>{this.renderTraceViewPanel()}</ErrorBoundaryAlert>}
|
2019-02-19 08:41:35 -06:00
|
|
|
</>
|
|
|
|
)}
|
2020-03-17 10:06:02 -05:00
|
|
|
{showRichHistory && (
|
|
|
|
<RichHistoryContainer
|
|
|
|
width={width}
|
|
|
|
exploreId={exploreId}
|
|
|
|
onClose={this.toggleShowRichHistory}
|
|
|
|
/>
|
|
|
|
)}
|
2020-08-06 10:22:54 -05:00
|
|
|
{showQueryInspector && (
|
|
|
|
<ExploreQueryInspector
|
|
|
|
exploreId={exploreId}
|
|
|
|
width={width}
|
|
|
|
onClose={this.toggleShowQueryInspector}
|
|
|
|
/>
|
|
|
|
)}
|
2019-09-04 06:59:30 -05:00
|
|
|
</ErrorBoundaryAlert>
|
2019-02-19 08:41:35 -06:00
|
|
|
</main>
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
</AutoSizer>
|
|
|
|
</div>
|
|
|
|
)}
|
2021-04-15 03:44:25 -05:00
|
|
|
</CustomScrollbar>
|
2018-04-26 04:58:42 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-22 04:43:13 -05:00
|
|
|
function mapStateToProps(state: StoreState, { exploreId }: ExploreProps) {
|
2019-01-11 11:26:56 -06:00
|
|
|
const explore = state.explore;
|
2021-02-12 14:33:26 -06:00
|
|
|
const { syncedTimes } = explore;
|
|
|
|
const item: ExploreItemState = explore[exploreId]!;
|
2019-04-29 11:28:41 -05:00
|
|
|
const timeZone = getTimeZone(state.user);
|
2019-01-10 07:24:31 -06:00
|
|
|
const {
|
|
|
|
datasourceInstance,
|
|
|
|
datasourceMissing,
|
2019-02-04 06:41:29 -06:00
|
|
|
queryKeys,
|
2019-05-20 06:28:23 -05:00
|
|
|
isLive,
|
2019-08-13 00:32:43 -05:00
|
|
|
graphResult,
|
2020-07-09 09:14:55 -05:00
|
|
|
logsResult,
|
|
|
|
showLogs,
|
|
|
|
showMetrics,
|
|
|
|
showTable,
|
|
|
|
showTrace,
|
2019-08-26 01:11:07 -05:00
|
|
|
absoluteRange,
|
2019-09-03 02:55:20 -05:00
|
|
|
queryResponse,
|
2021-01-19 09:34:43 -06:00
|
|
|
showNodeGraph,
|
2021-01-22 11:15:06 -06:00
|
|
|
loading,
|
2019-01-11 11:26:56 -06:00
|
|
|
} = item;
|
2019-04-29 11:28:41 -05:00
|
|
|
|
2019-01-10 07:24:31 -06:00
|
|
|
return {
|
|
|
|
datasourceInstance,
|
|
|
|
datasourceMissing,
|
2019-02-04 06:41:29 -06:00
|
|
|
queryKeys,
|
2019-05-20 06:28:23 -05:00
|
|
|
isLive,
|
2021-01-15 09:20:20 -06:00
|
|
|
graphResult,
|
2020-07-09 09:14:55 -05:00
|
|
|
logsResult: logsResult ?? undefined,
|
2019-08-26 01:11:07 -05:00
|
|
|
absoluteRange,
|
2019-09-03 02:55:20 -05:00
|
|
|
queryResponse,
|
2019-10-08 11:55:53 -05:00
|
|
|
syncedTimes,
|
2019-12-03 02:38:47 -06:00
|
|
|
timeZone,
|
2020-07-09 09:14:55 -05:00
|
|
|
showLogs,
|
|
|
|
showMetrics,
|
|
|
|
showTable,
|
|
|
|
showTrace,
|
2021-01-19 09:34:43 -06:00
|
|
|
showNodeGraph,
|
2021-01-22 11:15:06 -06:00
|
|
|
loading,
|
2019-01-10 07:24:31 -06:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-06-22 04:43:13 -05:00
|
|
|
const mapDispatchToProps = {
|
2019-01-11 11:26:56 -06:00
|
|
|
changeSize,
|
2019-01-10 07:24:31 -06:00
|
|
|
modifyQueries,
|
|
|
|
scanStart,
|
2019-02-04 00:47:10 -06:00
|
|
|
scanStopAction,
|
2019-01-15 12:52:53 -06:00
|
|
|
setQueries,
|
2019-06-25 07:44:19 -05:00
|
|
|
updateTimeRange,
|
2019-12-23 05:29:00 -06:00
|
|
|
addQueryRow,
|
2020-10-14 17:03:14 -05:00
|
|
|
splitOpen,
|
2019-01-10 07:24:31 -06:00
|
|
|
};
|
|
|
|
|
2021-06-22 04:43:13 -05:00
|
|
|
const connector = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
|
2021-08-31 05:55:05 -05:00
|
|
|
export default compose(connector, withTheme2)(Explore) as React.ComponentType<{ exploreId: ExploreId }>;
|