From 1559c1ef2cb970e86fea0116b2d08a3a86995df4 Mon Sep 17 00:00:00 2001 From: bizzguy Date: Wed, 20 Jan 2021 15:41:07 -0800 Subject: [PATCH] Network Plugin - Update UI for routes (#1831) Summary: The current UI for managing mock network request definitions (routes) has some issues - too small for the amount of information it displays - no formatting for JSON response bodies - uses the older design system (not ant) - no separation between commands for creating routes and the list of routes The following screen images show these problems. ![image](https://user-images.githubusercontent.com/337874/104691438-deb9cb00-56cb-11eb-92df-9e2d122f65c2.png) ![image](https://user-images.githubusercontent.com/337874/104691471-eda07d80-56cb-11eb-8f82-444d591ff966.png) ## Changelog Enhance UI for Mocks dialog in Network Plugin Pull Request resolved: https://github.com/facebook/flipper/pull/1831 Test Plan: Ran multiple manual tests using the Android sample app. Here is a screen image (at 1280 x 720) for the enhanced UI. ![image](https://user-images.githubusercontent.com/337874/104691649-37896380-56cc-11eb-849f-4e470bb7fbc4.png) Reviewed By: mweststrate Differential Revision: D25922798 Pulled By: priteshrnandgaonkar fbshipit-source-id: d27ba30a7eb51105a8d381097ecaafd82624cad5 --- .../network/ManageMockResponsePanel.tsx | 17 +++++-- .../plugins/network/MockResponseDetails.tsx | 51 +++++++++++-------- .../plugins/network/MockResponseDialog.tsx | 24 +++++---- 3 files changed, 56 insertions(+), 36 deletions(-) diff --git a/desktop/plugins/network/ManageMockResponsePanel.tsx b/desktop/plugins/network/ManageMockResponsePanel.tsx index 0174d9116..86c6b3fa9 100644 --- a/desktop/plugins/network/ManageMockResponsePanel.tsx +++ b/desktop/plugins/network/ManageMockResponsePanel.tsx @@ -8,6 +8,7 @@ */ import { + Layout, ManagedTable, Text, FlexBox, @@ -61,14 +62,17 @@ const Container = styled(FlexRow)({ flex: 1, justifyContent: 'space-around', alignItems: 'stretch', + height: '100%', + width: '100%', }); const LeftPanel = styled(FlexColumn)({ - flex: 1, + height: '100%', + width: '35%', }); const RightPanel = styled(FlexColumn)({ - flex: 3, + flex: 2, height: '100%', }); @@ -195,7 +199,7 @@ export function ManageMockResponsePanel(props: Props) { props.routes, ]); return ( - + { @@ -225,6 +229,13 @@ export function ManageMockResponsePanel(props: Props) { />  Copy Highlighted Calls +
@@ -298,7 +306,7 @@ export function MockResponseDetails({id, route, isDuplicated}: Props) { wrap="soft" autoComplete="off" spellCheck={false} - value={responseData} + value={formattedResponse} onChange={(event) => networkRouteManager.modifyRoute(id, { responseData: event.target.value, @@ -308,6 +316,25 @@ export function MockResponseDetails({id, route, isDuplicated}: Props) { + { + const newHeaders = { + ...route.responseHeaders, + [nextHeaderId.toString()]: {key: '', value: ''}, + }; + setNextHeaderId(nextHeaderId + 1); + networkRouteManager.modifyRoute(id, { + responseHeaders: newHeaders, + }); + }}> + +  Add Header + - { - const newHeaders = { - ...route.responseHeaders, - [nextHeaderId.toString()]: {key: '', value: ''}, - }; - setNextHeaderId(nextHeaderId + 1); - networkRouteManager.modifyRoute(id, { - responseHeaders: newHeaders, - }); - }}> - -  Add Header -
diff --git a/desktop/plugins/network/MockResponseDialog.tsx b/desktop/plugins/network/MockResponseDialog.tsx index a484c8b0d..9616504b7 100644 --- a/desktop/plugins/network/MockResponseDialog.tsx +++ b/desktop/plugins/network/MockResponseDialog.tsx @@ -7,7 +7,7 @@ * @format */ -import {FlexColumn, Button, styled} from 'flipper'; +import {FlexColumn, Button, styled, Layout} from 'flipper'; import {ManageMockResponsePanel} from './ManageMockResponsePanel'; import {Route, Request, Response} from './types'; @@ -40,19 +40,21 @@ const Row = styled(FlexColumn)({ export function MockResponseDialog(props: Props) { return ( - + Mock Network Responses - - + + + + - - + + ); }