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
This commit is contained in:
Anton Nikolaev
2020-06-02 09:47:54 -07:00
committed by Facebook GitHub Bot
parent 1082de41bc
commit 776d4098b9
6 changed files with 23 additions and 3 deletions

View File

@@ -66,6 +66,9 @@ const COLUMNS = {
name: { name: {
value: 'Name', value: 'Name',
}, },
version: {
value: 'Version',
},
status: { status: {
value: 'Status', value: 'Status',
}, },
@@ -83,6 +86,7 @@ const COLUMNS = {
const COLUMNS_SIZES = { const COLUMNS_SIZES = {
lamp: 20, lamp: 20,
name: 'flex', name: 'flex',
version: 60,
status: 110, status: 110,
gk: 120, gk: 120,
clients: 90, clients: 90,
@@ -93,6 +97,7 @@ type Props = OwnProps & StateFromProps & DispatchFromProps;
class PluginDebugger extends Component<Props> { class PluginDebugger extends Component<Props> {
buildRow( buildRow(
name: string, name: string,
version: string,
loaded: boolean, loaded: boolean,
status: string, status: string,
GKname: string | null | undefined, GKname: string | null | undefined,
@@ -103,6 +108,7 @@ class PluginDebugger extends Component<Props> {
columns: { columns: {
lamp: {value: <Lamp on={loaded} />}, lamp: {value: <Lamp on={loaded} />},
name: {value: <Ellipsis>{name}</Ellipsis>}, name: {value: <Ellipsis>{name}</Ellipsis>},
version: {value: <Ellipsis>{version}</Ellipsis>},
status: { status: {
value: status ? <Ellipsis title={status}>{status}</Ellipsis> : null, value: status ? <Ellipsis title={status}>{status}</Ellipsis> : null,
}, },
@@ -149,6 +155,7 @@ class PluginDebugger extends Component<Props> {
rows.push( rows.push(
this.buildRow( this.buildRow(
plugin.name, plugin.name,
plugin.version,
false, false,
'GK disabled', 'GK disabled',
plugin.gatekeeper, plugin.gatekeeper,
@@ -161,6 +168,7 @@ class PluginDebugger extends Component<Props> {
rows.push( rows.push(
this.buildRow( this.buildRow(
plugin.id, plugin.id,
plugin.version,
true, true,
'', '',
plugin.gatekeeper, plugin.gatekeeper,
@@ -173,6 +181,7 @@ class PluginDebugger extends Component<Props> {
rows.push( rows.push(
this.buildRow( this.buildRow(
plugin.id, plugin.id,
plugin.version,
true, true,
'', '',
plugin.gatekeeper, plugin.gatekeeper,
@@ -185,6 +194,7 @@ class PluginDebugger extends Component<Props> {
rows.push( rows.push(
this.buildRow( this.buildRow(
plugin.name, plugin.name,
plugin.version,
false, false,
'disabled', 'disabled',
null, null,
@@ -197,6 +207,7 @@ class PluginDebugger extends Component<Props> {
rows.push( rows.push(
this.buildRow( this.buildRow(
plugin.name, plugin.name,
plugin.version,
false, false,
status, status,
null, null,

View File

@@ -14,7 +14,7 @@ import PluginInstaller from './PluginInstaller';
const Container = styled(FlexColumn)({ const Container = styled(FlexColumn)({
padding: 15, padding: 15,
width: 700, width: 760,
}); });
const Row = styled(FlexColumn)({ const Row = styled(FlexColumn)({

View File

@@ -10,6 +10,7 @@
jest.mock('../../defaultPlugins'); jest.mock('../../defaultPlugins');
import dispatcher, { import dispatcher, {
PluginDefinition,
getDynamicPlugins, getDynamicPlugins,
checkDisabled, checkDisabled,
checkGK, checkGK,
@@ -24,7 +25,6 @@ import configureStore from 'redux-mock-store';
import {TEST_PASSING_GK, TEST_FAILING_GK} from '../../fb-stubs/GK'; import {TEST_PASSING_GK, TEST_FAILING_GK} from '../../fb-stubs/GK';
import TestPlugin from './TestPlugin'; import TestPlugin from './TestPlugin';
import {resetConfigForTesting} from '../../utils/processConfig'; import {resetConfigForTesting} from '../../utils/processConfig';
import {PluginDefinition} from '../../reducers/pluginManager';
const mockStore = configureStore<State, {}>([])( const mockStore = configureStore<State, {}>([])(
reducers(undefined, {type: 'INIT'}), reducers(undefined, {type: 'INIT'}),
@@ -70,6 +70,7 @@ test('checkDisabled', () => {
disabled({ disabled({
name: 'other Name', name: 'other Name',
entry: './test/index.js', entry: './test/index.js',
version: '1.0.0',
}), }),
).toBeTruthy(); ).toBeTruthy();
@@ -77,6 +78,7 @@ test('checkDisabled', () => {
disabled({ disabled({
name: disabledPlugin, name: disabledPlugin,
entry: './test/index.js', entry: './test/index.js',
version: '1.0.0',
}), }),
).toBeFalsy(); ).toBeFalsy();
}); });
@@ -86,6 +88,7 @@ test('checkGK for plugin without GK', () => {
checkGK([])({ checkGK([])({
name: 'pluginID', name: 'pluginID',
entry: './test/index.js', entry: './test/index.js',
version: '1.0.0',
}), }),
).toBeTruthy(); ).toBeTruthy();
}); });
@@ -96,6 +99,7 @@ test('checkGK for passing plugin', () => {
name: 'pluginID', name: 'pluginID',
gatekeeper: TEST_PASSING_GK, gatekeeper: TEST_PASSING_GK,
entry: './test/index.js', entry: './test/index.js',
version: '1.0.0',
}), }),
).toBeTruthy(); ).toBeTruthy();
}); });
@@ -107,6 +111,7 @@ test('checkGK for failing plugin', () => {
name, name,
gatekeeper: TEST_FAILING_GK, gatekeeper: TEST_FAILING_GK,
entry: './test/index.js', entry: './test/index.js',
version: '1.0.0',
}); });
expect(plugins).toBeFalsy(); expect(plugins).toBeFalsy();
@@ -118,6 +123,7 @@ test('requirePlugin returns null for invalid requires', () => {
const plugin = requireFn({ const plugin = requireFn({
name: 'pluginID', name: 'pluginID',
entry: 'this/path/does not/exist', entry: 'this/path/does not/exist',
version: '1.0.0',
}); });
expect(plugin).toBeNull(); expect(plugin).toBeNull();
@@ -129,6 +135,7 @@ test('requirePlugin loads plugin', () => {
const plugin = requireFn({ const plugin = requireFn({
name, name,
entry: path.join(__dirname, 'TestPlugin'), entry: path.join(__dirname, 'TestPlugin'),
version: '1.0.0',
}); });
expect(plugin!.prototype).toBeInstanceOf(FlipperPlugin); expect(plugin!.prototype).toBeInstanceOf(FlipperPlugin);
expect(plugin!.id).toBe(TestPlugin.id); expect(plugin!.id).toBe(TestPlugin.id);

View File

@@ -39,6 +39,7 @@ export type PluginDefinition = {
out?: string; out?: string;
gatekeeper?: string; gatekeeper?: string;
entry?: string; entry?: string;
version: string;
}; };
export default (store: Store, logger: Logger) => { export default (store: Store, logger: Logger) => {

View File

@@ -96,6 +96,7 @@ export abstract class FlipperBasePlugin<
static title: string | null = null; static title: string | null = null;
static category: string | null = null; static category: string | null = null;
static id: string = ''; static id: string = '';
static version: string = '';
static icon: string | null = null; static icon: string | null = null;
static gatekeeper: string | null = null; static gatekeeper: string | null = null;
static entry: string | null = null; static entry: string | null = null;

View File

@@ -72,7 +72,7 @@ test('do not add plugin twice', () => {
}); });
test('add gatekeeped plugin', () => { 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( const res = reducer(
{ {
devicePlugins: new Map(), devicePlugins: new Map(),