Logs: Move components to dedicated directory (#65936)

* move log-context components to dedicated directory

* fix any

* add right format of lerna.json
This commit is contained in:
Sven Grossmann
2023-04-11 12:19:28 +02:00
committed by GitHub
parent 1261345b81
commit e9b15eff72
14 changed files with 29 additions and 27 deletions

View File

@ -2948,15 +2948,12 @@ exports[`better eslint`] = {
"public/app/features/live/index.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/logs/components/LogRowContextProvider.tsx:5381": [
"public/app/features/logs/components/log-context/LogRowContextProvider.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"]
],
"public/app/features/logs/components/LogRows.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/logs/utils.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],

View File

@ -43,8 +43,8 @@ import { dedupLogRows, filterLogLevels } from 'app/core/logsModel';
import store from 'app/core/store';
import { ExploreId } from 'app/types/explore';
import { RowContextOptions } from '../logs/components/LogRowContextProvider';
import { LogRows } from '../logs/components/LogRows';
import { RowContextOptions } from '../logs/components/log-context/types';
import { LogsMetaRow } from './LogsMetaRow';
import LogsNavigation from './LogsNavigation';

View File

@ -20,16 +20,16 @@ import { checkLogsError, escapeUnescapedString } from '../utils';
import { LogDetails } from './LogDetails';
import { LogLabels } from './LogLabels';
import { LogRowMessage } from './LogRowMessage';
import { LogRowMessageDisplayedFields } from './LogRowMessageDisplayedFields';
import { getLogLevelStyles, LogRowStyles } from './getLogRowStyles';
import {
LogRowContextRows,
LogRowContextQueryErrors,
HasMoreContextRows,
LogRowContextProvider,
RowContextOptions,
} from './LogRowContextProvider';
import { LogRowMessage } from './LogRowMessage';
import { LogRowMessageDisplayedFields } from './LogRowMessageDisplayedFields';
import { getLogLevelStyles, LogRowStyles } from './getLogRowStyles';
} from './log-context/LogRowContextProvider';
import { RowContextOptions } from './log-context/types';
interface Props extends Themeable2 {
row: LogRowModel;

View File

@ -13,9 +13,9 @@ import {
import { IconButton, Tooltip } from '@grafana/ui';
import { LogMessageAnsi } from './LogMessageAnsi';
import { LogRowContext } from './LogRowContext';
import { LogRowContextQueryErrors, HasMoreContextRows, LogRowContextRows } from './LogRowContextProvider';
import { LogRowStyles } from './getLogRowStyles';
import { LogRowContext } from './log-context/LogRowContext';
import { LogRowContextQueryErrors, HasMoreContextRows, LogRowContextRows } from './log-context/LogRowContextProvider';
export const MAX_CHARACTERS = 100000;

View File

@ -11,6 +11,7 @@ import {
CoreApp,
DataFrame,
DataSourceWithLogsContextSupport,
DataQueryResponse,
} from '@grafana/data';
import { withTheme2, Themeable2 } from '@grafana/ui';
@ -18,8 +19,8 @@ import { sortLogRows } from '../utils';
//Components
import { LogRow } from './LogRow';
import { RowContextOptions } from './LogRowContextProvider';
import { getLogRowStyles } from './getLogRowStyles';
import { RowContextOptions } from './log-context/types';
export const PREVIEW_LIMIT = 100;
@ -42,7 +43,7 @@ export interface Props extends Themeable2 {
showContextToggle?: (row?: LogRowModel) => boolean;
onClickFilterLabel?: (key: string, value: string) => void;
onClickFilterOutLabel?: (key: string, value: string) => void;
getRowContext?: (row: LogRowModel, options?: RowContextOptions) => Promise<any>;
getRowContext?: (row: LogRowModel, options?: RowContextOptions) => Promise<DataQueryResponse>;
getLogRowContextUi?: DataSourceWithLogsContextSupport['getLogRowContextUi'];
getFieldLinks?: (field: Field, rowIndex: number, dataFrame: DataFrame) => Array<LinkModel<Field>>;
onClickShowField?: (key: string) => void;
@ -148,7 +149,7 @@ class UnThemedLogRows extends PureComponent<Props, State> {
// React profiler becomes unusable if we pass all rows to all rows and their labels, using getter instead
const getRows = this.makeGetRows(orderedRows);
const getRowContext = this.props.getRowContext ? this.props.getRowContext : () => Promise.resolve([]);
const getRowContext = this.props.getRowContext ? this.props.getRowContext : () => Promise.resolve({ data: [] });
return (
<table className={styles.logsRowsTable}>

View File

@ -22,7 +22,8 @@ import {
useTheme2,
} from '@grafana/ui';
import { LogMessageAnsi } from './LogMessageAnsi';
import { LogMessageAnsi } from '../LogMessageAnsi';
import { HasMoreContextRows, LogRowContextQueryErrors, LogRowContextRows } from './LogRowContextProvider';
export enum LogGroupPosition {

View File

@ -3,8 +3,10 @@ import React from 'react';
import { FieldType, LogRowModel, MutableDataFrame, DataQueryResponse } from '@grafana/data';
import { getRowContexts, LogRowContextProvider, RowContextOptions } from './LogRowContextProvider';
import { createLogRow } from './__mocks__/logRow';
import { createLogRow } from '../__mocks__/logRow';
import { getRowContexts, LogRowContextProvider } from './LogRowContextProvider';
import { RowContextOptions } from './types';
const row = createLogRow({ entry: '4', timeEpochMs: 4 });

View File

@ -12,10 +12,7 @@ import {
} from '@grafana/data';
import { reportInteraction } from '@grafana/runtime';
export interface RowContextOptions {
direction?: 'BACKWARD' | 'FORWARD';
limit?: number;
}
import { RowContextOptions } from './types';
export interface LogRowContextRows {
before?: string[];

View File

@ -0,0 +1,4 @@
export interface RowContextOptions {
direction?: 'BACKWARD' | 'FORWARD';
limit?: number;
}

View File

@ -16,7 +16,7 @@ import { DataSourceWithBackend } from '@grafana/runtime';
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
import { RowContextOptions } from '../../../features/logs/components/LogRowContextProvider';
import { RowContextOptions } from '../../../features/logs/components/log-context/types';
import { CloudWatchAnnotationSupport } from './annotationSupport';
import { DEFAULT_METRICS_QUERY, getDefaultLogsQuery } from './defaultQueries';

View File

@ -31,7 +31,7 @@ import { BackendDataSourceResponse, config, FetchError, FetchResponse, toDataQue
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { TemplateSrv } from 'app/features/templating/template_srv';
import { RowContextOptions } from '../../../../features/logs/components/LogRowContextProvider';
import { RowContextOptions } from '../../../../features/logs/components/log-context/types';
import {
CloudWatchJsonData,
CloudWatchLogsQuery,

View File

@ -37,7 +37,7 @@ import { queryLogsVolume } from 'app/core/logsModel';
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
import { RowContextOptions } from '../../../features/logs/components/LogRowContextProvider';
import { RowContextOptions } from '../../../features/logs/components/log-context/types';
import { getLogLevelFromKey } from '../../../features/logs/utils';
import { ElasticResponse } from './ElasticResponse';
@ -561,7 +561,7 @@ export class ElasticDatasource
return { data: [] };
}
/**
* The LogRowContextProvider requires there is a field in the dataFrame.fields
* The LogRowContext requires there is a field in the dataFrame.fields
* named `ts` for timestamp and `line` for the actual log line to display.
* Unfortunatly these fields are hardcoded and are required for the lines to
* be properly displayed. This code just copies the fields based on this.timeField

View File

@ -41,7 +41,7 @@ import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
import { serializeParams } from '../../../core/utils/fetch';
import { RowContextOptions } from '../../../features/logs/components/LogRowContextProvider';
import { RowContextOptions } from '../../../features/logs/components/log-context/types';
import { getLogLevelFromKey } from '../../../features/logs/utils';
import { renderLegendFormat } from '../prometheus/legend';
import { replaceVariables, returnVariables } from '../prometheus/querybuilder/shared/parsingUtils';