2021-03-25 06:42:14 -05:00
|
|
|
import React, { useState, useEffect } from 'react';
|
2021-04-01 07:15:23 -05:00
|
|
|
import { css } from '@emotion/css';
|
2021-03-25 06:42:14 -05:00
|
|
|
import { uniqBy } from 'lodash';
|
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
|
|
|
|
|
|
|
// Types
|
|
|
|
import { RichHistoryQuery, ExploreId } from 'app/types/explore';
|
|
|
|
|
|
|
|
// Utils
|
2021-09-29 02:35:41 -05:00
|
|
|
import { stylesFactory, useTheme, Select, MultiSelect, FilterInput } from '@grafana/ui';
|
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 { GrafanaTheme, SelectableValue } from '@grafana/data';
|
2020-08-06 11:35:49 -05:00
|
|
|
import { filterAndSortQueries, createDatasourcesList, SortOrder } from 'app/core/utils/richHistory';
|
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
|
|
|
|
|
|
|
// Components
|
|
|
|
import RichHistoryCard from './RichHistoryCard';
|
|
|
|
import { sortOrderOptions } from './RichHistory';
|
2021-03-25 06:42:14 -05:00
|
|
|
import { useDebounce } from 'react-use';
|
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
|
|
|
|
2020-03-17 17:24:27 -05:00
|
|
|
export interface 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
|
|
|
queries: RichHistoryQuery[];
|
|
|
|
sortOrder: SortOrder;
|
|
|
|
activeDatasourceOnly: boolean;
|
2021-07-20 03:57:03 -05:00
|
|
|
datasourceFilters: SelectableValue[];
|
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
|
|
|
exploreId: ExploreId;
|
|
|
|
onChangeSortOrder: (sortOrder: SortOrder) => void;
|
2020-07-09 08:16:35 -05:00
|
|
|
onSelectDatasourceFilters: (value: SelectableValue[]) => void;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
const getStyles = stylesFactory((theme: GrafanaTheme) => {
|
2020-04-12 08:05:49 -05:00
|
|
|
const bgColor = theme.isLight ? theme.palette.gray5 : theme.palette.dark4;
|
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 {
|
|
|
|
container: css`
|
|
|
|
display: flex;
|
|
|
|
`,
|
|
|
|
containerContent: css`
|
|
|
|
width: 100%;
|
|
|
|
`,
|
|
|
|
selectors: css`
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
2020-06-30 09:15:46 -05:00
|
|
|
flex-wrap: wrap;
|
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
|
|
|
`,
|
|
|
|
multiselect: css`
|
2020-06-30 09:15:46 -05:00
|
|
|
width: 100%;
|
|
|
|
margin-bottom: ${theme.spacing.sm};
|
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
|
|
|
.gf-form-select-box__multi-value {
|
|
|
|
background-color: ${bgColor};
|
|
|
|
padding: ${theme.spacing.xxs} ${theme.spacing.xs} ${theme.spacing.xxs} ${theme.spacing.sm};
|
|
|
|
border-radius: ${theme.border.radius.sm};
|
|
|
|
}
|
|
|
|
`,
|
2020-06-30 09:15:46 -05:00
|
|
|
filterInput: css`
|
|
|
|
margin-bottom: ${theme.spacing.sm};
|
|
|
|
`,
|
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
|
|
|
sort: css`
|
|
|
|
width: 170px;
|
|
|
|
`,
|
2020-05-04 03:02:34 -05:00
|
|
|
footer: css`
|
2020-03-19 02:47:27 -05:00
|
|
|
height: 60px;
|
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-top: ${theme.spacing.lg};
|
2020-03-19 02:47:27 -05:00
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
font-weight: ${theme.typography.weight.light};
|
|
|
|
font-size: ${theme.typography.size.sm};
|
|
|
|
a {
|
|
|
|
font-weight: ${theme.typography.weight.semibold};
|
|
|
|
margin-left: ${theme.spacing.xxs};
|
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
|
|
|
}
|
|
|
|
`,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
export function RichHistoryStarredTab(props: Props) {
|
|
|
|
const {
|
|
|
|
datasourceFilters,
|
|
|
|
onSelectDatasourceFilters,
|
|
|
|
queries,
|
|
|
|
onChangeSortOrder,
|
|
|
|
sortOrder,
|
|
|
|
activeDatasourceOnly,
|
|
|
|
exploreId,
|
|
|
|
} = props;
|
|
|
|
|
2021-11-24 06:52:44 -06:00
|
|
|
const [data, setData] = useState<[RichHistoryQuery[], ReturnType<typeof createDatasourcesList>]>([[], []]);
|
2020-06-30 09:15:46 -05:00
|
|
|
const [searchInput, setSearchInput] = useState('');
|
2021-03-25 06:42:14 -05:00
|
|
|
const [debouncedSearchInput, setDebouncedSearchInput] = useState('');
|
2020-06-30 09:15:46 -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
|
|
|
const theme = useTheme();
|
|
|
|
const styles = getStyles(theme);
|
2020-03-19 02:47:27 -05:00
|
|
|
|
2021-03-25 06:42:14 -05:00
|
|
|
useDebounce(
|
|
|
|
() => {
|
|
|
|
setDebouncedSearchInput(searchInput);
|
|
|
|
},
|
|
|
|
300,
|
|
|
|
[searchInput]
|
2020-06-30 09:15:46 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
useEffect(() => {
|
2021-11-24 06:52:44 -06:00
|
|
|
const datasourcesRetrievedFromQueryHistory = uniqBy(queries, 'datasourceName').map((d) => d.datasourceName);
|
|
|
|
const listOfDatasources = createDatasourcesList(datasourcesRetrievedFromQueryHistory);
|
2021-03-25 06:42:14 -05:00
|
|
|
const starredQueries = queries.filter((q) => q.starred === true);
|
2021-11-24 06:52:44 -06:00
|
|
|
setData([
|
2020-06-30 09:15:46 -05:00
|
|
|
filterAndSortQueries(
|
|
|
|
starredQueries,
|
|
|
|
sortOrder,
|
2021-07-20 03:57:03 -05:00
|
|
|
datasourceFilters.map((d) => d.value),
|
2021-03-25 06:42:14 -05:00
|
|
|
debouncedSearchInput
|
2021-11-24 06:52:44 -06:00
|
|
|
),
|
|
|
|
listOfDatasources,
|
|
|
|
]);
|
2021-03-25 06:42:14 -05:00
|
|
|
}, [queries, sortOrder, datasourceFilters, debouncedSearchInput]);
|
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-11-24 06:52:44 -06:00
|
|
|
const [filteredQueries, listOfDatasources] = data;
|
|
|
|
|
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 (
|
|
|
|
<div className={styles.container}>
|
|
|
|
<div className={styles.containerContent}>
|
|
|
|
<div className={styles.selectors}>
|
|
|
|
{!activeDatasourceOnly && (
|
2020-03-17 17:24:27 -05:00
|
|
|
<div aria-label="Filter datasources" className={styles.multiselect}>
|
2021-07-20 03:57:03 -05:00
|
|
|
<MultiSelect
|
2021-08-04 09:47:53 -05:00
|
|
|
menuShouldPortal
|
2020-03-19 02:47:27 -05:00
|
|
|
options={listOfDatasources}
|
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
|
|
|
value={datasourceFilters}
|
2020-03-17 10:06:02 -05:00
|
|
|
placeholder="Filter queries for specific data sources(s)"
|
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
|
|
|
onChange={onSelectDatasourceFilters}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
2020-06-30 09:15:46 -05:00
|
|
|
<div className={styles.filterInput}>
|
|
|
|
<FilterInput
|
|
|
|
placeholder="Search queries"
|
|
|
|
value={searchInput}
|
|
|
|
onChange={(value: string) => {
|
|
|
|
setSearchInput(value);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
2020-03-17 17:24:27 -05:00
|
|
|
<div aria-label="Sort queries" className={styles.sort}>
|
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
|
|
|
<Select
|
2021-08-04 09:47:53 -05:00
|
|
|
menuShouldPortal
|
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
|
|
|
options={sortOrderOptions}
|
2021-01-20 00:59:48 -06:00
|
|
|
value={sortOrderOptions.filter((order) => order.value === sortOrder)}
|
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
|
|
|
placeholder="Sort queries by"
|
2021-01-20 00:59:48 -06:00
|
|
|
onChange={(e) => onChangeSortOrder(e.value as SortOrder)}
|
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
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-20 00:59:48 -06:00
|
|
|
{filteredQueries.map((q) => {
|
|
|
|
const idx = listOfDatasources.findIndex((d) => d.label === q.datasourceName);
|
2020-03-19 02:47:27 -05:00
|
|
|
return (
|
|
|
|
<RichHistoryCard
|
|
|
|
query={q}
|
2022-02-10 06:59:43 -06:00
|
|
|
key={q.id}
|
2020-03-19 02:47:27 -05:00
|
|
|
exploreId={exploreId}
|
|
|
|
dsImg={listOfDatasources[idx].imgUrl}
|
|
|
|
isRemoved={listOfDatasources[idx].isRemoved}
|
|
|
|
/>
|
|
|
|
);
|
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
|
|
|
})}
|
2020-05-04 03:02:34 -05:00
|
|
|
<div className={styles.footer}>The history is local to your browser and is not shared with others.</div>
|
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
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|