Summary:
This is a collection of small UI fixes for the network plugin:

- image maxWidth is set to 100% to not cause vertical scrolling
- Panels now have horizontal scrollbars, if their content overflows
- fixing missing icon for failed network requests
- removing position sticky from table headers as it was not used and causing some rendering issues and performance problems
- Adding a `label` and `grow` option to the `Select`-component which is used in the sidebar of the network plugin.

Reviewed By: passy

Differential Revision: D12956336

fbshipit-source-id: 6e7e9cf97c058a2ff626576d4afdc6df65007ea1
This commit is contained in:
Daniel Büchele
2018-11-07 06:22:13 -08:00
committed by Facebook Github Bot
parent 4ff5c7294c
commit 8ab52839fb
5 changed files with 52 additions and 18 deletions

View File

@@ -12,7 +12,6 @@ import type {Request, Response, Header} from './index.js';
import { import {
Component, Component,
FlexColumn, FlexColumn,
FlexRow,
ManagedTable, ManagedTable,
ManagedDataInspector, ManagedDataInspector,
Text, Text,
@@ -223,14 +222,13 @@ export default class RequestDetails extends Component<
] ]
: null} : null}
<Panel heading={'Options'} floating={false} collapsed={true}> <Panel heading={'Options'} floating={false} collapsed={true}>
<FlexRow>
<Text>Body: </Text>
<Select <Select
grow
label="Body"
selected={bodyFormat} selected={bodyFormat}
onChange={this.onSelectFormat} onChange={this.onSelectFormat}
options={RequestDetails.BodyOptions} options={RequestDetails.BodyOptions}
/> />
</FlexRow>
</Panel> </Panel>
</RequestDetails.Container> </RequestDetails.Container>
); );
@@ -403,8 +401,7 @@ type ImageWithSizeState = {
class ImageWithSize extends Component<ImageWithSizeProps, ImageWithSizeState> { class ImageWithSize extends Component<ImageWithSizeProps, ImageWithSizeState> {
static Image = styled('img')({ static Image = styled('img')({
objectFit: 'scale-down', objectFit: 'scale-down',
maxWidth: 500, maxWidth: '100%',
maxHeight: 500,
marginBottom: 10, marginBottom: 10,
}); });

View File

@@ -207,7 +207,7 @@ export default class extends FlipperPlugin<State, *, PersistedState> {
this.state.selectedIds ? new Set(this.state.selectedIds) : null this.state.selectedIds ? new Set(this.state.selectedIds) : null
} }
/> />
<DetailSidebar>{this.renderSidebar()}</DetailSidebar> <DetailSidebar width={500}>{this.renderSidebar()}</DetailSidebar>
</FlexColumn> </FlexColumn>
); );
} }
@@ -384,7 +384,7 @@ class StatusColumn extends PureComponent<{
let glyph; let glyph;
if (children != null && children >= 400 && children < 600) { if (children != null && children >= 400 && children < 600) {
glyph = <Icon name="stop-solid" color={colors.red} />; glyph = <Icon name="stop" color={colors.red} />;
} }
return ( return (

View File

@@ -156,6 +156,7 @@ export default class Panel extends React.Component<
{children == null || (collapsable && collapsed) ? null : ( {children == null || (collapsable && collapsed) ? null : (
<Panel.PanelBody <Panel.PanelBody
scrollable
grow={grow} grow={grow}
padded={padded == null ? true : padded} padded={padded == null ? true : padded}
floating={floating}> floating={floating}>

View File

@@ -6,6 +6,22 @@
*/ */
import {Component} from 'react'; import {Component} from 'react';
import Text from './Text';
import styled from '../styled';
const Label = styled('label')({
display: 'flex',
alignItems: 'center',
});
const LabelText = styled(Text)({
fontWeight: '500',
marginRight: 5,
});
const SelectMenu = styled('select')(({grow}) => ({
flexGrow: grow ? 1 : null,
}));
/** /**
* Dropdown to select from a list of options * Dropdown to select from a list of options
@@ -21,20 +37,41 @@ export default class Select extends Component<{
onChange: (key: string) => void, onChange: (key: string) => void,
/** Selected key */ /** Selected key */
selected?: ?string, selected?: ?string,
/** Label shown next to the dropdown */
label?: string,
/** Select box should take all available space */
grow?: boolean,
}> { }> {
selectID: string = Math.random().toString(36);
onChange = (event: Object) => { onChange = (event: Object) => {
this.props.onChange(event.target.value); this.props.onChange(event.target.value);
}; };
render() { render() {
const {className, options, selected} = this.props; const {className, options, selected, label, grow} = this.props;
return ( let select = (
<select onChange={this.onChange} className={className}> <SelectMenu
grow={grow}
id={this.selectID}
onChange={this.onChange}
className={className}>
{Object.keys(options).map(key => ( {Object.keys(options).map(key => (
<option selected={key === selected}>{options[key]}</option> <option selected={key === selected}>{options[key]}</option>
))} ))}
</select> </SelectMenu>
);
if (label) {
select = (
<Label for={this.selectID}>
<LabelText>{label}</LabelText>
{select}
</Label>
); );
} }
return select;
}
} }

View File

@@ -49,7 +49,6 @@ const TableHeadContainer = styled(FlexRow)({
flexShrink: 0, flexShrink: 0,
left: 0, left: 0,
overflow: 'hidden', overflow: 'hidden',
position: 'sticky',
right: 0, right: 0,
textAlign: 'left', textAlign: 'left',
top: 0, top: 0,