Skip to content

Commit 5ce936c

Browse files
committed
feat: introduce deployment stage to node mapping for improved workflow handling
1 parent 6829c54 commit 5ce936c

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/Shared/Components/CICDHistory/TriggerOutput.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
URLS,
2828
ServerError,
2929
mapByKey,
30-
DeploymentNodeType,
3130
} from '../../../Common'
3231
import {
3332
FetchIdDataStatus,
@@ -45,7 +44,7 @@ import { DeploymentHistoryConfigDiff } from './DeploymentHistoryConfigDiff'
4544
import { GitChanges, Scroller } from './History.components'
4645
import Artifacts from './Artifacts'
4746
import TriggerDetails from './TriggerDetails'
48-
import { DeploymentStageType, EMPTY_STATE_STATUS } from '../../constants'
47+
import { DEPLOYMENT_STAGE_TO_NODE_MAP, EMPTY_STATE_STATUS } from '../../constants'
4948
import './cicdHistory.scss'
5049

5150
const HistoryLogs: React.FC<HistoryLogsProps> = ({
@@ -83,24 +82,12 @@ const HistoryLogs: React.FC<HistoryLogsProps> = ({
8382
envId: string
8483
}>()
8584

86-
const getCDWorkflowType = () => {
87-
if (triggerDetails.stage === DeploymentStageType.PRE) {
88-
return DeploymentNodeType.PRECD
89-
}
90-
91-
if (triggerDetails.stage === DeploymentStageType.POST) {
92-
return DeploymentNodeType.POSTCD
93-
}
94-
95-
return DeploymentNodeType.CD
96-
}
97-
9885
const paramsData = {
9986
appId,
10087
envId,
10188
appName: `${triggerDetails.helmPackageName}.tgz`,
10289
workflowId: triggerDetails.id,
103-
cdWorkflowType: getCDWorkflowType(),
90+
cdWorkflowType: DEPLOYMENT_STAGE_TO_NODE_MAP[triggerDetails.stage],
10491
}
10592

10693
const CDBuildReportUrl = `app/cd-pipeline/workflow/download/${appId}/${envId}/${pipelineId}/${triggerId}`

src/Shared/constants.tsx

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

17-
import { OptionType } from '@Common/Types'
17+
import { DeploymentNodeType, OptionType } from '@Common/Types'
1818
import { CDMaterialSidebarType, ConfigKeysWithLockType, ConfigurationType } from './types'
1919

2020
export const ARTIFACT_STATUS = {
@@ -537,3 +537,9 @@ export const Routes = {
537537
export const ENTERPRISE_SUPPORT_LINK = 'enterprise@devtron.ai'
538538

539539
export const INVALID_LICENSE_KEY = 'inValid'
540+
541+
export const DEPLOYMENT_STAGE_TO_NODE_MAP: Readonly<Record<DeploymentStageType, DeploymentNodeType>> = {
542+
[DeploymentStageType.DEPLOY]: DeploymentNodeType.CD,
543+
[DeploymentStageType.POST]: DeploymentNodeType.POSTCD,
544+
[DeploymentStageType.PRE]: DeploymentNodeType.PRECD,
545+
}

0 commit comments

Comments
 (0)