From 776d4098b9c98180cd1a404225828c37b8e9da64 Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Tue, 2 Jun 2020 09:47:54 -0700 Subject: [PATCH] Show plugin version in Plugin Manager list Summary: Added plugin version property + showing it in Plugin Manager Reviewed By: passy Differential Revision: D21839544 fbshipit-source-id: 89daed813cffb066b3b584f6df97d6674ca6be08 --- .../app/src/chrome/plugin-manager/PluginDebugger.tsx | 11 +++++++++++ .../app/src/chrome/plugin-manager/PluginManager.tsx | 2 +- desktop/app/src/dispatcher/__tests__/plugins.node.tsx | 9 ++++++++- desktop/app/src/dispatcher/plugins.tsx | 1 + desktop/app/src/plugin.tsx | 1 + desktop/app/src/reducers/__tests__/plugins.node.tsx | 2 +- 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/desktop/app/src/chrome/plugin-manager/PluginDebugger.tsx b/desktop/app/src/chrome/plugin-manager/PluginDebugger.tsx index 3b609d3f5..703bae5bb 100644 --- a/desktop/app/src/chrome/plugin-manager/PluginDebugger.tsx +++ b/desktop/app/src/chrome/plugin-manager/PluginDebugger.tsx @@ -66,6 +66,9 @@ const COLUMNS = { name: { value: 'Name', }, + version: { + value: 'Version', + }, status: { value: 'Status', }, @@ -83,6 +86,7 @@ const COLUMNS = { const COLUMNS_SIZES = { lamp: 20, name: 'flex', + version: 60, status: 110, gk: 120, clients: 90, @@ -93,6 +97,7 @@ type Props = OwnProps & StateFromProps & DispatchFromProps; class PluginDebugger extends Component { buildRow( name: string, + version: string, loaded: boolean, status: string, GKname: string | null | undefined, @@ -103,6 +108,7 @@ class PluginDebugger extends Component { columns: { lamp: {value: }, name: {value: {name}}, + version: {value: {version}}, status: { value: status ? {status} : null, }, @@ -149,6 +155,7 @@ class PluginDebugger extends Component { rows.push( this.buildRow( plugin.name, + plugin.version, false, 'GK disabled', plugin.gatekeeper, @@ -161,6 +168,7 @@ class PluginDebugger extends Component { rows.push( this.buildRow( plugin.id, + plugin.version, true, '', plugin.gatekeeper, @@ -173,6 +181,7 @@ class PluginDebugger extends Component { rows.push( this.buildRow( plugin.id, + plugin.version, true, '', plugin.gatekeeper, @@ -185,6 +194,7 @@ class PluginDebugger extends Component { rows.push( this.buildRow( plugin.name, + plugin.version, false, 'disabled', null, @@ -197,6 +207,7 @@ class PluginDebugger extends Component { rows.push( this.buildRow( plugin.name, + plugin.version, false, status, null, diff --git a/desktop/app/src/chrome/plugin-manager/PluginManager.tsx b/desktop/app/src/chrome/plugin-manager/PluginManager.tsx index bd8f0d79d..4eaf28a1d 100644 --- a/desktop/app/src/chrome/plugin-manager/PluginManager.tsx +++ b/desktop/app/src/chrome/plugin-manager/PluginManager.tsx @@ -14,7 +14,7 @@ import PluginInstaller from './PluginInstaller'; const Container = styled(FlexColumn)({ padding: 15, - width: 700, + width: 760, }); const Row = styled(FlexColumn)({ diff --git a/desktop/app/src/dispatcher/__tests__/plugins.node.tsx b/desktop/app/src/dispatcher/__tests__/plugins.node.tsx index 806d0a3f9..fd3acd4dd 100644 --- a/desktop/app/src/dispatcher/__tests__/plugins.node.tsx +++ b/desktop/app/src/dispatcher/__tests__/plugins.node.tsx @@ -10,6 +10,7 @@ jest.mock('../../defaultPlugins'); import dispatcher, { + PluginDefinition, getDynamicPlugins, checkDisabled, checkGK, @@ -24,7 +25,6 @@ import configureStore from 'redux-mock-store'; import {TEST_PASSING_GK, TEST_FAILING_GK} from '../../fb-stubs/GK'; import TestPlugin from './TestPlugin'; import {resetConfigForTesting} from '../../utils/processConfig'; -import {PluginDefinition} from '../../reducers/pluginManager'; const mockStore = configureStore([])( reducers(undefined, {type: 'INIT'}), @@ -70,6 +70,7 @@ test('checkDisabled', () => { disabled({ name: 'other Name', entry: './test/index.js', + version: '1.0.0', }), ).toBeTruthy(); @@ -77,6 +78,7 @@ test('checkDisabled', () => { disabled({ name: disabledPlugin, entry: './test/index.js', + version: '1.0.0', }), ).toBeFalsy(); }); @@ -86,6 +88,7 @@ test('checkGK for plugin without GK', () => { checkGK([])({ name: 'pluginID', entry: './test/index.js', + version: '1.0.0', }), ).toBeTruthy(); }); @@ -96,6 +99,7 @@ test('checkGK for passing plugin', () => { name: 'pluginID', gatekeeper: TEST_PASSING_GK, entry: './test/index.js', + version: '1.0.0', }), ).toBeTruthy(); }); @@ -107,6 +111,7 @@ test('checkGK for failing plugin', () => { name, gatekeeper: TEST_FAILING_GK, entry: './test/index.js', + version: '1.0.0', }); expect(plugins).toBeFalsy(); @@ -118,6 +123,7 @@ test('requirePlugin returns null for invalid requires', () => { const plugin = requireFn({ name: 'pluginID', entry: 'this/path/does not/exist', + version: '1.0.0', }); expect(plugin).toBeNull(); @@ -129,6 +135,7 @@ test('requirePlugin loads plugin', () => { const plugin = requireFn({ name, entry: path.join(__dirname, 'TestPlugin'), + version: '1.0.0', }); expect(plugin!.prototype).toBeInstanceOf(FlipperPlugin); expect(plugin!.id).toBe(TestPlugin.id); diff --git a/desktop/app/src/dispatcher/plugins.tsx b/desktop/app/src/dispatcher/plugins.tsx index 2e34c3773..99fbafda6 100644 --- a/desktop/app/src/dispatcher/plugins.tsx +++ b/desktop/app/src/dispatcher/plugins.tsx @@ -39,6 +39,7 @@ export type PluginDefinition = { out?: string; gatekeeper?: string; entry?: string; + version: string; }; export default (store: Store, logger: Logger) => { diff --git a/desktop/app/src/plugin.tsx b/desktop/app/src/plugin.tsx index bac0aa3e7..3ad0f24b6 100644 --- a/desktop/app/src/plugin.tsx +++ b/desktop/app/src/plugin.tsx @@ -96,6 +96,7 @@ export abstract class FlipperBasePlugin< static title: string | null = null; static category: string | null = null; static id: string = ''; + static version: string = ''; static icon: string | null = null; static gatekeeper: string | null = null; static entry: string | null = null; diff --git a/desktop/app/src/reducers/__tests__/plugins.node.tsx b/desktop/app/src/reducers/__tests__/plugins.node.tsx index 16ebd6a45..5250a7abe 100644 --- a/desktop/app/src/reducers/__tests__/plugins.node.tsx +++ b/desktop/app/src/reducers/__tests__/plugins.node.tsx @@ -72,7 +72,7 @@ test('do not add plugin twice', () => { }); test('add gatekeeped plugin', () => { - const gatekeepedPlugins = [{name: 'plugin', out: 'out.js'}]; + const gatekeepedPlugins = [{name: 'plugin', out: 'out.js', version: '1.0.0'}]; const res = reducer( { devicePlugins: new Map(),