Skip to content

Commit 229b4a6

Browse files
committed
Merge branch 'main' into modal-button-click-issue
2 parents d64ce5d + 7481202 commit 229b4a6

File tree

20 files changed

+272
-128
lines changed

20 files changed

+272
-128
lines changed

config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@
2727
| CLUSTER_TERMINAL_CONNECTION_POLLING_INTERVAL | 7000 | Interval for checking connection with cluster terminal. |
2828
| LOGIN_PAGE_IMAGE | "" | Login page image url |
2929
| LOGIN_PAGE_IMAGE_BG | "" | Login page image background color code |
30+
| DEFAULT_CI_TRIGGER_TYPE_MANUAL | "false" | Change default trigger behaviour of newly created ci-pipeline to manual |
3031

3132
# DASHBOARD CONFIG SECRET

src/components/CIPipelineN/AdvancedConfigOptions.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { ReactComponent as Add } from '../../assets/icons/ic-add.svg'
44
import { ReactComponent as QuestionIcon } from '../v2/assets/icons/ic-question.svg'
55
import { ReactComponent as HelpIcon } from '../../assets/icons/ic-help.svg'
66
import CIConfig from '../ciConfig/CIConfig'
7-
import { deepEqual } from '../common'
87
import { ComponentStates } from '../EnvironmentOverride/EnvironmentOverrides.type'
98
import { AdvancedConfigOptionsProps, CIConfigParentState } from '../ciConfig/types'
109
import { DockerConfigOverrideKeys } from '../ciPipeline/types'
@@ -18,7 +17,6 @@ import { pipelineContext } from '../workflowEditor/workflowEditor'
1817

