Skip to content

Commit

Permalink
Take dataset validation request state into account
Browse files Browse the repository at this point in the history
  • Loading branch information
weltenwort committed May 13, 2020
1 parent 0ed2cd1 commit 34d50f7
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,25 +212,29 @@ export const useAnalysisSetupState = <JobType extends string>({
}

return [
// index count
...(selectedIndexNames.length === 0 ? [{ error: 'TOO_FEW_SELECTED_INDICES' as const }] : []),
// time range
...(!isTimeRangeValid ? [{ error: 'INVALID_TIME_RANGE' as const }] : []),
// validate request status
...(validateIndicesRequest.state === 'rejected' ? [{ error: 'NETWORK_ERROR' as const }] : []),
...(validateIndicesRequest.state === 'rejected' ||
validateDatasetsRequest.state === 'rejected'
? [{ error: 'NETWORK_ERROR' as const }]
: []),
// validation request results
...validatedIndices.reduce<ValidationUIError[]>((errors, index) => {
return index.validity === 'invalid' && selectedIndexNames.includes(index.name)
? [...errors, ...index.errors]
: errors;
}, []),
// index count
...(selectedIndexNames.length === 0 ? [{ error: 'TOO_FEW_SELECTED_INDICES' as const }] : []),
// time range
...(!isTimeRangeValid ? [{ error: 'INVALID_TIME_RANGE' as const }] : []),
];
}, [
isValidating,
validateIndicesRequest.state,
validateDatasetsRequest.state,
validatedIndices,
selectedIndexNames,
isTimeRangeValid,
validatedIndices,
]);

const prevStartTime = usePrevious(startTime);
Expand Down

0 comments on commit 34d50f7

Please sign in to comment.