Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
pull/313/head
Charlike Mike Reagent 2019-10-23 19:43:28 +03:00
rodzic f9f3d38a1e
commit ce026e20df
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 05263C64003DE1FA
1 zmienionych plików z 5 dodań i 6 usunięć

Wyświetl plik

@ -113,13 +113,12 @@ const statesColor = {
unknown: 'grey'
}
function combined (states: Array<any>, stateKey?: string) {
const k = stateKey || 'state'
function combined (states: Array<any>, stateKey: string = 'state') {
if (states.length === 0) return 'unknown'
if (states.find(x => x[k] === 'error')) return 'error'
if (states.find(x => x[k] === 'failure')) return 'failure'
if (states.find(x => x[k] === 'pending')) return 'pending'
if (states.every(x => x[k] === 'success')) return 'success'
if (states.find(x => x[stateKey] === 'error')) return 'error'
if (states.find(x => x[stateKey] === 'failure')) return 'failure'
if (states.find(x => x[stateKey] === 'pending')) return 'pending'
if (states.every(x => x[stateKey] === 'success')) return 'success'
// this shouldn't happen, but in case it happens
throw new Error(`Unknown states: ${states.map(x => x.state).join()}`)