Skip to content

Commit 48385e0

Browse files
committed
feat: skipped status for change branch
1 parent ac7f35e commit 48385e0

File tree

6 files changed

+56
-9
lines changed

6 files changed

+56
-9
lines changed

src/components/ApplicationGroup/Constants.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export enum BulkResponseStatus {
4545
'PASS' = 'pass',
4646
'FAIL' = 'fail',
4747
'UNAUTHORIZE' = 'unauthorized',
48+
'SKIP' = 'skip',
4849
}
4950

5051
export const BULK_VIRTUAL_RESPONSE_STATUS = {
@@ -180,6 +181,8 @@ export const CREATE_GROUP_TABS = {
180181

181182
export const GetBranchChangeStatus = (statusText: string): BulkResponseStatus => {
182183
switch (statusText) {
184+
case BulkResponseStatus.SKIP:
185+
return BulkResponseStatus.SKIP
183186
case BULK_VIRTUAL_RESPONSE_STATUS.pass:
184187
return BulkResponseStatus.PASS
185188
case BULK_VIRTUAL_RESPONSE_STATUS.fail:
@@ -191,4 +194,6 @@ export const GetBranchChangeStatus = (statusText: string): BulkResponseStatus =>
191194
}
192195
}
193196

194-
export const FILTER_NAME_REGEX = /^[a-z][a-z0-9-]{1,}[a-z0-9]$/
197+
export const FILTER_NAME_REGEX = /^[a-z][a-z0-9-]{1,}[a-z0-9]$/
198+
export const SKIPPED_RESOURCES_MESSAGE = 'Build action is not applicable'
199+
export const SKIPPED_RESOURCES_STATUS_TEXT = 'Skipped'

src/components/ApplicationGroup/Details/TriggerView/BulkSourceChange.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import React, { useEffect, useRef, useState } from 'react'
33
import { ReactComponent as Close } from '../../../../assets/icons/ic-cross.svg'
44
import { ReactComponent as Warn } from '../../../../assets/icons/ic-warning.svg'
55
import SourceUpdateResponseModal from './SourceUpdateResponseModal'
6+
import { BulkSourceChangeProps } from './types'
67

7-
export default function BulkSourceChange({ closePopup, responseList, changeBranch, loading, selectedAppCount }) {
8+
export default function BulkSourceChange({ closePopup, responseList, changeBranch, loading, selectedAppCount, skippedResources=[] }: BulkSourceChangeProps) {
89
const sourceChangeDetailRef = useRef<HTMLDivElement>(null)
910

1011
const [showResponseModal, setShowResponseModal] = useState(false)
@@ -46,7 +47,7 @@ export default function BulkSourceChange({ closePopup, responseList, changeBranc
4647
}, [outsideClickHandler])
4748

4849
useEffect(() => {
49-
setShowResponseModal(responseList.length > 0)
50+
setShowResponseModal(responseList.length > 0 || skippedResources.length > 0)
5051
}, [responseList])
5152

5253
const updateBranch = () => {
@@ -137,7 +138,7 @@ export default function BulkSourceChange({ closePopup, responseList, changeBranc
137138
<div className="dc__window-bg h-100 bcn-0 bulk-ci-trigger-container" ref={sourceChangeDetailRef}>
138139
{renderHeaderSection()}
139140
{showResponseModal ? (
140-
<SourceUpdateResponseModal closePopup={closePopup} isLoading={false} responseList={responseList} />
141+
<SourceUpdateResponseModal closePopup={closePopup} isLoading={false} responseList={responseList} skippedResources={skippedResources}/>
141142
) : (
142143
<>
143144
{renderInfoBar()}

src/components/ApplicationGroup/Details/TriggerView/EnvTriggerView.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ import {
5757
BULK_CD_RESPONSE_STATUS_TEXT,
5858
BULK_VIRTUAL_RESPONSE_STATUS,
5959
GetBranchChangeStatus,
60+
SKIPPED_RESOURCES_STATUS_TEXT,
61+
SKIPPED_RESOURCES_MESSAGE,
6062
} from '../../Constants'
6163
import { ReactComponent as DeployIcon } from '../../../../assets/icons/ic-nav-rocket.svg'
6264
import { ReactComponent as Close } from '../../../../assets/icons/ic-cross.svg'
@@ -133,6 +135,8 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
133135
const [selectAllValue, setSelectAllValue] = useState<CHECKBOX_VALUE>(CHECKBOX_VALUE.CHECKED)
134136
const [isConfigPresent, setConfigPresent] = useState<boolean>(false)
135137
const [isDefaultConfigPresent, setDefaultConfig] = useState<boolean>(false)
138+
// TODO: Add types
139+
const [skippedResources, setSkippedResources] = useState([])
136140

137141
// ref to make sure that on initial mount after we fetch workflows we handle modal based on url
138142
const handledLocation = useRef(false)
@@ -1003,6 +1007,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
10031007

10041008
const changeBranch = (value): void => {
10051009
const appIds = []
1010+
const _skippedResources = []
10061011
const appNameMap = new Map()
10071012

10081013
filteredWorkflows.forEach((wf) => {
@@ -1012,15 +1017,25 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
10121017
)
10131018
if (_ciNode) {
10141019
// Need to add check for webhook if its source type is git
1015-
if (!_ciNode.isLinkedCI && !_ciNode.isLinkedCD) {
1020+
if (!_ciNode.isLinkedCI && !_ciNode.isLinkedCD && _ciNode.type !== WorkflowNodeType.WEBHOOK) {
10161021
appIds.push(wf.appId)
10171022
appNameMap.set(wf.appId, wf.name)
10181023
}
1024+
else {
1025+
_skippedResources.push({
1026+
appId: wf.appId,
1027+
appName: wf.name,
1028+
statusText: SKIPPED_RESOURCES_STATUS_TEXT,
1029+
status: GetBranchChangeStatus(BulkResponseStatus.SKIP),
1030+
envId: +envId,
1031+
message: SKIPPED_RESOURCES_MESSAGE,
1032+
})
1033+
}
10191034
}
10201035
}
10211036
})
10221037

1023-
if (!appIds.length) {
1038+
if (!appIds.length && !_skippedResources.length) {
10241039
toast.error('No valid application present')
10251040
return
10261041
}
@@ -1040,6 +1055,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
10401055
})
10411056
})
10421057
updateResponseListData(_responseList)
1058+
setSkippedResources(_skippedResources)
10431059
setCDLoading(false)
10441060
setCILoading(false)
10451061
preventBodyScroll(false)
@@ -1168,6 +1184,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
11681184
setCDLoading(false)
11691185
setShowBulkCDModal(false)
11701186
setResponseList([])
1187+
setSkippedResources([])
11711188

11721189
history.push({
11731190
search: '',
@@ -1187,6 +1204,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
11871204
setCILoading(false)
11881205
setShowBulkCIModal(false)
11891206
setResponseList([])
1207+
setSkippedResources([])
11901208
}
11911209

11921210
const onShowBulkCIModal = () => {
@@ -1206,6 +1224,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
12061224
setIsBranchChangeLoading(false)
12071225
setShowBulkSourceChangeModal(false)
12081226
setResponseList([])
1227+
setSkippedResources([])
12091228
}
12101229

12111230
const onShowChangeSourceModal = () => {
@@ -1403,6 +1422,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
14031422
setCILoading(false)
14041423
setShowBulkCIModal(false)
14051424
setResponseList([])
1425+
setSkippedResources([])
14061426
}
14071427
}
14081428

@@ -1832,6 +1852,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
18321852
<BulkSourceChange
18331853
closePopup={hideChangeSourceModal}
18341854
responseList={responseList}
1855+
skippedResources={skippedResources}
18351856
changeBranch={changeBranch}
18361857
loading={isBranchChangeLoading}
18371858
selectedAppCount={selectedAppList.length}

src/components/ApplicationGroup/Details/TriggerView/SourceUpdateResponseModal.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from 'react'
22
import { Progressing } from '@devtron-labs/devtron-fe-common-lib'
33
import { TriggerModalRow } from './TriggerModalTableRow'
4+
import { SourceUpdateResponseModalProps } from './types'
45

5-
export default function SourceUpdateResponseModal({ closePopup, responseList, isLoading }) {
6+
export default function SourceUpdateResponseModal({ closePopup, responseList, isLoading, skippedResources=[] }: SourceUpdateResponseModalProps) {
67
const renderResponseBodySection = (): JSX.Element => {
78
if (isLoading) {
89
return <Progressing pageLoader />
@@ -17,7 +18,7 @@ export default function SourceUpdateResponseModal({ closePopup, responseList, is
1718
<div className="fs-12 fw-6 cn-7 ">Branch Change status</div>
1819
<div className="fs-12 fw-6 cn-7 ">Message</div>
1920
</div>
20-
{responseList
21+
{[...responseList, ...skippedResources]
2122
.map((response, index) => (
2223
<TriggerModalRow key={response.appId} rowData={response} index={index} />
2324
))}

src/components/ApplicationGroup/Details/TriggerView/TriggerModalTableRow.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ReactComponent as Error } from '../../../../assets/icons/ic-error-excla
44
import { ReactComponent as Success } from '../../../../assets/icons/appstatus/healthy.svg'
55
import { ReactComponent as Download } from '../../../../assets/icons/ic-arrow-line-down.svg'
66
import { ReactComponent as UnAuthorized } from '../../../../assets/icons/ic-locked.svg'
7+
import { ReactComponent as ICInfoFilled } from '../../../../assets/icons/ic-info-filled.svg'
78
import { Progressing } from '@devtron-labs/devtron-fe-common-lib'
89
import { BulkResponseStatus } from '../../Constants'
910
import { importComponentFromFELibrary } from '../../../common'
@@ -20,7 +21,9 @@ export function TriggerModalRow({ rowData, index, isVirtualEnv, envName, setDown
2021
}
2122

2223
const renderStatusIcon = (rowData: ResponseRowType): JSX.Element => {
23-
if (rowData.status === BulkResponseStatus.UNAUTHORIZE) {
24+
if (rowData.status === BulkResponseStatus.SKIP) {
25+
return <ICInfoFilled className="mr-8 icon-dim-18" />
26+
} else if (rowData.status === BulkResponseStatus.UNAUTHORIZE) {
2427
return <UnAuthorized className="mr-8 icon-dim-18 fcy-7" />
2528
} else if (rowData.status === BulkResponseStatus.PASS) {
2629
return <Success className="mr-8 icon-dim-18" />
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Legacy component with no props so setting to any
2+
export interface BulkSourceChangeProps {
3+
closePopup: any
4+
responseList: any
5+
changeBranch: any
6+
loading: any
7+
selectedAppCount: any
8+
skippedResources?: any
9+
}
10+
11+
export interface SourceUpdateResponseModalProps {
12+
closePopup: any
13+
responseList: any
14+
isLoading: any
15+
skippedResources?: any
16+
}

0 commit comments

Comments
 (0)