From 9ec4ef67ad40faf2677afc94df762e69b8cbd691 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Mon, 4 Nov 2019 03:57:23 -0800 Subject: [PATCH] Cache the text entered by the user Summary: This diff introduces the following improvements which I got as a feedback from the user 1) Before this diff the text entered used to vanish away when one switched tabs and came back to the support form. This diff takes care of that. 2) With this diff user can rexport the flipper trace to override the previous cached state too. - For this I had to update the UI to show flipper trace a separate input box, rather than appending it in the question field. - This avoided the the appending of the text in flipper trace and facilitated the easy override of the trace 3) With this diff one can also override commit_hash without appending multiple text. WWW changes: D18250494, Do not land until this diff is landed. Reviewed By: passy Differential Revision: D18257524 fbshipit-source-id: 119edadf90ac95cb296c10520239513f1fef905d --- src/reducers/application.tsx | 21 +++++++++++++++++++++ src/utils/supportRequestsFormUtils.tsx | 13 ------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/reducers/application.tsx b/src/reducers/application.tsx index 3d49d0bfa..ffc80edac 100644 --- a/src/reducers/application.tsx +++ b/src/reducers/application.tsx @@ -66,6 +66,10 @@ export type ShareType = { closeOnFinish: boolean; } & SubShareType; +export type NTUsersFormData = { + flipper_trace: string | null; +}; + export type State = { leftSidebarVisible: boolean; rightSidebarVisible: boolean; @@ -80,6 +84,7 @@ export type State = { flipperRating: number | null; statusMessages: Array; xcodeCommandLineToolsDetected: boolean; + supportForm: {webState: NTUsersFormData} | null; }; type BooleanActionType = @@ -150,6 +155,12 @@ export type Action = payload: { isDetected: boolean; }; + } + | { + type: 'SET_SUPPORT_FORM_STATE'; + payload: { + webState: NTUsersFormData; + } | null; }; export const initialState: () => State = () => ({ @@ -172,6 +183,7 @@ export const initialState: () => State = () => ({ flipperRating: null, statusMessages: [], xcodeCommandLineToolsDetected: false, + supportForm: null, }); function statusMessage(sender: string, msg: string): string { @@ -285,6 +297,8 @@ export default function reducer( return state; } else if (action.type === 'SET_XCODE_DETECTED') { return {...state, xcodeCommandLineToolsDetected: action.payload.isDetected}; + } else if (action.type === 'SET_SUPPORT_FORM_STATE') { + return {...state, supportForm: action.payload}; } else { return state; } @@ -370,3 +384,10 @@ export const setXcodeDetected = (isDetected: boolean): Action => ({ type: 'SET_XCODE_DETECTED', payload: {isDetected}, }); + +export const setSupportFormState = ( + payload: {webState: NTUsersFormData} | null, +): Action => ({ + type: 'SET_SUPPORT_FORM_STATE', + payload, +}); diff --git a/src/utils/supportRequestsFormUtils.tsx b/src/utils/supportRequestsFormUtils.tsx index e1a69bc34..c0e31a390 100644 --- a/src/utils/supportRequestsFormUtils.tsx +++ b/src/utils/supportRequestsFormUtils.tsx @@ -21,19 +21,6 @@ export function sendDidMountMessage(webview: WebviewTag) { 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, - }); -} /** *