Skip to content

Commit b1419f8

Browse files
authored
Merge pull request #424 from devtron-labs/feat/mandatory-tags-v2
feat: mandatory tags v2
2 parents 271d68a + 26ce641 commit b1419f8

25 files changed

+364
-190
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ src/Common/Common.service.ts
1616
src/Common/CustomInput/CustomInput.tsx
1717
src/Common/CustomTagSelector/PropagateTagInfo.tsx
1818
src/Common/CustomTagSelector/TagDetails.tsx
19-
src/Common/CustomTagSelector/TagLabelSelect.tsx
2019
src/Common/CustomTagSelector/TagLabelValueSelector.tsx
21-
src/Common/CustomTagSelector/TagSelector.utils.ts
2220
src/Common/CustomTagSelector/ValidationRules.ts
2321
src/Common/DebouncedSearch/DebouncedSearch.tsx
2422
src/Common/DebouncedSearch/Utils.ts

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.3.0",
3+
"version": "1.3.0-patch-2",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/Common.service.ts

Lines changed: 17 additions & 1 deletion
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, RuntimePluginVariables } from '@Shared/types'
19+
import { PolicyBlockInfo, RuntimeParamsAPIResponseType, RuntimePluginVariables } from '@Shared/types'
2020
import { getIsManualApprovalSpecific, sanitizeUserApprovalConfig, stringComparatorBySortOrder } from '@Shared/Helpers'
2121
import { get, post } from './Api'
2222
import { GitProviderType, ROUTES } from './Constants'
@@ -116,6 +116,21 @@ const sanitizeApprovalConfigFromApprovalMetadata = (
116116
}
117117
}
118118

119+
const sanitizeDeploymentBlockedState = (deploymentBlockedState: PolicyBlockInfo) => {
120+
if (!deploymentBlockedState) {
121+
return {
122+
isBlocked: false,
123+
blockedBy: null,
124+
reason: '',
125+
}
126+
}
127+
return {
128+
isBlocked: deploymentBlockedState.isBlocked || false,
129+
blockedBy: deploymentBlockedState.blockedBy || null,
130+
reason: deploymentBlockedState.reason || '',
131+
}
132+
}
133+
119134
const cdMaterialListModal = ({
120135
artifacts,
121136
offset,
@@ -210,6 +225,7 @@ const cdMaterialListModal = ({
210225
deploymentWindowArtifactMetadata: material.deploymentWindowArtifactMetadata ?? null,
211226
configuredInReleases: material.configuredInReleases ?? [],
212227
appWorkflowId: material.appWorkflowId ?? null,
228+
deploymentBlockedState: sanitizeDeploymentBlockedState(material.deploymentBlockedState)
213229
}
214230
})
215231
return materials

src/Common/Constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ export const DOCUMENTATION = {
3333
}
3434

3535
export const PATTERNS = {
36+
STRING: /^[a-zA-Z0-9_]+$/,
3637
DECIMAL_NUMBERS: /^-?\d*\.?\d*$/,
3738
NATURAL_NUMBERS: /^\d*\.?\d*$/,
3839
KUBERNETES_KEY_PREFIX: /^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$/,
3940
KUBERNETES_KEY_NAME: /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$/,
40-
START_END_ALPHANUMERIC: /^([Az09].*[A-Za-z0-9])$|[A-Za-z0-9]$/,
41+
START_END_ALPHANUMERIC: /^(([A-Za-z0-9].*[A-Za-z0-9])|[A-Za-z0-9])$/,
4142
ALPHANUMERIC_WITH_SPECIAL_CHAR: /^[A-Za-z0-9._-]+$/, // allow alphanumeric,(.) ,(-),(_)
4243
ESCAPED_CHARACTERS: /[.*+?^${}()|[\]\\]/g,
4344
NUMBERS_WITH_SCOPE_VARIABLES: /^(\d+(\.\d+)?|@{{[a-zA-Z0-9-]+}})$/,

src/Common/CustomTagSelector/PropagateTagInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default function PropagateTagInfo({ isCreateApp }: { isCreateApp: boolean
3939
<TippyCustomized
4040
theme={TippyTheme.white}
4141
className="w-300"
42-
placement="top"
42+
placement="left"
4343
Icon={InjectTag}
4444
heading="Propagate tags to K8s resources"
4545
infoText=""

src/Common/CustomTagSelector/TagLabelSelect.tsx

Lines changed: 0 additions & 73 deletions
This file was deleted.

src/Common/CustomTagSelector/TagSelector.utils.ts

Lines changed: 0 additions & 86 deletions
This file was deleted.

src/Common/CustomTagSelector/Types.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ export interface SuggestedTagOptionType extends OptionType {
2222
description: string
2323
propagate: boolean
2424
}
25+
26+
export enum DeploymentPolicy {
27+
ALLOW = 'allow',
28+
BLOCK = 'block',
29+
BLOCK_PROD = 'block-prod',
30+
BLOCK_NON_PROD = 'block-non-prod',
31+
}
32+
33+
export interface VariableValueConstraintTypes {
34+
choices?: string[]
35+
blockCustomValue?: boolean
36+
}
2537
export interface TagType {
2638
id?: number
2739
key: string
@@ -33,21 +45,8 @@ export interface TagType {
3345
isInvalidValue?: boolean
3446
isSuggested?: boolean
3547
isPropagateDisabled?: boolean
36-
}
37-
38-
export interface TagErrorType {
39-
isValid: boolean
40-
messages: string[]
41-
}
42-
export interface TagLabelSelectType {
43-
isCreateApp?: boolean
44-
labelTags: TagType[]
45-
setLabelTags: (tagList: TagType[]) => void
46-
tabIndex?: number
47-
selectedProjectId?: number
48-
suggestedTagsOptions?: SuggestedTagOptionType[]
49-
reloadProjectTags?: boolean
50-
hidePropagateTag?: boolean
48+
deploymentPolicy?: DeploymentPolicy
49+
valueConstraint?: VariableValueConstraintTypes
5150
}
5251

5352
export interface TagDetailType {

src/Common/CustomTagSelector/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
export { default as PropagateTagInfo } from './PropagateTagInfo'
1818
export * from './TagDetails'
19-
export * from './TagLabelSelect'
2019
export * from './TagLabelValueSelector'
2120
export * from './ResizableTagTextArea'
2221
export * from './Types'
22+
export { validateTagKeyValue, validateTagValue } from './tags.utils'

0 commit comments

Comments
 (0)