Skip to content

Commit fa7d75f

Browse files
committed
feat: add help icon and enhance workflow execution stages handling in CICD components
1 parent 71a758d commit fa7d75f

File tree

5 files changed

+57
-6
lines changed

5 files changed

+57
-6
lines changed

src/Assets/Icon/ic-help-filled.svg

Lines changed: 4 additions & 0 deletions
Loading

src/Shared/Components/CICDHistory/Sidebar.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { ReactComponent as ICDocker } from '../../../Assets/Icon/ic-docker.svg'
4242
import { GitTriggers } from '../../types'
4343
import { CiPipelineSourceConfig } from './CiPipelineSourceConfig'
4444
import { HISTORY_LABEL, FILTER_STYLE, statusColor as colorMap } from './constants'
45-
import { getTriggerStatusIcon, getWorkflowNodeStatusTitle } from './utils'
45+
import { getHistoryItemStatusIconFromWorkflowStages, getTriggerStatusIcon, getWorkflowNodeStatusTitle } from './utils'
4646

4747
const SummaryTooltipCard = React.memo(
4848
({
@@ -145,6 +145,7 @@ const HistorySummaryCard = React.memo(
145145
renderRunSource,
146146
runSource,
147147
resourceId,
148+
workflowExecutionStages,
148149
}: HistorySummaryCardType): JSX.Element => {
149150
const { path, params } = useRouteMatch()
150151
const { pathname } = useLocation()
@@ -215,7 +216,9 @@ const HistorySummaryCard = React.memo(
215216
ref={assignTargetCardRef}
216217
>
217218
<div className="w-100 deployment-history-card">
218-
{getTriggerStatusIcon(status)}
219+
{workflowExecutionStages
220+
? getHistoryItemStatusIconFromWorkflowStages(workflowExecutionStages)
221+
: getTriggerStatusIcon(status)}
219222
<div className="flexbox-col dc__gap-8">
220223
<div className="flex column left">
221224
<div className="cn-9 fs-13 lh-20">
@@ -393,6 +396,7 @@ const Sidebar = React.memo(
393396
runSource={triggerDetails.runSource}
394397
renderRunSource={renderRunSource}
395398
resourceId={resourceId}
399+
workflowExecutionStages={triggerDetails.workflowExecutionStages}
396400
/>
397401
))}
398402
{hasMore && (fetchIdData === FetchIdDataStatus.SUSPEND || !fetchIdData) && (

src/Shared/Components/CICDHistory/TriggerOutput.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ const WorkerStatus = React.memo(
155155
&nbsp;
156156
{podStatus && (
157157
<span>
158-
{WORKFLOW_STAGE_STATUS_TO_TEXT_MAP[podStatus] || podStatus.toLowerCase()}&nbsp;
158+
:&nbsp;{WORKFLOW_STAGE_STATUS_TO_TEXT_MAP[podStatus] || podStatus.toLowerCase()}
159+
&nbsp;
159160
</span>
160161
)}
161162
</div>
@@ -352,7 +353,9 @@ const StartDetails = ({
352353
const { pathname } = useLocation()
353354

354355
return (
355-
<div className="w-100 pr-20 flex column left dc__border-bottom-n1">
356+
<div
357+
className={`w-100 pr-20 flex column left ${stage === DeploymentStageType.DEPLOY ? 'dc__border-bottom-n1' : ''}`}
358+
>
356359
<div className="flexbox dc__gap-8 dc__align-items-center pb-12 flex-wrap">
357360
<div className="flex left dc__gap-4 cn-9 fs-13 fw-6 lh-20">
358361
<div className="flex left dc__no-shrink dc__gap-4" data-testid="deployment-history-start-heading">
@@ -509,7 +512,6 @@ export const TriggerDetails = React.memo(
509512

510513
return (
511514
<div className="trigger-details flexbox-col pb-12">
512-
{/* */}
513515
<div className="flexbox-col py-12">
514516
<div className="trigger-details__summary lh-20">
515517
<div className="display-grid trigger-details__grid">

src/Shared/Components/CICDHistory/types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export interface SidebarType extends RenderRunSourceType {
242242
resourceId?: number
243243
}
244244

245-
export interface HistorySummaryCardType extends RenderRunSourceType {
245+
export interface HistorySummaryCardType extends RenderRunSourceType, Pick<History, 'workflowExecutionStages'> {
246246
id: number
247247
status: string
248248
startedOn: string

src/Shared/Components/CICDHistory/utils.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
import { ReactElement } from 'react'
1617
import { TIMELINE_STATUS } from '@Shared/constants'
1718
import { ReactComponent as ICAborted } from '@Icons/ic-aborted.svg'
1819
import { ReactComponent as ICErrorCross } from '@Icons/ic-error-cross.svg'
@@ -25,6 +26,8 @@ import { ReactComponent as Disconnect } from '@Icons/ic-disconnected.svg'
2526
import { ReactComponent as TimeOut } from '@Icons/ic-timeout-red.svg'
2627
import { ReactComponent as ICCheck } from '@Icons/ic-check.svg'
2728
import { ReactComponent as ICInProgress } from '@Icons/ic-in-progress.svg'
29+
import { ReactComponent as ICHelpFilled } from '@Icons/ic-help-filled.svg'
30+
import { ReactComponent as ICWarningY5 } from '@Icons/ic-warning-y5.svg'
2831
import { isTimeStringAvailable } from '@Shared/Helpers'
2932
import { DEFAULT_CLUSTER_ID, TERMINAL_STATUS_MAP } from './constants'
3033
import { ResourceKindType, WorkflowStatusEnum } from '../../types'
@@ -287,6 +290,44 @@ export const sanitizeWorkflowExecutionStages = (
287290
}
288291
}
289292

293+
export const getHistoryItemStatusIconFromWorkflowStages = (
294+
workflowExecutionStages: WorkflowExecutionStagesMapDTO['workflowExecutionStages'],
295+
): ReactElement => {
296+
const executionInfo = sanitizeWorkflowExecutionStages(workflowExecutionStages)
297+
const baseClass = 'icon-dim-20 dc__no-shrink'
298+
299+
if (!executionInfo) {
300+
return <ICHelpFilled className={baseClass} />
301+
}
302+
303+
if (!executionInfo.finishedOn) {
304+
return renderProgressingTriggerIcon()
305+
}
306+
307+
if (FAILED_WORKFLOW_STAGE_STATUS_MAP[executionInfo.workerDetails?.status]) {
308+
return <ICWarningY5 className={baseClass} />
309+
}
310+
311+
const status = executionInfo.currentStatus
312+
313+
switch (status) {
314+
case WorkflowStageStatusType.TIMEOUT:
315+
return <TimeOut className={baseClass} />
316+
317+
case WorkflowStageStatusType.ABORTED:
318+
return <ICAborted className={baseClass} />
319+
320+
case WorkflowStageStatusType.FAILED:
321+
return renderFailedTriggerIcon()
322+
323+
case WorkflowStageStatusType.SUCCEEDED:
324+
return <ICCheck className={baseClass} />
325+
326+
default:
327+
return <ICHelpFilled className={baseClass} />
328+
}
329+
}
330+
290331
export const getWorkerPodBaseUrl = (clusterId: number = DEFAULT_CLUSTER_ID, podNamespace: string = 'devtron-ci') =>
291332
`/resource-browser/${clusterId}/${podNamespace}/pod/k8sEmptyGroup`
292333

0 commit comments

Comments
 (0)