Remove SupportRequestFormV2

Summary: This is now replaced by the support entry point and we need to delete the calling sites before we can clean up the everstore type.

Reviewed By: lawrencelomax

Differential Revision: D37090901

fbshipit-source-id: 597684bb149783d75e46ba61113e73878bf271a8
This commit is contained in:
Pascal Hartig
2022-06-13 07:16:47 -07:00
committed by Facebook GitHub Bot
parent ad7d2e0362
commit b25a212890
8 changed files with 2 additions and 441 deletions

View File

@@ -26,7 +26,6 @@ import ShareSheetErrorList from './ShareSheetErrorList';
import {reportPlatformFailures} from 'flipper-common';
import ShareSheetPendingDialog from './ShareSheetPendingDialog';
import {getLogger} from 'flipper-common';
import {resetSupportFormV2State} from '../reducers/supportForm';
import {MiddlewareAPI} from '../reducers/index';
import {getFlipperLib, Layout} from 'flipper-plugin';
import {Button, Modal} from 'antd';
@@ -121,7 +120,6 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
});
}
this.setState({fetchMetaDataErrors, result});
this.store.dispatch(resetSupportFormV2State());
this.props.logger.trackTimeSince(mark, 'export:url-success');
} catch (e) {
const result: DataExportError = {

View File

@@ -7,7 +7,6 @@
* @format
*/
import {Group, SUPPORTED_GROUPS} from './reducers/supportForm';
import {getLogger, Logger} from 'flipper-common';
import {Store} from './reducers/index';
import {importDataToStore} from './utils/exportData';
@@ -72,14 +71,6 @@ export async function handleDeeplink(
});
}
throw unknownError();
} else if (uri.pathname.match(/^\/*support-form\/*$/)) {
const formParam = uri.searchParams.get('form');
const grp = deeplinkFormParamToGroups(formParam);
if (grp) {
grp.handleSupportFormDeeplinks(store);
return;
}
throw unknownError();
} else if (uri.pathname.match(/^\/*login\/*$/)) {
const token = uri.searchParams.get('token');
showLoginDialog(token ?? '');
@@ -127,17 +118,6 @@ export async function handleDeeplink(
}
}
function deeplinkFormParamToGroups(
formParam: string | null,
): Group | undefined {
if (!formParam) {
return undefined;
}
return SUPPORTED_GROUPS.find((grp) => {
return grp.deeplinkSuffix.toLowerCase() === formParam.toLowerCase();
});
}
export const uriComponents = (url: string): Array<string> => {
if (!url) {
return [];

View File

@@ -9,7 +9,6 @@
import BaseDevice from './BaseDevice';
import type {DeviceOS, DeviceType} from 'flipper-plugin';
import {SupportFormRequestDetailsState} from '../reducers/supportForm';
export default class ArchivedDevice extends BaseDevice {
isArchived = true;
@@ -21,7 +20,6 @@ export default class ArchivedDevice extends BaseDevice {
os: DeviceOS;
screenshotHandle?: string | null;
source?: string;
supportRequestDetails?: SupportFormRequestDetailsState;
}) {
super(
{
@@ -53,7 +51,6 @@ export default class ArchivedDevice extends BaseDevice {
);
this.connected.set(false);
this.source = options.source || '';
this.supportRequestDetails = options.supportRequestDetails;
this.archivedScreenshotHandle = options.screenshotHandle ?? null;
}
@@ -63,8 +60,6 @@ export default class ArchivedDevice extends BaseDevice {
return `${this.title} ${this.source ? '(Imported)' : '(Offline)'}`;
}
supportRequestDetails?: SupportFormRequestDetailsState;
getArchivedScreenshotHandle(): string | null {
return this.archivedScreenshotHandle;
}

View File

@@ -198,13 +198,6 @@ export default (state: State = INITAL_STATE, action: Actions): State => {
};
}
case 'RESET_SUPPORT_FORM_V2_STATE': {
return {
...state,
staticView: null,
};
}
case 'SELECT_DEVICE': {
const {payload} = action;
return {

View File

@@ -32,10 +32,6 @@ import plugins, {
persistMigrations as pluginsPersistMigrations,
persistVersion as pluginsPersistVersion,
} from './plugins';
import supportForm, {
State as SupportFormState,
Action as SupportFormAction,
} from './supportForm';
import settings, {Action as SettingsAction} from './settings';
import launcherSettings, {
Action as LauncherSettingsAction,
@@ -74,7 +70,6 @@ export type Actions =
| UserAction
| SettingsAction
| LauncherSettingsAction
| SupportFormAction
| PluginManagerAction
| HealthcheckAction
| TrackingAction
@@ -90,7 +85,6 @@ export type State = {
user: UserState & PersistPartial;
settingsState: Settings;
launcherSettingsState: LauncherSettings;
supportForm: SupportFormState;
pluginManager: PluginManagerState;
healthchecks: HealthcheckState & PersistPartial;
usageTracking: TrackingState;
@@ -151,7 +145,6 @@ export function createRootReducer() {
},
plugins,
),
supportForm,
pluginManager,
user: user as any,
settingsState: settings,

View File

@@ -1,366 +0,0 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {Actions, Store} from './';
import {setStaticView} from './connections';
import {deconstructClientId} from 'flipper-common';
import {switchPlugin} from './pluginManager';
import {showStatusUpdatesForDuration} from '../utils/promiseTimeout';
import {selectedPlugins as setSelectedPlugins} from './plugins';
import {addStatusMessage, removeStatusMessage} from './application';
import constants from '../fb-stubs/constants';
import {getLogger} from 'flipper-common';
import {logPlatformSuccessRate} from 'flipper-common';
export const SUPPORT_FORM_PREFIX = 'support-form-v2';
import {getExportablePlugins} from '../selectors/connections';
import {DeviceOS} from 'flipper-plugin';
import SupportRequestFormV2 from '../fb-stubs/SupportRequestFormV2';
const {DEFAULT_SUPPORT_GROUP} = constants;
type SubmediaType =
| {uploadID: string; status: 'Uploaded'}
| {status: 'NotUploaded' | 'Uploading'};
type MediaObject = SubmediaType & {
description: string;
path: string;
};
export type GroupValidationErrors = {
plugins: string | null;
os: string | null;
};
export class Group {
constructor(
name: string,
workplaceGroupID: number,
requiredPlugins: Array<string>,
defaultPlugins: Array<string>,
supportedOS: Array<DeviceOS>,
deeplinkSuffix: string,
papercuts?: string,
) {
this.name = name;
this.requiredPlugins = requiredPlugins;
this.defaultPlugins = defaultPlugins;
this.workplaceGroupID = workplaceGroupID;
this.supportedOS = supportedOS;
this.deeplinkSuffix = deeplinkSuffix;
this.papercuts = papercuts;
}
readonly name: string;
requiredPlugins: Array<string>;
defaultPlugins: Array<string>;
workplaceGroupID: number;
supportedOS: Array<DeviceOS>;
deeplinkSuffix: string;
papercuts?: string;
getPluginsToSelect(): Array<string> {
return Array.from(
new Set([...this.defaultPlugins, ...this.requiredPlugins]),
);
}
getValidationMessage(
selectedPlugins: Array<string>,
selectedOS: DeviceOS | null,
): GroupValidationErrors {
const nonSelectedPlugin: Array<string> = [];
for (const plugin of this.requiredPlugins) {
if (!selectedPlugins.includes(plugin)) {
nonSelectedPlugin.push(plugin);
}
}
// Plugin validation
let str: string | null =
'should be exported if you want to submit to this group. Make sure, if your selected app supports those plugins, if so then enable it and select it from the plugin selection.';
if (nonSelectedPlugin.length == 1) {
str = `the ${nonSelectedPlugin.pop()} plugin ${str}`;
} else if (nonSelectedPlugin.length > 1) {
const lastPlugin = nonSelectedPlugin.pop();
str = `the ${nonSelectedPlugin.join(',')} and ${lastPlugin} ${str}`;
} else {
// nonSelectedPlugin is empty
str = null;
}
// OS validation
let osError: string | null = null;
if (this.name !== 'Flipper') {
if (!selectedOS) {
osError = 'Please select an app from the drop down.';
} else if (!this.supportedOS.includes(selectedOS)) {
osError = `The group ${
this.name
} supports exports from ${this.supportedOS.join(
', ',
)}. But your selected device's OS is ${selectedOS}, which is unsupported.`;
}
}
return {plugins: str, os: osError};
}
handleSupportFormDeeplinks(store: Store) {
getLogger().track('usage', 'support-form-source', {
source: 'deeplink',
group: this.name,
});
store.dispatch(setStaticView(SupportRequestFormV2));
const selectedAppId = store.getState().connections.selectedAppId;
const selectedClient = store
.getState()
.connections.clients.get(selectedAppId!);
let errorMessage: string | undefined = undefined;
if (selectedAppId) {
const {app} = deconstructClientId(selectedAppId);
const enabledPlugins: Array<string> | null =
store.getState().connections.enabledPlugins[app];
const unsupportedPlugins = [];
for (const requiredPlugin of this.requiredPlugins) {
const requiredPluginEnabled =
enabledPlugins != null && enabledPlugins.includes(requiredPlugin);
if (
selectedClient &&
selectedClient.plugins.has(requiredPlugin) &&
!requiredPluginEnabled
) {
const plugin =
store.getState().plugins.clientPlugins.get(requiredPlugin) ||
store.getState().plugins.devicePlugins.get(requiredPlugin)!;
store.dispatch(
switchPlugin({
selectedApp: app,
plugin,
}),
);
} else if (
!selectedClient ||
!selectedClient.plugins.has(requiredPlugin)
) {
unsupportedPlugins.push(requiredPlugin);
}
}
if (unsupportedPlugins.length > 0) {
errorMessage = `The current client does not support ${unsupportedPlugins.join(
', ',
)}. Please change the app from the dropdown in the support form.`;
logPlatformSuccessRate(`${SUPPORT_FORM_PREFIX}-deeplink`, {
kind: 'failure',
supportedOperation: true,
error: errorMessage,
});
showStatusUpdatesForDuration(
errorMessage,
'Deeplink',
10000,
(payload) => {
store.dispatch(addStatusMessage(payload));
},
(payload) => {
store.dispatch(removeStatusMessage(payload));
},
);
}
} else {
errorMessage =
'Selected app is null, thus the deeplink failed to enable required plugin.';
showStatusUpdatesForDuration(
'Please select an app and the device from the dropdown.',
'Deeplink',
10000,
(payload) => {
store.dispatch(addStatusMessage(payload));
},
(payload) => {
store.dispatch(removeStatusMessage(payload));
},
);
}
store.dispatch(
setSupportFormV2State({
...store.getState().supportForm.supportFormV2,
selectedGroup: this,
}),
);
const pluginsList = getExportablePlugins(store.getState());
store.dispatch(
setSelectedPlugins(
this.getPluginsToSelect().filter((s) => {
return pluginsList.map((s) => s.id).includes(s);
}),
),
);
logPlatformSuccessRate(
`${SUPPORT_FORM_PREFIX}-deeplink`,
errorMessage
? {
kind: 'failure',
supportedOperation: true,
error: errorMessage,
}
: {kind: 'success'},
);
}
getWarningMessage(
state: Parameters<typeof getExportablePlugins>[0],
): string | null {
const activePersistentPlugins = getExportablePlugins(state);
const emptyPlugins: Array<string> = [];
for (const plugin of this.requiredPlugins) {
if (
!activePersistentPlugins.find((o) => {
return o.id === plugin;
})
) {
emptyPlugins.push(plugin);
}
}
const commonStr = 'Are you sure you want to submit?';
if (emptyPlugins.length == 1) {
return `There is no data in ${emptyPlugins.pop()} plugin. ${commonStr}`;
} else if (emptyPlugins.length > 1) {
return `The following plugins have no data: ${emptyPlugins.join(
',',
)}. ${commonStr}`;
}
return null;
}
}
export 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,
DEFAULT_SUPPORT_GROUP.papercuts,
);
export const SUPPORTED_GROUPS: Array<Group> = [
DEFAULT_GROUP,
...constants.SUPPORT_GROUPS.map(
({
name,
workplaceGroupID,
requiredPlugins,
defaultPlugins,
supportedOS,
deeplinkSuffix,
papercuts,
}) => {
return new Group(
name,
workplaceGroupID,
requiredPlugins,
defaultPlugins,
supportedOS,
deeplinkSuffix,
papercuts,
);
},
),
];
export type MediaType = Array<MediaObject>;
export type SupportFormV2State = {
title: string;
description: string;
commitHash: string;
screenshots?: MediaType;
videos?: MediaType;
selectedGroup: Group;
};
export type SupportFormRequestDetailsState = SupportFormV2State & {
appName: string;
};
export type State = {
webState: NTUsersFormData | null;
supportFormV2: SupportFormV2State;
};
export type Action =
| {
type: 'SET_SUPPORT_FORM_STATE';
payload: NTUsersFormData | null;
}
| {
type: 'SET_SUPPORT_FORM_V2_STATE';
payload: SupportFormV2State;
}
| {
type: 'RESET_SUPPORT_FORM_V2_STATE';
};
export type NTUsersFormData = {
flipper_trace: string | null;
};
export const initialState: () => State = () => ({
webState: null,
supportFormV2: {
title: '',
description: [
'## Context',
'What are you trying to accomplish at a high level? Feel free to include mocks and tasks.',
'',
'## Problem',
"What's blocking you?",
'',
"## Workarounds I've Tried",
'',
].join('\n'),
commitHash: '',
appName: '',
selectedGroup: DEFAULT_GROUP,
},
});
export default function reducer(
state: State | undefined,
action: Actions,
): State {
state = state || initialState();
if (action.type === 'SET_SUPPORT_FORM_STATE') {
return {
...state,
webState: action.payload,
};
} else if (action.type === 'SET_SUPPORT_FORM_V2_STATE') {
return {
...state,
supportFormV2: action.payload,
};
} else if (action.type === 'RESET_SUPPORT_FORM_V2_STATE') {
return initialState();
} else {
return state;
}
}
export const setSupportFormState = (
payload: NTUsersFormData | null,
): Action => ({
type: 'SET_SUPPORT_FORM_STATE',
payload,
});
export const setSupportFormV2State = (payload: SupportFormV2State): Action => ({
type: 'SET_SUPPORT_FORM_V2_STATE',
payload,
});
export const resetSupportFormV2State = (): Action => ({
type: 'RESET_SUPPORT_FORM_V2_STATE',
});

View File

@@ -43,7 +43,6 @@ import {logout} from '../reducers/user';
import config from '../fb-stubs/config';
import styled from '@emotion/styled';
import {showEmulatorLauncher} from './appinspect/LaunchEmulator';
import SupportRequestFormV2 from '../fb-stubs/SupportRequestFormV2';
import {setStaticView} from '../reducers/connections';
import {getLogger} from 'flipper-common';
import {SandyRatingButton} from '../chrome/RatingButton';
@@ -302,13 +301,7 @@ function ExtrasMenu() {
source: 'sidebar',
group: undefined,
});
if (
getRenderHostInstance().GK('flipper_support_entry_point')
) {
openSupportRequestForm(fullState);
} else {
store.dispatch(setStaticView(SupportRequestFormV2));
}
openSupportRequestForm(fullState);
}}>
Feedback
</Menu.Item>

View File

@@ -22,12 +22,6 @@ import {default as ArchivedDevice} from '../devices/ArchivedDevice';
import {v4 as uuidv4} from 'uuid';
import {tryCatchReportPlatformFailures} from 'flipper-common';
import {TestIdler} from './Idler';
import {setStaticView} from '../reducers/connections';
import {
resetSupportFormV2State,
SupportFormRequestDetailsState,
} from '../reducers/supportForm';
import {deconstructClientId} from 'flipper-common';
import {processMessageQueue} from './messageQueue';
import {getPluginTitle} from './pluginUtils';
import {capture} from './screenshot';
@@ -38,7 +32,6 @@ import ShareSheetExportFile from '../chrome/ShareSheetExportFile';
import ExportDataPluginSheet from '../chrome/ExportDataPluginSheet';
import {getRenderHostInstance} from '../RenderHost';
import {uploadFlipperMedia} from '../fb-stubs/user';
import SupportRequestDetails from '../fb-stubs/SupportRequestDetails';
export const IMPORT_FLIPPER_TRACE_EVENT = 'import-flipper-trace';
export const EXPORT_FLIPPER_TRACE_EVENT = 'export-flipper-trace';
@@ -66,7 +59,6 @@ export type ExportType = {
// The GraphQL plugin relies on this format for generating
// Flipper traces from employee dogfooding. See D28209561.
pluginStates2: SandyPluginStates;
supportRequestDetails?: SupportFormRequestDetailsState;
};
type ProcessNotificationStatesOptions = {
@@ -482,15 +474,6 @@ export async function exportStore(
statusUpdate,
idler,
);
if (includeSupportDetails) {
exportData.supportRequestDetails = {
...state.supportForm?.supportFormV2,
appName:
state.connections.selectedAppId == null
? ''
: deconstructClientId(state.connections.selectedAppId).app,
};
}
statusUpdate && statusUpdate('Serializing Flipper data...');
const serializedString = JSON.stringify(exportData);
@@ -524,7 +507,6 @@ export const exportStoreToFile = (
exportFilePath,
serializedString,
);
store.dispatch(resetSupportFormV2State());
return {fetchMetaDataErrors};
},
);
@@ -533,7 +515,7 @@ export const exportStoreToFile = (
export function importDataToStore(source: string, data: string, store: Store) {
getLogger().track('usage', IMPORT_FLIPPER_TRACE_EVENT);
const json: ExportType = JSON.parse(data);
const {device, clients, supportRequestDetails, deviceScreenshot} = json;
const {device, clients, deviceScreenshot} = json;
if (device == null) {
return;
}
@@ -546,7 +528,6 @@ export function importDataToStore(source: string, data: string, store: Store) {
os,
screenshotHandle: deviceScreenshot,
source,
supportRequestDetails,
});
archivedDevice.loadDevicePlugins(
store.getState().plugins.devicePlugins,
@@ -579,12 +560,6 @@ export function importDataToStore(source: string, data: string, store: Store) {
).initFromImport(sandyPluginStates),
});
});
if (supportRequestDetails) {
store.dispatch(
// Late require to avoid circular dependency issue
setStaticView(SupportRequestDetails),
);
}
}
export const importFileToStore = async (file: string, store: Store) => {