mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
LogDetailsRow: customize filters tooltip according to the current app (#89183)
* LogDetailsRow: customize filters tooltip * Update tests
This commit is contained in:
parent
bd35fa10f1
commit
06c0ce4325
@ -11,6 +11,7 @@ import {
|
||||
FieldType,
|
||||
createDataFrame,
|
||||
DataFrameType,
|
||||
CoreApp,
|
||||
} from '@grafana/data';
|
||||
|
||||
import { LogDetails, Props } from './LogDetails';
|
||||
@ -32,6 +33,7 @@ const setup = (propOverrides?: Partial<Props>, rowOverrides?: Partial<LogRowMode
|
||||
onClickHideField: () => {},
|
||||
theme,
|
||||
styles,
|
||||
app: CoreApp.Explore,
|
||||
...(propOverrides || {}),
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import React, { ComponentProps } from 'react';
|
||||
|
||||
import { CoreApp } from '@grafana/data';
|
||||
|
||||
import { LogDetailsRow } from './LogDetailsRow';
|
||||
import { createLogRow } from './__mocks__/logRow';
|
||||
|
||||
@ -20,6 +22,7 @@ const setup = (propOverrides?: Partial<Props>) => {
|
||||
displayedFields: [],
|
||||
row: createLogRow(),
|
||||
disableActions: false,
|
||||
app: CoreApp.Explore,
|
||||
};
|
||||
|
||||
Object.assign(props, propOverrides);
|
||||
|
@ -261,6 +261,7 @@ class UnThemedLogDetailsRow extends PureComponent<Props, State> {
|
||||
onClickFilterOutLabel,
|
||||
disableActions,
|
||||
row,
|
||||
app,
|
||||
} = this.props;
|
||||
const { showFieldsStats, fieldStats, fieldCount } = this.state;
|
||||
const styles = getStyles(theme);
|
||||
@ -268,7 +269,7 @@ class UnThemedLogDetailsRow extends PureComponent<Props, State> {
|
||||
const singleKey = parsedKeys == null ? false : parsedKeys.length === 1;
|
||||
const singleVal = parsedValues == null ? false : parsedValues.length === 1;
|
||||
const hasFilteringFunctionality = !disableActions && onClickFilterLabel && onClickFilterOutLabel;
|
||||
const refIdTooltip = row.dataFrame?.refId ? ` in query ${row.dataFrame?.refId}` : '';
|
||||
const refIdTooltip = app === CoreApp.Explore && row.dataFrame?.refId ? ` in query ${row.dataFrame?.refId}` : '';
|
||||
|
||||
const isMultiParsedValueWithNoContent =
|
||||
!singleVal && parsedValues != null && !parsedValues.every((val) => val === '');
|
||||
|
@ -374,9 +374,9 @@ describe('LogsPanel', () => {
|
||||
expect(await screen.findByRole('row')).toBeInTheDocument();
|
||||
|
||||
await userEvent.click(screen.getByText('logline text'));
|
||||
await userEvent.click(screen.getByLabelText('Filter for value in query A'));
|
||||
await userEvent.click(screen.getByLabelText('Filter for value'));
|
||||
expect(filterForMock).toHaveBeenCalledTimes(1);
|
||||
await userEvent.click(screen.getByLabelText('Filter out value in query A'));
|
||||
await userEvent.click(screen.getByLabelText('Filter out value'));
|
||||
expect(filterOutMock).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(isFilterLabelActiveMock).toHaveBeenCalledTimes(1);
|
||||
@ -399,8 +399,8 @@ describe('LogsPanel', () => {
|
||||
|
||||
await userEvent.click(screen.getByText('logline text'));
|
||||
|
||||
expect(screen.queryByLabelText('Filter for value in query A')).not.toBeInTheDocument();
|
||||
expect(screen.queryByLabelText('Filter out value in query A')).not.toBeInTheDocument();
|
||||
expect(screen.queryByLabelText('Filter for value')).not.toBeInTheDocument();
|
||||
expect(screen.queryByLabelText('Filter out value')).not.toBeInTheDocument();
|
||||
});
|
||||
it('shows the controls if onAddAdHocFilter is defined', async () => {
|
||||
jest.spyOn(grafanaUI, 'usePanelContext').mockReturnValue({
|
||||
@ -421,8 +421,8 @@ describe('LogsPanel', () => {
|
||||
|
||||
expect(await screen.findByText('common_app')).toBeInTheDocument();
|
||||
|
||||
expect(screen.getByLabelText('Filter for value in query A')).toBeInTheDocument();
|
||||
expect(screen.getByLabelText('Filter out value in query A')).toBeInTheDocument();
|
||||
expect(screen.getByLabelText('Filter for value')).toBeInTheDocument();
|
||||
expect(screen.getByLabelText('Filter out value')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user