Skip to content

Commit f92ca67

Browse files
authored
Merge pull request #708 from devtron-labs/feat/app-env-details
feat: add other app list api from fe-lib
2 parents 5c41781 + 1a36e49 commit f92ca67

File tree

11 files changed

+66
-33
lines changed

11 files changed

+66
-33
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.12.0-pre-1",
3+
"version": "1.12.0-pre-2",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Assets/Icon/ic-nav-rocket.svg

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

src/Common/Common.service.ts

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ import {
2222
sanitizeUserApprovalList,
2323
stringComparatorBySortOrder,
2424
} from '@Shared/Helpers'
25-
import {
26-
PolicyBlockInfo,
27-
RuntimeParamsAPIResponseType,
28-
RuntimePluginVariables,
29-
} from '@Shared/types'
25+
import { PolicyBlockInfo, RuntimeParamsAPIResponseType, RuntimePluginVariables } from '@Shared/types'
3026
import { GitProviderType, ROUTES } from './Constants'
3127
import { getUrlWithSearchParams, sortCallback } from './Helper'
3228
import {
@@ -49,10 +45,14 @@ import {
4945
GlobalVariableDTO,
5046
GlobalVariableOptionType,
5147
UserRole,
48+
EnvAppsMetaDTO,
49+
GetAppsInfoForEnvProps,
50+
AppMeta,
5251
} from './Types'
5352
import { ApiResourceType, STAGE_MAP } from '../Pages'
5453
import { RefVariableType, VariableTypeFormat } from './CIPipeline.Types'
5554
import { get, post } from './API'
55+
import { StatusType } from '@Shared/Components'
5656

5757
export const getTeamListMin = (): Promise<TeamList> => {
5858
// ignore active field
@@ -264,7 +264,7 @@ export const parseRuntimeParams = (response: RuntimeParamsAPIResponseType): Runt
264264
const runtimeParams = (response?.runtimePluginVariables ?? []).map<RuntimePluginVariables>((variable) => ({
265265
...variable,
266266
defaultValue: variable.value,
267-
stepVariableId: variable.stepVariableId || Math.floor(new Date().valueOf() * Math.random())
267+
stepVariableId: variable.stepVariableId || Math.floor(new Date().valueOf() * Math.random()),
268268
}))
269269

270270
runtimeParams.push(...envVariables)
@@ -515,3 +515,25 @@ export const getGlobalVariables = async ({
515515
throw err
516516
}
517517
}
518+
519+
export const getAppsInfoForEnv = async ({ envId, appIds }: GetAppsInfoForEnvProps): Promise<EnvAppsMetaDTO> => {
520+
const url = getUrlWithSearchParams(`${ROUTES.ENV}/${envId}/${ROUTES.APP_METADATA}`, {
521+
appIds: appIds?.join(),
522+
})
523+
const response = await get<EnvAppsMetaDTO>(url)
524+
525+
return {
526+
appCount: response.result?.appCount ?? 0,
527+
apps: (response.result?.apps ?? []).reduce<AppMeta[]>((agg, { appId, appName, appStatus }) => {
528+
if (!appId) {
529+
return agg
530+
}
531+
agg.push({
532+
appId,
533+
appName: appName || '',
534+
appStatus: appStatus || StatusType.UNKNOWN,
535+
})
536+
return agg
537+
}, []),
538+
}
539+
}

src/Common/Constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ export const ROUTES = {
157157
ENVIRONMENT_DATA: 'global/environment-variables',
158158
DASHBOARD_EVENT: 'dashboard-event',
159159
LICENSE_DATA: 'license/data',
160+
ENV: 'env',
161+
APP_METADATA: 'app-metadata',
160162
} as const
161163

162164
export enum KEY_VALUE {

src/Common/Types.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
TargetPlatformItemDTO,
2828
ButtonProps,
2929
ComponentLayoutType,
30+
StatusType,
3031
} from '../Shared'
3132
import {
3233
ACTION_STATE,
@@ -1109,3 +1110,19 @@ export enum ActionTypes {
11091110
EDIT = 'edit',
11101111
APPROVER = 'approver',
11111112
}
1113+
1114+
export interface GetAppsInfoForEnvProps {
1115+
envId: number
1116+
appIds?: number[]
1117+
}
1118+
1119+
export interface AppMeta {
1120+
appId: number
1121+
appStatus: StatusType
1122+
appName: string
1123+
}
1124+
1125+
export interface EnvAppsMetaDTO {
1126+
appCount: number
1127+
apps: AppMeta[]
1128+
}

src/Shared/Components/AnimatedDeployButton/AnimatedDeployButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
import { SyntheticEvent, useEffect, useRef, useState } from 'react'
1818
import { motion } from 'framer-motion'
1919

20-
import { ReactComponent as ICDeploy } from '@Icons/ic-nav-rocket.svg'
2120
import DeployAudio from '@Sounds/DeployAudio.mp3'
2221
import { ComponentSizeType } from '@Shared/constants'
2322

2423
import { Button } from '../Button'
24+
import { Icon } from '../Icon'
2525
import { AnimatedDeployButtonProps } from './types'
2626

2727
import './animatedDeployButton.scss'
@@ -83,7 +83,7 @@ const AnimatedDeployButton = ({ isVirtualEnvironment, onButtonClick }: AnimatedD
8383
: {}
8484
}
8585
>
86-
<ICDeploy className="icon-dim-16" />
86+
<Icon name="ic-rocket-launch" color={null} />
8787
</motion.div>
8888
}
8989
size={ComponentSizeType.large}

src/Shared/Components/Icon/Icon.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { ReactComponent as ICGoogle } from '@IconsV2/ic-google.svg'
5656
import { ReactComponent as ICGoogleArtifactRegistry } from '@IconsV2/ic-google-artifact-registry.svg'
5757
import { ReactComponent as ICGoogleContainerRegistry } from '@IconsV2/ic-google-container-registry.svg'
5858
import { ReactComponent as ICGridView } from '@IconsV2/ic-grid-view.svg'
59+
import { ReactComponent as ICHandPointing } from '@IconsV2/ic-hand-pointing.svg'
5960
import { ReactComponent as ICHeartGreen } from '@IconsV2/ic-heart-green.svg'
6061
import { ReactComponent as ICHeartRed } from '@IconsV2/ic-heart-red.svg'
6162
import { ReactComponent as ICHeartRedAnimated } from '@IconsV2/ic-heart-red-animated.svg'
@@ -91,6 +92,7 @@ import { ReactComponent as ICPaperPlaneColor } from '@IconsV2/ic-paper-plane-col
9192
import { ReactComponent as ICPencil } from '@IconsV2/ic-pencil.svg'
9293
import { ReactComponent as ICQuay } from '@IconsV2/ic-quay.svg'
9394
import { ReactComponent as ICQuote } from '@IconsV2/ic-quote.svg'
95+
import { ReactComponent as ICRocketLaunch } from '@IconsV2/ic-rocket-launch.svg'
9496
import { ReactComponent as ICShieldCheck } from '@IconsV2/ic-shield-check.svg'
9597
import { ReactComponent as ICSlidersVertical } from '@IconsV2/ic-sliders-vertical.svg'
9698
import { ReactComponent as ICSortAscending } from '@IconsV2/ic-sort-ascending.svg'
@@ -172,6 +174,7 @@ export const iconMap = {
172174
'ic-google-container-registry': ICGoogleContainerRegistry,
173175
'ic-google': ICGoogle,
174176
'ic-grid-view': ICGridView,
177+
'ic-hand-pointing': ICHandPointing,
175178
'ic-heart-green': ICHeartGreen,
176179
'ic-heart-red-animated': ICHeartRedAnimated,
177180
'ic-heart-red': ICHeartRed,
@@ -207,6 +210,7 @@ export const iconMap = {
207210
'ic-pencil': ICPencil,
208211
'ic-quay': ICQuay,
209212
'ic-quote': ICQuote,
213+
'ic-rocket-launch': ICRocketLaunch,
210214
'ic-shield-check': ICShieldCheck,
211215
'ic-sliders-vertical': ICSlidersVertical,
212216
'ic-sort-ascending': ICSortAscending,

0 commit comments

Comments
 (0)