Added spinner while submitting bug report

Summary:
Solves this T65385916.
Before this diff the bugreporter showed a disabled UI while waiting for the upload to finish. Its confusing for the user as, it can be seen from the above the task.  Thus I added an intermediate UI with a spinner and a text "Submitting..." which makes it clear for the user that we are uploading a bug report.

Reviewed By: mweststrate

Differential Revision: D21017426

fbshipit-source-id: ce12dfbefc8726adfad9ef17abd744cc92c254ed
This commit is contained in:
Pritesh Nandgaonkar
2020-04-14 10:34:53 -07:00
committed by Facebook GitHub Bot
parent a08bed86b7
commit adebae54fa
2 changed files with 96 additions and 71 deletions

View File

@@ -25,13 +25,20 @@ import {
styled, styled,
} from 'flipper'; } from 'flipper';
import {State as Store} from '../reducers'; import {State as Store} from '../reducers';
import LoadingIndicator from '../ui/components/LoadingIndicator';
const Container = styled(FlexColumn)({ const Container = styled(FlexColumn)({
padding: 10, padding: 10,
width: 400, width: 400,
height: 300, height: 300,
}); });
const CenteredContainer = styled(FlexColumn)<{size: number}>(({size}) => ({
justifyContent: 'center',
alignItems: 'center',
width: size,
height: size,
}));
const Icon = styled(Glyph)({ const Icon = styled(Glyph)({
marginRight: 8, marginRight: 8,
marginLeft: 3, marginLeft: 3,
@@ -193,10 +200,14 @@ class BugReporterDialog extends Component<Props, State> {
}; };
onCancel = () => { onCancel = () => {
if (this.state.submitting) {
this.props.bugReporter.abort();
}
this.setState({ this.setState({
error: null, error: null,
title: '', title: '',
description: '', description: '',
submitting: false,
}); });
this.props.onHide(); this.props.onHide();
}; };
@@ -233,6 +244,25 @@ class BugReporterDialog extends Component<Props, State> {
</FlexColumn> </FlexColumn>
</FlexCenter> </FlexCenter>
); );
} else {
if (submitting) {
content = (
<Fragment>
<FlexCenter grow={true}>
<CenteredContainer size={200}>
<LoadingIndicator size={16} />
<Title> Submitting... </Title>
</CenteredContainer>
</FlexCenter>
<Footer>
<SubmitButtonContainer>
<Button onClick={this.onCancel} disabled={false} compact padded>
Cancel
</Button>
</SubmitButtonContainer>
</Footer>
</Fragment>
);
} else { } else {
content = ( content = (
<Fragment> <Fragment>
@@ -242,7 +272,6 @@ class BugReporterDialog extends Component<Props, State> {
value={title} value={title}
ref={this.setTitleRef} ref={this.setTitleRef}
onChange={this.onTitleChange} onChange={this.onTitleChange}
disabled={submitting}
/> />
<DescriptionTextarea <DescriptionTextarea
@@ -250,7 +279,6 @@ class BugReporterDialog extends Component<Props, State> {
value={description} value={description}
ref={this.setDescriptionRef} ref={this.setDescriptionRef}
onChange={this.onDescriptionChange} onChange={this.onDescriptionChange}
disabled={submitting}
/> />
{activePlugin && activePlugin.bugs && ( {activePlugin && activePlugin.bugs && (
<InfoBox> <InfoBox>
@@ -269,10 +297,13 @@ class BugReporterDialog extends Component<Props, State> {
</Link> </Link>
</span> </span>
)} )}
{activePlugin && activePlugin.bugs && activePlugin.bugs.email && ( {activePlugin &&
activePlugin.bugs &&
activePlugin.bugs.email && (
<span> <span>
, you might also want contact{' '} , you might also want contact{' '}
<Link href={'mailto:' + String(activePlugin.bugs.email)}> <Link
href={'mailto:' + String(activePlugin.bugs.email)}>
{activePlugin.bugs.email} {activePlugin.bugs.email}
</Link> </Link>
, the author/oncall of this plugin, directly , the author/oncall of this plugin, directly
@@ -286,19 +317,10 @@ class BugReporterDialog extends Component<Props, State> {
<Footer> <Footer>
{error != null && <Text color={colors.red}>{error}</Text>} {error != null && <Text color={colors.red}>{error}</Text>}
<SubmitButtonContainer> <SubmitButtonContainer>
<Button <Button onClick={this.onCancel} compact padded>
onClick={this.onCancel}
disabled={submitting}
compact
padded>
Cancel Cancel
</Button> </Button>
<Button <Button type="primary" onClick={this.onSubmit} compact padded>
type="primary"
onClick={this.onSubmit}
disabled={submitting}
compact
padded>
Submit Report Submit Report
</Button> </Button>
</SubmitButtonContainer> </SubmitButtonContainer>
@@ -306,7 +328,7 @@ class BugReporterDialog extends Component<Props, State> {
</Fragment> </Fragment>
); );
} }
}
return <Container>{content}</Container>; return <Container>{content}</Container>;
} }
} }

View File

@@ -12,6 +12,9 @@ import {Store} from '../reducers/index';
export default class BugReporter { export default class BugReporter {
constructor(_logManager: Logger, _store: Store) {} constructor(_logManager: Logger, _store: Store) {}
public abort() {
console.log('Stub implementation of an abort function.');
}
async report(_title: string, _body: string): Promise<number> { async report(_title: string, _body: string): Promise<number> {
return Promise.resolve(-1); return Promise.resolve(-1);
} }