Skip to content

Commit 07c18ef

Browse files
authored
Merge pull request #2095 from devtron-labs/feat/isolated-app-details
feat: update the info for airgapped env
2 parents cfb0c1f + a0fc3f3 commit 07c18ef

File tree

5 files changed

+81
-22
lines changed

5 files changed

+81
-22
lines changed

src/assets/icons/ic-camera.svg

Lines changed: 4 additions & 0 deletions
Loading

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
aggregateNodes,
3333
ArtifactInfoModal,
3434
ReleaseMode,
35+
handleUTCTime,
3536
} from '@devtron-labs/devtron-fe-common-lib'
3637
import { Link, useParams, useHistory, useRouteMatch, generatePath, Route, useLocation } from 'react-router-dom'
3738
import { toast } from 'react-toastify'
@@ -294,6 +295,7 @@ export const Details: React.FC<DetailsType> = ({
294295
const appDetailsAbortRef = useRef(null)
295296
const shouldFetchTimelineRef = useRef(false)
296297

298+
297299
const [deploymentStatusDetailsBreakdownData, setDeploymentStatusDetailsBreakdownData] =
298300
useState<DeploymentStatusDetailsBreakdownDataType>({
299301
...(isVirtualEnvRef.current && processVirtualEnvironmentDeploymentData
@@ -354,6 +356,7 @@ export const Details: React.FC<DetailsType> = ({
354356
],
355357
)
356358

359+
// This is called only when timeline modal is open
357360
const getDeploymentDetailStepsData = useCallback(
358361
(showTimeline?: boolean): void => {
359362
const shouldFetchTimeline = showTimeline ?? shouldFetchTimelineRef.current
@@ -423,7 +426,10 @@ export const Details: React.FC<DetailsType> = ({
423426
}
424427
IndexStore.publishAppDetails(appDetailsRef.current, AppType.DEVTRON_APP)
425428
setAppDetails(appDetailsRef.current)
426-
_getDeploymentStatusDetail(appDetailsRef.current.deploymentAppType)
429+
430+
const isIsolatedEnv = isVirtualEnvRef.current && !!appDetailsRef.current.resourceTree
431+
432+
_getDeploymentStatusDetail(appDetailsRef.current.deploymentAppType, isIsolatedEnv, isIsolatedEnv ? appDetailsRef.current?.resourceTree?.wfrId : null)
427433

428434
if (fetchExternalLinks && response.result?.clusterId) {
429435
getExternalLinksAndTools(response.result.clusterId)
@@ -468,13 +474,15 @@ export const Details: React.FC<DetailsType> = ({
468474
})
469475
}
470476

471-
function _getDeploymentStatusDetail(deploymentAppType: DeploymentAppTypes) {
477+
function _getDeploymentStatusDetail(deploymentAppType: DeploymentAppTypes, isIsolatedEnv: boolean, triggerIdToFetch?: number) {
472478
const shouldFetchTimeline = shouldFetchTimelineRef.current
473479

474-
getDeploymentStatusDetail(params.appId, params.envId, shouldFetchTimeline)
480+
// triggerIdToFetch represents the wfrId to fetch for any specific deployment
481+
getDeploymentStatusDetail(params.appId, params.envId, shouldFetchTimeline, triggerIdToFetch?.toString())
475482
.then((deploymentStatusDetailRes) => {
476483
if (deploymentStatusDetailRes.result) {
477-
if (deploymentAppType === DeploymentAppTypes.HELM) {
484+
// Timelines are not applicable for helm deployments and air gapped envs
485+
if (deploymentAppType === DeploymentAppTypes.HELM || isIsolatedEnv) {
478486
setDeploymentStatusDetailsBreakdownData({
479487
...deploymentStatusDetailsBreakdownData,
480488
deploymentStatus:

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

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@
1414
* limitations under the License.
1515
*/
1616

17-
// @ts-nocheck - @TODO: Remove this by fixing the type issues
18-
import React, { useEffect, useMemo, useState } from 'react'
19-
import { useParams } from 'react-router-dom'
17+
import { useEffect, useMemo, useState } from 'react'
18+
import { Link, useParams } from 'react-router-dom'
2019
import Tippy from '@tippyjs/react'
20+
import moment from 'moment'
2121
import {
2222
ConditionalWrap,
23+
DATE_TIME_FORMATS,
2324
DeploymentAppTypes,
2425
getIsManualApprovalConfigured,
26+
handleUTCTime,
2527
ReleaseMode,
2628
showError,
2729
Tooltip,
2830
} from '@devtron-labs/devtron-fe-common-lib'
31+
import { ReactComponent as ICCamera } from '@Icons/ic-camera.svg'
2932
import { URLS } from '../../../../config'
3033
import { EnvSelector } from './AppDetails'
3134
import { DeploymentAppTypeNameMapping } from '../../../../config/constantMessaging'
@@ -44,7 +47,6 @@ import { ReactComponent as RotateIcon } from '../../../../assets/icons/ic-arrows
4447
import { ReactComponent as LinkIcon } from '../../../../assets/icons/ic-link.svg'
4548
import { ReactComponent as Trash } from '../../../../assets/icons/ic-delete-dots.svg'
4649
import { ReactComponent as ScaleDown } from '../../../../assets/icons/ic-scale-down.svg'
47-
import { ConfigApplyStatusCard } from './ConfigApplyStatusCard'
4850
import HelmAppConfigApplyStatusCard from '@Components/v2/appDetails/sourceInfo/environmentStatus/HelmAppConfigApplyStatusCard'
4951

5052
const AppDetailsDownloadCard = importComponentFromFELibrary('AppDetailsDownloadCard')
@@ -83,6 +85,7 @@ export const SourceInfo = ({
8385
// helmMigratedAppNotTriggered means the app is migrated from a helm release and has not been deployed yet i.e. CD Pipeline has not been triggered
8486
const helmMigratedAppNotTriggered =
8587
appDetails?.releaseMode === ReleaseMode.MIGRATE_HELM && !appDetails?.isPipelineTriggered
88+
const isIsolatedEnv = isVirtualEnvironment && !!appDetails?.resourceTree
8689

8790
if (
8891
['progressing', 'degraded'].includes(status?.toLowerCase()) &&
@@ -167,6 +170,10 @@ export const SourceInfo = ({
167170
const renderDevtronAppsEnvironmentSelector = (environment) => {
168171
// If moving to a component then move getIsApprovalConfigured with it as well with memoization.
169172
const isApprovalConfigured = getIsApprovalConfigured()
173+
const relativeSnapshotTime = appDetails?.resourceTree?.lastSnapshotTime ? handleUTCTime(
174+
appDetails.resourceTree.lastSnapshotTime,
175+
true,
176+
) : ''
170177

171178
return (
172179
<div className="flex left w-100">
@@ -183,17 +190,42 @@ export const SourceInfo = ({
183190
}`}
184191
>
185192
<div className={`flex ${!appDetails.isVirtualEnvironment ? 'ml-16' : ''}`}>
186-
<DeploymentTypeIcon deploymentAppType={appDetails?.deploymentAppType} />
193+
{/* TODO: verify what appType needs to be passed */}
194+
<DeploymentTypeIcon deploymentAppType={appDetails?.deploymentAppType} appType={null} />
187195
</div>
188196
</Tooltip>
189197
)}
190198
{isdeploymentAppDeleting && (
191-
<div data-testid="deleteing-argocd-pipeline">
199+
<div data-testid="deleteing-argocd-pipeline" className="flex left">
192200
<Trash className="icon-dim-16 mr-8 ml-12" />
193201
<span className="cr-5 fw-6">Deleting deployment pipeline </span>
194202
<span className="dc__loading-dots cr-5" />
195203
</div>
196204
)}
205+
{/* Last snapshot time */}
206+
{isIsolatedEnv && relativeSnapshotTime && (
207+
<Tooltip
208+
content={
209+
<div className="fw-4 lh-18 flexbox-col dc__ga-2">
210+
<h6 className="fs-12 fw-6 cn-0 m-0">Last snapshot received</h6>
211+
<p className="m-0 fs-12 cn-50">
212+
{moment(appDetails.resourceTree.lastSnapshotTime).format(
213+
DATE_TIME_FORMATS.TWELVE_HOURS_FORMAT,
214+
)}
215+
</p>
216+
</div>
217+
}
218+
alwaysShowTippyOnHover
219+
>
220+
<div className="flex left">
221+
<div className="dc__divider h-20 mr-8 ml-8" />
222+
<div className="flex left dc__gap-6 px-8 py-4">
223+
<ICCamera className="scn-9 dc__no-shrink icon-dim-16" />
224+
<p className="m-0 fs-13 fw-4 lh-20 cn-9 dc__truncate">{relativeSnapshotTime}</p>
225+
</div>
226+
</div>
227+
</Tooltip>
228+
)}
197229
{!loadingResourceTree && environment && (
198230
<>
199231
{!isdeploymentAppDeleting && (
@@ -231,7 +263,7 @@ export const SourceInfo = ({
231263
<button
232264
data-testid="app-details-rotate-pods-modal-button"
233265
className="cta cta-with-img small cancel fs-12 fw-6 mr-6"
234-
onClick={setRotateModal}
266+
onClick={() => setRotateModal(true)}
235267
disabled={isApprovalConfigured}
236268
>
237269
<RotateIcon className="icon-dim-16 mr-6 icon-color-n7 scn-4" />
@@ -286,13 +318,15 @@ export const SourceInfo = ({
286318
environment && (
287319
<div className="flex left w-100">
288320
{status && (
289-
<AppStatusCard
290-
appDetails={appDetails}
291-
status={status}
292-
cardLoading={cardLoading}
293-
setDetailed={setDetailed}
294-
message={message}
295-
/>
321+
<AppStatusCard
322+
// TODO: Fix and remove
323+
// @ts-ignore
324+
appDetails={appDetails}
325+
status={status}
326+
cardLoading={cardLoading}
327+
setDetailed={setDetailed}
328+
message={message}
329+
/>
296330
)}
297331
{!helmMigratedAppNotTriggered && (
298332
<>
@@ -304,21 +338,24 @@ export const SourceInfo = ({
304338
setDetailed={setDetailed}
305339
/>
306340
)}
307-
{isVirtualEnvironment && appDetails?.resourceTree && (
341+
{isIsolatedEnv && (
308342
<HelmAppConfigApplyStatusCard
309343
cardLoading={cardLoading}
310344
releaseStatus={appDetails.resourceTree.releaseStatus}
311345
/>
312346
)}
313347
</>
314348
)}
315-
{isVirtualEnvironment && renderGeneratedManifestDownloadCard()}
349+
{isVirtualEnvironment && !isIsolatedEnv && renderGeneratedManifestDownloadCard()}
316350
{!helmMigratedAppNotTriggered && (
317351
<>
318352
<DeploymentStatusCard
319353
deploymentStatusDetailsBreakdownData={deploymentStatusDetailsBreakdownData}
320354
cardLoading={cardLoading}
321-
hideDetails={appDetails?.deploymentAppType === DeploymentAppTypes.HELM}
355+
hideDetails={
356+
appDetails?.deploymentAppType === DeploymentAppTypes.HELM ||
357+
isIsolatedEnv
358+
}
322359
isVirtualEnvironment={isVirtualEnvironment}
323360
refetchDeploymentStatus={refetchDeploymentStatus}
324361
/>

src/components/app/details/appDetails/appDetails.type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export interface SecurityVulnerabilityCardType {
232232
}
233233

234234
export interface DeployedCommitCardType {
235-
showCommitInfoDrawer: () => void
235+
showCommitInfoDrawer: (e) => void
236236
cardLoading?: boolean
237237
envId: number | string
238238
ciArtifactId: number

src/components/app/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
RuntimeParamsListItemType,
2626
RuntimeParamsTriggerPayloadType,
2727
ReleaseMode,
28+
HelmReleaseStatus,
2829
} from '@devtron-labs/devtron-fe-common-lib'
2930
import { RouteComponentProps } from 'react-router'
3031
import { AppEnvironment } from '../../services/service.types'
@@ -90,9 +91,14 @@ export interface CDModalProps {
9091
parentEnvironmentName: string
9192
ciPipelineId?: number
9293
isRedirectedFromAppDetails?: boolean
94+
deploymentUserActionState?: ACTION_STATE
9395
}
9496

9597
export interface AppDetails extends CDModalProps {
98+
appStoreChartId: number
99+
appStoreChartName: string
100+
appStoreAppVersion: string
101+
appStoreAppName: string
96102
appId: number
97103
deploymentAppType?: DeploymentAppTypes
98104
externalCi?: boolean
@@ -187,6 +193,10 @@ interface ResourceTree {
187193
status: string
188194
podMetadata: PodMetadatum[]
189195
conditions?: any
196+
releaseStatus?: HelmReleaseStatus
197+
// lastSnapshotTime and wfrId are only available for isolated
198+
lastSnapshotTime?: string
199+
wfrId?: number
190200
}
191201

192202
interface Node {

0 commit comments

Comments
 (0)