diff --git a/src/chrome/MainSidebar.js b/src/chrome/MainSidebar.js index 96a781cb9..c6fff268b 100644 --- a/src/chrome/MainSidebar.js +++ b/src/chrome/MainSidebar.js @@ -182,16 +182,6 @@ class MainSidebar extends Component { } = this.props; let {clients} = this.props; - let enabledPlugins = []; - for (const devicePlugin of devicePlugins) { - if (selectedDevice && selectedDevice.supportsPlugin(devicePlugin)) { - enabledPlugins.push(devicePlugin); - } - } - enabledPlugins = enabledPlugins.sort((a, b) => { - return (a.title || '').localeCompare(b.title); - }); - clients = clients .filter( (client: Client) => @@ -237,7 +227,7 @@ class MainSidebar extends Component { )} {selectedDevice && devicePlugins - .filter(selectedDevice.supportsPlugin) + .filter(plugin => plugin.supportsDevice(selectedDevice)) .map((plugin: Class>) => ( { hardwareInfo: '', }; + static supportsDevice(device: Device) { + return device.os === 'Android' && device.deviceType === 'physical'; + } + init() { let device = ((this.device: any): AndroidDevice); this.adbClient = device.adb; diff --git a/src/device-plugins/logs/index.js b/src/device-plugins/logs/index.js index d605206c0..4b0a28f74 100644 --- a/src/device-plugins/logs/index.js +++ b/src/device-plugins/logs/index.js @@ -28,6 +28,7 @@ import { FlipperDevicePlugin, SearchableTable, styled, + Device, } from 'flipper'; import textContent from '../../utils/textContent.js'; import createPaste from '../../utils/createPaste.js'; @@ -256,6 +257,10 @@ export default class LogTable extends FlipperDevicePlugin< initTimer: ?TimeoutID; batchTimer: ?TimeoutID; + static supportsDevice(device: Device) { + return device.os === 'iOS' || device.os === 'Android'; + } + onKeyboardAction = (action: string) => { if (action === 'clear') { this.clearLogs(); diff --git a/src/devices/AndroidDevice.js b/src/devices/AndroidDevice.js index e975fea79..2175eb77e 100644 --- a/src/devices/AndroidDevice.js +++ b/src/devices/AndroidDevice.js @@ -23,9 +23,6 @@ export default class AndroidDevice extends BaseDevice { ) { super(serial, deviceType, title); this.adb = adb; - if (deviceType == 'physical') { - this.supportedPlugins.push('DeviceCPU'); - } this.adb.openLogcat(this.serial).then(reader => { reader.on('entry', entry => { @@ -63,12 +60,6 @@ export default class AndroidDevice extends BaseDevice { }); } - supportedPlugins = [ - 'DeviceLogs', - 'DeviceShell', - 'DeviceFiles', - 'DeviceScreen', - ]; icon = 'icons/android.svg'; os = 'Android'; adb: ADBClient; diff --git a/src/devices/BaseDevice.js b/src/devices/BaseDevice.js index 681f485c5..7e3f505d7 100644 --- a/src/devices/BaseDevice.js +++ b/src/devices/BaseDevice.js @@ -56,9 +56,6 @@ export default class BaseDevice { // serial number for this device serial: string; - // supported device plugins for this platform - supportedPlugins: Array = []; - // possible src of icon to display next to the device title icon: ?string; @@ -69,10 +66,6 @@ export default class BaseDevice { return os.toLowerCase() === this.os.toLowerCase(); } - supportsPlugin = (DevicePlugin: Class>): boolean => { - return this.supportedPlugins.includes(DevicePlugin.id); - }; - toJSON() { return `<${this.constructor.name}#${this.title}>`; } diff --git a/src/devices/IOSDevice.js b/src/devices/IOSDevice.js index d61d6dfe8..7e52adac1 100644 --- a/src/devices/IOSDevice.js +++ b/src/devices/IOSDevice.js @@ -31,7 +31,6 @@ type RawLogEntry = {| |}; export default class IOSDevice extends BaseDevice { - supportedPlugins = ['DeviceLogs']; icon = 'icons/ios.svg'; os = 'iOS'; diff --git a/src/devices/WindowsDevice.js b/src/devices/WindowsDevice.js index 75f5f5096..954cae5ec 100644 --- a/src/devices/WindowsDevice.js +++ b/src/devices/WindowsDevice.js @@ -8,8 +8,7 @@ import BaseDevice from './BaseDevice.js'; export default class WindowsDevice extends BaseDevice { - supportedPlugins = []; - os = 'windows'; + os = 'Windows'; constructor() { super('', 'physical', 'desktop'); diff --git a/src/plugin.js b/src/plugin.js index b53ddc703..53f92c6f5 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -100,6 +100,12 @@ export class FlipperDevicePlugin extends FlipperBasePlugin< _init() { this.init(); } + + static supportsDevice(device: BaseDevice) { + throw new Error( + 'supportsDevice is unimplemented in FlipperDevicePlugin class', + ); + } } export class FlipperPlugin extends FlipperBasePlugin<