Skip to content

Commit 2eda4f5

Browse files
committed
feat: add skipped status for build image
1 parent 48385e0 commit 2eda4f5

File tree

4 files changed

+38
-23
lines changed

4 files changed

+38
-23
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ReactComponent as Warn } from '../../../../assets/icons/ic-warning.svg'
55
import SourceUpdateResponseModal from './SourceUpdateResponseModal'
66
import { BulkSourceChangeProps } from './types'
77

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

1111
const [showResponseModal, setShowResponseModal] = useState(false)
@@ -47,7 +47,7 @@ export default function BulkSourceChange({ closePopup, responseList, changeBranc
4747
}, [outsideClickHandler])
4848

4949
useEffect(() => {
50-
setShowResponseModal(responseList.length > 0 || skippedResources.length > 0)
50+
setShowResponseModal(responseList.length > 0)
5151
}, [responseList])
5252

5353
const updateBranch = () => {
@@ -138,7 +138,7 @@ export default function BulkSourceChange({ closePopup, responseList, changeBranc
138138
<div className="dc__window-bg h-100 bcn-0 bulk-ci-trigger-container" ref={sourceChangeDetailRef}>
139139
{renderHeaderSection()}
140140
{showResponseModal ? (
141-
<SourceUpdateResponseModal closePopup={closePopup} isLoading={false} responseList={responseList} skippedResources={skippedResources}/>
141+
<SourceUpdateResponseModal closePopup={closePopup} isLoading={false} responseList={responseList}/>
142142
) : (
143143
<>
144144
{renderInfoBar()}

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

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
135135
const [selectAllValue, setSelectAllValue] = useState<CHECKBOX_VALUE>(CHECKBOX_VALUE.CHECKED)
136136
const [isConfigPresent, setConfigPresent] = useState<boolean>(false)
137137
const [isDefaultConfigPresent, setDefaultConfig] = useState<boolean>(false)
138-
// TODO: Add types
139-
const [skippedResources, setSkippedResources] = useState([])
138+
const [skippedResources, setSkippedResources] = useState<ResponseRowType[]>([])
140139

141140
// ref to make sure that on initial mount after we fetch workflows we handle modal based on url
142141
const handledLocation = useRef(false)
@@ -1005,6 +1004,10 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
10051004
setFilteredWorkflows(_workflows)
10061005
}
10071006

1007+
const isBuildAndBranchTriggerAllowed = (node: NodeAttr): boolean => (
1008+
!node.isLinkedCI && !node.isLinkedCD && node.type !== WorkflowNodeType.WEBHOOK
1009+
)
1010+
10081011
const changeBranch = (value): void => {
10091012
const appIds = []
10101013
const _skippedResources = []
@@ -1016,8 +1019,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
10161019
(node) => node.type === WorkflowNodeType.CI || node.type === WorkflowNodeType.WEBHOOK,
10171020
)
10181021
if (_ciNode) {
1019-
// Need to add check for webhook if its source type is git
1020-
if (!_ciNode.isLinkedCI && !_ciNode.isLinkedCD && _ciNode.type !== WorkflowNodeType.WEBHOOK) {
1022+
if (isBuildAndBranchTriggerAllowed(_ciNode)) {
10211023
appIds.push(wf.appId)
10221024
appNameMap.set(wf.appId, wf.name)
10231025
}
@@ -1026,7 +1028,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
10261028
appId: wf.appId,
10271029
appName: wf.name,
10281030
statusText: SKIPPED_RESOURCES_STATUS_TEXT,
1029-
status: GetBranchChangeStatus(BulkResponseStatus.SKIP),
1031+
status: BulkResponseStatus.SKIP,
10301032
envId: +envId,
10311033
message: SKIPPED_RESOURCES_MESSAGE,
10321034
})
@@ -1039,7 +1041,8 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
10391041
toast.error('No valid application present')
10401042
return
10411043
}
1042-
1044+
1045+
setSkippedResources(_skippedResources)
10431046
setIsBranchChangeLoading(true)
10441047
triggerBranchChange(appIds, +envId, value)
10451048
.then((response: any) => {
@@ -1055,13 +1058,13 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
10551058
})
10561059
})
10571060
updateResponseListData(_responseList)
1058-
setSkippedResources(_skippedResources)
10591061
setCDLoading(false)
10601062
setCILoading(false)
10611063
preventBodyScroll(false)
10621064
})
10631065
.catch((error) => {
10641066
showError(error)
1067+
setSkippedResources([])
10651068
})
10661069
.finally(() => {
10671070
setIsBranchChangeLoading(false)
@@ -1422,7 +1425,6 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
14221425
setCILoading(false)
14231426
setShowBulkCIModal(false)
14241427
setResponseList([])
1425-
setSkippedResources([])
14261428
}
14271429
}
14281430

