Skip to content

Commit de8fd78

Browse files
committed
feat: parseRuntimeParams util, types update, Regex PATTERNS add
1 parent 151be48 commit de8fd78

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/Common/Common.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { MutableRefObject } from 'react'
1818
import moment from 'moment'
19-
import { RuntimeParamsAPIResponseType } from '@Shared/types'
19+
import { RuntimeParamsAPIResponseType, RuntimePluginVariables } from '@Shared/types'
2020
import { getIsManualApprovalSpecific, sanitizeUserApprovalConfig, stringComparatorBySortOrder } from '@Shared/Helpers'
2121
import { get, getIsRequestAborted, post } from './Api'
2222
import { API_STATUS_CODES, GitProviderType, ROUTES } from './Constants'
@@ -324,7 +324,8 @@ const processCDMaterialsApprovalInfo = (enableApproval: boolean, cdMaterialsResu
324324
}
325325
}
326326

327-
327+
export const parseRuntimeParams = (response: RuntimeParamsAPIResponseType): RuntimePluginVariables[] =>
328+
(response?.runtimePluginVariables ?? []).map((variable) => ({ ...variable, defaultValue: variable.value }))
328329

329330
const processCDMaterialsMetaInfo = (cdMaterialsResult): CDMaterialsMetaInfo => {
330331
if (!cdMaterialsResult) {
@@ -346,7 +347,7 @@ const processCDMaterialsMetaInfo = (cdMaterialsResult): CDMaterialsMetaInfo => {
346347
resourceFilters: cdMaterialsResult.resourceFilters ?? [],
347348
totalCount: cdMaterialsResult.totalCount ?? 0,
348349
requestedUserId: cdMaterialsResult.requestedUserId,
349-
runtimeParams: cdMaterialsResult.runtimeParams.runtimePluginVariables ?? [],
350+
runtimeParams: parseRuntimeParams(cdMaterialsResult.runtimeParams),
350351
}
351352
}
352353

src/Common/Constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ export const DOCUMENTATION = {
3232
}
3333

3434
export const PATTERNS = {
35+
NATURAL_NUMBERS: /^\d*\.?\d*$/,
3536
KUBERNETES_KEY_PREFIX: /^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$/,
3637
KUBERNETES_KEY_NAME: /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$/,
3738
START_END_ALPHANUMERIC: /^([Az09].*[A-Za-z0-9])$|[A-Za-z0-9]$/,
3839
ALPHANUMERIC_WITH_SPECIAL_CHAR: /^[A-Za-z0-9._-]+$/, // allow alphanumeric,(.) ,(-),(_)
3940
ESCAPED_CHARACTERS: /[.*+?^${}()|[\]\\]/g,
41+
NUMBERS_WITH_SCOPE_VARIABLES: /^(\d+(\.\d+)?|@{{[a-zA-Z0-9-]+}})$/,
4042
}
4143

4244
export const URLS = {

src/Shared/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ export interface GitTriggers {
339339
}
340340

341341
export interface RuntimePluginVariables
342-
extends Pick<VariableType, 'name' | 'value' | 'format' | 'fileReferenceId' | 'fileMountDir'> {
342+
extends Pick<VariableType, 'name' | 'value' | 'defaultValue' | 'format' | 'fileReferenceId' | 'fileMountDir'> {
343343
variableStepScope: string
344344
valueConstraint: ValueConstraintType & { id: number }
345345
stepVariableId: number

0 commit comments

Comments
 (0)