1918
export default function AdvancedConfigOptions({
2019
ciPipeline,
21-
setDockerConfigOverridden,
2220
}: AdvancedConfigOptionsProps) {
2321
const {
2422
formData,
@@ -151,9 +149,6 @@ export default function AdvancedConfigOptions({
151149

152150
// set updated form data
153151
setFormData(_form)
154-
155-
// Check for diff in global & current CI config and set isDockerConfigOverridden flag accordingly
156-
setDockerConfigOverridden(!deepEqual(_form.dockerConfigOverride, parentState.defaultDockerConfigs))
157152
}
158153

159154
const renderDockerArgs = () => {

src/components/CIPipelineN/Build.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export function Build({
1616
ciPipeline,
1717
pageState,
1818
isSecurityModuleInstalled,
19-
setDockerConfigOverridden,
2019
isJobView,
2120
getPluginData,
2221
}: BuildType) {
@@ -261,7 +260,6 @@ export function Build({
261260
{isSecurityModuleInstalled && renderScanner()}
262261
<AdvancedConfigOptions
263262
ciPipeline={ciPipeline}
264-
setDockerConfigOverridden={setDockerConfigOverridden}
265263
/>
266264
</>
267265
)}

src/components/CIPipelineN/CIPipeline.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
VisibleModal,
1515
Drawer,
1616
DeleteDialog,
17-
DockerConfigOverrideType,
1817
RefVariableType,
1918
VariableType,
2019
MandatoryPluginDataType,
@@ -179,7 +178,6 @@ export default function CIPipeline({
179178
},
180179
})
181180
const validationRules = new ValidationRules()
182-
const [isDockerConfigOverridden, setDockerConfigOverridden] = useState(false)
183181
const [mandatoryPluginData, setMandatoryPluginData] = useState<MandatoryPluginDataType>(null)
184182
const selectedBranchRef = useRef(null)
185183

@@ -285,6 +283,7 @@ export default function CIPipeline({
285283
setPageState(ViewType.LOADING)
286284
getSecurityModuleStatus()
287285
if (ciPipelineId) {
286+
// TODO: Would need to add loader for getAvailablePlugins to avoid state toggle
288287
getInitDataWithCIPipeline(appId, ciPipelineId, true)
289288
.then((ciResponse) => {
290289
const preBuildVariable = calculateLastStepDetail(
@@ -383,7 +382,10 @@ export default function CIPipeline({
383382
} catch (error) {}
384383
}
385384

386-
const getMandatoryPluginData = (_formData: PipelineFormType, pluginList: PluginDetailType[]): void => {
385+
const getMandatoryPluginData = (
386+
_formData: PipelineFormType,
387+
pluginList: PluginDetailType[],
388+
): void => {
387389
if (!isJobCard && processPluginData && prepareFormData && pluginList.length) {
388390
let branchName = ''
389391
if (_formData?.materials?.length) {
@@ -398,9 +400,7 @@ export default function CIPipeline({
398400
processPluginData(_formData, pluginList, appId, ciPipelineId, branchName)
399401
.then((response: MandatoryPluginDataType) => {
400402
setMandatoryPluginData(response)
401-
if (_formData) {
402-
setFormData(prepareFormData(_formData, response?.pluginData ?? []))
403-
}
403+
setFormData((prevForm) => prepareFormData({ ...prevForm }, response?.pluginData ?? []))
404404
})
405405
.catch((error: ServerErrors) => {
406406
showError(error)
@@ -533,11 +533,6 @@ export default function CIPipeline({
533533

534534
const msg = ciPipeline.id ? 'Pipeline Updated' : 'Pipeline Created'
535535

536-
// Reset allow override flag to false if config matches with global
537-
if (!ciPipeline.isDockerConfigOverridden && !isDockerConfigOverridden) {
538-
formData.isDockerConfigOverridden = false
539-
formData.dockerConfigOverride = {} as DockerConfigOverrideType
540-
}
541536
//here we check for the case where the pipeline is multigit and user selects pullrequest or tag creation(webhook)
542537
//in that case we only send the webhook data not the other one.
543538
let _materials = formData.materials
@@ -813,7 +808,6 @@ export default function CIPipeline({
813808
isAdvanced={isAdvanced}
814809
ciPipeline={ciPipeline}
815810
isSecurityModuleInstalled={isSecurityModuleInstalled}
816-
setDockerConfigOverridden={setDockerConfigOverridden}
817811
isJobView={isJobCard}
818812
getPluginData={getPluginData}
819813
/>

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

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
showError,
44
Progressing,
55
ConfirmationDialog,
6-
Host,
76
noop,
87
stopPropagation,
98
multiSelectStyles,
@@ -24,7 +23,7 @@ import {
2423
HELM_DEPLOYMENT_STATUS_TEXT,
2524
RESOURCES_NOT_FOUND,
2625
} from '../../../../config'
27-
import { NavigationArrow, useAppContext, useEventSource, FragmentHOC, ScanDetailsModal } from '../../../common'
26+
import { NavigationArrow, useAppContext, FragmentHOC, ScanDetailsModal } from '../../../common'
2827
import { CustomValueContainer, groupHeaderStyle, GroupHeading, Option } from './../../../v2/common/ReactSelect.utils'
2928
import {
3029
getAppConfigStatus,
@@ -139,8 +138,10 @@ export default function AppDetail({ filteredEnvIds }: { filteredEnvIds?: string
139138

140139
// Set the URL and push to navigation stack
141140
if (selectedEnvId) {
142-
const newUrl = getAppDetailsURL(params.appId, selectedEnvId)
143-
push(newUrl)
141+
if (String(selectedEnvId) !== String(params.envId)) {
142+
const newUrl = getAppDetailsURL(params.appId, selectedEnvId)
143+
push(newUrl)
144+
}
144145
} else {
145146
setEnvironmentId(null)
146147
}
@@ -224,7 +225,8 @@ export const Details: React.FC<DetailsType> = ({
224225
}) => {
225226
const params = useParams<{ appId: string; envId: string }>()
226227
const location = useLocation()
227-
const [streamData, setStreamData] = useState<AppStreamData>(null)
228+
// fixme: the state is not being set anywhere and just being drilled down
229+
const [streamData] = useState<AppStreamData>(null)
228230
const [detailedStatus, toggleDetailedStatus] = useState<boolean>(false)
229231
const [resourceTreeFetchTimeOut, setResourceTreeFetchTimeOut] = useState<boolean>(false)
230232
const [urlInfo, setUrlInfo] = useState<boolean>(false)
@@ -246,13 +248,15 @@ export const Details: React.FC<DetailsType> = ({
246248
})
247249
const [loadingDetails, setLoadingDetails] = useState(true)
248250
const [loadingResourceTree, setLoadingResourceTree] = useState(true)
251+
// State to track the loading state for the timeline data when the detailed status modal opens
252+
const [isInitialTimelineDataLoading, setIsInitialTimelineDataLoading] = useState(true)
249253
const [errorsList, setErrorsList] = useState<ErrorItem[]>([])
250254
const appDetailsRef = useRef(null)
251255
const appDetailsRequestRef = useRef(null)
252-
const deploymentModalShownRef = useRef(false)
253256
const { envId } = useParams<{ appId: string; envId?: string }>()
254257
const pollResourceTreeRef = useRef(true)
255258
const appDetailsAbortRef = useRef(null)
259+
const shouldFetchTimelineRef = useRef(false)
256260

257261
const [deploymentStatusDetailsBreakdownData, setDeploymentStatusDetailsBreakdownData] =
258262
useState<DeploymentStatusDetailsBreakdownDataType>({
@@ -267,26 +271,18 @@ export const Details: React.FC<DetailsType> = ({
267271
const interval = window._env_.DEVTRON_APP_DETAILS_POLLING_INTERVAL || 30000
268272
appDetailsRequestRef.current = appDetails?.deploymentAppDeleteRequest
269273

270-
const syncSSE = useEventSource(
271-
`${Host}/api/v1/applications/stream?name=${appDetails?.appName}-${appDetails?.environmentName}`,
272-
[params.appId, params.envId],
273-
appDetails &&
274-
!!appDetails.appName &&
275-
!!appDetails.environmentName &&
276-
appDetails.deploymentAppType !== DeploymentAppTypes.HELM,
277-
(event) => setStreamData(JSON.parse(event.data)),
278-
)
279-
280274
const aggregatedNodes: AggregatedNodes = useMemo(() => {
281275
return aggregateNodes(appDetails?.resourceTree?.nodes || [], appDetails?.resourceTree?.podMetadata || [])
282276
}, [appDetails])
283277

284278
useEffect(() => {
285-
if (location.search.includes(DEPLOYMENT_STATUS_QUERY_PARAM)) {
286-
deploymentModalShownRef.current = true
287-
} else {
288-
deploymentModalShownRef.current = false
279+
const isModalOpen = location.search.includes(DEPLOYMENT_STATUS_QUERY_PARAM)
280+
// Reset the loading state when the modal is closed
281+
if (shouldFetchTimelineRef.current && !isModalOpen) {
282+
setIsInitialTimelineDataLoading(true)
289283
}
284+
// The timeline should be fetched by default if the modal is open
285+
shouldFetchTimelineRef.current = isModalOpen
290286
}, [location.search])
291287

292288
const clearDeploymentStatusTimer = useCallback((): void => {
@@ -304,15 +300,6 @@ export const Details: React.FC<DetailsType> = ({
304300

305301
clearDeploymentStatusTimer()
306302

307-
if (
308-
processedDeploymentStatusDetailsData.deploymentStatus === DEPLOYMENT_STATUS.HEALTHY ||
309-
processedDeploymentStatusDetailsData.deploymentStatus === DEPLOYMENT_STATUS.TIMED_OUT ||
310-
processedDeploymentStatusDetailsData.deploymentStatus === DEPLOYMENT_STATUS.SUPERSEDED ||
311-
processedDeploymentStatusDetailsData.deploymentStatus === DEPLOYMENT_STATUS.SUCCEEDED
312-
) {
313-
deploymentModalShownRef.current = false
314-
}
315-
316303
if (processedDeploymentStatusDetailsData.deploymentStatus === DEPLOYMENT_STATUS.INPROGRESS) {
317304
deploymentStatusTimer = setTimeout(() => {
318305
getDeploymentDetailStepsData()
@@ -327,24 +314,29 @@ export const Details: React.FC<DetailsType> = ({
327314
processDeploymentStatusDetailsData,
328315
clearDeploymentStatusTimer,
329316
DEPLOYMENT_STATUS,
330-
deploymentModalShownRef,
331317
setDeploymentStatusDetailsBreakdownData,
332318
],
333319
)
334320

335321
const getDeploymentDetailStepsData = useCallback(
336322
(showTimeline?: boolean): void => {
323+
const shouldFetchTimeline = showTimeline ?? shouldFetchTimelineRef.current
324+
337325
// Deployments status details for Devtron apps
338-
getDeploymentStatusDetail(params.appId, params.envId, showTimeline ?? deploymentModalShownRef.current).then(
326+
getDeploymentStatusDetail(params.appId, params.envId, shouldFetchTimeline).then(
339327
(deploymentStatusDetailRes) => {
340328
processDeploymentStatusData(deploymentStatusDetailRes.result)
329+
// Update the loading status if the modal is open
330+
if (shouldFetchTimeline) {
331+
setIsInitialTimelineDataLoading(false)
332+
}
341333
},
342334
)
343335
},
344336
[
345337
params.appId,
346338
params.envId,
347-
deploymentModalShownRef.current,
339+
shouldFetchTimelineRef.current,
348340
getDeploymentStatusDetail,
349341
processDeploymentStatusData,
350342
],
@@ -437,7 +429,9 @@ export const Details: React.FC<DetailsType> = ({
437429
}
438430

439431
function _getDeploymentStatusDetail(deploymentAppType: DeploymentAppTypes) {
440-
getDeploymentStatusDetail(params.appId, params.envId, deploymentModalShownRef.current)
432+
const shouldFetchTimeline = shouldFetchTimelineRef.current
433+
434+
getDeploymentStatusDetail(params.appId, params.envId, shouldFetchTimeline)
441435
.then((deploymentStatusDetailRes) => {
442436
if (deploymentStatusDetailRes.result) {
443437
if (deploymentAppType === DeploymentAppTypes.HELM) {
@@ -456,6 +450,9 @@ export const Details: React.FC<DetailsType> = ({
456450
} else {
457451
processDeploymentStatusData(deploymentStatusDetailRes.result)
458452
}
453+
if (shouldFetchTimeline) {
454+
setIsInitialTimelineDataLoading(false)
455+
}
459456
}
460457
})
461458
.catch(noop)
@@ -687,6 +684,7 @@ export const Details: React.FC<DetailsType> = ({
687684
streamData={streamData}
688685
deploymentStatusDetailsBreakdownData={deploymentStatusDetailsBreakdownData}
689686
isVirtualEnvironment={isVirtualEnvRef.current}
687+
isLoading={isInitialTimelineDataLoading}
690688
/>
691689
)}
692690
{showScanDetailsModal && (

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ export default function DeploymentStatusDetailBreakdown({
4646
type={TIMELINE_STATUS.GIT_COMMIT}
4747
deploymentDetailedData={deploymentStatusDetailsBreakdownData}
4848
/>
49+
50+
<ErrorInfoStatusBar
51+
type={TIMELINE_STATUS.ARGOCD_SYNC}
52+
nonDeploymentError={deploymentStatusDetailsBreakdownData.nonDeploymentError}
53+
errorMessage={deploymentStatusDetailsBreakdownData.deploymentError}
54+
/>
55+
<DeploymentStatusDetailRow
56+
type={TIMELINE_STATUS.ARGOCD_SYNC}
57+
deploymentDetailedData={deploymentStatusDetailsBreakdownData}
58+
/>
59+
4960
<ErrorInfoStatusBar
5061
type={TIMELINE_STATUS.KUBECTL_APPLY}
5162
nonDeploymentError={deploymentStatusDetailsBreakdownData.nonDeploymentError}
@@ -55,6 +66,7 @@ export default function DeploymentStatusDetailBreakdown({
5566
type={TIMELINE_STATUS.KUBECTL_APPLY}
5667
deploymentDetailedData={deploymentStatusDetailsBreakdownData}
5768
/>
69+
5870
<DeploymentStatusDetailRow
5971
type={TIMELINE_STATUS.APP_HEALTH}
6072
hideVerticalConnector={true}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ function DeploymentStatusCard({
8787

8888
const onClickLastDeploymentStatus = (e) => {
8989
if (!hideDetails) {
90-
refetchDeploymentStatus(true)
9190
showDeploymentDetailedStatus(e)
91+
refetchDeploymentStatus(true)
9292
}
9393
}
9494

0 commit comments

Comments
 (0)