Skip to content

Commit 2b3921a

Browse files
Merge pull request #499 from devtron-labs/feat/build-infra-v3
feat: build infra v3
2 parents e627669 + d57cc69 commit 2b3921a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3006
-506
lines changed

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
@@ -86,7 +86,6 @@
8686
"patch-package": "^8.0.0",
8787
"react": "^17.0.2",
8888
"react-dom": "^17.0.2",
89-
"react-draggable": "^4.4.5",
9089
"react-ga4": "^1.4.1",
9190
"react-mde": "^11.5.0",
9291
"react-router-dom": "^5.3.0",
@@ -108,7 +107,8 @@
108107
"react-monaco-editor": "^0.54.0",
109108
"react-virtualized-sticky-tree": "^3.0.0-beta18",
110109
"sass": "^1.69.7",
111-
"tslib": "2.7.0"
110+
"tslib": "2.7.0",
111+
"react-draggable": "^4.4.5"
112112
},
113113
"overrides": {
114114
"cross-spawn": "^7.0.5",

src/Assets/Icon/ic-view-variable-toggle.svg

Lines changed: 2 additions & 7 deletions
Loading

src/Common/Constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ export const PATTERNS = {
4343
ALPHANUMERIC_WITH_SPECIAL_CHAR: /^[A-Za-z0-9._-]+$/, // allow alphanumeric,(.) ,(-),(_)
4444
ESCAPED_CHARACTERS: /[.*+?^${}()|[\]\\]/g,
4545
NUMBERS_WITH_SCOPE_VARIABLES: /^(\d+(\.\d+)?|@{{[a-zA-Z0-9-]+}})$/,
46+
ALL_DIGITS_BETWEEN_0_AND_7: /^[0-7]*$/,
47+
// eslint-disable-next-line no-useless-escape
48+
CONFIG_MAP_AND_SECRET_MULTIPLE_KEYS: /^[-._a-zA-Z0-9\,\?\s]*[-._a-zA-Z0-9\s]$/,
49+
CONFIG_MAP_AND_SECRET_KEY: /^[-._a-zA-Z0-9]+$/,
50+
CONFIGMAP_AND_SECRET_NAME: /^[a-z0-9][a-z0-9-.]*[a-z0-9]$/,
51+
ALPHANUMERIC_WITH_SPECIAL_CHAR_AND_SLASH: /^[A-Za-z0-9._/-]+$/, // allow alphanumeric,(.) ,(-),(_),(/)
4652
}
4753

4854
export const URLS = {
@@ -130,6 +136,7 @@ export const ROUTES = {
130136
FILE_UPLOAD: 'file/upload',
131137
PLUGIN_GLOBAL_VARIABLES: 'plugin/global/list/global-variable',
132138
CONFIG_COMPARE_SECRET: 'config/compare/secret',
139+
SCOPED_GLOBAL_VARIABLES: 'global/variables',
133140
CD_TRIGGER_POST: 'app/cd-pipeline/trigger',
134141
DELETE_RESOURCE: 'k8s/resource/delete',
135142
NODE_CAPACITY: 'k8s/capacity/node',

src/Pages/GlobalConfigurations/BuildInfra/BuildInfraConfigForm.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ const BuildInfraConfigForm: FunctionComponent<BuildInfraConfigFormProps> = ({
111111
}
112112
showDivider={index !== BUILD_INFRA_FORM_FIELDS.length - 1}
113113
isInheriting={isInheritingProfileValues(field.actions)}
114-
handleProfileInputChange={handleProfileInputChange}
115-
locator={field.locator}
116-
isGlobalProfile={isGlobalProfile}
117114
>
118115
<div className="w-50 flexbox dc__gap-12 w-100 dc__align-start">
119116
{field.actions.map((action) => (

src/Pages/GlobalConfigurations/BuildInfra/BuildInfraDescriptionField.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@ import { BUILD_INFRA_TEXT } from './constants'
2121

2222
const BuildInfraProfileDescriptionField: FunctionComponent<BuildInfraProfileMetaFieldProps> = ({
2323
handleProfileInputChange,
24+
onChange,
2425
currentValue,
2526
error,
2627
}) => {
2728
const handleChange = (e: FormEvent<HTMLTextAreaElement>) => {
28-
handleProfileInputChange({
29-
action: BuildInfraMetaConfigTypes.DESCRIPTION,
30-
data: { value: e.currentTarget.value },
31-
})
29+
if (handleProfileInputChange) {
30+
handleProfileInputChange({
31+
action: BuildInfraMetaConfigTypes.DESCRIPTION,
32+
data: { value: e.currentTarget.value },
33+
})
34+
35+
return
36+
}
37+
38+
onChange(e)
3239
}
3340

3441
return (

src/Pages/GlobalConfigurations/BuildInfra/BuildInfraFormItem.tsx

Lines changed: 14 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,60 +14,31 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { FormEvent, FunctionComponent } from 'react'
18-
import { BUILD_INFRA_DEFAULT_PLATFORM_NAME, getBuildInfraInheritActionFromLocator } from '@Pages/index'
17+
import { FunctionComponent } from 'react'
1918
import { BuildInfraFormItemProps } from './types'
20-
import { CHECKBOX_VALUE, Checkbox } from '../../../Common'
2119

2220
const BuildInfraFormItem: FunctionComponent<BuildInfraFormItemProps> = ({
2321
heading,
2422
marker: Marker,
2523
children,
2624
isInheriting,
2725
showDivider,
28-
handleProfileInputChange,
29-
locator,
30-
isGlobalProfile,
31-
targetPlatform = BUILD_INFRA_DEFAULT_PLATFORM_NAME,
32-
}) => {
33-
const handleActivationChange = (e: FormEvent<HTMLInputElement>) => {
34-
const { checked } = e.currentTarget
35-
const action = getBuildInfraInheritActionFromLocator(locator, checked)
36-
handleProfileInputChange({ action, data: { targetPlatform } })
37-
}
38-
39-
const renderMarker = () => {
40-
if (isGlobalProfile) {
41-
return <Marker className="icon-dim-20 dc__no-shrink" />
42-
}
43-
44-
return (
45-
<Checkbox
46-
onChange={handleActivationChange}
47-
isChecked={!isInheriting}
48-
value={CHECKBOX_VALUE.CHECKED}
49-
dataTestId={`${locator}_marker`}
50-
/>
51-
)
52-
}
53-
26+
}) => (
5427
// If in configuration active is false, means it is inheriting values from other profile
55-
return (
56-
<>
57-
<div className="flexbox-col dc__gap-8 w-100">
58-
<div className="flexbox dc__gap-12 dc__align-start w-100">
59-
{renderMarker()}
60-
61-
<div className="flexbox-col dc__gap-8 w-100">
62-
{heading}
63-
{!isInheriting && children}
64-
</div>
28+
<>
29+
<div className="flexbox-col dc__gap-8 w-100">
30+
<div className="flexbox dc__gap-12 dc__align-start w-100">
31+
<Marker className="icon-dim-20 dc__no-shrink" />
32+
33+
<div className="flexbox-col dc__gap-8 w-100">
34+
{heading}
35+
{!isInheriting && children}
6536
</div>
6637
</div>
38+
</div>
6739

68-
{showDivider && <div className="w-100 dc__border-bottom-n1" />}
69-
</>
70-
)
71-
}
40+
{showDivider && <div className="w-100 dc__border-bottom-n1" />}
41+
</>
42+
)
7243

7344
export default BuildInfraFormItem

src/Pages/GlobalConfigurations/BuildInfra/BuildInfraProfileNameField.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@ import { CustomInput } from '../../../Common'
2020
import { BUILD_INFRA_TEXT } from './constants'
2121

2222
const BuildInfraProfileNameField: FunctionComponent<BuildInfraProfileMetaFieldProps> = ({
23+
onChange,
2324
handleProfileInputChange,
2425
currentValue,
2526
error,
2627
}) => {
2728
const handleChange = (e: FormEvent<HTMLInputElement>) => {
28-
handleProfileInputChange({
29-
action: BuildInfraMetaConfigTypes.NAME,
30-
data: { value: e.currentTarget.value },
31-
})
29+
if (handleProfileInputChange) {
30+
handleProfileInputChange({
31+
action: BuildInfraMetaConfigTypes.NAME,
32+
data: { value: e.currentTarget.value },
33+
})
34+
return
35+
}
36+
37+
onChange(e)
3238
}
3339

3440
return (
@@ -43,6 +49,7 @@ const BuildInfraProfileNameField: FunctionComponent<BuildInfraProfileMetaFieldPr
4349
error={error}
4450
required
4551
inputWrapClassName="w-100"
52+
autoFocus
4653
/>
4754
</div>
4855
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { createContext, useContext } from 'react'
2+
import { BuildInfraUtilityContextType } from '@Pages/index'
3+
4+
export const BuildInfraUtilityContext = createContext<BuildInfraUtilityContextType>(null)
5+
6+
export const useBuildInfraUtilityContext = () => {
7+
const context = useContext(BuildInfraUtilityContext)
8+
9+
if (!context) {
10+
throw new Error('Please wrap parent component with BuildInfraUtilityProvider')
11+
}
12+
13+
return context
14+
}

src/Pages/GlobalConfigurations/BuildInfra/Descriptor.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const Descriptor = ({
2626
tippyInfoText,
2727
tippyAdditionalContent,
2828
tooltipNode,
29+
tooltipHeading,
2930
}: BuildInfraDescriptorProps) => (
3031
<div className={`flexbox dc__content-space dc__align-items-center w-100 ${additionalContainerClasses ?? ''}`}>
3132
<div className="flexbox dc__align-items-center dc__gap-4">
@@ -35,7 +36,7 @@ const Descriptor = ({
3536
<InfoIconTippy
3637
infoText={tippyInfoText ?? BUILD_INFRA_TEXT.EDIT_DEFAULT_TOOLTIP}
3738
additionalContent={tippyAdditionalContent}
38-
heading={BUILD_INFRA_TEXT.HEADING}
39+
heading={tooltipHeading || BUILD_INFRA_TEXT.HEADING}
3940
documentationLink={DOCUMENTATION.GLOBAL_CONFIG_BUILD_INFRA}
4041
documentationLinkText="View Documentation"
4142
iconClassName="icon-dim-20 fcn-6"

0 commit comments

Comments
 (0)