Skip to content

Commit

Permalink
Merge branch 'main' of github.com:devtron-labs/devtron-fe-common-lib …
Browse files Browse the repository at this point in the history
…into chore/main-to-dev-sync-rc-26
  • Loading branch information
eshankvaish committed Jan 3, 2025
2 parents dd65fc6 + 82caa5f commit 3cd8c50
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtron-labs/devtron-fe-common-lib",
"version": "1.4.0",
"version": "1.4.0-patch-1",
"description": "Supporting common component library",
"type": "module",
"main": "dist/index.js",
Expand Down
39 changes: 34 additions & 5 deletions src/Common/Common.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { MutableRefObject } from 'react'
import moment from 'moment'
import { sanitizeApprovalConfigData, sanitizeUserApprovalList } from '@Shared/Helpers'
import { sanitizeApprovalConfigData, sanitizeUserApprovalList, stringComparatorBySortOrder } from '@Shared/Helpers'
import { PolicyBlockInfo, RuntimeParamsAPIResponseType, RuntimePluginVariables } from '@Shared/types'
import { get, post } from './Api'
import { GitProviderType, ROUTES } from './Constants'
Expand All @@ -42,7 +42,7 @@ import {
GlobalVariableOptionType,
} from './Types'
import { ApiResourceType } from '../Pages'
import { RefVariableType } from './CIPipeline.Types'
import { RefVariableType, VariableTypeFormat } from './CIPipeline.Types'

export const getTeamListMin = (): Promise<TeamList> => {
// ignore active field
Expand Down Expand Up @@ -203,7 +203,7 @@ const cdMaterialListModal = ({
deploymentWindowArtifactMetadata: material.deploymentWindowArtifactMetadata ?? null,
configuredInReleases: material.configuredInReleases ?? [],
appWorkflowId: material.appWorkflowId ?? null,
deploymentBlockedState: sanitizeDeploymentBlockedState(material.deploymentBlockedState)
deploymentBlockedState: sanitizeDeploymentBlockedState(material.deploymentBlockedState),
}
})
return materials
Expand Down Expand Up @@ -244,8 +244,37 @@ const processCDMaterialsApprovalInfo = (enableApproval: boolean, cdMaterialsResu
}
}

export const parseRuntimeParams = (response: RuntimeParamsAPIResponseType): RuntimePluginVariables[] =>
(response?.runtimePluginVariables ?? []).map((variable) => ({ ...variable, defaultValue: variable.value }))
export const parseRuntimeParams = (response: RuntimeParamsAPIResponseType): RuntimePluginVariables[] => {
const envVariables = Object.entries(response?.envVariables || {}).map<RuntimePluginVariables>(
([key, value]) => ({
name: key,
value,
defaultValue: '',
format: VariableTypeFormat.STRING,
isRequired: false,
valueType: RefVariableType.NEW,
variableStepScope: RefVariableType.GLOBAL,
stepName: null,
stepType: null,
// TODO: (Rohit/Eshank) Replace this with getUniqueId (nanoId method)
stepVariableId: Math.floor(new Date().valueOf() * Math.random()),
valueConstraint: null,
description: null,
fileReferenceId: null,
fileMountDir: null,
}),
)

const runtimeParams = (response?.runtimePluginVariables ?? []).map<RuntimePluginVariables>((variable) => ({
...variable,
defaultValue: variable.value,
}))

runtimeParams.push(...envVariables)
runtimeParams.sort((a, b) => stringComparatorBySortOrder(a.name, b.name))

return runtimeParams
}

const processCDMaterialsMetaInfo = (cdMaterialsResult): CDMaterialsMetaInfo => {
if (!cdMaterialsResult) {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export interface customEnv {
FEATURE_PROMO_EMBEDDED_BUTTON_TEXT?: string
FEATURE_PROMO_EMBEDDED_MODAL_TITLE?: string
FEATURE_PROMO_EMBEDDED_IFRAME_URL?: string
FEATURE_SWAP_TRAFFIC_ENABLE?: boolean
FEATURE_BULK_RESTART_WORKLOADS_FROM_RB: string
FEATURE_RB_SYNC_CLUSTER_ENABLE?: boolean
FEATURE_DEFAULT_MERGE_STRATEGY?: OverrideMergeStrategyType
Expand Down

0 comments on commit 3cd8c50

Please sign in to comment.