@@ -1446,18 +1448,28 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
14461448
ReactGA.event(ENV_TRIGGER_VIEW_GA_EVENTS.BulkCITriggered)
14471449
setCILoading(true)
14481450
let node
1451+
const _skippedResources = []
14491452
const nodeList: NodeAttr[] = [],
14501453
triggeredAppList: { appId: number; appName: string }[] = []
14511454
for (const _wf of filteredWorkflows) {
14521455
if (_wf.isSelected && (!appsToRetry || appsToRetry[_wf.appId])) {
14531456
node = _wf.nodes.find((node) => {
1454-
return node.type === WorkflowNodeType.CI
1457+
return node.type === WorkflowNodeType.CI || node.type === WorkflowNodeType.WEBHOOK
14551458
})
1456-
// Maybe we dont need to push webhook as well
1457-
if (node && !node.isLinkedCI && !node.isLinkedCD) {
1459+
1460+
if (node && isBuildAndBranchTriggerAllowed(node)) {
14581461
triggeredAppList.push({ appId: _wf.appId, appName: _wf.name })
14591462
nodeList.push(node)
14601463
}
1464+
else if (node && !isBuildAndBranchTriggerAllowed(node)){
1465+
_skippedResources.push({
1466+
appId: _wf.appId,
1467+
appName: _wf.name,
1468+
statusText: SKIPPED_RESOURCES_STATUS_TEXT,
1469+
status: BulkResponseStatus.SKIP,
1470+
message: SKIPPED_RESOURCES_MESSAGE,
1471+
})
1472+
}
14611473
}
14621474
}
14631475
const _CITriggerPromiseList = []
@@ -1499,12 +1511,17 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
14991511
}
15001512
_CITriggerPromiseList.push(triggerCINode(payload))
15011513
})
1502-
if (!_CITriggerPromiseList.length) {
1514+
1515+
if (!_CITriggerPromiseList.length && !appsToRetry && !_skippedResources.length) {
15031516
toast.error('No valid CI pipeline found')
15041517
setCDLoading(false)
15051518
setCILoading(false)
15061519
return
15071520
}
1521+
if (!appsToRetry) {
1522+
setSkippedResources(_skippedResources)
1523+
}
1524+
15081525
handleBulkTrigger(_CITriggerPromiseList, triggeredAppList, WorkflowNodeType.CI)
15091526
}
15101527

@@ -1836,7 +1853,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
18361853
webhookPayloads={webhookPayloads}
18371854
isWebhookPayloadLoading={isWebhookPayloadLoading}
18381855
isShowRegexModal={isShowRegexModal}
1839-
responseList={responseList}
1856+
responseList={[...responseList, ...skippedResources]}
18401857
isLoading={isCILoading}
18411858
setLoading={setCILoading}
18421859
/>
@@ -1851,8 +1868,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
18511868
return (
18521869
<BulkSourceChange
18531870
closePopup={hideChangeSourceModal}
1854-
responseList={responseList}
1855-
skippedResources={skippedResources}
1871+
responseList={[...responseList, ...skippedResources]}
18561872
changeBranch={changeBranch}
18571873
loading={isBranchChangeLoading}
18581874
selectedAppCount={selectedAppList.length}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Progressing } from '@devtron-labs/devtron-fe-common-lib'
33
import { TriggerModalRow } from './TriggerModalTableRow'
44
import { SourceUpdateResponseModalProps } from './types'
55

6-
export default function SourceUpdateResponseModal({ closePopup, responseList, isLoading, skippedResources=[] }: SourceUpdateResponseModalProps) {
6+
export default function SourceUpdateResponseModal({ closePopup, responseList, isLoading }: SourceUpdateResponseModalProps) {
77
const renderResponseBodySection = (): JSX.Element => {
88
if (isLoading) {
99
return <Progressing pageLoader />
@@ -18,14 +18,15 @@ export default function SourceUpdateResponseModal({ closePopup, responseList, is
1818
<div className="fs-12 fw-6 cn-7 ">Branch Change status</div>
1919
<div className="fs-12 fw-6 cn-7 ">Message</div>
2020
</div>
21-
{[...responseList, ...skippedResources]
21+
{responseList
2222
.map((response, index) => (
2323
<TriggerModalRow key={response.appId} rowData={response} index={index} />
2424
))}
2525
</div>
2626
)
2727
}
2828

29+
// ASK: Why there is no retry button for failed request?
2930
const renderFooterSection = (): JSX.Element => {
3031
return (
3132
<div
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
// Legacy component with no props so setting to any
1+
// Legacy components with no props so setting to any
22
export interface BulkSourceChangeProps {
33
closePopup: any
44
responseList: any
55
changeBranch: any
66
loading: any
77
selectedAppCount: any
8-
skippedResources?: any
98
}
109

1110
export interface SourceUpdateResponseModalProps {
1211
closePopup: any
1312
responseList: any
1413
isLoading: any
15-
skippedResources?: any
1614
}

0 commit comments

Comments
 (0)