Skip to content

Commit

Permalink
Disable Next button before first attempt to generate assertions (if I…
Browse files Browse the repository at this point in the history
…RV contests exist)
  • Loading branch information
charliecarlton committed Sep 5, 2024
1 parent 1ff4127 commit a8432e7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions client/src/component/DOS/DefineAudit/GenerateAssertionsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface GenerateAssertionsPageProps {
interface GenerateAssertionsPageState {
generatingAssertions: boolean;
generationTimeOutSeconds: number;
generationWasRun: boolean;
}

class GenerateAssertionsPage extends React.Component<GenerateAssertionsPageProps, GenerateAssertionsPageState> {
Expand All @@ -36,6 +37,7 @@ class GenerateAssertionsPage extends React.Component<GenerateAssertionsPageProps
this.state = {
generatingAssertions: false,
generationTimeOutSeconds: 5,
generationWasRun: false,
};
}

Expand All @@ -57,6 +59,7 @@ class GenerateAssertionsPage extends React.Component<GenerateAssertionsPageProps
alert('generateAssertions error in fetchAction ' + reason);
}).finally(() => {
this.setState({generatingAssertions: false});
this.setState({generationWasRun: true});
// Refresh dashboard to collect full assertion info
dashboardRefresh();
});
Expand Down Expand Up @@ -94,6 +97,7 @@ class GenerateAssertionsPage extends React.Component<GenerateAssertionsPageProps
}
<div className='control-buttons mt-default'>
<Button onClick={forward}
disabled={this.disableNextButton()}
className='pt-button pt-intent-primary'>
Next
</Button>
Expand All @@ -116,6 +120,19 @@ class GenerateAssertionsPage extends React.Component<GenerateAssertionsPageProps
this.setState({generationTimeOutSeconds: Number(timeout)});
}

private disableNextButton() {
const assertionsAlreadyGenerated = this.props.dosState.generateAssertionsSummaries.length > 0;
const atLeastOneIrvContest = Object.values(this.props.dosState.contests)
.some(contest => contest.description === 'IRV');

// Activate button if any attempt to generate is made
if (this.state.generationWasRun) {
return false;
}

return (!assertionsAlreadyGenerated && atLeastOneIrvContest);
}

private getAssertionGenerationStatusTable() {

interface CombinedData {
Expand Down

0 comments on commit a8432e7

Please sign in to comment.