Skip to content

Commit de6bc06

Browse files
committed
feat: StatusComponent - add inprogress icon, code refactor
1 parent a21118d commit de6bc06

File tree

8 files changed

+40
-11
lines changed

8 files changed

+40
-11
lines changed

src/Assets/IconV2/ic-in-progress.svg

Lines changed: 4 additions & 0 deletions
Loading

src/Shared/Components/CICDHistory/Sidebar.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { HISTORY_LABEL, FILTER_STYLE } from './constants'
4545
import { statusColor as colorMap } from '../../constants'
4646
import { DeploymentStatus } from '../StatusComponent'
4747
import { Icon } from '../Icon'
48+
import { getTriggerStatusIcon } from './utils'
4849

4950
const SummaryTooltipCard = React.memo(
5051
({
@@ -217,7 +218,12 @@ const HistorySummaryCard = React.memo(
217218
ref={assignTargetCardRef}
218219
>
219220
<div className="w-100 deployment-history-card">
220-
<DeploymentStatus status={status} hideMessage hideIconTooltip iconSize={20} />
221+
<DeploymentStatus
222+
status={getTriggerStatusIcon(status)}
223+
hideMessage
224+
hideIconTooltip
225+
iconSize={20}
226+
/>
221227
<div className="flexbox-col dc__gap-8">
222228
<div className="flex column left">
223229
<div className="cn-9 fs-13 lh-20">

src/Shared/Components/CICDHistory/utils.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import {
3434
NodeFilters,
3535
} from './types'
3636
import { Icon } from '../Icon'
37-
import { AppStatus } from '../StatusComponent'
37+
import { AppStatus, StatusType } from '../StatusComponent'
38+
import { TERMINAL_STATUS_MAP } from './constants'
3839

3940
export const getTriggerHistoryFilterCriteria = ({
4041
appId,
@@ -219,3 +220,17 @@ export const getStatusFilters = ({
219220
export const getAppStatusIcon = (status: NodeStatus | NodeFilters, hideMessage = false) => (
220221
<AppStatus status={status} hideMessage={hideMessage} hideIconTooltip />
221222
)
223+
224+
export const getTriggerStatusIcon = (status: string) => {
225+
const triggerStatus = status?.toLowerCase()
226+
227+
switch (triggerStatus) {
228+
case TERMINAL_STATUS_MAP.RUNNING:
229+
case TERMINAL_STATUS_MAP.PROGRESSING:
230+
case TERMINAL_STATUS_MAP.STARTING:
231+
case TERMINAL_STATUS_MAP.INITIATING:
232+
return StatusType.INPROGRESS
233+
default:
234+
return status
235+
}
236+
}

src/Shared/Components/Icon/Icon.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { ReactComponent as ICHeartGreen } from '@IconsV2/ic-heart-green.svg'
2626
import { ReactComponent as ICHeartRedAnimated } from '@IconsV2/ic-heart-red-animated.svg'
2727
import { ReactComponent as ICHeartRed } from '@IconsV2/ic-heart-red.svg'
2828
import { ReactComponent as ICHibernate } from '@IconsV2/ic-hibernate.svg'
29+
import { ReactComponent as ICInProgress } from '@IconsV2/ic-in-progress.svg'
2930
import { ReactComponent as ICInfoOutline } from '@IconsV2/ic-info-outline.svg'
3031
import { ReactComponent as ICJobColor } from '@IconsV2/ic-job-color.svg'
3132
import { ReactComponent as ICMissing } from '@IconsV2/ic-missing.svg'
@@ -70,6 +71,7 @@ export const iconMap = {
7071
'ic-heart-red-animated': ICHeartRedAnimated,
7172
'ic-heart-red': ICHeartRed,
7273
'ic-hibernate': ICHibernate,
74+
'ic-in-progress': ICInProgress,
7375
'ic-info-outline': ICInfoOutline,
7476
'ic-job-color': ICJobColor,
7577
'ic-missing': ICMissing,

src/Shared/Components/StatusComponent/AppStatus.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { StatusComponent } from './StatusComponent'
1919
import { APP_STATUS } from './constants'
2020

2121
export const AppStatus = ({ status, isJobView = false, isVirtualEnv = false, ...restProps }: AppStatusProps) => {
22-
const appStatus = isVirtualEnv ? APP_STATUS.NOT_AVAILABLE : status
22+
const appStatus = isVirtualEnv ? APP_STATUS.NOT_AVAILABLE : (status ?? '')
2323
const isNotDeployed =
2424
appStatus.toLowerCase().replace(/ /g, '-') === APP_STATUS.NOT_DEPLOYED ||
2525
appStatus.toLowerCase() === APP_STATUS.NOT_DEPLOYED_NO_SPACE

src/Shared/Components/StatusComponent/StatusComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const StatusComponent = ({
3434
hideIconTooltip = false,
3535
message,
3636
}: StatusComponentProps) => {
37-
const appStatusLowerCase = status.toLowerCase().replace(/ /g, '-')
37+
const appStatusLowerCase = (status || '').toLowerCase().replace(/ /g, '-')
3838
const textContent = message || status || '-'
3939

4040
const renderIcon = () => {
@@ -73,7 +73,7 @@ export const StatusComponent = ({
7373
const renderMessage = () => (
7474
<Tooltip content={textContent}>
7575
<p
76-
data-testid={`${status}-status`}
76+
data-testid={`${status || 'status-is-null'}-status`}
7777
className="m-0 dc__ellipsis-right dc__first-letter-capitalize fs-13 lh-20 cn-6"
7878
>
7979
{textContent}

src/Shared/Components/StatusComponent/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export enum StatusType {
1515
SUSPENDED = 'SUSPENDED',
1616
DEGRADED = 'DEGRADED',
1717
PROGRESSING = 'PROGRESSING',
18+
INPROGRESS = 'INPROGRESS',
1819
HIBERNATING = 'HIBERNATING',
1920
TIMED_OUT = 'TIMED_OUT',
2021
}

src/Shared/Components/StatusComponent/utils.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { TIMELINE_STATUS } from '@Shared/constants'
22
import { IconName, IconsProps } from '../Icon'
3+
import { StatusType } from './types'
34

45
export const getIconName = (status: string, showAnimatedIcon: boolean): IconName => {
56
switch (status) {
@@ -42,8 +43,9 @@ export const getIconName = (status: string, showAnimatedIcon: boolean): IconName
4243
case 'running':
4344
case 'request_accepted':
4445
case 'starting':
45-
case 'inprogress':
4646
return 'ic-circle-loader'
47+
case 'inprogress':
48+
return 'ic-in-progress'
4749
case 'hibernating':
4850
case 'hibernated':
4951
return 'ic-hibernate'
@@ -69,7 +71,6 @@ export const getIconColor = (status: string): IconsProps['color'] => {
6971
case 'running':
7072
case 'request_accepted':
7173
case 'starting':
72-
case 'inprogress':
7374
return 'O500'
7475
case 'timedout':
7576
case 'timed_out':
@@ -84,13 +85,13 @@ export const getDeploymentStatusFromStatus = (status: string): string => {
8485

8586
switch (deploymentStatus) {
8687
case TIMELINE_STATUS.ABORTED:
87-
return 'Aborted'
88+
return StatusType.ABORTED
8889
case TIMELINE_STATUS.DEGRADED:
89-
return 'Failed'
90+
return StatusType.FAILED
9091
case TIMELINE_STATUS.HEALTHY:
91-
return 'Succeeded'
92+
return StatusType.SUCCEEDED
9293
case TIMELINE_STATUS.INPROGRESS:
93-
return 'Progressing'
94+
return StatusType.INPROGRESS
9495
default:
9596
return status
9697
}

0 commit comments

Comments
 (0)