Misc UI fixes (#1873)
Summary: Continue with cleanup of Network plugin mock screens. This mostly consists of replacing FlexColumn, FlexRow and FlexBox with equivalent Sandy components. Here is the new screen: - replace text buttons with Button - add NUX info to "Copy Highlighted Calls" button - add message when no calls have been highlighted - in routes list remove padding on line items  Here is the prior screen:  ## Changelog Network Plugin - Additional cleanup of UI on mock screen Pull Request resolved: https://github.com/facebook/flipper/pull/1873 Test Plan: Create and modify mocks Verify that the functionality has not been affected by UI changes Reviewed By: passy Differential Revision: D26172915 Pulled By: mweststrate fbshipit-source-id: f0af143d8509b53585076737832657fb095e75a6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
118cb7e9ff
commit
6a9d06a4ce
@@ -8,11 +8,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Layout,
|
Button,
|
||||||
ManagedTable,
|
ManagedTable,
|
||||||
Text,
|
Text,
|
||||||
FlexBox,
|
|
||||||
FlexRow,
|
|
||||||
Glyph,
|
Glyph,
|
||||||
styled,
|
styled,
|
||||||
colors,
|
colors,
|
||||||
@@ -26,6 +24,9 @@ import {MockResponseDetails} from './MockResponseDetails';
|
|||||||
import {NetworkRouteContext} from './index';
|
import {NetworkRouteContext} from './index';
|
||||||
import {RequestId} from './types';
|
import {RequestId} from './types';
|
||||||
|
|
||||||
|
import {message} from 'antd';
|
||||||
|
import {NUX, Layout} from 'flipper-plugin';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
routes: {[id: string]: Route};
|
routes: {[id: string]: Route};
|
||||||
highlightedRows: Set<string> | null | undefined;
|
highlightedRows: Set<string> | null | undefined;
|
||||||
@@ -37,16 +38,6 @@ const ColumnSizes = {route: 'flex'};
|
|||||||
|
|
||||||
const Columns = {route: {value: 'Route', resizable: false}};
|
const Columns = {route: {value: 'Route', resizable: false}};
|
||||||
|
|
||||||
const Button = styled(FlexBox)({
|
|
||||||
color: colors.blackAlpha50,
|
|
||||||
alignItems: 'center',
|
|
||||||
padding: 5,
|
|
||||||
flexShrink: 0,
|
|
||||||
whiteSpace: 'nowrap',
|
|
||||||
overflow: 'hidden',
|
|
||||||
textOverflow: 'ellipsis',
|
|
||||||
});
|
|
||||||
|
|
||||||
const TextEllipsis = styled(Text)({
|
const TextEllipsis = styled(Text)({
|
||||||
overflowX: 'hidden',
|
overflowX: 'hidden',
|
||||||
textOverflow: 'ellipsis',
|
textOverflow: 'ellipsis',
|
||||||
@@ -110,11 +101,11 @@ function RouteRow(props: {
|
|||||||
handleRemoveId: () => void;
|
handleRemoveId: () => void;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<FlexRow grow={true}>
|
<Layout.Horizontal>
|
||||||
<FlexRow onClick={props.handleRemoveId}>
|
<Layout.Horizontal onClick={props.handleRemoveId}>
|
||||||
<Icon name="cross-circle" color={colors.red} />
|
<Icon name="cross-circle" color={colors.red} />
|
||||||
</FlexRow>
|
</Layout.Horizontal>
|
||||||
<FlexRow grow={true}>
|
<Layout.Horizontal>
|
||||||
{props.showWarning && (
|
{props.showWarning && (
|
||||||
<Icon name="caution-triangle" color={colors.yellow} />
|
<Icon name="caution-triangle" color={colors.yellow} />
|
||||||
)}
|
)}
|
||||||
@@ -125,8 +116,8 @@ function RouteRow(props: {
|
|||||||
) : (
|
) : (
|
||||||
<TextEllipsis>{props.text}</TextEllipsis>
|
<TextEllipsis>{props.text}</TextEllipsis>
|
||||||
)}
|
)}
|
||||||
</FlexRow>
|
</Layout.Horizontal>
|
||||||
</FlexRow>
|
</Layout.Horizontal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,35 +164,37 @@ export function ManageMockResponsePanel(props: Props) {
|
|||||||
<Layout.Container style={{height: 550}}>
|
<Layout.Container style={{height: 550}}>
|
||||||
<Layout.Left>
|
<Layout.Left>
|
||||||
<Layout.Container width={450} pad={10} gap={5}>
|
<Layout.Container width={450} pad={10} gap={5}>
|
||||||
|
<Layout.Horizontal gap>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
networkRouteManager.addRoute();
|
networkRouteManager.addRoute();
|
||||||
}}>
|
}}>
|
||||||
<Glyph
|
Add Route
|
||||||
name="plus-circle"
|
|
||||||
size={16}
|
|
||||||
variant="outline"
|
|
||||||
color={colors.blackAlpha30}
|
|
||||||
/>
|
|
||||||
Add Route
|
|
||||||
</Button>
|
</Button>
|
||||||
|
<NUX
|
||||||
|
title="It is now possible to highlight calls from the network call list and convert them into mock routes."
|
||||||
|
placement="bottom">
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (
|
||||||
|
!props.highlightedRows ||
|
||||||
|
props.highlightedRows.size == 0
|
||||||
|
) {
|
||||||
|
message.info('No network calls have been highlighted');
|
||||||
|
return;
|
||||||
|
}
|
||||||
networkRouteManager.copyHighlightedCalls(
|
networkRouteManager.copyHighlightedCalls(
|
||||||
props.highlightedRows as Set<string>,
|
props.highlightedRows as Set<string>,
|
||||||
props.requests,
|
props.requests,
|
||||||
props.responses,
|
props.responses,
|
||||||
);
|
);
|
||||||
}}>
|
}}>
|
||||||
<Glyph
|
Copy Highlighted Calls
|
||||||
name="plus-circle"
|
|
||||||
size={16}
|
|
||||||
variant="outline"
|
|
||||||
color={colors.blackAlpha30}
|
|
||||||
/>
|
|
||||||
Copy Highlighted Calls
|
|
||||||
</Button>
|
</Button>
|
||||||
|
</NUX>
|
||||||
|
</Layout.Horizontal>
|
||||||
<Panel
|
<Panel
|
||||||
|
padded={false}
|
||||||
grow={true}
|
grow={true}
|
||||||
collapsable={false}
|
collapsable={false}
|
||||||
floating={false}
|
floating={false}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
import {
|
import {
|
||||||
FlexRow,
|
FlexRow,
|
||||||
FlexColumn,
|
FlexColumn,
|
||||||
FlexBox,
|
|
||||||
Layout,
|
Layout,
|
||||||
|
Button,
|
||||||
Input,
|
Input,
|
||||||
Text,
|
Text,
|
||||||
Tabs,
|
Tabs,
|
||||||
@@ -103,17 +103,6 @@ const Warning = styled(FlexRow)({
|
|||||||
marginTop: 8,
|
marginTop: 8,
|
||||||
});
|
});
|
||||||
|
|
||||||
const AddHeaderButton = styled(FlexBox)({
|
|
||||||
color: colors.blackAlpha50,
|
|
||||||
marginTop: 8,
|
|
||||||
alignItems: 'center',
|
|
||||||
padding: 10,
|
|
||||||
flexShrink: 0,
|
|
||||||
whiteSpace: 'nowrap',
|
|
||||||
overflow: 'hidden',
|
|
||||||
textOverflow: 'ellipsis',
|
|
||||||
});
|
|
||||||
|
|
||||||
const HeadersColumnSizes = {
|
const HeadersColumnSizes = {
|
||||||
close: '4%',
|
close: '4%',
|
||||||
warning: '4%',
|
warning: '4%',
|
||||||
@@ -210,7 +199,7 @@ function _buildMockResponseHeaderRows(
|
|||||||
},
|
},
|
||||||
close: {
|
close: {
|
||||||
value: (
|
value: (
|
||||||
<FlexBox
|
<Layout.Container
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const newHeaders = produce(
|
const newHeaders = produce(
|
||||||
route.responseHeaders,
|
route.responseHeaders,
|
||||||
@@ -223,7 +212,7 @@ function _buildMockResponseHeaderRows(
|
|||||||
});
|
});
|
||||||
}}>
|
}}>
|
||||||
<HeaderGlyph name="cross-circle" color={colors.red} />
|
<HeaderGlyph name="cross-circle" color={colors.red} />
|
||||||
</FlexBox>
|
</Layout.Container>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -317,7 +306,8 @@ export function MockResponseDetails({id, route, isDuplicated}: Props) {
|
|||||||
</Tab>
|
</Tab>
|
||||||
<Tab key={'headers'} label={'Headers'}>
|
<Tab key={'headers'} label={'Headers'}>
|
||||||
<Layout.Container style={{width: '100%'}}>
|
<Layout.Container style={{width: '100%'}}>
|
||||||
<AddHeaderButton
|
<Layout.Horizontal>
|
||||||
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const newHeaders = {
|
const newHeaders = {
|
||||||
...route.responseHeaders,
|
...route.responseHeaders,
|
||||||
@@ -327,16 +317,14 @@ export function MockResponseDetails({id, route, isDuplicated}: Props) {
|
|||||||
networkRouteManager.modifyRoute(id, {
|
networkRouteManager.modifyRoute(id, {
|
||||||
responseHeaders: newHeaders,
|
responseHeaders: newHeaders,
|
||||||
});
|
});
|
||||||
}}>
|
}}
|
||||||
<Glyph
|
compact
|
||||||
name="plus-circle"
|
padded
|
||||||
size={16}
|
style={{marginBottom: 10}}>
|
||||||
variant="outline"
|
Add Header
|
||||||
color={colors.blackAlpha30}
|
</Button>
|
||||||
/>
|
</Layout.Horizontal>
|
||||||
Add Header
|
<Layout.ScrollContainer>
|
||||||
</AddHeaderButton>
|
|
||||||
<Layout.ScrollContainer style={{width: '100%'}}>
|
|
||||||
<ManagedTable
|
<ManagedTable
|
||||||
hideHeader={true}
|
hideHeader={true}
|
||||||
multiline={true}
|
multiline={true}
|
||||||
|
|||||||
Reference in New Issue
Block a user