Skip to content

Commit 6cd239d

Browse files
committed
refactor: not rendering WebhookAddImageModal if other route based modals are opened
1 parent cffa5e3 commit 6cd239d

File tree

2 files changed

+39
-12
lines changed

2 files changed

+39
-12
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,6 +2396,22 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
23962396
setSelectedWebhookNode(null)
23972397
}
23982398

2399+
const renderWebhookAddImageModal = () => {
2400+
// Not showing modal whenever either CDMaterial, CIMaterial or LinkedCIDetails modals are open.
2401+
if (
2402+
location.search.includes('cd-node') ||
2403+
location.search.includes('rollback-node') ||
2404+
location.pathname.includes(URLS.BUILD) ||
2405+
location.pathname.includes(URLS.LINKED_CI_DETAILS) ||
2406+
!WebhookAddImageModal ||
2407+
!selectedWebhookNode
2408+
) {
2409+
return null
2410+
}
2411+
2412+
return <WebhookAddImageModal getWebhookDetails={getWebhookDetails} onClose={handleWebhookAddImageModalClose} />
2413+
}
2414+
23992415
const renderWorkflow = (): JSX.Element => {
24002416
return (
24012417
<>
@@ -2423,12 +2439,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
24232439
)
24242440
})}
24252441
<LinkedCIDetail workflows={filteredWorkflows} handleClose={handleModalClose} />
2426-
{WebhookAddImageModal && selectedWebhookNode && (
2427-
<WebhookAddImageModal
2428-
getWebhookDetails={getWebhookDetails}
2429-
onClose={handleWebhookAddImageModalClose}
2430-
/>
2431-
)}
2442+
{renderWebhookAddImageModal()}
24322443
</>
24332444
)
24342445
}

src/components/app/details/triggerView/TriggerView.tsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,27 @@ class TriggerView extends Component<TriggerViewProps, TriggerViewState> {
13651365
return null
13661366
}
13671367

1368+
renderWebhookAddImageModal() {
1369+
// Not showing modal whenever either CDMaterial, CIMaterial or LinkedCIDetails modals are open.
1370+
if (
1371+
this.props.location.search.includes('cd-node') ||
1372+
this.props.location.search.includes('rollback-node') ||
1373+
this.props.location.pathname.includes(URLS.BUILD) ||
1374+
this.props.location.pathname.includes(URLS.LINKED_CI_DETAILS) ||
1375+
!WebhookAddImageModal ||
1376+
!this.state.selectedWebhookNodeId
1377+
) {
1378+
return null
1379+
}
1380+
1381+
return (
1382+
<WebhookAddImageModal
1383+
getWebhookDetails={this.getWebhookDetails}
1384+
onClose={this.handleWebhookAddImageModalClose}
1385+
/>
1386+
)
1387+
}
1388+
13681389
handleModalClose = () => {
13691390
this.props.history.push(this.props.match.url)
13701391
}
@@ -1397,12 +1418,7 @@ class TriggerView extends Component<TriggerViewProps, TriggerViewState> {
13971418
)
13981419
})}
13991420
<LinkedCIDetail workflows={this.state.workflows} handleClose={this.handleModalClose} />
1400-
{WebhookAddImageModal && this.state.selectedWebhookNodeId && (
1401-
<WebhookAddImageModal
1402-
getWebhookDetails={this.getWebhookDetails}
1403-
onClose={this.handleWebhookAddImageModalClose}
1404-
/>
1405-
)}
1421+
{this.renderWebhookAddImageModal()}
14061422
</>
14071423
)
14081424
}

0 commit comments

Comments
 (0)