From 28e8d7d56e1dc78ab0c53a223a31ed8b4e1c5995 Mon Sep 17 00:00:00 2001 From: Matias Chomicki Date: Fri, 31 Oct 2025 13:00:30 +0100 Subject: [PATCH] Logs in Explore: Hide "show original line" when using the table (#113215) * Logs in Explore: Hide "show original line" when using the table * Test update --- public/app/features/explore/Logs/Logs.tsx | 1 + .../app/features/explore/Logs/LogsMetaRow.test.tsx | 12 +++++++++++- public/app/features/explore/Logs/LogsMetaRow.tsx | 9 ++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/public/app/features/explore/Logs/Logs.tsx b/public/app/features/explore/Logs/Logs.tsx index f4e0c956e4d..7820e5eb9e9 100644 --- a/public/app/features/explore/Logs/Logs.tsx +++ b/public/app/features/explore/Logs/Logs.tsx @@ -979,6 +979,7 @@ const UnthemedLogs: React.FunctionComponent = (props: Props) => { displayedFields={displayedFields} clearDisplayedFields={clearDisplayedFields} defaultDisplayedFields={defaultDisplayedFields} + visualisationType={visualisationType} />
diff --git a/public/app/features/explore/Logs/LogsMetaRow.test.tsx b/public/app/features/explore/Logs/LogsMetaRow.test.tsx index ea0e65f91cb..4210df96dff 100644 --- a/public/app/features/explore/Logs/LogsMetaRow.test.tsx +++ b/public/app/features/explore/Logs/LogsMetaRow.test.tsx @@ -28,9 +28,10 @@ const defaultProps: LogsMetaRowProps = { logRows: [], clearDisplayedFields: jest.fn(), defaultDisplayedFields: [], + visualisationType: 'logs', }; -const setup = (propOverrides?: object, disableDownload = false) => { +const setup = (propOverrides?: Partial, disableDownload = false) => { const props = { ...defaultProps, ...propOverrides, @@ -55,6 +56,15 @@ describe('LogsMetaRow', () => { ).toBeInTheDocument(); }); + it('does not render the show original line button if the current viz is the table', () => { + setup({ displayedFields: ['test'], visualisationType: 'table' }); + expect( + screen.queryByRole('button', { + name: 'Show original line', + }) + ).not.toBeInTheDocument(); + }); + it('renders the displayed fields', async () => { setup({ displayedFields: ['testField1234'] }); expect(await screen.findByText('testField1234')).toBeInTheDocument(); diff --git a/public/app/features/explore/Logs/LogsMetaRow.tsx b/public/app/features/explore/Logs/LogsMetaRow.tsx index 04673a11de2..1ed09165690 100644 --- a/public/app/features/explore/Logs/LogsMetaRow.tsx +++ b/public/app/features/explore/Logs/LogsMetaRow.tsx @@ -19,6 +19,7 @@ import { LogLabels, LogLabelsList, Props as LogLabelsProps } from '../../logs/co import { DownloadFormat, downloadLogs } from '../../logs/utils'; import { MetaInfoText, MetaItemProps } from '../MetaInfoText'; +import { LogsVisualisationType } from './Logs'; import { SETTINGS_KEYS } from './utils/logs'; const getStyles = () => ({ @@ -41,6 +42,7 @@ export type Props = { logRows: LogRowModel[]; clearDisplayedFields: () => void; defaultDisplayedFields: string[]; + visualisationType: LogsVisualisationType; }; export const LogsMetaRow = memo( @@ -52,6 +54,7 @@ export const LogsMetaRow = memo( clearDisplayedFields, logRows, defaultDisplayedFields, + visualisationType, }: Props) => { const style = useStyles2(getStyles); @@ -67,7 +70,11 @@ export const LogsMetaRow = memo( } // Add detected fields info - if (displayedFields?.length > 0 && shallowCompare(displayedFields, defaultDisplayedFields) === false) { + if ( + visualisationType === 'logs' && + displayedFields?.length > 0 && + shallowCompare(displayedFields, defaultDisplayedFields) === false + ) { logsMetaItem.push( { label: t('explore.logs-meta-row.label.showing-only-selected-fields', 'Showing only selected fields'),