kopia lustrzana https://github.com/badgen/badgen.net
tweaks
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>pull/313/head
rodzic
f9f3d38a1e
commit
ce026e20df
|
|
@ -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()}`)
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue