diff --git a/public/app/core/history/richHistoryStorageProvider.ts b/public/app/core/history/richHistoryStorageProvider.ts index a4086776ddd..44337ffbb0e 100644 --- a/public/app/core/history/richHistoryStorageProvider.ts +++ b/public/app/core/history/richHistoryStorageProvider.ts @@ -1,4 +1,5 @@ import { config } from '@grafana/runtime'; +import { contextSrv } from 'app/core/core'; import { SortOrder } from '../utils/richHistoryTypes'; @@ -19,6 +20,7 @@ interface RichHistorySupportedFeatures { clearHistory: boolean; onlyActiveDataSource: boolean; changeRetention: boolean; + queryHistoryAvailable: boolean; } export const supportedFeatures = (): RichHistorySupportedFeatures => { @@ -29,6 +31,7 @@ export const supportedFeatures = (): RichHistorySupportedFeatures => { clearHistory: false, onlyActiveDataSource: false, changeRetention: false, + queryHistoryAvailable: contextSrv.isSignedIn, } : { availableFilters: [SortOrder.Descending, SortOrder.Ascending, SortOrder.DatasourceAZ, SortOrder.DatasourceZA], @@ -36,5 +39,6 @@ export const supportedFeatures = (): RichHistorySupportedFeatures => { clearHistory: true, onlyActiveDataSource: true, changeRetention: true, + queryHistoryAvailable: true, }; }; diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index 3dbe10a8c19..df058b92202 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -11,6 +11,7 @@ import { selectors } from '@grafana/e2e-selectors'; import { Collapse, CustomScrollbar, ErrorBoundaryAlert, Themeable2, withTheme2, PanelContainer } from '@grafana/ui'; import { FILTER_FOR_OPERATOR, FILTER_OUT_OPERATOR, FilterItem } from '@grafana/ui/src/components/Table/types'; import appEvents from 'app/core/app_events'; +import { supportedFeatures } from 'app/core/history/richHistoryStorageProvider'; import { getNodeGraphDataFrames } from 'app/plugins/panel/nodeGraph/utils'; import { StoreState } from 'app/types'; import { AbsoluteTimeEvent } from 'app/types/events'; @@ -347,6 +348,7 @@ export class Explore extends React.PureComponent { const styles = getStyles(theme); const showPanels = queryResponse && queryResponse.state !== LoadingState.NotStarted; const showRichHistory = openDrawer === ExploreDrawer.RichHistory; + const richHistoryRowButtonHidden = !supportedFeatures().queryHistoryAvailable; const showQueryInspector = openDrawer === ExploreDrawer.QueryInspector; const showNoData = queryResponse.state === LoadingState.Done && @@ -375,6 +377,7 @@ export class Explore extends React.PureComponent { // We cannot show multiple traces at the same time right now so we do not show add query button. //TODO:unification addQueryRowButtonHidden={false} + richHistoryRowButtonHidden={richHistoryRowButtonHidden} richHistoryButtonActive={showRichHistory} queryInspectorButtonActive={showQueryInspector} onClickAddQueryRowButton={this.onClickAddQueryRowButton} diff --git a/public/app/features/explore/SecondaryActions.test.tsx b/public/app/features/explore/SecondaryActions.test.tsx index a8dbbd1d9df..e5684b9a1c9 100644 --- a/public/app/features/explore/SecondaryActions.test.tsx +++ b/public/app/features/explore/SecondaryActions.test.tsx @@ -20,10 +20,11 @@ describe('SecondaryActions', () => { expect(screen.getByRole('button', { name: /Query inspector button/i })).toBeInTheDocument(); }); - it('should not render add row button if addQueryRowButtonHidden=true', () => { + it('should not render hidden elements', () => { render( { ); expect(screen.queryByRole('button', { name: /Add row button/i })).not.toBeInTheDocument(); - expect(screen.getByRole('button', { name: /Rich history button/i })).toBeInTheDocument(); + expect(screen.queryByRole('button', { name: /Rich history button/i })).not.toBeInTheDocument(); expect(screen.getByRole('button', { name: /Query inspector button/i })).toBeInTheDocument(); }); diff --git a/public/app/features/explore/SecondaryActions.tsx b/public/app/features/explore/SecondaryActions.tsx index b18ccd78349..97cf5f21bd4 100644 --- a/public/app/features/explore/SecondaryActions.tsx +++ b/public/app/features/explore/SecondaryActions.tsx @@ -7,6 +7,7 @@ import { Button, HorizontalGroup, useTheme2 } from '@grafana/ui'; type Props = { addQueryRowButtonDisabled?: boolean; addQueryRowButtonHidden?: boolean; + richHistoryRowButtonHidden?: boolean; richHistoryButtonActive?: boolean; queryInspectorButtonActive?: boolean; @@ -39,15 +40,17 @@ export function SecondaryActions(props: Props) { Add query )} - + {!props.richHistoryRowButtonHidden && ( + + )}