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
This commit is contained in:
Pritesh Nandgaonkar
2019-11-04 03:57:23 -08:00
committed by Facebook Github Bot
parent da21b6add2
commit 9ec4ef67ad
2 changed files with 21 additions and 13 deletions

View File

@@ -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<string>;
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,
});

View File

@@ -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,
});
}
/**
*