Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
fix: remove 'Cancel' on submission to avoid data loss (fixes #162)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKohler committed Apr 14, 2019
1 parent 2dd26f7 commit 0cb4065
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 36 deletions.
9 changes: 0 additions & 9 deletions web/src/actions/index.js
Expand Up @@ -21,8 +21,6 @@ export const ACTION_SUBMIT_SENTENCES_REQUEST = 'SUBMIT_SENTENCES_REQUEST';
export const ACTION_SUBMIT_SENTENCES_SUCCESS = 'SUBMIT_SENTENCES_SUCCESS';
export const ACTION_SUBMIT_SENTENCES_FAILURE_SINGLE = 'SUBMIT_SENTENCES_FAILURE_SINGLE';

export const ACTION_RESET_STATE = 'ACTION_RESET_STATE';

const VALID_USERNAME_CHARACTERS = /^[a-zA-Z0-9]+$/;

export function login(username, password) {
Expand Down Expand Up @@ -221,10 +219,3 @@ export function submitSentencesFailureSingle(errors) {
errors,
};
}

export function resetFullState() {
return {
type: ACTION_RESET_STATE,
};
}

5 changes: 1 addition & 4 deletions web/src/components/confirm-form.jsx
Expand Up @@ -10,7 +10,6 @@ class ConfirmForm extends React.Component {
this.state = {};
this.onSubmit = this.onSubmit.bind(this);
this.onReview = this.props.onReview.bind(this);
this.onCancel = this.props.onCancel.bind(this);
}

onSubmit(evt) {
Expand Down Expand Up @@ -79,8 +78,6 @@ class ConfirmForm extends React.Component {
<button type="submit" disabled={readyCount === 0}>Confirm</button>
}

<button onClick={this.onCancel}>Cancel</button>

{ this.state.pendingSentences && (
<div>
<p className="loadingText">Sentences are being uploaded. This can take several minutes depending on the number of sentences added.
Expand All @@ -93,7 +90,7 @@ class ConfirmForm extends React.Component {

{ Object.keys(filtered).length > 0 && (
<section>
<h2>Filtered sentences due to requirements failing:</h2>
<h2>Filtered sentences due to requirements failing (please submit fixed versions as new sentences):</h2>
<p>Please check the <a href="https://common-voice.github.io/sentence-collector/#/how-to">guidelines</a>.</p>

{
Expand Down
12 changes: 0 additions & 12 deletions web/src/components/pages/add.jsx
Expand Up @@ -31,7 +31,6 @@ export default class Add extends React.Component {

this.onSubmit = this.onSubmit.bind(this);
this.onConfirm = this.onConfirm.bind(this);
this.onCancel = this.onCancel.bind(this);
this.onReview = this.onReview.bind(this);
this.onReviewed = this.onReviewed.bind(this);
}
Expand All @@ -40,11 +39,6 @@ export default class Add extends React.Component {
this.setState(DEFAULT_STATE);
}

resetFullState() {
this.resetState();
this.props.resetFullState();
}

getLanguageInput() {
const input = document.querySelector('#add-form select');
return input && input.value;
Expand Down Expand Up @@ -161,11 +155,6 @@ export default class Add extends React.Component {
}
}

onCancel(evt) {
evt.preventDefault();
this.resetFullState();
}

onReview() {
this.setState({
reviewing: this.state.unreviewed,
Expand Down Expand Up @@ -207,7 +196,6 @@ export default class Add extends React.Component {
// The confirm form is a stats page where sentence submission happens.
return <ConfirmForm onSubmit={this.onConfirm}
onReview={this.onReview}
onCancel={this.onCancel}
submitted={this.state.submitted}
unreviewed={this.state.unreviewed}
validated={this.state.validated}
Expand Down
2 changes: 0 additions & 2 deletions web/src/containers/add.js
Expand Up @@ -4,7 +4,6 @@ import Add from '../components/pages/add';

import {
submitSentences,
resetFullState,
} from '../actions';

import {
Expand All @@ -24,7 +23,6 @@ function mapDispatchToProps(dispatch) {
submitSentences:
(language, sentences, source) => dispatch(submitSentences(language, sentences, source)),
parseSentences: (language, text) => dispatch(parseSentences(language, text)),
resetFullState: () => dispatch(resetFullState()),
};
}

Expand Down
9 changes: 0 additions & 9 deletions web/src/reducers/index.js
Expand Up @@ -16,7 +16,6 @@ import {
ACTION_SUBMIT_SENTENCES_REQUEST,
ACTION_SUBMIT_SENTENCES_SUCCESS,
ACTION_SUBMIT_SENTENCES_FAILURE_SINGLE,
ACTION_RESET_STATE,
} from '../actions';

import {
Expand Down Expand Up @@ -143,14 +142,6 @@ export default function reducer(state = INITIAL_STATE, action) {
errorMessage: action.error.message,
});

case ACTION_RESET_STATE:
return Object.assign({}, state, INITIAL_STATE, {
username: state.username,
password: state.password,
authed: state.authed,
languages: state.languages,
});

default:
return state;
}
Expand Down

0 comments on commit 0cb4065

Please sign in to comment.