Skip to content
14 changes: 14 additions & 0 deletions src/Common/Common.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import {
GlobalVariableDTO,
GlobalVariableOptionType,
UserRole,
EnvAppsMetaDTO,
GetAppsInfoForEnvProps,
} from './Types'
import { ApiResourceType, STAGE_MAP } from '../Pages'
import { RefVariableType, VariableTypeFormat } from './CIPipeline.Types'
Expand Down Expand Up @@ -515,3 +517,15 @@ export const getGlobalVariables = async ({
throw err
}
}

export const getAppsInfoForEnv = async ({ envId, appIds }: GetAppsInfoForEnvProps): Promise<EnvAppsMetaDTO> => {
const url = getUrlWithSearchParams(`${ROUTES.ENV}/${envId}/${ROUTES.APP_METADATA}`, {
appIds: appIds?.join(),
})
const response = await get<EnvAppsMetaDTO>(url)

return {
appCount: response.result?.appCount ?? 0,
apps: response.result?.apps ?? [],
Comment thread
AbhishekA1509 marked this conversation as resolved.
Outdated
}
}
2 changes: 2 additions & 0 deletions src/Common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export const ROUTES = {
ENVIRONMENT_DATA: 'global/environment-variables',
DASHBOARD_EVENT: 'dashboard-event',
LICENSE_DATA: 'license/data',
ENV: 'env',
APP_METADATA: 'app-metadata',
} as const

export enum KEY_VALUE {
Expand Down
17 changes: 17 additions & 0 deletions src/Common/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
TargetPlatformItemDTO,
ButtonProps,
ComponentLayoutType,
StatusType,
} from '../Shared'
import {
ACTION_STATE,
Expand Down Expand Up @@ -1109,3 +1110,19 @@ export enum ActionTypes {
EDIT = 'edit',
APPROVER = 'approver',
}

export interface GetAppsInfoForEnvProps {
envId: number
appIds?: number[]
}

interface AppMeta {
appId: number
appStatus: StatusType
appName: string
}

export interface EnvAppsMetaDTO {
appCount: number
apps: AppMeta[]
}