From 94eaaf5dca3ba12d0f7b769cc3cdbc6cec818767 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 4 Aug 2020 07:44:56 -0700 Subject: [PATCH] killed the concept of customizable column sets per device in device logs Summary: No device was using this feature, so doesn't look like there is a reason to keep it. ...if somebody was about to use this feature, let me know :). But probably, if we need this, a much more simple solution is to determine the visible columns with a simple switch on device type in the logs plugin, even though that is strictly speaking less scalable. But the current solution feels a bit over-engineered for something that is not really used. Marked [interesting] as I might be missing some background concept which would make this relevant as well. Reviewed By: jknoxville, nikoant Differential Revision: D22763507 fbshipit-source-id: ecdbc779cbbfa3b0b72c80b459b12c1a25bf3fc4 --- desktop/app/src/devices/AndroidDevice.tsx | 4 ---- desktop/app/src/devices/BaseDevice.tsx | 4 ---- desktop/app/src/devices/IOSDevice.tsx | 4 ---- desktop/app/src/devices/MacDevice.tsx | 4 ---- desktop/app/src/devices/WindowsDevice.tsx | 4 ---- desktop/plugins/logs/index.tsx | 20 ++++---------------- desktop/plugins/logs/logUtils.tsx | 10 ---------- 7 files changed, 4 insertions(+), 46 deletions(-) diff --git a/desktop/app/src/devices/AndroidDevice.tsx b/desktop/app/src/devices/AndroidDevice.tsx index 46f7ac7bd..b069fdc0f 100644 --- a/desktop/app/src/devices/AndroidDevice.tsx +++ b/desktop/app/src/devices/AndroidDevice.tsx @@ -70,10 +70,6 @@ export default class AndroidDevice extends BaseDevice { pidAppMapping: {[key: number]: string} = {}; private recordingProcess?: Promise; - supportedColumns(): Array { - return ['date', 'pid', 'tid', 'tag', 'message', 'type', 'time']; - } - reverse(ports: [number, number]): Promise { return Promise.all( ports.map((port) => diff --git a/desktop/app/src/devices/BaseDevice.tsx b/desktop/app/src/devices/BaseDevice.tsx index cb06092d2..dd7829907 100644 --- a/desktop/app/src/devices/BaseDevice.tsx +++ b/desktop/app/src/devices/BaseDevice.tsx @@ -95,10 +95,6 @@ export default class BaseDevice { } } - supportedColumns(): Array { - return ['date', 'pid', 'tid', 'tag', 'message', 'type', 'time']; - } - addLogListener(callback: DeviceLogListener): Symbol { const id = Symbol(); this.logListeners.set(id, callback); diff --git a/desktop/app/src/devices/IOSDevice.tsx b/desktop/app/src/devices/IOSDevice.tsx index 1515cccfc..103a2c52f 100644 --- a/desktop/app/src/devices/IOSDevice.tsx +++ b/desktop/app/src/devices/IOSDevice.tsx @@ -75,10 +75,6 @@ export default class IOSDevice extends BaseDevice { } } - supportedColumns(): Array { - return ['date', 'pid', 'tid', 'tag', 'message', 'type', 'time']; - } - startLogListener(retries: number = 3) { if (this.deviceType === 'physical') { return; diff --git a/desktop/app/src/devices/MacDevice.tsx b/desktop/app/src/devices/MacDevice.tsx index 8e2e92b45..16a076b49 100644 --- a/desktop/app/src/devices/MacDevice.tsx +++ b/desktop/app/src/devices/MacDevice.tsx @@ -15,8 +15,4 @@ export default class MacDevice extends BaseDevice { } teardown() {} - - supportedColumns(): Array { - return []; - } } diff --git a/desktop/app/src/devices/WindowsDevice.tsx b/desktop/app/src/devices/WindowsDevice.tsx index 11770d3d3..e83da5ee7 100644 --- a/desktop/app/src/devices/WindowsDevice.tsx +++ b/desktop/app/src/devices/WindowsDevice.tsx @@ -15,8 +15,4 @@ export default class WindowsDevice extends BaseDevice { } teardown() {} - - supportedColumns(): Array { - return []; - } } diff --git a/desktop/plugins/logs/index.tsx b/desktop/plugins/logs/index.tsx index c73798ceb..591ea3f25 100644 --- a/desktop/plugins/logs/index.tsx +++ b/desktop/plugins/logs/index.tsx @@ -9,9 +9,6 @@ import { TableBodyRow, - TableColumnOrder, - TableColumnSizes, - TableColumns, TableRowSortOrder, Props as PluginProps, BaseAction, @@ -39,7 +36,7 @@ import { import LogWatcher from './LogWatcher'; import React from 'react'; import {Icon, LogCount, HiddenScrollText} from './logComponents'; -import {pad, getLineCount, keepKeys} from './logUtils'; +import {pad, getLineCount} from './logUtils'; const LOG_WATCHER_LOCAL_STORAGE_KEY = 'LOG_WATCHER_LOCAL_STORAGE_KEY'; @@ -404,9 +401,6 @@ export default class LogTable extends FlipperDevicePlugin< }; tableRef: ManagedTableClass | undefined; - columns: TableColumns; - columnSizes: TableColumnSizes; - columnOrder: TableColumnOrder; logListener: Symbol | undefined; batch: Array<{ @@ -418,12 +412,6 @@ export default class LogTable extends FlipperDevicePlugin< constructor(props: PluginProps) { super(props); - const supportedColumns = this.device.supportedColumns(); - this.columns = keepKeys(COLUMNS, supportedColumns); - this.columnSizes = keepKeys(COLUMN_SIZE, supportedColumns); - this.columnOrder = INITIAL_COLUMN_ORDER.filter((obj) => - supportedColumns.includes(obj.key), - ); const initialState = addEntriesToState( this.device @@ -595,9 +583,9 @@ export default class LogTable extends FlipperDevicePlugin< innerRef={this.setTableRef} floating={false} multiline={true} - columnSizes={this.columnSizes} - columnOrder={this.columnOrder} - columns={this.columns} + columnSizes={COLUMN_SIZE} + columnOrder={INITIAL_COLUMN_ORDER} + columns={COLUMNS} rows={this.state.rows} highlightedRows={this.state.highlightedRows} onRowHighlighted={this.onRowHighlighted} diff --git a/desktop/plugins/logs/logUtils.tsx b/desktop/plugins/logs/logUtils.tsx index 8f0fc32f3..77e23a6f2 100644 --- a/desktop/plugins/logs/logUtils.tsx +++ b/desktop/plugins/logs/logUtils.tsx @@ -20,16 +20,6 @@ export function getLineCount(str: string): number { return count; } -export function keepKeys(obj: A, keys: Array): A { - const result: A = {} as A; - for (const key in obj) { - if (keys.includes(key)) { - result[key] = obj[key]; - } - } - return result; -} - export function pad(chunk: any, len: number): string { let str = String(chunk); while (str.length < len) {