Update LogsDedupStrategy enum to keep consistent with radio button capitalization
This commit is contained in:
@@ -97,10 +97,10 @@ export interface LogLabelStatsModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum LogsDedupStrategy {
|
export enum LogsDedupStrategy {
|
||||||
none = 'none',
|
None = 'none',
|
||||||
exact = 'exact',
|
Exact = 'exact',
|
||||||
numbers = 'numbers',
|
Numbers = 'numbers',
|
||||||
signature = 'signature',
|
Signature = 'signature',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LogsParser {
|
export interface LogsParser {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ describe('LogRows', () => {
|
|||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<LogRows
|
<LogRows
|
||||||
logRows={rows}
|
logRows={rows}
|
||||||
dedupStrategy={LogsDedupStrategy.none}
|
dedupStrategy={LogsDedupStrategy.None}
|
||||||
highlighterExpressions={[]}
|
highlighterExpressions={[]}
|
||||||
showLabels={false}
|
showLabels={false}
|
||||||
showTime={false}
|
showTime={false}
|
||||||
@@ -32,7 +32,7 @@ describe('LogRows', () => {
|
|||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<LogRows
|
<LogRows
|
||||||
logRows={rows}
|
logRows={rows}
|
||||||
dedupStrategy={LogsDedupStrategy.none}
|
dedupStrategy={LogsDedupStrategy.None}
|
||||||
highlighterExpressions={[]}
|
highlighterExpressions={[]}
|
||||||
showLabels={false}
|
showLabels={false}
|
||||||
showTime={false}
|
showTime={false}
|
||||||
@@ -62,7 +62,7 @@ describe('LogRows', () => {
|
|||||||
<LogRows
|
<LogRows
|
||||||
logRows={rows}
|
logRows={rows}
|
||||||
deduplicatedRows={dedupedRows}
|
deduplicatedRows={dedupedRows}
|
||||||
dedupStrategy={LogsDedupStrategy.none}
|
dedupStrategy={LogsDedupStrategy.None}
|
||||||
highlighterExpressions={[]}
|
highlighterExpressions={[]}
|
||||||
showLabels={false}
|
showLabels={false}
|
||||||
showTime={false}
|
showTime={false}
|
||||||
@@ -82,7 +82,7 @@ describe('LogRows', () => {
|
|||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<LogRows
|
<LogRows
|
||||||
logRows={rows}
|
logRows={rows}
|
||||||
dedupStrategy={LogsDedupStrategy.none}
|
dedupStrategy={LogsDedupStrategy.None}
|
||||||
highlighterExpressions={[]}
|
highlighterExpressions={[]}
|
||||||
showLabels={false}
|
showLabels={false}
|
||||||
showTime={false}
|
showTime={false}
|
||||||
@@ -103,7 +103,7 @@ describe('LogRows', () => {
|
|||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<LogRows
|
<LogRows
|
||||||
logRows={rows}
|
logRows={rows}
|
||||||
dedupStrategy={LogsDedupStrategy.none}
|
dedupStrategy={LogsDedupStrategy.None}
|
||||||
highlighterExpressions={[]}
|
highlighterExpressions={[]}
|
||||||
showLabels={false}
|
showLabels={false}
|
||||||
showTime={false}
|
showTime={false}
|
||||||
@@ -141,7 +141,7 @@ describe('LogRows', () => {
|
|||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<LogRows
|
<LogRows
|
||||||
logRows={rows}
|
logRows={rows}
|
||||||
dedupStrategy={LogsDedupStrategy.none}
|
dedupStrategy={LogsDedupStrategy.None}
|
||||||
highlighterExpressions={[]}
|
highlighterExpressions={[]}
|
||||||
showLabels={false}
|
showLabels={false}
|
||||||
showTime={false}
|
showTime={false}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class UnThemedLogRows extends PureComponent<Props, State> {
|
|||||||
const dedupCount = dedupedRows
|
const dedupCount = dedupedRows
|
||||||
? dedupedRows.reduce((sum, row) => (row.duplicates ? sum + row.duplicates : sum), 0)
|
? dedupedRows.reduce((sum, row) => (row.duplicates ? sum + row.duplicates : sum), 0)
|
||||||
: 0;
|
: 0;
|
||||||
const showDuplicates = dedupStrategy !== LogsDedupStrategy.none && dedupCount > 0;
|
const showDuplicates = dedupStrategy !== LogsDedupStrategy.None && dedupCount > 0;
|
||||||
|
|
||||||
// For horizontal scrolling we can't use CustomScrollbar as it causes the problem with logs context - it is not visible
|
// For horizontal scrolling we can't use CustomScrollbar as it causes the problem with logs context - it is not visible
|
||||||
// for top log rows. Therefore we use CustomScrollbar only in LogsPanel and for Explore, we use custom css styling.
|
// for top log rows. Therefore we use CustomScrollbar only in LogsPanel and for Explore, we use custom css styling.
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ describe('dedupLogRows()', () => {
|
|||||||
entry: 'WARN test 1.23 on [xxx]',
|
entry: 'WARN test 1.23 on [xxx]',
|
||||||
},
|
},
|
||||||
] as any;
|
] as any;
|
||||||
expect(dedupLogRows(rows, LogsDedupStrategy.none)).toMatchObject(rows);
|
expect(dedupLogRows(rows, LogsDedupStrategy.None)).toMatchObject(rows);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should dedup on exact matches', () => {
|
test('should dedup on exact matches', () => {
|
||||||
@@ -38,7 +38,7 @@ describe('dedupLogRows()', () => {
|
|||||||
entry: 'WARN test 1.23 on [xxx]',
|
entry: 'WARN test 1.23 on [xxx]',
|
||||||
},
|
},
|
||||||
] as any;
|
] as any;
|
||||||
expect(dedupLogRows(rows, LogsDedupStrategy.exact)).toEqual([
|
expect(dedupLogRows(rows, LogsDedupStrategy.Exact)).toEqual([
|
||||||
{
|
{
|
||||||
duplicates: 1,
|
duplicates: 1,
|
||||||
entry: 'WARN test 1.23 on [xxx]',
|
entry: 'WARN test 1.23 on [xxx]',
|
||||||
@@ -69,7 +69,7 @@ describe('dedupLogRows()', () => {
|
|||||||
entry: 'WARN test 1.23 on [xxx]',
|
entry: 'WARN test 1.23 on [xxx]',
|
||||||
},
|
},
|
||||||
] as any;
|
] as any;
|
||||||
expect(dedupLogRows(rows, LogsDedupStrategy.numbers)).toEqual([
|
expect(dedupLogRows(rows, LogsDedupStrategy.Numbers)).toEqual([
|
||||||
{
|
{
|
||||||
duplicates: 1,
|
duplicates: 1,
|
||||||
entry: 'WARN test 1.2323423 on [xxx]',
|
entry: 'WARN test 1.2323423 on [xxx]',
|
||||||
@@ -100,7 +100,7 @@ describe('dedupLogRows()', () => {
|
|||||||
entry: 'WARN test 1.23 on [xxx]',
|
entry: 'WARN test 1.23 on [xxx]',
|
||||||
},
|
},
|
||||||
] as any;
|
] as any;
|
||||||
expect(dedupLogRows(rows, LogsDedupStrategy.signature)).toEqual([
|
expect(dedupLogRows(rows, LogsDedupStrategy.Signature)).toEqual([
|
||||||
{
|
{
|
||||||
duplicates: 3,
|
duplicates: 3,
|
||||||
entry: 'WARN test 1.2323423 on [xxx]',
|
entry: 'WARN test 1.2323423 on [xxx]',
|
||||||
@@ -120,7 +120,7 @@ describe('dedupLogRows()', () => {
|
|||||||
entry: 'WARN 123',
|
entry: 'WARN 123',
|
||||||
},
|
},
|
||||||
] as any;
|
] as any;
|
||||||
expect(dedupLogRows(rows, LogsDedupStrategy.exact)).toEqual([
|
expect(dedupLogRows(rows, LogsDedupStrategy.Exact)).toEqual([
|
||||||
{
|
{
|
||||||
duplicates: 0,
|
duplicates: 0,
|
||||||
entry: 'INFO 123',
|
entry: 'INFO 123',
|
||||||
@@ -131,7 +131,7 @@ describe('dedupLogRows()', () => {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(dedupLogRows(rows, LogsDedupStrategy.none)).toEqual(rows);
|
expect(dedupLogRows(rows, LogsDedupStrategy.None)).toEqual(rows);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -48,14 +48,14 @@ export const LogLevelColor = {
|
|||||||
const isoDateRegexp = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-6]\d[,\.]\d+([+-][0-2]\d:[0-5]\d|Z)/g;
|
const isoDateRegexp = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-6]\d[,\.]\d+([+-][0-2]\d:[0-5]\d|Z)/g;
|
||||||
function isDuplicateRow(row: LogRowModel, other: LogRowModel, strategy?: LogsDedupStrategy): boolean {
|
function isDuplicateRow(row: LogRowModel, other: LogRowModel, strategy?: LogsDedupStrategy): boolean {
|
||||||
switch (strategy) {
|
switch (strategy) {
|
||||||
case LogsDedupStrategy.exact:
|
case LogsDedupStrategy.Exact:
|
||||||
// Exact still strips dates
|
// Exact still strips dates
|
||||||
return row.entry.replace(isoDateRegexp, '') === other.entry.replace(isoDateRegexp, '');
|
return row.entry.replace(isoDateRegexp, '') === other.entry.replace(isoDateRegexp, '');
|
||||||
|
|
||||||
case LogsDedupStrategy.numbers:
|
case LogsDedupStrategy.Numbers:
|
||||||
return row.entry.replace(/\d/g, '') === other.entry.replace(/\d/g, '');
|
return row.entry.replace(/\d/g, '') === other.entry.replace(/\d/g, '');
|
||||||
|
|
||||||
case LogsDedupStrategy.signature:
|
case LogsDedupStrategy.Signature:
|
||||||
return row.entry.replace(/\w/g, '') === other.entry.replace(/\w/g, '');
|
return row.entry.replace(/\w/g, '') === other.entry.replace(/\w/g, '');
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -64,7 +64,7 @@ function isDuplicateRow(row: LogRowModel, other: LogRowModel, strategy?: LogsDed
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function dedupLogRows(rows: LogRowModel[], strategy?: LogsDedupStrategy): LogRowModel[] {
|
export function dedupLogRows(rows: LogRowModel[], strategy?: LogsDedupStrategy): LogRowModel[] {
|
||||||
if (strategy === LogsDedupStrategy.none) {
|
if (strategy === LogsDedupStrategy.None) {
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const DEFAULT_EXPLORE_STATE: ExploreUrlState = {
|
|||||||
showingGraph: true,
|
showingGraph: true,
|
||||||
showingTable: true,
|
showingTable: true,
|
||||||
showingLogs: true,
|
showingLogs: true,
|
||||||
dedupStrategy: LogsDedupStrategy.none,
|
dedupStrategy: LogsDedupStrategy.None,
|
||||||
},
|
},
|
||||||
originPanelId: undefined,
|
originPanelId: undefined,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export const DEFAULT_UI_STATE = {
|
|||||||
showingTable: true,
|
showingTable: true,
|
||||||
showingGraph: true,
|
showingGraph: true,
|
||||||
showingLogs: true,
|
showingLogs: true,
|
||||||
dedupStrategy: LogsDedupStrategy.none,
|
dedupStrategy: LogsDedupStrategy.None,
|
||||||
};
|
};
|
||||||
|
|
||||||
const MAX_HISTORY_ITEMS = 100;
|
const MAX_HISTORY_ITEMS = 100;
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export class Logs extends PureComponent<Props, State> {
|
|||||||
onChangeDedup = (dedup: LogsDedupStrategy) => {
|
onChangeDedup = (dedup: LogsDedupStrategy) => {
|
||||||
const { onDedupStrategyChange } = this.props;
|
const { onDedupStrategyChange } = this.props;
|
||||||
if (this.props.dedupStrategy === dedup) {
|
if (this.props.dedupStrategy === dedup) {
|
||||||
return onDedupStrategyChange(LogsDedupStrategy.none);
|
return onDedupStrategyChange(LogsDedupStrategy.None);
|
||||||
}
|
}
|
||||||
return onDedupStrategyChange(dedup);
|
return onDedupStrategyChange(dedup);
|
||||||
};
|
};
|
||||||
@@ -202,7 +202,7 @@ export class Logs extends PureComponent<Props, State> {
|
|||||||
: 0;
|
: 0;
|
||||||
const meta = logsMeta ? [...logsMeta] : [];
|
const meta = logsMeta ? [...logsMeta] : [];
|
||||||
|
|
||||||
if (dedupStrategy !== LogsDedupStrategy.none) {
|
if (dedupStrategy !== LogsDedupStrategy.None) {
|
||||||
meta.push({
|
meta.push({
|
||||||
label: 'Dedup count',
|
label: 'Dedup count',
|
||||||
value: dedupCount,
|
value: dedupCount,
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ export class LogsContainer extends PureComponent<LogsContainerProps, LogsContain
|
|||||||
logsMeta,
|
logsMeta,
|
||||||
logsSeries,
|
logsSeries,
|
||||||
dedupedRows,
|
dedupedRows,
|
||||||
|
dedupStrategy,
|
||||||
onClickFilterLabel,
|
onClickFilterLabel,
|
||||||
onClickFilterOutLabel,
|
onClickFilterOutLabel,
|
||||||
onStartScanning,
|
onStartScanning,
|
||||||
@@ -159,7 +160,7 @@ export class LogsContainer extends PureComponent<LogsContainerProps, LogsContain
|
|||||||
collapsible
|
collapsible
|
||||||
>
|
>
|
||||||
<Logs
|
<Logs
|
||||||
dedupStrategy={this.props.dedupStrategy || LogsDedupStrategy.none}
|
dedupStrategy={dedupStrategy || LogsDedupStrategy.None}
|
||||||
logRows={logRows}
|
logRows={logRows}
|
||||||
logsMeta={logsMeta}
|
logsMeta={logsMeta}
|
||||||
logsSeries={logsSeries}
|
logsSeries={logsSeries}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ const setup = (updateOverides?: Partial<ExploreUpdateState>) => {
|
|||||||
const exploreId = ExploreId.left;
|
const exploreId = ExploreId.left;
|
||||||
const containerWidth = 1920;
|
const containerWidth = 1920;
|
||||||
const eventBridge = {} as Emitter;
|
const eventBridge = {} as Emitter;
|
||||||
const ui = { dedupStrategy: LogsDedupStrategy.none, showingGraph: false, showingLogs: false, showingTable: false };
|
const ui = { dedupStrategy: LogsDedupStrategy.None, showingGraph: false, showingLogs: false, showingTable: false };
|
||||||
const timeZone = DefaultTimeZone;
|
const timeZone = DefaultTimeZone;
|
||||||
const range = testRange;
|
const range = testRange;
|
||||||
const urlState: ExploreUrlState = {
|
const urlState: ExploreUrlState = {
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ export const setup = (urlStateOverrides?: any) => {
|
|||||||
to: '',
|
to: '',
|
||||||
},
|
},
|
||||||
ui: {
|
ui: {
|
||||||
dedupStrategy: LogsDedupStrategy.none,
|
dedupStrategy: LogsDedupStrategy.None,
|
||||||
showingGraph: false,
|
showingGraph: false,
|
||||||
showingTable: false,
|
showingTable: false,
|
||||||
showingLogs: false,
|
showingLogs: false,
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ export const makeExploreItemState = (): ExploreItemState => ({
|
|||||||
tableResult: null,
|
tableResult: null,
|
||||||
graphResult: null,
|
graphResult: null,
|
||||||
logsResult: null,
|
logsResult: null,
|
||||||
dedupStrategy: LogsDedupStrategy.none,
|
dedupStrategy: LogsDedupStrategy.None,
|
||||||
eventBridge: (null as unknown) as Emitter,
|
eventBridge: (null as unknown) as Emitter,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ const state: any = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
hiddenLogLevels: undefined,
|
hiddenLogLevels: undefined,
|
||||||
dedupStrategy: LogsDedupStrategy.none,
|
dedupStrategy: LogsDedupStrategy.None,
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Deduplication selector', () => {
|
describe('Deduplication selector', () => {
|
||||||
@@ -66,7 +66,7 @@ describe('Deduplication selector', () => {
|
|||||||
it('should correctly extracts rows and deduplicates them', () => {
|
it('should correctly extracts rows and deduplicates them', () => {
|
||||||
const dedups = deduplicatedRowsSelector({
|
const dedups = deduplicatedRowsSelector({
|
||||||
...state,
|
...state,
|
||||||
dedupStrategy: LogsDedupStrategy.numbers,
|
dedupStrategy: LogsDedupStrategy.Numbers,
|
||||||
} as ExploreItemState);
|
} as ExploreItemState);
|
||||||
expect(dedups?.length).toBe(2);
|
expect(dedups?.length).toBe(2);
|
||||||
expect(dedups).not.toBe(state.logsResult.rows);
|
expect(dedups).not.toBe(state.logsResult.rows);
|
||||||
@@ -82,7 +82,7 @@ describe('Deduplication selector', () => {
|
|||||||
|
|
||||||
dedups = deduplicatedRowsSelector({
|
dedups = deduplicatedRowsSelector({
|
||||||
...state,
|
...state,
|
||||||
dedupStrategy: LogsDedupStrategy.numbers,
|
dedupStrategy: LogsDedupStrategy.Numbers,
|
||||||
hiddenLogLevels: [LogLevel.debug],
|
hiddenLogLevels: [LogLevel.debug],
|
||||||
} as ExploreItemState);
|
} as ExploreItemState);
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export const LogsPanel: React.FunctionComponent<LogsPanelProps> = ({
|
|||||||
<CustomScrollbar autoHide>
|
<CustomScrollbar autoHide>
|
||||||
<LogRows
|
<LogRows
|
||||||
logRows={newResults?.rows || []}
|
logRows={newResults?.rows || []}
|
||||||
dedupStrategy={LogsDedupStrategy.none}
|
dedupStrategy={LogsDedupStrategy.None}
|
||||||
highlighterExpressions={[]}
|
highlighterExpressions={[]}
|
||||||
showLabels={showLabels}
|
showLabels={showLabels}
|
||||||
showTime={showTime}
|
showTime={showTime}
|
||||||
|
|||||||
Reference in New Issue
Block a user