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
This commit is contained in:
Matias Chomicki
2025-10-31 12:00:30 +00:00
committed by GitHub
parent 3a6459cda3
commit 28e8d7d56e
3 changed files with 20 additions and 2 deletions
@@ -979,6 +979,7 @@ const UnthemedLogs: React.FunctionComponent<Props> = (props: Props) => {
displayedFields={displayedFields}
clearDisplayedFields={clearDisplayedFields}
defaultDisplayedFields={defaultDisplayedFields}
visualisationType={visualisationType}
/>
</div>
<div className={cx(styles.logsSection, visualisationType === 'table' ? styles.logsTable : undefined)}>
@@ -28,9 +28,10 @@ const defaultProps: LogsMetaRowProps = {
logRows: [],
clearDisplayedFields: jest.fn(),
defaultDisplayedFields: [],
visualisationType: 'logs',
};
const setup = (propOverrides?: object, disableDownload = false) => {
const setup = (propOverrides?: Partial<LogsMetaRowProps>, 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();
@@ -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'),