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.   ## 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.  Reviewed By: mweststrate Differential Revision: D25922798 Pulled By: priteshrnandgaonkar fbshipit-source-id: d27ba30a7eb51105a8d381097ecaafd82624cad5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9cc69673be
commit
1559c1ef2c
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
Layout,
|
||||||
ManagedTable,
|
ManagedTable,
|
||||||
Text,
|
Text,
|
||||||
FlexBox,
|
FlexBox,
|
||||||
@@ -61,14 +62,17 @@ const Container = styled(FlexRow)({
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
justifyContent: 'space-around',
|
justifyContent: 'space-around',
|
||||||
alignItems: 'stretch',
|
alignItems: 'stretch',
|
||||||
|
height: '100%',
|
||||||
|
width: '100%',
|
||||||
});
|
});
|
||||||
|
|
||||||
const LeftPanel = styled(FlexColumn)({
|
const LeftPanel = styled(FlexColumn)({
|
||||||
flex: 1,
|
height: '100%',
|
||||||
|
width: '35%',
|
||||||
});
|
});
|
||||||
|
|
||||||
const RightPanel = styled(FlexColumn)({
|
const RightPanel = styled(FlexColumn)({
|
||||||
flex: 3,
|
flex: 2,
|
||||||
height: '100%',
|
height: '100%',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -195,7 +199,7 @@ export function ManageMockResponsePanel(props: Props) {
|
|||||||
props.routes,
|
props.routes,
|
||||||
]);
|
]);
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container style={{height: 580}}>
|
||||||
<LeftPanel>
|
<LeftPanel>
|
||||||
<AddRouteButton
|
<AddRouteButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -225,6 +229,13 @@ export function ManageMockResponsePanel(props: Props) {
|
|||||||
/>
|
/>
|
||||||
Copy Highlighted Calls
|
Copy Highlighted Calls
|
||||||
</CopyHighlightedCallsButton>
|
</CopyHighlightedCallsButton>
|
||||||
|
<hr
|
||||||
|
style={{
|
||||||
|
height: 1,
|
||||||
|
backgroundColor: colors.grey,
|
||||||
|
width: '95%',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<ManagedTable
|
<ManagedTable
|
||||||
hideHeader={true}
|
hideHeader={true}
|
||||||
multiline={true}
|
multiline={true}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ const StyledText = styled(Text)({
|
|||||||
const textAreaStyle: React.CSSProperties = {
|
const textAreaStyle: React.CSSProperties = {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
marginTop: 8,
|
marginTop: 8,
|
||||||
height: 300,
|
height: 430,
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
color: '#333',
|
color: '#333',
|
||||||
padding: 10,
|
padding: 10,
|
||||||
@@ -240,6 +240,14 @@ export function MockResponseDetails({id, route, isDuplicated}: Props) {
|
|||||||
const [nextHeaderId, setNextHeaderId] = useState(0);
|
const [nextHeaderId, setNextHeaderId] = useState(0);
|
||||||
|
|
||||||
const {requestUrl, requestMethod, responseData, responseStatus} = route;
|
const {requestUrl, requestMethod, responseData, responseStatus} = route;
|
||||||
|
|
||||||
|
let formattedResponse = '';
|
||||||
|
try {
|
||||||
|
formattedResponse = JSON.stringify(JSON.parse(responseData), null, 2);
|
||||||
|
} catch (e) {
|
||||||
|
formattedResponse = responseData;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<FlexRow style={{width: '100%'}}>
|
<FlexRow style={{width: '100%'}}>
|
||||||
@@ -298,7 +306,7 @@ export function MockResponseDetails({id, route, isDuplicated}: Props) {
|
|||||||
wrap="soft"
|
wrap="soft"
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
spellCheck={false}
|
spellCheck={false}
|
||||||
value={responseData}
|
value={formattedResponse}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
networkRouteManager.modifyRoute(id, {
|
networkRouteManager.modifyRoute(id, {
|
||||||
responseData: event.target.value,
|
responseData: event.target.value,
|
||||||
@@ -308,26 +316,6 @@ export function MockResponseDetails({id, route, isDuplicated}: Props) {
|
|||||||
</Tab>
|
</Tab>
|
||||||
<Tab key={'headers'} label={'Headers'}>
|
<Tab key={'headers'} label={'Headers'}>
|
||||||
<FlexColumn>
|
<FlexColumn>
|
||||||
<ManagedTable
|
|
||||||
hideHeader={true}
|
|
||||||
multiline={true}
|
|
||||||
columnSizes={HeadersColumnSizes}
|
|
||||||
columns={HeadersColumns}
|
|
||||||
rows={_buildMockResponseHeaderRows(
|
|
||||||
id,
|
|
||||||
route,
|
|
||||||
selectedHeaderIds.length === 1 ? selectedHeaderIds[0] : null,
|
|
||||||
networkRouteManager,
|
|
||||||
)}
|
|
||||||
stickyBottom={true}
|
|
||||||
autoHeight={true}
|
|
||||||
floating={false}
|
|
||||||
// height={300}
|
|
||||||
zebra={false}
|
|
||||||
onRowHighlighted={setSelectedHeaderIds}
|
|
||||||
highlightedRows={new Set(selectedHeaderIds)}
|
|
||||||
/>
|
|
||||||
</FlexColumn>
|
|
||||||
<AddHeaderButton
|
<AddHeaderButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const newHeaders = {
|
const newHeaders = {
|
||||||
@@ -347,6 +335,25 @@ export function MockResponseDetails({id, route, isDuplicated}: Props) {
|
|||||||
/>
|
/>
|
||||||
Add Header
|
Add Header
|
||||||
</AddHeaderButton>
|
</AddHeaderButton>
|
||||||
|
<ManagedTable
|
||||||
|
hideHeader={true}
|
||||||
|
multiline={true}
|
||||||
|
columnSizes={HeadersColumnSizes}
|
||||||
|
columns={HeadersColumns}
|
||||||
|
rows={_buildMockResponseHeaderRows(
|
||||||
|
id,
|
||||||
|
route,
|
||||||
|
selectedHeaderIds.length === 1 ? selectedHeaderIds[0] : null,
|
||||||
|
networkRouteManager,
|
||||||
|
)}
|
||||||
|
stickyBottom={true}
|
||||||
|
autoHeight={true}
|
||||||
|
floating={false}
|
||||||
|
zebra={false}
|
||||||
|
onRowHighlighted={setSelectedHeaderIds}
|
||||||
|
highlightedRows={new Set(selectedHeaderIds)}
|
||||||
|
/>
|
||||||
|
</FlexColumn>
|
||||||
</Tab>
|
</Tab>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {FlexColumn, Button, styled} from 'flipper';
|
import {FlexColumn, Button, styled, Layout} from 'flipper';
|
||||||
|
|
||||||
import {ManageMockResponsePanel} from './ManageMockResponsePanel';
|
import {ManageMockResponsePanel} from './ManageMockResponsePanel';
|
||||||
import {Route, Request, Response} from './types';
|
import {Route, Request, Response} from './types';
|
||||||
@@ -40,19 +40,21 @@ const Row = styled(FlexColumn)({
|
|||||||
|
|
||||||
export function MockResponseDialog(props: Props) {
|
export function MockResponseDialog(props: Props) {
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Layout.Container pad width={1200}>
|
||||||
<Title>Mock Network Responses</Title>
|
<Title>Mock Network Responses</Title>
|
||||||
|
<Layout.Horizontal>
|
||||||
<ManageMockResponsePanel
|
<ManageMockResponsePanel
|
||||||
routes={props.routes}
|
routes={props.routes}
|
||||||
highlightedRows={props.highlightedRows}
|
highlightedRows={props.highlightedRows}
|
||||||
requests={props.requests}
|
requests={props.requests}
|
||||||
responses={props.responses}
|
responses={props.responses}
|
||||||
/>
|
/>
|
||||||
<Row>
|
</Layout.Horizontal>
|
||||||
|
<Layout.Horizontal>
|
||||||
<Button compact padded onClick={props.onHide}>
|
<Button compact padded onClick={props.onHide}>
|
||||||
Close
|
Close
|
||||||
</Button>
|
</Button>
|
||||||
</Row>
|
</Layout.Horizontal>
|
||||||
</Container>
|
</Layout.Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user