Create Support Requests from Flipper
Summary: This diff adds an initial support to prefill the app information and the revision information. This diff also copies the workplace url in the clipboard. Reviewed By: passy Differential Revision: D16990925 fbshipit-source-id: 4f354e52de5fea07c2ea36336761d6963c27ef66
This commit is contained in:
committed by
Facebook Github Bot
parent
b041da6d61
commit
84c5067210
38
src/utils/clientUtils.tsx
Normal file
38
src/utils/clientUtils.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright 2018-present Facebook.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* @format
|
||||
*/
|
||||
import Client from '../Client';
|
||||
import BaseDevice from '../devices/BaseDevice';
|
||||
|
||||
export function currentActiveApps(
|
||||
clients: Array<Client>,
|
||||
selectedDevice: null | BaseDevice,
|
||||
): Array<string> {
|
||||
const currentActiveApps: Array<string> = clients
|
||||
.map(({id}: {id: string}) => {
|
||||
const appName = appNameFromClienID(id) || '';
|
||||
const device = deviceFromClienID(id) || '';
|
||||
return {appName, device};
|
||||
})
|
||||
.filter(
|
||||
({device}: {device: string}) =>
|
||||
device && selectedDevice && device == selectedDevice.os,
|
||||
)
|
||||
.map(client => client.appName);
|
||||
return currentActiveApps;
|
||||
}
|
||||
|
||||
export function appNameFromClienID(id: string): string | undefined {
|
||||
const arr = id.split('#');
|
||||
const appName = arr[0];
|
||||
return appName;
|
||||
}
|
||||
|
||||
export function deviceFromClienID(id: string): string | undefined {
|
||||
const arr = id.split('#');
|
||||
const device = arr[1];
|
||||
return device;
|
||||
}
|
||||
62
src/utils/supportRequestsFormUtils.tsx
Normal file
62
src/utils/supportRequestsFormUtils.tsx
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Copyright 2018-present Facebook.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* @format
|
||||
*/
|
||||
import {WebviewTag} from 'electron';
|
||||
|
||||
// TODO: Get rid off this function
|
||||
function injectJavaScript(webview: WebviewTag, command: string): Promise<any> {
|
||||
// @ts-ignore: Typescript doesn't have type src in the currentTarget variable in the event, due to which there is a discrepancy in the event callback.
|
||||
return webview.executeJavaScript(command, false);
|
||||
}
|
||||
|
||||
export function sendDidMountMessage(webview: WebviewTag) {
|
||||
webview.send('hostMessage', {
|
||||
type: 'onMountFlipper',
|
||||
payload: null,
|
||||
});
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param webview
|
||||
* @param text
|
||||
* This helper function is for appending a text in the questions input text field.
|
||||
* One should use it only for the pages backed by NTUsersFormContainer.react.js
|
||||
*/
|
||||
export function appendTextInQuestionsField(webview: WebviewTag, text: string) {
|
||||
webview.send('hostMessage', {
|
||||
type: 'appendQuestionString',
|
||||
payload: text,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param webview
|
||||
* @param data
|
||||
* This helper function is for updating a react state in NTUsersFormContainer.react.js
|
||||
*/
|
||||
export function updateStateInSupportForm(
|
||||
webview: WebviewTag,
|
||||
data: {[key: string]: any},
|
||||
) {
|
||||
webview.send('hostMessage', {
|
||||
type: 'updateState',
|
||||
payload: data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param webview
|
||||
* This helper function returns the supported apps by NTUsersFormContainer.react.js
|
||||
*/
|
||||
export function supportedApps(webview: WebviewTag): Promise<Array<string>> {
|
||||
// TODO: Replace this with a promisified call to the guest page
|
||||
return injectJavaScript(
|
||||
webview,
|
||||
"Array.from(document.querySelector('ul[role=radiogroup]').children).map(e => e.getAttribute('data-value'))",
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user