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:
Pritesh Nandgaonkar
2020-04-29 05:39:17 -07:00
committed by Facebook GitHub Bot
parent 38186c8995
commit 513414de04
3 changed files with 55 additions and 69 deletions

View File

@@ -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(