Skip to content

Commit d7057fe

Browse files
authored
Merge pull request #2788 from devtron-labs/feat/generic-description-empty
chore: sync main
2 parents f6b2416 + e2e8dea commit d7057fe

File tree

11 files changed

+133
-157
lines changed

11 files changed

+133
-157
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "1.15.3-pre-4",
7+
"@devtron-labs/devtron-fe-common-lib": "1.16.0-pre-0",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ const ClusterForm = ({
422422
setRemoteConnectionFalse()
423423
setTlsConnectionFalse()
424424
reload()
425-
hideEditModal()
425+
if (typeof hideEditModal === 'function') hideEditModal()
426426
} catch (err) {
427427
showError(err)
428428
} finally {

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,9 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
14421442
}
14431443

14441444
// Helper to get selected CD nodes
1445-
const getSelectedCDNodesWithArtifacts = (selectedWorkflows: WorkflowType[]): { node: CommonNodeAttr; wf: WorkflowType }[] =>
1445+
const getSelectedCDNodesWithArtifacts = (
1446+
selectedWorkflows: WorkflowType[],
1447+
): { node: CommonNodeAttr; wf: WorkflowType }[] =>
14461448
selectedWorkflows
14471449
.filter((wf) => wf.isSelected)
14481450
.map((wf) => {
@@ -1452,7 +1454,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
14521454
if (!_cdNode) return null
14531455

14541456
const _selectedNode: CommonNodeAttr | undefined = getSelectedCDNode(bulkTriggerType, _cdNode)
1455-
1457+
14561458
const selectedArtifacts = _selectedNode?.[materialType]?.filter((artifact) => artifact.isSelected) ?? []
14571459
if (selectedArtifacts.length > 0) {
14581460
return { node: _selectedNode, wf }
@@ -1499,7 +1501,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
14991501
const strategy = pipelineIdVsStrategyMap[pipelineId]
15001502

15011503
// skip app if bulkDeploymentStrategy is not default and strategy is not configured for app
1502-
if (ciArtifact && (bulkDeploymentStrategy === 'DEFAULT' || !!strategy)) {
1504+
if (ciArtifact && (bulkDeploymentStrategy === 'DEFAULT' || !!strategy)) {
15031505
_CDTriggerPromiseFunctionList.push(() =>
15041506
triggerCDNode({
15051507
pipelineId,
@@ -2094,7 +2096,9 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
20942096

20952097
const { uniqueReleaseTags } = bulkCDDetailTypeResponse
20962098

2097-
const feasiblePipelineIds = new Set(getSelectedCDNodesWithArtifacts(filteredWorkflows).map(({ node }) => +node.id))
2099+
const feasiblePipelineIds = new Set(
2100+
getSelectedCDNodesWithArtifacts(filteredWorkflows).map(({ node }) => +node.id),
2101+
)
20982102

20992103
// Have to look for its each prop carefully
21002104
// No need to send uniqueReleaseTags will get those in BulkCDTrigger itself
@@ -2117,7 +2121,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
21172121
setRuntimeParamsErrorState={setRuntimeParamsErrorState}
21182122
bulkDeploymentStrategy={bulkDeploymentStrategy}
21192123
setBulkDeploymentStrategy={setBulkDeploymentStrategy}
2120-
/>
2124+
/>
21212125
)
21222126
}
21232127

src/components/app/details/appDetails/AppDetails.tsx

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
getAppDetailsURL,
3333
getAppsInfoForEnv,
3434
getIsRequestAborted,
35+
handleAnalyticsEvent,
3536
Icon,
3637
MODAL_TYPE,
3738
noop,
@@ -51,6 +52,7 @@ import { ReactComponent as ForwardArrow } from '@Icons/ic-arrow-forward.svg'
5152
import { ReactComponent as Trash } from '@Icons/ic-delete-dots.svg'
5253
import AppNotConfiguredIcon from '@Images/app-not-configured.png'
5354
import noGroups from '@Images/[email protected]'
55+
import { URL_PARAM_MODE_TYPE } from '@Components/common/helpers/types'
5456

5557
import {
5658
DEFAULT_STATUS,
@@ -78,6 +80,7 @@ import { TriggerUrlModal } from '../../list/TriggerUrl'
7880
import { fetchAppDetailsInTime, fetchResourceTreeInTime } from '../../service'
7981
import { AggregatedNodes } from '../../types'
8082
import { renderCIListHeader } from '../cdDetails/utils'
83+
import { MATERIAL_TYPE } from '../triggerView/types'
8184
import AppEnvSelector from './AppDetails.components'
8285
import { getDeploymentStatusDetail } from './appDetails.service'
8386
import {
@@ -87,7 +90,7 @@ import {
8790
ErrorItem,
8891
HibernationModalTypes,
8992
} from './appDetails.type'
90-
import AppDetailsCDButton from './AppDetailsCDButton'
93+
import AppDetailsCDModal from './AppDetailsCDModal'
9194
import { AppMetrics } from './AppMetrics'
9295
import { AG_APP_DETAILS_GA_EVENTS, DA_APP_DETAILS_GA_EVENTS } from './constants'
9396
import HibernateModal from './HibernateModal'
@@ -207,7 +210,7 @@ const Details: React.FC<DetailsType> = ({
207210
}) => {
208211
const params = useParams<{ appId: string; envId: string }>()
209212
const location = useLocation()
210-
const { replace } = useHistory()
213+
const { replace, push } = useHistory()
211214
const { path, url } = useRouteMatch()
212215

213216
const { setAIAgentContext } = useMainContext()
@@ -232,6 +235,7 @@ const Details: React.FC<DetailsType> = ({
232235
const [rotateModal, setRotateModal] = useState<boolean>(false)
233236
const [hibernating, setHibernating] = useState<boolean>(false)
234237
const [showIssuesModal, toggleIssuesModal] = useState<boolean>(false)
238+
const [CDModalMaterialType, setCDModalMaterialType] = useState<string | null>(null)
235239
const [appDetailsError, setAppDetailsError] = useState(undefined)
236240

237241
const [hibernationPatchChartName, setHibernationPatchChartName] = useState<string>('')
@@ -541,9 +545,45 @@ const Details: React.FC<DetailsType> = ({
541545
setShowAppStatusModal(true)
542546
}
543547

544-
const renderSelectImageButton = () =>
545-
appDetails && (
546-
<AppDetailsCDButton
548+
const handleOpenCDModal = (isForRollback?: boolean) => () => {
549+
push({
550+
search: new URLSearchParams({
551+
mode: URL_PARAM_MODE_TYPE.LIST,
552+
}).toString(),
553+
})
554+
setCDModalMaterialType(isForRollback ? MATERIAL_TYPE.rollbackMaterialList : MATERIAL_TYPE.inputMaterialList)
555+
556+
if (isForRollback) {
557+
handleAnalyticsEvent(
558+
isAppView
559+
? DA_APP_DETAILS_GA_EVENTS.RollbackButtonClicked
560+
: AG_APP_DETAILS_GA_EVENTS.RollbackButtonClicked,
561+
)
562+
return
563+
}
564+
handleAnalyticsEvent(
565+
isAppView ? DA_APP_DETAILS_GA_EVENTS.DeployButtonClicked : AG_APP_DETAILS_GA_EVENTS.DeployButtonClicked,
566+
)
567+
}
568+
569+
const handleCloseCDModal = () => {
570+
setCDModalMaterialType(null)
571+
push({ search: '' })
572+
}
573+
574+
const renderSelectImageButton = () => (
575+
<Button
576+
dataTestId="select-image-to-deploy"
577+
startIcon={<Icon name="ic-hand-pointing" color={null} />}
578+
text="Select Image to deploy"
579+
onClick={handleOpenCDModal()}
580+
/>
581+
)
582+
583+
const renderCDModal = () =>
584+
appDetails &&
585+
CDModalMaterialType && (
586+
<AppDetailsCDModal
547587
appId={appDetails.appId}
548588
environmentId={appDetails.environmentId}
549589
environmentName={appDetails.environmentName}
@@ -558,16 +598,8 @@ const Details: React.FC<DetailsType> = ({
558598
triggerType: appDetails.triggerType,
559599
}}
560600
handleSuccess={callAppDetailsAPI}
561-
gaEvent={
562-
isAppView
563-
? DA_APP_DETAILS_GA_EVENTS.DeployButtonClicked
564-
: AG_APP_DETAILS_GA_EVENTS.DeployButtonClicked
565-
}
566-
buttonProps={{
567-
dataTestId: 'select-image-to-deploy',
568-
startIcon: <Icon name="ic-hand-pointing" color={null} />,
569-
text: 'Select Image to deploy',
570-
}}
601+
materialType={CDModalMaterialType}
602+
closeCDModal={handleCloseCDModal}
571603
/>
572604
)
573605

@@ -598,12 +630,15 @@ const Details: React.FC<DetailsType> = ({
598630
showApplicationDetailedModal={showApplicationDetailedModal}
599631
/>
600632
) : (
601-
<AppNotConfigured
602-
image={noGroups}
603-
title={ERROR_EMPTY_SCREEN.ALL_SET_GO_CONFIGURE}
604-
subtitle={ERROR_EMPTY_SCREEN.DEPLOYEMENT_WILL_BE_HERE}
605-
renderCustomButton={renderSelectImageButton}
606-
/>
633+
<>
634+
<AppNotConfigured
635+
image={noGroups}
636+
title={ERROR_EMPTY_SCREEN.ALL_SET_GO_CONFIGURE}
637+
subtitle={ERROR_EMPTY_SCREEN.DEPLOYEMENT_WILL_BE_HERE}
638+
renderCustomButton={renderSelectImageButton}
639+
/>
640+
{renderCDModal()}
641+
</>
607642
)}
608643
</>
609644
)
@@ -705,6 +740,7 @@ const Details: React.FC<DetailsType> = ({
705740
setHibernationPatchChartName={setHibernationPatchChartName}
706741
applications={applications}
707742
isResourceTreeReloading={isReloadResourceTreeInProgress}
743+
handleOpenCDModal={handleOpenCDModal}
708744
/>
709745
</div>
710746
{!loadingDetails && !loadingResourceTree && !appDetails?.deploymentAppDeleteRequest && (
@@ -774,6 +810,7 @@ const Details: React.FC<DetailsType> = ({
774810
)}
775811
{appDetails && !!hibernateConfirmationModal && renderHibernateModal()}
776812
{rotateModal && renderRestartWorkload()}
813+
{renderCDModal()}
777814
</>
778815
)
779816
}

src/components/app/details/appDetails/AppDetailsCDButton.tsx renamed to src/components/app/details/appDetails/AppDetailsCDModal.tsx

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

17-
import React from 'react'
18-
import ReactGA from 'react-ga4'
1917
import { useHistory, useLocation } from 'react-router-dom'
2018

21-
import {
22-
Button,
23-
DeploymentNodeType,
24-
stopPropagation,
25-
useSearchString,
26-
VisibleModal,
27-
} from '@devtron-labs/devtron-fe-common-lib'
19+
import { DeploymentNodeType, stopPropagation, VisibleModal } from '@devtron-labs/devtron-fe-common-lib'
2820

2921
import { importComponentFromFELibrary } from '../../../common'
3022
import { URL_PARAM_MODE_TYPE } from '../../../common/helpers/types'
3123
import { getModuleInfo } from '../../../v2/devtronStackManager/DevtronStackManager.service'
32-
import { AppDetailsCDButtonType } from '../../types'
24+
import { AppDetailsCDModalType } from '../../types'
3325
import CDMaterial from '../triggerView/cdMaterial'
3426
import { TRIGGER_VIEW_PARAMS } from '../triggerView/Constants'
35-
import { MATERIAL_TYPE } from '../triggerView/types'
3627

3728
const ApprovalMaterialModal = importComponentFromFELibrary('ApprovalMaterialModal')
3829

39-
const AppDetailsCDButton = ({
30+
const AppDetailsCDModal = ({
4031
appId,
4132
appName,
4233
environmentId,
@@ -46,40 +37,14 @@ const AppDetailsCDButton = ({
4637
loadingDetails,
4738
environmentName,
4839
handleSuccess,
49-
isForRollback = false,
50-
buttonProps,
51-
gaEvent,
52-
}: AppDetailsCDButtonType): JSX.Element => {
40+
materialType,
41+
closeCDModal,
42+
}: AppDetailsCDModalType): JSX.Element => {
5343
const history = useHistory()
54-
const { searchParams } = useSearchString()
5544
const location = useLocation()
5645
const queryParams = new URLSearchParams(location.search)
5746
const mode = queryParams.get('mode')
5847

59-
// deriving from URL and not props as on app details multiple instances exist, but we are rendering only one at a time
60-
const materialType = queryParams.get('materialType')
61-
62-
const onClickDeployButton = (event) => {
63-
stopPropagation(event)
64-
const newParams = {
65-
...searchParams,
66-
mode: URL_PARAM_MODE_TYPE.LIST,
67-
// setting materialType from props acc to rollback or input material list
68-
materialType: isForRollback ? MATERIAL_TYPE.rollbackMaterialList : MATERIAL_TYPE.inputMaterialList,
69-
}
70-
71-
history.push({
72-
search: new URLSearchParams(newParams).toString(),
73-
})
74-
75-
ReactGA.event(gaEvent)
76-
}
77-
78-
const closeCDModal = (e: React.MouseEvent): void => {
79-
stopPropagation(e)
80-
history.push({ search: '' })
81-
}
82-
8348
const node = {
8449
environmentName,
8550
parentEnvironmentName: cdModal.parentEnvironmentName,
@@ -131,10 +96,9 @@ const AppDetailsCDButton = ({
13196

13297
return (
13398
<>
134-
<Button {...buttonProps} onClick={onClickDeployButton} />
13599
{renderCDModal()}
136100
{renderApprovalMaterial()}
137101
</>
138102
)
139103
}
140-
export default AppDetailsCDButton
104+
export default AppDetailsCDModal

0 commit comments

Comments
 (0)