feature: Cleanup execution dialog, and log display status. (#378)

* feature: Cleanup execution dialog, and log display status.

* fmt: Remove empty block

* cicd: Use ActionStatusDisplay in test

* bugfix: missed promise

* bugfix: missed promise

* bugfix: Didnt return getText on ActionStatusDisplay
This commit is contained in:
James Read
2024-08-08 21:46:46 +01:00
committed by GitHub
parent 8d839ee6ce
commit fab0264d9b
6 changed files with 100 additions and 90 deletions

View File

@@ -0,0 +1,41 @@
export class ActionStatusDisplay {
constructor (parentElement) {
this.exitCodeElement = document.createElement('span')
this.statusElement = document.createElement('span')
this.statusElement.innerText = 'unknown'
parentElement.innerText = ''
parentElement.appendChild(this.statusElement)
parentElement.appendChild(this.exitCodeElement)
}
getText () {
return this.statusElement.innerText
}
update (logEntry) {
this.statusElement.classList.remove(...this.statusElement.classList)
if (logEntry.executionFinished) {
this.statusElement.innerText = 'Completed'
this.exitCodeElement.innerText = ', Exit code: ' + logEntry.exitCode
if (logEntry.exitCode === 0) {
this.statusElement.classList.add('action-success')
} else if (logEntry.blocked) {
this.statusElement.innerText = 'Blocked'
this.statusElement.classList.add('action-blocked')
this.exitCodeElement.innerText = ''
} else if (logEntry.timedOut) {
this.statusElement.innerText = 'Timed out'
this.statusElement.classList.add('action-timeout')
this.exitCodeElement.innerText = ''
} else {
this.statusElement.classList.add('action-nonzero-exit')
}
} else {
this.statusElement.innerText = 'Still running...'
this.exitCodeElement.innerText = ''
}
}
}