Skip to content

Commit

Permalink
contest: add loading state to regrade all button
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar committed May 26, 2024
1 parent 7f9c664 commit 7f766bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Button, Intent } from '@blueprintjs/core';
import { Refresh } from '@blueprintjs/icons';

export function RegradeAllButton({ onRegradeAll }) {
export function RegradeAllButton({ onRegradeAll, isRegradingAll }) {
return (
<Button intent={Intent.PRIMARY} icon={<Refresh />} onClick={onRegradeAll}>
<Button intent={Intent.PRIMARY} icon={<Refresh />} onClick={onRegradeAll} loading={isRegradingAll}>
Regrade all pages
</Button>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class ContestSubmissionsPage extends Component {
response: undefined,
filter: { username, problemAlias },
isFilterLoading: false,
isRegradingAll: false,
};
}

Expand Down Expand Up @@ -70,7 +71,7 @@ export class ContestSubmissionsPage extends Component {
if (!this.state.response || !this.state.response.config.canManage) {
return null;
}
return <RegradeAllButton onRegradeAll={this.onRegradeAll} />;
return <RegradeAllButton onRegradeAll={this.onRegradeAll} isRegradingAll={this.state.isRegradingAll} />;
};

renderFilterWidget = () => {
Expand Down Expand Up @@ -154,7 +155,10 @@ export class ContestSubmissionsPage extends Component {
onRegradeAll = async () => {
if (reallyConfirm('Regrade all submissions in all pages for the current filter?')) {
const { username, problemAlias } = this.state.filter;

this.setState({ isRegradingAll: true });
await this.props.onRegradeAll(this.props.contest.jid, username, problemAlias);
this.setState({ isRegradingAll: false });
const queries = parse(this.props.location.search);
await this.refreshSubmissions(username, problemAlias, queries.page);
}
Expand Down

0 comments on commit 7f766bd

Please sign in to comment.