Skip to content

Commit 8e78dc2

Browse files
committed
[FEATURE]: add teansform to the logs table
Signed-off-by: Mahmoud <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com>
1 parent 4f341f1 commit 8e78dc2

11 files changed

Lines changed: 554 additions & 430 deletions

logstable/cue.mod/module.cue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ language: {
55
source: {
66
kind: "git"
77
}
8+
deps: {
9+
"github.com/perses/shared/cue@v0": {
10+
v: "v0.53.0-rc.1"
11+
default: true
12+
}
13+
}

logstable/schemas/logstable.cue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313

1414
package model
1515

16+
import ("github.com/perses/shared/cue/common")
17+
1618
kind: "LogsTable"
1719
spec: close({
1820
allowWrap?: bool
1921
enableDetails?: bool
2022
showTime?: bool
23+
transforms?: [...common.#transform]
2124
})

logstable/src/LogsTable.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ import { PanelPlugin } from '@perses-dev/plugin-system';
1515
import { LogsTableComponent } from './LogsTableComponent';
1616
import { LogsTableOptions, LogsTableProps } from './model';
1717
import { LogsTableSettingsEditor } from './LogsTableSettingsEditor';
18+
import { LogsTableTransforms } from './components/LogsTableTransforms';
1819

1920
export const LogsTable: PanelPlugin<LogsTableOptions, LogsTableProps> = {
2021
PanelComponent: LogsTableComponent,
21-
panelOptionsEditorComponents: [{ label: 'Settings', content: LogsTableSettingsEditor }],
22+
panelOptionsEditorComponents: [
23+
{ label: 'Settings', content: LogsTableSettingsEditor },
24+
{ label: 'Transforms', content: LogsTableTransforms },
25+
],
2226
supportedQueryTypes: ['LogQuery'],
2327
createInitialOptions: () => ({
2428
showTime: true,

logstable/src/LogsTableComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { LogsTableProps } from './model';
1717
import { LogsList } from './components/LogsList';
1818

1919
export function LogsTableComponent(props: LogsTableProps): ReactElement | null {
20-
const { queryResults, spec } = props;
20+
const { queryResults, spec, contentDimensions } = props;
2121

2222
// all queries results must be included
2323
const logs = queryResults
@@ -39,5 +39,5 @@ export function LogsTableComponent(props: LogsTableProps): ReactElement | null {
3939
);
4040
}
4141

42-
return <LogsList logs={logs} spec={spec} />;
42+
return <LogsList logs={logs} spec={spec} contentDimensions={contentDimensions} />;
4343
}

logstable/src/LogsTableSettingsEditor.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ import {
1717
ThresholdsEditor,
1818
ThresholdsEditorProps,
1919
} from '@perses-dev/components';
20-
import { LegendOptionsEditor, LegendOptionsEditorProps, OptionsEditorProps } from '@perses-dev/plugin-system';
20+
import { LegendOptionsEditor, LegendOptionsEditorProps } from '@perses-dev/plugin-system';
2121
import { ReactElement } from 'react';
22-
import { LogsTableOptions } from './model';
23-
24-
type LogsTableSettingsEditorProps = OptionsEditorProps<LogsTableOptions>;
22+
import { LogsTableSettingsEditorProps } from './model';
2523

2624
export function LogsTableSettingsEditor(props: LogsTableSettingsEditorProps): ReactElement {
2725
const { onChange, value } = props;

logstable/src/components/LogsList.tsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,12 @@
1212
// limitations under the License.
1313

1414
import React from 'react';
15+
// import { useExpandedRows } from './hooks/useExpandedRows';
1516
import { LogEntry } from '@perses-dev/core';
16-
import { LogsTableOptions } from '../model';
17-
import { EmptyLogsState } from './EmptyLogsState';
18-
import { useExpandedRows } from './hooks/useExpandedRows';
17+
import { LogsTableProps } from '../model';
1918
import { VirtualizedLogsList } from './VirtualizedLogsList';
2019

21-
interface LogsListProps {
22-
logs: LogEntry[];
23-
spec: LogsTableOptions;
24-
}
25-
26-
export const LogsList: React.FC<LogsListProps> = ({ logs, spec }) => {
27-
const { expandedRows, toggleExpand } = useExpandedRows();
28-
29-
if (!logs.length) {
30-
return <EmptyLogsState />;
31-
}
32-
33-
return <VirtualizedLogsList logs={logs} spec={spec} expandedRows={expandedRows} onToggleExpand={toggleExpand} />;
20+
type Props = Pick<LogsTableProps, 'spec' | 'contentDimensions'> & { logs: LogEntry[] };
21+
export const LogsList: React.FC<Props> = ({ spec, logs, contentDimensions }) => {
22+
return <VirtualizedLogsList contentDimensions={contentDimensions} logs={logs} spec={spec} />;
3423
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright The Perses Authors
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
import { TransformsEditor, TransformsEditorProps } from '@perses-dev/components';
15+
import { ReactElement } from 'react';
16+
import { LogsTableSettingsEditorProps } from '../model';
17+
18+
export const LogsTableTransforms = (props: LogsTableSettingsEditorProps): ReactElement => {
19+
const { onChange, value } = props;
20+
21+
const handleTransformsChange: TransformsEditorProps['onChange'] = (transforms) => {
22+
onChange({ ...value, transforms });
23+
};
24+
25+
return <TransformsEditor value={value.transforms ?? []} onChange={handleTransformsChange} />;
26+
};

0 commit comments

Comments
 (0)