Skip to content

Commit f6e2a6c

Browse files
committed
feat(LogsTablePanel): add wrap text support
1 parent 463561d commit f6e2a6c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/Components/ServiceScene/LogsTablePanelScene.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { reportAppInteraction, USER_EVENTS_ACTIONS, USER_EVENTS_PAGES } from '..
2626
import { areArraysEqual } from '../../services/comparison';
2727
import { getAllLabelsFromDataFrame } from '../../services/labels';
2828
import { setControlsExpandedStateFromLocalStorage } from '../../services/scenes';
29-
import { getLogOption, setDisplayedFieldsInStorage } from '../../services/store';
29+
import { getBooleanLogOption, getLogOption, setDisplayedFieldsInStorage, setLogOption } from '../../services/store';
3030
import { clearVariables } from '../../services/variableHelpers';
3131
import { PanelMenu } from '../Panels/PanelMenu';
3232
import { DEFAULT_URL_COLUMNS, DETECTED_LEVEL, LEVEL } from '../Table/constants';
@@ -102,7 +102,10 @@ export class LogsTablePanelScene extends SceneObjectBase<LogsTableSceneState> {
102102
}
103103

104104
protected onOptionsChange(options: DeepPartial<Options>, prevOptions: DeepPartial<Options>) {
105-
console.log('options change', options);
105+
// todo: Update after Grafana >= 13.1
106+
if ('wrapText' in options && 'wrapText' in prevOptions && options.wrapText !== prevOptions.wrapText) {
107+
setLogOption('wrapText', Boolean(options.wrapText));
108+
}
106109
}
107110

108111
public onActivate() {
@@ -112,6 +115,7 @@ export class LogsTablePanelScene extends SceneObjectBase<LogsTableSceneState> {
112115
...defaultOptions,
113116
// Could do url columns
114117
displayedFields: parentScene.state.displayedFields,
118+
wrapText: getBooleanLogOption('wrapText', true),
115119
}));
116120

117121
// @todo set field defaults

src/services/store.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,10 @@ export function getLogOption<T>(option: keyof Options, defaultValue: T): T {
296296
return localStorageResult ? (localStorageResult as T) : defaultValue;
297297
}
298298

299-
export function getBooleanLogOption(option: keyof Options | 'controlsExpanded', defaultValue: boolean): boolean {
299+
export function getBooleanLogOption(
300+
option: keyof Options | 'controlsExpanded' | 'wrapText',
301+
defaultValue: boolean
302+
): boolean {
300303
const localStorageResult = localStorage.getItem(`${LOG_OPTIONS_LOCALSTORAGE_KEY}.${option}`);
301304
if (localStorageResult === null) {
302305
return defaultValue;
@@ -305,7 +308,7 @@ export function getBooleanLogOption(option: keyof Options | 'controlsExpanded',
305308
}
306309

307310
export function setLogOption(
308-
option: keyof Options | 'maxLines' | 'controlsExpanded',
311+
option: keyof Options | 'maxLines' | 'controlsExpanded' | 'wrapText',
309312
value: string | number | boolean
310313
) {
311314
let storedValue = value.toString();

0 commit comments

Comments
 (0)