Skip to content

Commit 6880819

Browse files
Merge pull request #1587 from devtron-labs/feat/build-infra
feat: build infra
2 parents 2c0c6b2 + 14d2961 commit 6880819

File tree

24 files changed

+290
-24
lines changed

24 files changed

+290
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "0.0.62",
7+
"@devtron-labs/devtron-fe-common-lib": "0.0.63",
88
"@rjsf/core": "^5.13.3",
99
"@rjsf/utils": "^5.13.3",
1010
"@rjsf/validator-ajv8": "^5.13.3",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { FunctionComponent } from 'react'
2+
import { ErrorScreenNotAuthorized } from '@devtron-labs/devtron-fe-common-lib'
3+
import { importComponentFromFELibrary } from '../../../components/common'
4+
import { BuildInfraProps } from './types'
5+
import ProfileForm from './ProfileForm'
6+
7+
const BuildInfraRouter = importComponentFromFELibrary('BuildInfraRouter', null, 'function')
8+
9+
export const BuildInfra: FunctionComponent<BuildInfraProps> = ({ isSuperAdmin }) => {
10+
if (!isSuperAdmin) {
11+
return <ErrorScreenNotAuthorized />
12+
}
13+
14+
if (BuildInfraRouter) {
15+
return <BuildInfraRouter />
16+
}
17+
18+
return <ProfileForm />
19+
}
20+
21+
export default BuildInfra
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import React, { FunctionComponent, useMemo } from 'react'
2+
import {
3+
BUILD_INFRA_BREADCRUMB,
4+
BuildInfraDescriptor,
5+
BuildInfraFooter,
6+
useBreadcrumb,
7+
BuildInfraConfigForm,
8+
useBuildInfraForm,
9+
DEFAULT_PROFILE_NAME,
10+
APIResponseHandler,
11+
BUILD_INFRA_TEXT,
12+
} from '@devtron-labs/devtron-fe-common-lib'
13+
import './styles.scss'
14+
15+
const ProfileForm: FunctionComponent = () => {
16+
const { breadcrumbs } = useBreadcrumb(BUILD_INFRA_BREADCRUMB)
17+
const {
18+
isLoading,
19+
profileResponse,
20+
responseError,
21+
reloadRequest,
22+
profileInput,
23+
profileInputErrors,
24+
handleProfileInputChange,
25+
loadingActionRequest,
26+
handleSubmit,
27+
} = useBuildInfraForm({ name: DEFAULT_PROFILE_NAME, editProfile: true })
28+
// Would use this to disable the save button, if all keys in profileInputErrors are null or undefined, then there are no errors
29+
// Empty string means isRequired but no need to show error below input field
30+
const formErrorCount = useMemo(
31+
() =>
32+
Object.keys(profileInputErrors).filter(
33+
(item) => profileInputErrors[item] !== null && profileInputErrors[item] !== undefined,
34+
).length,
35+
[profileInputErrors],
36+
)
37+
38+
const handleKeyDown = (event: React.KeyboardEvent<HTMLFormElement>) => {
39+
if (event.key === 'Enter') {
40+
event.preventDefault()
41+
}
42+
}
43+
44+
const showActionItems = !isLoading && !responseError && profileInput?.configurations
45+
46+
return (
47+
<form
48+
className="h-100 flexbox-col build-infra pl pr pt pb dc__content-space bcn-0"
49+
onKeyDown={handleKeyDown}
50+
onSubmit={handleSubmit}
51+
>
52+
<div className="flexbox-col dc__gap-24 pt pr pb pl h-100 dc__overflow-scroll">
53+
<BuildInfraDescriptor breadCrumbs={breadcrumbs} />
54+
55+
<APIResponseHandler
56+
isLoading={isLoading}
57+
progressingProps={{
58+
pageLoader: true,
59+
}}
60+
error={responseError}
61+
reloadProps={{
62+
reload: reloadRequest,
63+
}}
64+
notFoundText={{
65+
title: BUILD_INFRA_TEXT.PROFILE_NOT_FOUND.title,
66+
subTitle: BUILD_INFRA_TEXT.PROFILE_NOT_FOUND.subTitle,
67+
}}
68+
>
69+
<BuildInfraConfigForm
70+
profileInput={profileInput}
71+
profileInputErrors={profileInputErrors}
72+
handleProfileInputChange={handleProfileInputChange}
73+
isDefaultProfile
74+
unitsMap={profileResponse?.configurationUnits}
75+
/>
76+
</APIResponseHandler>
77+
</div>
78+
79+
{showActionItems && (
80+
<BuildInfraFooter disabled={formErrorCount !== 0} editProfile loading={loadingActionRequest} />
81+
)}
82+
</form>
83+
)
84+
}
85+
86+
export default ProfileForm
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* eslint-disable import/prefer-default-export */
2+
export { default as BuildInfra } from './BuildInfra'
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.build-infra {
2+
.pl {
3+
padding-left: 20px;
4+
}
5+
.pr {
6+
padding-right: 20px;
7+
}
8+
.pt {
9+
padding-top: 16px;
10+
}
11+
.pb {
12+
padding-bottom: 16px;
13+
}
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface BuildInfraProps {
2+
isSuperAdmin: boolean
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './BuildInfra'

src/Pages/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './GlobalConfigurations'

src/assets/icons/ic-bulk-check.svg

Lines changed: 5 additions & 0 deletions
Loading

src/components/app/details/triggerView/ciMaterial.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from 'react'
2-
import { showError, ServerErrors, Checkbox, noop } from '@devtron-labs/devtron-fe-common-lib'
2+
import { showError, ServerErrors, Checkbox, noop, CHECKBOX_VALUE } from '@devtron-labs/devtron-fe-common-lib'
33
import { CIMaterialProps, CIMaterialState, RegexValueType } from './types'
44
import { ReactComponent as Play } from '../../../../assets/icons/misc/arrow-solid-right.svg'
55
import { ReactComponent as Info } from '../../../../assets/icons/info-filled.svg'
@@ -106,7 +106,7 @@ export class CIMaterial extends Component<CIMaterialProps, CIMaterialState> {
106106
isChecked={this.context.invalidateCache}
107107
onClick={this.onClickStopPropagation}
108108
rootClassName="form__checkbox-label--ignore-cache mb-0"
109-
value={'CHECKED'}
109+
value={CHECKBOX_VALUE.CHECKED}
110110
onChange={this.context.toggleInvalidateCache}
111111
data-testid="set-clone-directory"
112112
>

0 commit comments

Comments
 (0)