-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
service: obs: apply suggestions from @calebcartwright
- Loading branch information
Showing
5 changed files
with
32 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,34 @@ | ||
import Joi from 'joi' | ||
import { | ||
isBuildStatus as gIsBuildStatus, | ||
renderBuildStatusBadge as gRenderBuildStatusBadge, | ||
} from '../build-status.js' | ||
|
||
// colors from OBS webinterface | ||
/* const statusmap = { | ||
//Green | ||
succeeded: "#008000", | ||
// Blue | ||
building: "#069", | ||
// Cyan | ||
scheduled: "#007a7c", | ||
// Yellow | ||
signing: "#f0ad4e", | ||
finished: "#f0ad4e", | ||
// Red | ||
unresolvable: "#dc3545", | ||
broken: "#dc3545", | ||
failed: "#dc3545", | ||
// Gray | ||
disabled: "#6c757d", | ||
blocked: "#6c757d", | ||
// Orange | ||
"scheduled-warning": "#a50", | ||
unknown: "#a50" | ||
} */ | ||
|
||
// shields colors | ||
const statusmap = { | ||
// Green | ||
succeeded: 'success', | ||
// Blue | ||
building: 'blue', | ||
// Cyan | ||
scheduled: '#007a7c', | ||
// Yellow | ||
signing: 'yellow', | ||
finished: 'yellow', | ||
// Red | ||
unresolvable: 'critical', | ||
broken: 'critical', | ||
failed: 'critical', | ||
// Gray | ||
disabled: 'inactive', | ||
const localStatuses = { | ||
blocked: 'inactive', | ||
// Orange | ||
'scheduled-warning': 'important', | ||
unknown: 'lightgray', | ||
disabled: 'inactive', | ||
finished: 'orange', | ||
'scheduled-warning': 'orange', | ||
signing: 'orange', | ||
unknown: 'inactive', | ||
unresolvable: 'red', | ||
} | ||
|
||
const isBuildStatus = Joi.equal(...Object.keys(statusmap)) | ||
function getIsMessageStatus() { | ||
const status = [] | ||
Object.keys(statusmap).forEach(key => | ||
status.push(key.charAt(0).toUpperCase() + key.slice(1)) | ||
) | ||
|
||
return Joi.equal(...status) | ||
} | ||
const isBuildStatus = Joi.alternatives().try( | ||
gIsBuildStatus, | ||
Joi.equal(...Object.keys(localStatuses)) | ||
) | ||
|
||
function renderBuildStatusBadge({ repository, status }) { | ||
const color = statusmap[status] | ||
|
||
return { | ||
label: repository.replace(/_/g, ' '), | ||
message: status.charAt(0).toUpperCase() + status.slice(1), | ||
color, | ||
const color = localStatuses[status] | ||
if (color) { | ||
return { | ||
message: status.toLowerCase(), | ||
color, | ||
} | ||
} else { | ||
return gRenderBuildStatusBadge({ status: status.toLowerCase() }) | ||
} | ||
} | ||
|
||
export { isBuildStatus, getIsMessageStatus, renderBuildStatusBadge } | ||
export { isBuildStatus, renderBuildStatusBadge } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters