From d2ab55a6f84b55fc455d4217de5f4f9141960e70 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Thu, 14 Nov 2019 05:44:31 -0800 Subject: [PATCH] Introduce support request details form Summary: Initial setup for a support detail form. Will only show up if meta data is present in the flipper file, so use the attached one to see it. Reviewed By: jknoxville Differential Revision: D18479193 fbshipit-source-id: 61da089f1e883fea20b2422a6bea99b2f8a4434b --- src/MenuBar.tsx | 2 +- src/chrome/MainSidebar.tsx | 62 ++++++++++++++++++++------ src/devices/ArchivedDevice.tsx | 5 +++ src/fb-stubs/SupportRequestDetails.tsx | 17 +++++++ src/plugins/crash_reporter/index.js | 7 ++- src/utils/exportData.tsx | 13 +++++- 6 files changed, 89 insertions(+), 17 deletions(-) create mode 100644 src/fb-stubs/SupportRequestDetails.tsx diff --git a/src/MenuBar.tsx b/src/MenuBar.tsx index 679285330..26e84d2a2 100644 --- a/src/MenuBar.tsx +++ b/src/MenuBar.tsx @@ -214,7 +214,7 @@ function getTemplate( ]; if (constants.ENABLE_SHAREABLE_LINK) { exportSubmenu.push({ - label: 'Sharable Link', + label: 'Shareable Link', accelerator: 'CommandOrControl+Shift+E', click: function() { store.dispatch( diff --git a/src/chrome/MainSidebar.tsx b/src/chrome/MainSidebar.tsx index 47f0b2708..aa8d5f217 100644 --- a/src/chrome/MainSidebar.tsx +++ b/src/chrome/MainSidebar.tsx @@ -30,6 +30,7 @@ import { LoadingIndicator, Button, StarButton, + ArchivedDevice, } from 'flipper'; import React, {Component, PureComponent, Fragment} from 'react'; import NotificationsHub from '../NotificationsHub'; @@ -46,6 +47,7 @@ import {connect} from 'react-redux'; import {BackgroundColorProperty} from 'csstype'; import {StyledOtherComponent} from 'create-emotion-styled'; import SupportRequestFormManager from '../fb-stubs/SupportRequestFormManager'; +import SupportRequestDetails from '../fb-stubs/SupportRequestDetails'; type FlipperPlugins = typeof FlipperPlugin[]; type PluginsByCategory = [string, FlipperPlugins][]; @@ -309,20 +311,7 @@ class MainSidebar extends PureComponent { {selectedDevice.title} - {selectedDevice.isArchived && selectedDevice.source ? ( - - Snapshot imported from: -
- {selectedDevice.source} -
- ) : null} + {this.showArchivedDeviceDetails(selectedDevice)} )} {selectedDevice && @@ -447,6 +436,51 @@ class MainSidebar extends PureComponent { ); } + showArchivedDeviceDetails(selectedDevice: BaseDevice) { + if (!selectedDevice.isArchived || !selectedDevice.source) { + return null; + } + const {staticView, setStaticView} = this.props; + return ( + <> + + Snapshot imported from: +
+ {selectedDevice.source} +
+ {this.state.showSupportForm && + (selectedDevice as ArchivedDevice).supportRequestDetails && ( + setStaticView(SupportRequestDetails)}> + + + Support Request Details + + + )} + + ); + } + renderPluginsByCategory( client: Client, plugins: FlipperPlugins, diff --git a/src/devices/ArchivedDevice.tsx b/src/devices/ArchivedDevice.tsx index 06795a5a1..91c688070 100644 --- a/src/devices/ArchivedDevice.tsx +++ b/src/devices/ArchivedDevice.tsx @@ -9,6 +9,7 @@ import BaseDevice from './BaseDevice'; import {DeviceType, OS, DeviceShell, DeviceLogEntry} from './BaseDevice'; +import {SupportRequestDetailsMetaData} from '../utils/exportData'; function normalizeArchivedDeviceType(deviceType: DeviceType): DeviceType { let archivedDeviceType = deviceType; @@ -28,16 +29,20 @@ export default class ArchivedDevice extends BaseDevice { os: OS, logEntries: Array, source: string = '', + supportRequestDetails?: SupportRequestDetailsMetaData, ) { super(serial, normalizeArchivedDeviceType(deviceType), title, os); this.logs = logEntries; this.source = source; + this.supportRequestDetails = supportRequestDetails; } logs: Array; isArchived = true; + supportRequestDetails?: SupportRequestDetailsMetaData; + getLogs() { return this.logs; } diff --git a/src/fb-stubs/SupportRequestDetails.tsx b/src/fb-stubs/SupportRequestDetails.tsx new file mode 100644 index 000000000..9677e01ea --- /dev/null +++ b/src/fb-stubs/SupportRequestDetails.tsx @@ -0,0 +1,17 @@ +/** + * Copyright (c) Facebook, Inc. and its 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 React, {Component} from 'react'; +import {Text} from '../ui'; + +export default class extends Component { + render() { + return Build your support request deteails form.; + } +} diff --git a/src/plugins/crash_reporter/index.js b/src/plugins/crash_reporter/index.js index 77a292740..e848cc674 100644 --- a/src/plugins/crash_reporter/index.js +++ b/src/plugins/crash_reporter/index.js @@ -753,7 +753,12 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin< ]}> {children.map(child => { - return ; + return ( + + ); })} diff --git a/src/utils/exportData.tsx b/src/utils/exportData.tsx index 8dac56591..3a26c9c37 100644 --- a/src/utils/exportData.tsx +++ b/src/utils/exportData.tsx @@ -48,6 +48,7 @@ export type ExportType = { pluginStates: PluginStatesExportState; activeNotifications: Array; }; + supportRequestDetails?: SupportRequestDetailsMetaData; }; type ProcessPluginStatesOptions = { @@ -81,6 +82,15 @@ type AddSaltToDeviceSerialOptions = { statusUpdate?: (msg: string) => void; }; +export type SupportRequestDetailsMetaData = { + title: string; + app: string; + description: string; + commitHash: string; + screenshots: {image: string; description: string}[]; + videos: {url: string; description: string}[]; +}; + export function processClients( clients: Array, serial: string, @@ -577,7 +587,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} = json; + const {device, clients, supportRequestDetails} = json; if (device == null) { return; } @@ -593,6 +603,7 @@ export function importDataToStore(source: string, data: string, store: Store) { }) : [], source, + supportRequestDetails, ); const devices = store.getState().connections.devices; const matchedDevices = devices.filter(