-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust Workflow Selection Logic (#84)
* Adjust Workflow Selection Logic * Clean Up Code for Final Review * Reintroduce Popup and Set Focus with Dialog Opening
- Loading branch information
1 parent
6971449
commit 3420bd8
Showing
12 changed files
with
344 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
import { withRouter } from 'react-router-dom'; | ||
import QuestionPrompt from './QuestionPrompt'; | ||
import WorkflowPrompt from './WorkflowPrompt'; | ||
import { toggleSelection } from '../ducks/workflow'; | ||
import { togglePopup } from '../ducks/dialog'; | ||
import { WorkInProgress } from '../ducks/work-in-progress'; | ||
|
||
class StartNewWorkConfirmation extends React.Component { | ||
constructor() { | ||
super(); | ||
|
||
this.startNewWork = this.startNewWork.bind(this); | ||
this.continueWork = this.continueWork.bind(this); | ||
} | ||
|
||
proceedToClassifier() { | ||
this.props.dispatch(toggleSelection(false)); | ||
this.props.dispatch(togglePopup(null)); | ||
this.props.history.push('/classify'); | ||
window.scrollTo(0, 0); | ||
} | ||
|
||
startNewWork() { | ||
if (this.props.user && WorkInProgress.check(this.props.user)) { | ||
this.props.dispatch(WorkInProgress.clear()); | ||
} | ||
this.proceedToClassifier(); | ||
this.props.dispatch(togglePopup(<WorkflowPrompt />)); | ||
} | ||
|
||
continueWork() { | ||
if (this.props.user && WorkInProgress.check(this.props.user)) { | ||
this.props.dispatch(WorkInProgress.load()); | ||
} | ||
this.proceedToClassifier(); | ||
} | ||
|
||
render() { | ||
return ( | ||
<QuestionPrompt | ||
confirm="Yes, start a new page" | ||
deny="No, continue saved work" | ||
onConfirm={this.startNewWork} | ||
onDeny={this.continueWork} | ||
question="Are you sure you want to start a new workflow? This will delete any saved work you may have." | ||
title="Start new Work?" | ||
/> | ||
); | ||
} | ||
} | ||
|
||
StartNewWorkConfirmation.propTypes = { | ||
dispatch: PropTypes.func.isRequired, | ||
history: PropTypes.shape({ | ||
push: PropTypes.func | ||
}).isRequired, | ||
user: PropTypes.shape({ | ||
id: PropTypes.string | ||
}) | ||
}; | ||
|
||
StartNewWorkConfirmation.defaultProps = { | ||
user: null | ||
}; | ||
|
||
const mapStateToProps = state => { | ||
const user = state.login.user; | ||
const userHasWorkInProgress = user && WorkInProgress.check(user); | ||
|
||
return { | ||
activeAnnotationExists: (!!state.workflow.data && !!state.subject.currentSubject) || userHasWorkInProgress, | ||
user: state.login.user | ||
}; | ||
}; | ||
|
||
export default connect(mapStateToProps)(withRouter(StartNewWorkConfirmation)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.