Skip to content

Commit

Permalink
fix setState to reset page on workflow change (#46)
Browse files Browse the repository at this point in the history
* handle anonymous user toolbar login
* bump version
  • Loading branch information
aclowes authored Jul 28, 2018
1 parent 4efee7c commit ef697df
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
4 changes: 3 additions & 1 deletion frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export default class App extends React.Component {
};

renderToolbar() {
const userAction = this.state.user ? `Logout (${this.state.user.username})` : 'Login';
const userName = this.state.user && this.state.user.username;
// anonymous user has empty string username, so show Login for them too
const userAction = userName ? `Logout (${userName})` : 'Login';
return (
<div>
<Nav>
Expand Down
25 changes: 15 additions & 10 deletions frontend/src/WorkflowDetailHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ export default class WorkflowDetailHistory extends React.Component {
componentWillReceiveProps(nextProps) {
// the version changed...
if (nextProps.workflow !== this.props.workflow) {
this.setState({runs: null, error: null, pagination: {page: 'last'}});
this.loadRuns(nextProps.workflow.id);
this.setState({runs: null, error: null, pagination: {page: 'last'}},
() => {
this.loadRuns(nextProps.workflow.id);
}
);
}
}

Expand All @@ -56,7 +59,9 @@ export default class WorkflowDetailHistory extends React.Component {

selectPage = (pageNumber) => {
this.setState({pagination: {...this.state.pagination, page: pageNumber}},
() => {this.loadRuns(this.props.workflow.id)});
() => {
this.loadRuns(this.props.workflow.id)
});
};

renderRunHeaders() {
Expand Down Expand Up @@ -156,15 +161,15 @@ export default class WorkflowDetailHistory extends React.Component {
</Table>
<ButtonToolbar>
<ButtonGroup>
<Pagination
ellipsis
items={this.state.pagination.page_count}
maxButtons={10}
activePage={this.state.pagination.page}
onSelect={this.selectPage}/>
<Pagination
ellipsis
items={this.state.pagination.page_count}
maxButtons={10}
activePage={this.state.pagination.page}
onSelect={this.selectPage}/>
</ButtonGroup>
<ButtonGroup>
<Button onClick={this.submitRun}>Start new run</Button>
<Button onClick={this.submitRun}>Start new run</Button>
</ButtonGroup>
</ButtonToolbar>
</div>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.2.4',
version='0.2.5',

description='Yet Another Workflow Engine, a subprocess-based DAG execution system',
long_description=long_description,
Expand Down
5 changes: 5 additions & 0 deletions yawn/settings/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
CSRF_COOKIE_SECURE = False
SECURE_PROXY_SSL_HEADER = None
SECURE_SSL_REDIRECT = False

# anonymous read-only allowed
REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES'] = [ # noqa
'rest_framework.permissions.IsAuthenticatedOrReadOnly',
]

0 comments on commit ef697df

Please sign in to comment.