Skip to content

Commit f6dbef8

Browse files
committed
feat: enhance job status handling and improve UI feedback for waiting states
1 parent c6fc4d5 commit f6dbef8

File tree

6 files changed

+41
-11
lines changed

6 files changed

+41
-11
lines changed

src/Common/AppStatus/AppStatus.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
*/
1616

1717
import Tippy from '@tippyjs/react'
18+
import { WorkflowStatusEnum } from '@Shared/types'
19+
import { renderProgressingTriggerIcon } from '@Shared/Components'
1820
import { ReactComponent as ICErrorCross } from '@Icons/ic-error-cross.svg'
19-
import { ReactComponent as InfoIcon } from '../../Assets/Icon/ic-info-outlined.svg'
21+
import { ReactComponent as InfoIcon } from '@Icons/ic-info-outlined.svg'
2022
import { StatusConstants, YET_TO_RUN } from './constants'
2123
import { AppStatusType } from './types'
22-
import { triggerStatus } from './utils'
24+
import { parseJobStatus, triggerStatus } from './utils'
2325

2426
export default function AppStatus({
2527
appStatus,
@@ -31,6 +33,8 @@ export default function AppStatus({
3133
let status = appStatus
3234
if (isDeploymentStatus) {
3335
status = triggerStatus(appStatus)
36+
} else if (isJobView) {
37+
status = parseJobStatus(appStatus)
3438
}
3539
const appStatusLowerCase = status?.toLowerCase()
3640
const isNotDeployed = appStatusLowerCase === StatusConstants.NOT_DEPLOYED.noSpaceLower
@@ -52,6 +56,10 @@ export default function AppStatus({
5256
const iconClass = getIconClass()
5357

5458
const renderIcon = () => {
59+
if (isJobView && appStatus === WorkflowStatusEnum.WAITING_TO_START) {
60+
return renderProgressingTriggerIcon()
61+
}
62+
5563
if (iconClass) {
5664
return iconClass === 'failed' || iconClass === 'error' ? (
5765
<ICErrorCross className="icon-dim-16 dc__no-shrink ic-error-cross-red" />

src/Common/AppStatus/utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { WorkflowStatusEnum } from '@Shared/types'
1718
import { TIMELINE_STATUS } from '../../Shared/constants'
1819

1920
export const triggerStatus = (triggerDetailStatus: string): string => {
@@ -29,3 +30,11 @@ export const triggerStatus = (triggerDetailStatus: string): string => {
2930
}
3031
return triggerDetailStatus
3132
}
33+
34+
export const parseJobStatus = (status: string): string => {
35+
if (status === WorkflowStatusEnum.WAITING_TO_START) {
36+
return 'Waiting to start'
37+
}
38+
39+
return status
40+
}

src/Shared/Components/CICDHistory/Artifacts.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,20 @@ const Artifacts = ({
153153
buildId: string
154154
}>()
155155

156+
const lowerCaseStatus = status.toLowerCase()
157+
156158
async function handleArtifact() {
157159
await handleDownload({
158160
downloadUrl: downloadArtifactUrl,
159161
fileName: `${buildId || triggerId}.zip`,
160162
})
161163
}
162164

163-
if (status.toLowerCase() === TERMINAL_STATUS_MAP.RUNNING || status.toLowerCase() === TERMINAL_STATUS_MAP.STARTING) {
165+
if (
166+
lowerCaseStatus === TERMINAL_STATUS_MAP.RUNNING ||
167+
lowerCaseStatus === TERMINAL_STATUS_MAP.STARTING ||
168+
lowerCaseStatus === TERMINAL_STATUS_MAP.WAITING_TO_START
169+
) {
164170
return <CIProgressView />
165171
}
166172
// If artifactId is not 0 image info is shown, if isArtifactUploaded is true reports are shown
@@ -170,9 +176,10 @@ const Artifacts = ({
170176
// NOTE: This means there are no reports and no image artifacts i.e. empty state
171177
if (!isArtifactUploaded && !artifactId) {
172178
if (
173-
status.toLowerCase() === TERMINAL_STATUS_MAP.FAILED ||
174-
status.toLowerCase() === TERMINAL_STATUS_MAP.CANCELLED ||
175-
status.toLowerCase() === TERMINAL_STATUS_MAP.ERROR
179+
lowerCaseStatus === TERMINAL_STATUS_MAP.FAILED ||
180+
lowerCaseStatus === TERMINAL_STATUS_MAP.CANCELLED ||
181+
lowerCaseStatus === TERMINAL_STATUS_MAP.ERROR ||
182+
lowerCaseStatus === TERMINAL_STATUS_MAP.TIMED_OUT
176183
) {
177184
return (
178185
<GenericEmptyState
@@ -190,7 +197,7 @@ const Artifacts = ({
190197
)
191198
}
192199

193-
if (status.toLowerCase() === TERMINAL_STATUS_MAP.SUCCEEDED) {
200+
if (lowerCaseStatus === TERMINAL_STATUS_MAP.SUCCEEDED) {
194201
return (
195202
<GenericEmptyState
196203
title={EMPTY_STATE_STATUS.ARTIFACTS_EMPTY_STATE_TEXTS.NoArtifactsFound}

src/Shared/Components/CICDHistory/constants.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export const TERMINAL_STATUS_MAP = {
5555
ERROR: 'error',
5656
CANCELLED: 'cancelled',
5757
UNABLE_TO_FETCH: 'unabletofetch',
58-
TIMED_OUT: 'timedout',
58+
TIMED_OUT: WorkflowStatusEnum.TIMED_OUT.toLowerCase(),
59+
WAITING_TO_START: WorkflowStatusEnum.WAITING_TO_START.toLowerCase(),
5960
}
6061

6162
export const EVENT_STREAM_EVENTS_MAP = {
@@ -99,6 +100,7 @@ export const statusColor = {
99100
initiating: 'var(--O500)',
100101
starting: 'var(--O500)',
101102
[WorkflowStatusEnum.WAITING_TO_START.toLowerCase()]: 'var(--O500)',
103+
[WorkflowStatusEnum.TIMED_OUT.toLowerCase()]: 'var(--R500)',
102104
succeeded: 'var(--G500)',
103105
running: 'var(--O500)',
104106
failed: 'var(--R500)',
@@ -141,10 +143,12 @@ export const TERMINAL_STATUS_COLOR_CLASS_MAP = {
141143
[TERMINAL_STATUS_MAP.FAILED]: 'cr-5',
142144
[TERMINAL_STATUS_MAP.CANCELLED]: 'cr-5',
143145
[TERMINAL_STATUS_MAP.ERROR]: 'cr-5',
146+
[TERMINAL_STATUS_MAP.TIMED_OUT]: 'cr-5',
147+
[TERMINAL_STATUS_MAP.WAITING_TO_START]: 'co-5',
144148
} as const
145149

146150
export const PROGRESSING_STATUS = {
147-
[WorkflowStatusEnum.WAITING_TO_START.toLowerCase()]: 'running',
151+
[TERMINAL_STATUS_MAP.WAITING_TO_START]: 'running',
148152
[TERMINAL_STATUS_MAP.RUNNING]: 'running',
149153
[TERMINAL_STATUS_MAP.PROGRESSING]: 'progressing',
150154
[TERMINAL_STATUS_MAP.STARTING]: 'starting',

src/Shared/Components/CICDHistory/utils.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ const renderAbortedTriggerIcon = (): JSX.Element => <ICAborted className="icon-d
162162
const renderFailedTriggerIcon = (baseClass: string = 'icon-dim-20'): JSX.Element => (
163163
<ICErrorCross className={`${baseClass} dc__no-shrink ic-error-cross-red`} />
164164
)
165-
const renderProgressingTriggerIcon = (baseClass: string = 'icon-dim-20'): JSX.Element => (
165+
export const renderProgressingTriggerIcon = (baseClass: string = 'icon-dim-20'): JSX.Element => (
166166
<ICInProgress className={`${baseClass} dc__no-shrink ic-in-progress-orange`} />
167167
)
168168
const renderSuccessTriggerIcon = (baseClass: string = 'icon-dim-20'): JSX.Element => (
@@ -193,13 +193,14 @@ export const getTriggerStatusIcon = (triggerDetailStatus: string): JSX.Element =
193193

194194
case TERMINAL_STATUS_MAP.FAILED:
195195
case TERMINAL_STATUS_MAP.ERROR:
196+
case TERMINAL_STATUS_MAP.TIMED_OUT:
196197
return renderFailedTriggerIcon()
197198

198199
case TERMINAL_STATUS_MAP.RUNNING:
199200
case TERMINAL_STATUS_MAP.PROGRESSING:
200201
case TERMINAL_STATUS_MAP.STARTING:
201202
case TERMINAL_STATUS_MAP.INITIATING:
202-
case WorkflowStatusEnum.WAITING_TO_START.toLowerCase():
203+
case TERMINAL_STATUS_MAP.WAITING_TO_START:
203204
return renderProgressingTriggerIcon()
204205

205206
case TERMINAL_STATUS_MAP.SUCCEEDED:

src/Shared/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,7 @@ export enum WorkflowStatusEnum {
940940
RUNNING = 'Running',
941941
PROGRESSING = 'Progressing',
942942
WAITING_TO_START = 'WaitingToStart',
943+
TIMED_OUT = 'TimedOut',
943944
CANCELLED = 'CANCELLED',
944945
}
945946

0 commit comments

Comments
 (0)