Make integration of new groups simpler
Summary: This diff simplifies the way new groups can be added into the Support form. Users will have to just make an entry in constants folder, thats it. It will automatically be added into the support form. Reviewed By: jknoxville Differential Revision: D21257033 fbshipit-source-id: 8823855c7a7732862a964fc17fa7311512b861db
This commit is contained in:
committed by
Facebook GitHub Bot
parent
38186c8995
commit
513414de04
@@ -9,12 +9,7 @@
|
||||
|
||||
import {remote, ipcRenderer, IpcRendererEvent} from 'electron';
|
||||
import {toggleAction} from '../reducers/application';
|
||||
import {
|
||||
Group,
|
||||
GRAPHQL_ANDROID_GROUP,
|
||||
GRAPHQL_IOS_GROUP,
|
||||
LITHO_GROUP,
|
||||
} from '../reducers/supportForm';
|
||||
import {Group, SUPPORTED_GROUPS} from '../reducers/supportForm';
|
||||
import {Store} from '../reducers/index';
|
||||
import {Logger} from '../fb-interfaces/Logger';
|
||||
import {parseFlipperPorts} from '../utils/environmentVariables';
|
||||
@@ -111,18 +106,15 @@ export default (store: Store, _logger: Logger) => {
|
||||
},
|
||||
);
|
||||
|
||||
function deeplinkFormParamToGroups(formParam: string | null): Group | null {
|
||||
function deeplinkFormParamToGroups(
|
||||
formParam: string | null,
|
||||
): Group | undefined {
|
||||
if (!formParam) {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
if (formParam.toLowerCase() === 'litho') {
|
||||
return LITHO_GROUP;
|
||||
} else if (formParam.toLowerCase() === 'graphql_android') {
|
||||
return GRAPHQL_ANDROID_GROUP;
|
||||
} else if (formParam.toLowerCase() === 'graphql_ios') {
|
||||
return GRAPHQL_IOS_GROUP;
|
||||
}
|
||||
return null;
|
||||
return SUPPORTED_GROUPS.find((grp) => {
|
||||
return grp.deeplinkSuffix.toLowerCase() === formParam.toLowerCase();
|
||||
});
|
||||
}
|
||||
|
||||
ipcRenderer.on(
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {OS} from '../devices/BaseDevice';
|
||||
|
||||
export default Object.freeze({
|
||||
GRAPH_APP_ID: '',
|
||||
GRAPH_CLIENT_TOKEN: '',
|
||||
@@ -29,8 +31,14 @@ export default Object.freeze({
|
||||
FEEDBACK_GROUP_LINK: 'https://github.com/facebook/flipper/issues',
|
||||
|
||||
// Workplace Group ID's
|
||||
LITHO_SUPPORT_GROUP_ID: 0,
|
||||
GRAPHQL_ANDROID_SUPPORT_GROUP_ID: 0,
|
||||
GRAPHQL_IOS_SUPPORT_GROUP_ID: 0,
|
||||
COMPONENTKIT_GROUP_ID: 0,
|
||||
DEFAULT_SUPPORT_GROUP: {
|
||||
name: 'Default Support Group',
|
||||
workplaceGroupID: 0,
|
||||
requiredPlugins: ['Inspector'],
|
||||
defaultPlugins: ['DeviceLogs'],
|
||||
supportedOS: ['Android'] as Array<OS>,
|
||||
deeplinkSuffix: 'default',
|
||||
},
|
||||
|
||||
SUPPORT_GROUPS: [],
|
||||
});
|
||||
|
||||
@@ -26,12 +26,8 @@ import {State as PluginMessageQueueState} from '../reducers/pluginMessageQueue';
|
||||
import Client from '../Client';
|
||||
import {OS} from '../devices/BaseDevice';
|
||||
|
||||
const {
|
||||
GRAPHQL_IOS_SUPPORT_GROUP_ID,
|
||||
GRAPHQL_ANDROID_SUPPORT_GROUP_ID,
|
||||
LITHO_SUPPORT_GROUP_ID,
|
||||
COMPONENTKIT_GROUP_ID,
|
||||
} = constants;
|
||||
const {DEFAULT_SUPPORT_GROUP} = constants;
|
||||
|
||||
type SubmediaType =
|
||||
| {uploadID: string; status: 'Uploaded'}
|
||||
| {status: 'NotUploaded' | 'Uploading'};
|
||||
@@ -47,23 +43,26 @@ export type GroupValidationErrors = {
|
||||
|
||||
export class Group {
|
||||
constructor(
|
||||
name: GroupNames,
|
||||
name: string,
|
||||
workplaceGroupID: number,
|
||||
requiredPlugins: Array<string>,
|
||||
defaultPlugins: Array<string>,
|
||||
supportedOS: Array<OS>,
|
||||
deeplinkSuffix: string,
|
||||
) {
|
||||
this.name = name;
|
||||
this.requiredPlugins = requiredPlugins;
|
||||
this.defaultPlugins = defaultPlugins;
|
||||
this.workplaceGroupID = workplaceGroupID;
|
||||
this.supportedOS = supportedOS;
|
||||
this.deeplinkSuffix = deeplinkSuffix;
|
||||
}
|
||||
readonly name: GroupNames;
|
||||
readonly name: string;
|
||||
requiredPlugins: Array<string>;
|
||||
defaultPlugins: Array<string>;
|
||||
workplaceGroupID: number;
|
||||
supportedOS: Array<OS>;
|
||||
deeplinkSuffix: string;
|
||||
|
||||
getPluginsToSelect(): Array<string> {
|
||||
return Array.from(
|
||||
@@ -252,49 +251,36 @@ export class Group {
|
||||
}
|
||||
}
|
||||
|
||||
export type GroupNames =
|
||||
| 'Litho Support'
|
||||
| 'GraphQL Android Support'
|
||||
| 'GraphQL iOS Support'
|
||||
| 'ComponentKit';
|
||||
|
||||
export const LITHO_GROUP = new Group(
|
||||
'Litho Support',
|
||||
LITHO_SUPPORT_GROUP_ID,
|
||||
['Inspector'],
|
||||
['Sections', 'DeviceLogs'],
|
||||
['Android'],
|
||||
);
|
||||
|
||||
export const GRAPHQL_ANDROID_GROUP = new Group(
|
||||
'GraphQL Android Support',
|
||||
GRAPHQL_ANDROID_SUPPORT_GROUP_ID,
|
||||
['GraphQL', 'Network'],
|
||||
['DeviceLogs'],
|
||||
['Android'],
|
||||
);
|
||||
|
||||
export const GRAPHQL_IOS_GROUP = new Group(
|
||||
'GraphQL iOS Support',
|
||||
GRAPHQL_IOS_SUPPORT_GROUP_ID,
|
||||
['GraphQL', 'Network'],
|
||||
['DeviceLogs'],
|
||||
['iOS'],
|
||||
);
|
||||
|
||||
export const COMPONENTKIT_GROUP = new Group(
|
||||
'ComponentKit',
|
||||
COMPONENTKIT_GROUP_ID,
|
||||
['Inspector'],
|
||||
['Sections', 'DeviceLogs'],
|
||||
['iOS'],
|
||||
const DEFAULT_GROUP = new Group(
|
||||
DEFAULT_SUPPORT_GROUP.name,
|
||||
DEFAULT_SUPPORT_GROUP.workplaceGroupID,
|
||||
DEFAULT_SUPPORT_GROUP.requiredPlugins,
|
||||
DEFAULT_SUPPORT_GROUP.defaultPlugins,
|
||||
DEFAULT_SUPPORT_GROUP.supportedOS,
|
||||
DEFAULT_SUPPORT_GROUP.deeplinkSuffix,
|
||||
);
|
||||
|
||||
export const SUPPORTED_GROUPS: Array<Group> = [
|
||||
LITHO_GROUP,
|
||||
GRAPHQL_ANDROID_GROUP,
|
||||
GRAPHQL_IOS_GROUP,
|
||||
COMPONENTKIT_GROUP,
|
||||
DEFAULT_GROUP,
|
||||
...constants.SUPPORT_GROUPS.map(
|
||||
({
|
||||
name,
|
||||
workplaceGroupID,
|
||||
requiredPlugins,
|
||||
defaultPlugins,
|
||||
supportedOS,
|
||||
deeplinkSuffix,
|
||||
}) => {
|
||||
return new Group(
|
||||
name,
|
||||
workplaceGroupID,
|
||||
requiredPlugins,
|
||||
defaultPlugins,
|
||||
supportedOS,
|
||||
deeplinkSuffix,
|
||||
);
|
||||
},
|
||||
),
|
||||
];
|
||||
|
||||
export type MediaType = Array<MediaObject>;
|
||||
@@ -347,7 +333,7 @@ export const initialState: () => State = () => ({
|
||||
].join('\n'),
|
||||
commitHash: '',
|
||||
appName: '',
|
||||
selectedGroup: LITHO_GROUP,
|
||||
selectedGroup: DEFAULT_GROUP,
|
||||
},
|
||||
});
|
||||
export default function reducer(
|
||||
|
||||
Reference in New Issue
Block a user