@devtron-labs/devtron-fe-common-lib 0.0.61-beta-10 → 0.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/Common/Constants.d.ts +14 -1
  2. package/dist/Common/Hooks/index.d.ts +1 -0
  3. package/dist/Common/Hooks/useUrlFilters/constants.d.ts +8 -0
  4. package/dist/Common/Hooks/useUrlFilters/index.d.ts +2 -0
  5. package/dist/Common/Hooks/useUrlFilters/types.d.ts +6 -0
  6. package/dist/Common/Hooks/useUrlFilters/useUrlFilters.d.ts +32 -0
  7. package/dist/Common/SortableTableHeaderCell/SortableTableHeaderCell.d.ts +18 -0
  8. package/dist/Common/SortableTableHeaderCell/index.d.ts +2 -0
  9. package/dist/Common/SortableTableHeaderCell/types.d.ts +25 -0
  10. package/dist/Common/Types.d.ts +15 -4
  11. package/dist/Common/index.d.ts +1 -0
  12. package/dist/Pages/GlobalConfigurations/Authorization/constants.d.ts +15 -0
  13. package/dist/Pages/GlobalConfigurations/Authorization/index.d.ts +1 -0
  14. package/dist/Pages/GlobalConfigurations/index.d.ts +1 -1
  15. package/dist/index.d.ts +0 -1
  16. package/dist/index.js +346 -1427
  17. package/package.json +1 -1
  18. package/src/Assets/Icon/ic-arrow-up-down.svg +3 -0
  19. package/src/Assets/Icon/ic-sort-arrow-down.svg +3 -0
  20. package/src/Common/BreadCrumb/Types.ts +1 -0
  21. package/src/Common/Checkbox.tsx +0 -1
  22. package/src/Common/Constants.ts +18 -3
  23. package/src/Common/CustomInput/CustomInput.tsx +1 -2
  24. package/src/Common/DraggableWrapper/DraggableWrapper.tsx +1 -3
  25. package/src/Common/Hooks/index.ts +1 -0
  26. package/src/Common/Hooks/useUrlFilters/constants.ts +9 -0
  27. package/src/Common/Hooks/useUrlFilters/index.ts +2 -0
  28. package/src/Common/Hooks/useUrlFilters/types.ts +6 -0
  29. package/src/Common/Hooks/useUrlFilters/useUrlFilters.ts +121 -0
  30. package/src/Common/RJSF/utils.ts +0 -2
  31. package/src/Common/SearchBar/searchBar.scss +1 -1
  32. package/src/Common/SortableTableHeaderCell/SortableTableHeaderCell.tsx +44 -0
  33. package/src/Common/SortableTableHeaderCell/index.ts +2 -0
  34. package/src/Common/SortableTableHeaderCell/types.ts +26 -0
  35. package/src/Common/Types.ts +14 -4
  36. package/src/Common/index.ts +1 -0
  37. package/src/Pages/GlobalConfigurations/Authorization/constants.ts +16 -0
  38. package/src/Pages/GlobalConfigurations/Authorization/index.ts +1 -0
  39. package/src/Pages/GlobalConfigurations/index.ts +1 -1
  40. package/src/index.ts +0 -1
  41. package/dist/Pages/GlobalConfigurations/BuildInfra/BuildInfraConfigForm.d.ts +0 -4
  42. package/dist/Pages/GlobalConfigurations/BuildInfra/BuildInfraDescriptionField.d.ts +0 -4
  43. package/dist/Pages/GlobalConfigurations/BuildInfra/BuildInfraFormAction.d.ts +0 -7
  44. package/dist/Pages/GlobalConfigurations/BuildInfra/BuildInfraFormItem.d.ts +0 -4
  45. package/dist/Pages/GlobalConfigurations/BuildInfra/BuildInfraProfileNameField.d.ts +0 -4
  46. package/dist/Pages/GlobalConfigurations/BuildInfra/Descriptor.d.ts +0 -4
  47. package/dist/Pages/GlobalConfigurations/BuildInfra/Footer.d.ts +0 -4
  48. package/dist/Pages/GlobalConfigurations/BuildInfra/constants.d.ts +0 -50
  49. package/dist/Pages/GlobalConfigurations/BuildInfra/index.d.ts +0 -7
  50. package/dist/Pages/GlobalConfigurations/BuildInfra/services.d.ts +0 -6
  51. package/dist/Pages/GlobalConfigurations/BuildInfra/types.d.ts +0 -286
  52. package/dist/Pages/GlobalConfigurations/BuildInfra/utils.d.ts +0 -12
  53. package/dist/Shared/Components/APIResponseHandler/APIResponseHandler.d.ts +0 -4
  54. package/dist/Shared/Components/APIResponseHandler/constants.d.ts +0 -4
  55. package/dist/Shared/Components/APIResponseHandler/index.d.ts +0 -2
  56. package/dist/Shared/Components/APIResponseHandler/types.d.ts +0 -37
  57. package/dist/Shared/Components/BulkSelection/BulkSelection.d.ts +0 -4
  58. package/dist/Shared/Components/BulkSelection/BulkSelectionDropdownItems.d.ts +0 -4
  59. package/dist/Shared/Components/BulkSelection/BulkSelectionProvider.d.ts +0 -4
  60. package/dist/Shared/Components/BulkSelection/constants.d.ts +0 -10
  61. package/dist/Shared/Components/BulkSelection/index.d.ts +0 -4
  62. package/dist/Shared/Components/BulkSelection/types.d.ts +0 -54
  63. package/dist/Shared/Components/ReactSelect/index.d.ts +0 -1
  64. package/dist/Shared/Components/ReactSelect/utils.d.ts +0 -12
  65. package/dist/Shared/Components/index.d.ts +0 -3
  66. package/dist/Shared/Helpers.d.ts +0 -16
  67. package/dist/Shared/index.d.ts +0 -3
  68. package/dist/Shared/validations.d.ts +0 -8
  69. package/src/Assets/Icon/ic-check-all.svg +0 -5
  70. package/src/Assets/Icon/ic-check-square.svg +0 -4
  71. package/src/Assets/Icon/ic-close.svg +0 -9
  72. package/src/Assets/Icon/ic-cpu.svg +0 -4
  73. package/src/Assets/Icon/ic-memory.svg +0 -3
  74. package/src/Assets/Icon/ic-timer.svg +0 -3
  75. package/src/Pages/GlobalConfigurations/BuildInfra/BuildInfraConfigForm.tsx +0 -128
  76. package/src/Pages/GlobalConfigurations/BuildInfra/BuildInfraDescriptionField.tsx +0 -44
  77. package/src/Pages/GlobalConfigurations/BuildInfra/BuildInfraFormAction.tsx +0 -106
  78. package/src/Pages/GlobalConfigurations/BuildInfra/BuildInfraFormItem.tsx +0 -55
  79. package/src/Pages/GlobalConfigurations/BuildInfra/BuildInfraProfileNameField.tsx +0 -32
  80. package/src/Pages/GlobalConfigurations/BuildInfra/Descriptor.tsx +0 -45
  81. package/src/Pages/GlobalConfigurations/BuildInfra/Footer.tsx +0 -56
  82. package/src/Pages/GlobalConfigurations/BuildInfra/Readme.md +0 -4
  83. package/src/Pages/GlobalConfigurations/BuildInfra/constants.tsx +0 -139
  84. package/src/Pages/GlobalConfigurations/BuildInfra/index.ts +0 -7
  85. package/src/Pages/GlobalConfigurations/BuildInfra/services.tsx +0 -167
  86. package/src/Pages/GlobalConfigurations/BuildInfra/types.tsx +0 -339
  87. package/src/Pages/GlobalConfigurations/BuildInfra/utils.tsx +0 -507
  88. package/src/Shared/Components/APIResponseHandler/APIResponseHandler.tsx +0 -41
  89. package/src/Shared/Components/APIResponseHandler/constants.tsx +0 -5
  90. package/src/Shared/Components/APIResponseHandler/index.ts +0 -2
  91. package/src/Shared/Components/APIResponseHandler/types.tsx +0 -39
  92. package/src/Shared/Components/BulkSelection/BulkSelection.tsx +0 -77
  93. package/src/Shared/Components/BulkSelection/BulkSelectionDropdownItems.tsx +0 -33
  94. package/src/Shared/Components/BulkSelection/BulkSelectionProvider.tsx +0 -171
  95. package/src/Shared/Components/BulkSelection/constants.tsx +0 -14
  96. package/src/Shared/Components/BulkSelection/index.ts +0 -4
  97. package/src/Shared/Components/BulkSelection/types.tsx +0 -65
  98. package/src/Shared/Components/ReactSelect/index.ts +0 -1
  99. package/src/Shared/Components/ReactSelect/utils.tsx +0 -97
  100. package/src/Shared/Components/index.ts +0 -3
  101. package/src/Shared/Helpers.tsx +0 -29
  102. package/src/Shared/index.ts +0 -3
  103. package/src/Shared/validations.tsx +0 -130
@@ -1,128 +0,0 @@
1
- import { FunctionComponent } from 'react'
2
- import { Progressing } from '../../../Common'
3
- import BuildInfraFormAction from './BuildInfraFormAction'
4
- import BuildInfraFormItem from './BuildInfraFormItem'
5
- import BuildInfraProfileDescriptionField from './BuildInfraDescriptionField'
6
- import BuildInfraProfileNameField from './BuildInfraProfileNameField'
7
- import { BUILD_INFRA_FORM_FIELDS, BUILD_INFRA_TEXT } from './constants'
8
- import { BuildInfraActionType, BuildInfraConfigFormProps, InheritingHeaderProps } from './types'
9
-
10
- const InheritingHeader = ({
11
- defaultHeading,
12
- inheritingData,
13
- isInheriting,
14
- isDefaultProfile,
15
- }: InheritingHeaderProps) => {
16
- const inheritingDataString = inheritingData.map((data) => `${data.value} ${data.unit ?? ''}`).join(' - ')
17
-
18
- if (isDefaultProfile || !isInheriting) {
19
- // For typing issues
20
- // eslint-disable-next-line react/jsx-no-useless-fragment
21
- return <>{defaultHeading}</>
22
- }
23
-
24
- return (
25
- <div className="flexbox dc__align-items-center dc__content-space w-100">
26
- {defaultHeading}
27
-
28
- <div className="flexbox dc__content-space w-100">
29
- <span className="m-0 pt-0 pb-0 pl-4 pr-4 fs-13 lh-20 fw-4 cn-9 dc__ellipsis-right dc__word-break-all flex-grow-1">
30
- {inheritingDataString}
31
- </span>
32
-
33
- {/* TODO: Add ellipsis */}
34
- <p className="m-0 cn-7 fs-13 fw-4 lh-20 dc__no-shrink">
35
- {BUILD_INFRA_TEXT.INHERITING_HEADING_DESCRIPTION}
36
- </p>
37
- </div>
38
- </div>
39
- )
40
- }
41
-
42
- const BuildInfraConfigForm: FunctionComponent<BuildInfraConfigFormProps> = ({
43
- profileInput,
44
- profileInputErrors,
45
- handleProfileInputChange,
46
- isDefaultProfile,
47
- unitsMap,
48
- configurationContainerLabel,
49
- }) => {
50
- const currentConfigurations = profileInput?.configurations
51
-
52
- // will get the desired configuration from the currentConfigurations and then check if it is active or not
53
- const isInheritingProfileValues = (actions: BuildInfraActionType[]) =>
54
- actions.some((action) => !currentConfigurations[action.actionType].active)
55
-
56
- // Had to show loader for an instance due to batching of state updates not working as expected :/
57
- if (!currentConfigurations) {
58
- return <Progressing pageLoader />
59
- }
60
-
61
- return (
62
- <div className="flexbox-col dc__mxw-920 dc__gap-16">
63
- {!isDefaultProfile && (
64
- <div className="flexbox-col dc__gap-12">
65
- <BuildInfraProfileNameField
66
- handleProfileInputChange={handleProfileInputChange}
67
- currentValue={profileInput.name}
68
- error={profileInputErrors.name}
69
- />
70
-
71
- <BuildInfraProfileDescriptionField
72
- handleProfileInputChange={handleProfileInputChange}
73
- currentValue={profileInput.description}
74
- error={profileInputErrors.description}
75
- />
76
- </div>
77
- )}
78
-
79
- <div className="flexbox-col dc__gap-12">
80
- {configurationContainerLabel}
81
-
82
- <div className="w-100 flexbox-col dc__gap-16 br-4 dc__border-n1 p-16">
83
- {BUILD_INFRA_FORM_FIELDS.map((field, index) => (
84
- <BuildInfraFormItem
85
- key={field.locator}
86
- marker={field.marker}
87
- heading={
88
- <InheritingHeader
89
- defaultHeading={field.heading}
90
- inheritingData={field.actions.map(
91
- (action) => currentConfigurations[action.actionType],
92
- )}
93
- isInheriting={isInheritingProfileValues(field.actions)}
94
- isDefaultProfile={isDefaultProfile}
95
- />
96
- }
97
- showDivider={index !== BUILD_INFRA_FORM_FIELDS.length - 1}
98
- isInheriting={isInheritingProfileValues(field.actions)}
99
- handleProfileInputChange={handleProfileInputChange}
100
- locator={field.locator}
101
- isDefaultProfile={isDefaultProfile}
102
- >
103
- <div className="w-50 flexbox dc__gap-12 w-100 dc__align-start">
104
- {field.actions.map((action) => (
105
- <BuildInfraFormAction
106
- key={action.actionType}
107
- actionType={action.actionType}
108
- label={action.label}
109
- placeholder={action.placeholder}
110
- error={profileInputErrors[action.actionType]}
111
- // Assumption is for default profiles all input fields are required
112
- isRequired
113
- profileUnitsMap={unitsMap[action.actionType]}
114
- handleProfileInputChange={handleProfileInputChange}
115
- currentUnitName={currentConfigurations[action.actionType].unit}
116
- currentValue={currentConfigurations[action.actionType].value}
117
- />
118
- ))}
119
- </div>
120
- </BuildInfraFormItem>
121
- ))}
122
- </div>
123
- </div>
124
- </div>
125
- )
126
- }
127
-
128
- export default BuildInfraConfigForm
@@ -1,44 +0,0 @@
1
- import { FormEvent, FunctionComponent } from 'react'
2
- import { ReactComponent as ErrorIcon } from '../../../Assets/Icon/ic-warning.svg'
3
- import { BuildInfraInputFieldComponentProps, BuildInfraMetaConfigTypes } from './types'
4
- import { BUILD_INFRA_TEXT } from './constants'
5
-
6
- const BuildInfraProfileDescriptionField: FunctionComponent<BuildInfraInputFieldComponentProps> = ({
7
- handleProfileInputChange,
8
- currentValue,
9
- error,
10
- }) => {
11
- const handleChange = (e: FormEvent<HTMLTextAreaElement>) => {
12
- handleProfileInputChange({
13
- action: BuildInfraMetaConfigTypes.DESCRIPTION,
14
- data: { value: e.currentTarget.value },
15
- })
16
- }
17
-
18
- return (
19
- <div className="flexbox-col dc__gap-4 w-100 dc__align-start">
20
- <label htmlFor="build-infra-profile-description" className="m-0 fs-13 fw-4 lh-20 cn-7">
21
- {BUILD_INFRA_TEXT.DESCRIPTION_LABEL}
22
- </label>
23
-
24
- <textarea
25
- data-testid="build-infra-profile-description"
26
- name="profile-description"
27
- className="form__textarea mxh-140 dc__hover-border-n300"
28
- id="build-infra-profile-description"
29
- placeholder={BUILD_INFRA_TEXT.DESCRIPTION_PLACEHOLDER}
30
- value={currentValue}
31
- onChange={handleChange}
32
- />
33
-
34
- {error && (
35
- <div className="form__error">
36
- <ErrorIcon className="form__icon form__icon--error" />
37
- {error}
38
- </div>
39
- )}
40
- </div>
41
- )
42
- }
43
-
44
- export default BuildInfraProfileDescriptionField
@@ -1,106 +0,0 @@
1
- import { FormEvent, FunctionComponent, useMemo } from 'react'
2
- import ReactSelect from 'react-select'
3
- import { BuildInfraFormActionProps } from './types'
4
- import { OptionType } from '../../../Common'
5
- import { unitSelectorStyles } from './utils'
6
- import { BUILD_INFRA_INPUT_CONSTRAINTS } from './constants'
7
- import { ReactComponent as ErrorIcon } from '../../../Assets/Icon/ic-warning.svg'
8
-
9
- /**
10
- * In case need arise for variants break this CustomInput and Select as a separate component
11
- */
12
- const BuildInfraFormAction: FunctionComponent<BuildInfraFormActionProps> = ({
13
- actionType,
14
- label,
15
- placeholder,
16
- error,
17
- isRequired,
18
- profileUnitsMap,
19
- handleProfileInputChange,
20
- currentUnitName,
21
- currentValue,
22
- }) => {
23
- const handleUnitChange = (selectedUnit: OptionType) => {
24
- const data = {
25
- unit: selectedUnit.label,
26
- value: currentValue,
27
- }
28
- handleProfileInputChange({ action: actionType, data })
29
- }
30
-
31
- const handleInputChange = (e: FormEvent<HTMLInputElement>) => {
32
- const data = {
33
- unit: currentUnitName,
34
- value: e.currentTarget.value,
35
- }
36
- handleProfileInputChange({ action: actionType, data })
37
- }
38
-
39
- const unitOptions = useMemo(() => {
40
- const units =
41
- Object.values(profileUnitsMap)?.map((unit) => ({
42
- label: unit.name,
43
- value: String(unit.conversionFactor),
44
- })) ?? []
45
- return units.sort((a, b) => Number(a.value) - Number(b.value))
46
- }, [profileUnitsMap])
47
-
48
- const currentUnit = useMemo(
49
- () => unitOptions.find((unit) => unit.label === currentUnitName),
50
- [unitOptions, currentUnitName],
51
- )
52
-
53
- return (
54
- <div className="flexbox-col dc__gap-4 dc__mxw-420 w-100 dc__align-start">
55
- <label
56
- htmlFor={`${actionType}-input`}
57
- className={`fs-13 fw-4 lh-20 cn-7 ${isRequired ? 'dc__required-field' : ''}`}
58
- >
59
- {label}
60
- </label>
61
- <div className="w-100 flexbox dc__align-items-center">
62
- <div className="flex-grow-1">
63
- <input
64
- data-testid={`${actionType}-input-field`}
65
- name={actionType}
66
- type="number"
67
- step={BUILD_INFRA_INPUT_CONSTRAINTS.STEP}
68
- min={BUILD_INFRA_INPUT_CONSTRAINTS.MIN}
69
- className="form__input dc__no-right-border dc__no-right-radius"
70
- placeholder={placeholder}
71
- value={currentValue}
72
- onChange={handleInputChange}
73
- required={isRequired}
74
- autoComplete="off"
75
- id={`${actionType}-input`}
76
- />
77
- </div>
78
-
79
- {profileUnitsMap && (
80
- <ReactSelect
81
- name={`${actionType}-unit`}
82
- className="bcn-0 dc__mxw-120"
83
- options={unitOptions}
84
- value={currentUnit}
85
- onChange={handleUnitChange}
86
- isSearchable={false}
87
- components={{
88
- IndicatorSeparator: null,
89
- ClearIndicator: null,
90
- }}
91
- styles={unitSelectorStyles()}
92
- />
93
- )}
94
- </div>
95
-
96
- {error && (
97
- <div className="form__error">
98
- <ErrorIcon className="form__icon form__icon--error" />
99
- {error}
100
- </div>
101
- )}
102
- </div>
103
- )
104
- }
105
-
106
- export default BuildInfraFormAction
@@ -1,55 +0,0 @@
1
- import { FormEvent, FunctionComponent } from 'react'
2
- import { BuildInfraFormItemProps, BuildInfraInheritActions } from './types'
3
- import { CHECKBOX_VALUE, Checkbox } from '../../../Common'
4
-
5
- const BuildInfraFormItem: FunctionComponent<BuildInfraFormItemProps> = ({
6
- heading,
7
- marker: Marker,
8
- children,
9
- isInheriting,
10
- showDivider,
11
- handleProfileInputChange,
12
- locator,
13
- isDefaultProfile,
14
- }) => {
15
- const handleActivationChange = (e: FormEvent<HTMLInputElement>) => {
16
- const { checked } = e.currentTarget
17
- const action = (checked ? `activate_${locator}` : `de_activate_${locator}`) as BuildInfraInheritActions
18
- handleProfileInputChange({ action })
19
- }
20
-
21
- const renderMarker = () => {
22
- if (isDefaultProfile) {
23
- return <Marker className="icon-dim-20 dc__no-shrink" />
24
- }
25
-
26
- return (
27
- <Checkbox
28
- onChange={handleActivationChange}
29
- isChecked={!isInheriting}
30
- value={CHECKBOX_VALUE.CHECKED}
31
- dataTestId={`${locator}_marker`}
32
- />
33
- )
34
- }
35
-
36
- // If in configuration active is false, means it is inheriting values from other profile
37
- return (
38
- <>
39
- <div className="flexbox-col dc__gap-8 w-100">
40
- <div className="flexbox dc__gap-12 dc__align-start w-100">
41
- {renderMarker()}
42
-
43
- <div className="flexbox-col dc__gap-8 w-100">
44
- {heading}
45
- {!isInheriting && children}
46
- </div>
47
- </div>
48
- </div>
49
-
50
- {showDivider && <div className="w-100 dc__border-bottom-n1" />}
51
- </>
52
- )
53
- }
54
-
55
- export default BuildInfraFormItem
@@ -1,32 +0,0 @@
1
- import { FormEvent, FunctionComponent } from 'react'
2
- import { BuildInfraMetaConfigTypes, BuildInfraInputFieldComponentProps } from './types'
3
- import { CustomInput } from '../../../Common'
4
- import { BUILD_INFRA_TEXT } from './constants'
5
-
6
- const BuildInfraProfileNameField: FunctionComponent<BuildInfraInputFieldComponentProps> = ({
7
- handleProfileInputChange,
8
- currentValue,
9
- error,
10
- }) => {
11
- const handleChange = (e: FormEvent<HTMLInputElement>) => {
12
- handleProfileInputChange({ action: BuildInfraMetaConfigTypes.NAME, data: { value: e.currentTarget.value } })
13
- }
14
-
15
- return (
16
- <div className="flexbox-col dc__gap-4 w-100 dc__align-start">
17
- <CustomInput
18
- name="profile-name"
19
- label={BUILD_INFRA_TEXT.PROFILE_LABEL}
20
- labelClassName="m-0 dc__required-field fs-13 fw-4 lh-20 cn-7"
21
- placeholder={BUILD_INFRA_TEXT.PROFILE_PLACEHOLDER}
22
- value={currentValue}
23
- onChange={handleChange}
24
- error={error}
25
- required
26
- inputWrapClassName="w-100"
27
- />
28
- </div>
29
- )
30
- }
31
-
32
- export default BuildInfraProfileNameField
@@ -1,45 +0,0 @@
1
- import { DescriptorProps } from './types'
2
- import { BreadCrumb, TippyCustomized, TippyTheme } from '../../../Common'
3
- import { ReactComponent as QuestionFilled } from '../../../Assets/Icon/ic-help.svg'
4
- import { ReactComponent as ICHelpOutline } from '../../../Assets/Icon/ic-help-outline.svg'
5
- import { BUILD_INFRA_TEXT } from './constants'
6
-
7
- const Descriptor = ({
8
- additionalContainerClasses,
9
- breadCrumbs,
10
- children,
11
- tippyInfoText,
12
- tippyAdditionalContent,
13
- }: DescriptorProps) => (
14
- <div className={`flexbox dc__content-space dc__align-items-center w-100 ${additionalContainerClasses ?? ''}`}>
15
- <div className="flexbox dc__align-items-center dc__gap-4">
16
- <BreadCrumb breadcrumbs={breadCrumbs} />
17
-
18
- <TippyCustomized
19
- theme={TippyTheme.white}
20
- className="w-300 h-100 dc__align-left"
21
- placement="right"
22
- Icon={QuestionFilled}
23
- iconClass="fcv-5"
24
- infoText={tippyInfoText ?? BUILD_INFRA_TEXT.EDIT_DEFAULT_TOOLTIP}
25
- additionalContent={tippyAdditionalContent}
26
- heading={BUILD_INFRA_TEXT.HEADING}
27
- showCloseButton
28
- trigger="click"
29
- interactive
30
- >
31
- <button
32
- className="p-0 h-20 dc__no-background dc__no-border dc__tab-focus"
33
- type="button"
34
- aria-label="build-infra-info"
35
- >
36
- <ICHelpOutline className="icon-dim-20" />
37
- </button>
38
- </TippyCustomized>
39
- </div>
40
-
41
- {children}
42
- </div>
43
- )
44
-
45
- export default Descriptor
@@ -1,56 +0,0 @@
1
- import { FunctionComponent, ReactElement } from 'react'
2
- import Tippy from '@tippyjs/react'
3
- import { BUILD_INFRA_TEST_IDS, BUILD_INFRA_TEXT } from './constants'
4
- import { FooterProps } from './types'
5
- import { ConditionalWrap, Progressing } from '../../../Common'
6
-
7
- const Footer: FunctionComponent<FooterProps> = ({ disabled, handleCancel, editProfile, loading }) => {
8
- const disableMessage = disabled
9
- ? BUILD_INFRA_TEXT.SUBMIT_BUTTON_TIPPY.INVALID_INPUT
10
- : BUILD_INFRA_TEXT.SUBMIT_BUTTON_TIPPY.REQUEST_IN_PROGRESS
11
-
12
- const getButtonText = () => {
13
- if (editProfile) {
14
- return BUILD_INFRA_TEXT.EDIT_SUBMIT
15
- }
16
-
17
- return BUILD_INFRA_TEXT.SAVE_SUBMIT
18
- }
19
-
20
- const renderTippy = (children: ReactElement) => (
21
- <Tippy content={disableMessage} placement="top" className="default-tt" arrow={false}>
22
- {children}
23
- </Tippy>
24
- )
25
-
26
- return (
27
- <div className="flex pl pr pb pt h-64 dc__gap-12 dc__border-top dc__content-start">
28
- <ConditionalWrap condition={disabled || loading} wrap={renderTippy}>
29
- <div className="flexbox dc__align-items-center">
30
- <button
31
- type="submit"
32
- className="cta submit h-32 flex"
33
- disabled={disabled || loading}
34
- data-testid={BUILD_INFRA_TEST_IDS.SUBMIT_BUTTON}
35
- >
36
- {loading ? <Progressing size={16} /> : getButtonText()}
37
- </button>
38
- </div>
39
- </ConditionalWrap>
40
-
41
- {handleCancel && (
42
- <button
43
- type="button"
44
- className="cta cancel h-32 flex"
45
- disabled={loading}
46
- data-testid={BUILD_INFRA_TEST_IDS.CANCEL_BUTTON}
47
- onClick={handleCancel}
48
- >
49
- {BUILD_INFRA_TEXT.EDIT_CANCEL}
50
- </button>
51
- )}
52
- </div>
53
- )
54
- }
55
-
56
- export default Footer
@@ -1,4 +0,0 @@
1
- In case someone wants to add a new build infrastructure field, the following steps should be followed:
2
- - Update the BUILD_INFRA_FORM_FIELDS, in constants.tsx
3
- - Add BuildInfraConfigTypes, BuildInfraLocators, BuildInfraInheritActions(If any) in types.tsx
4
- - In utils.tsx, update the handleProfileInputChange and validation functions accordingly
@@ -1,139 +0,0 @@
1
- import { ReactComponent as ICCpu } from '../../../Assets/Icon/ic-cpu.svg'
2
- import { ReactComponent as ICMemory } from '../../../Assets/Icon/ic-memory.svg'
3
- import { ReactComponent as ICTimer } from '../../../Assets/Icon/ic-timer.svg'
4
- import { UseBreadcrumbProps } from '../../../Common/BreadCrumb/Types'
5
- import {
6
- BuildInfraConfigTypes,
7
- BuildInfraFormFieldType,
8
- BuildInfraLocators,
9
- BuildInfraMetaConfigTypes,
10
- ProfileInputErrorType,
11
- BuildInfraProfileBase,
12
- BuildInfraProfileVariants,
13
- HandleProfileInputChangeType,
14
- } from './types'
15
-
16
- export const BUILD_INFRA_INPUT_CONSTRAINTS = {
17
- // Will not enforce any decimal specification on input field
18
- STEP: 'any',
19
- MIN: 0,
20
- DECIMAL_PLACES: 2,
21
- } as const
22
-
23
- export const BUILD_INFRA_TEXT = {
24
- HEADING: 'Build Infra Configuration',
25
- EDIT_SUBMIT: 'Save changes',
26
- SAVE_SUBMIT: 'Save',
27
- EDIT_CANCEL: 'Cancel',
28
- EDIT_DEFAULT_TOOLTIP:
29
- 'Efficiently control infrastructure settings such as CPU, Memory, and Build timeout for your build pipelines. Streamline resource management to optimise build time and cost effortlessly.',
30
- DESCRIPTION_LABEL: 'Description',
31
- DESCRIPTION_PLACEHOLDER: 'Enter a description here',
32
- PROFILE_LABEL: 'Profile name',
33
- PROFILE_PLACEHOLDER: 'Enter a name eg. java/node/small/medium/large',
34
- INHERITING_HEADING_DESCRIPTION: 'Inheriting from default',
35
- SUBMIT_BUTTON_TIPPY: {
36
- INVALID_INPUT: 'Valid input is required for all mandatory fields.',
37
- REQUEST_IN_PROGRESS: 'Request in progress.',
38
- },
39
- VALIDATE_REQUEST_LIMIT: {
40
- REQUEST_LESS_THAN_LIMIT: 'Request should be less than or equal to limit.',
41
- CAN_NOT_COMPUTE: 'Request and limit value diff are too high to validate.',
42
- REQUEST_DECIMAL_PLACES: `Request should be upto ${BUILD_INFRA_INPUT_CONSTRAINTS.DECIMAL_PLACES} decimal places.`,
43
- LIMIT_DECIMAL_PLACES: `Limit should be upto ${BUILD_INFRA_INPUT_CONSTRAINTS.DECIMAL_PLACES} decimal places.`,
44
- },
45
- getInvalidActionMessage: (action: HandleProfileInputChangeType['action']) => `Invalid action type: ${action}`,
46
- getSubmitSuccessMessage: (profileName: string, isEdited: boolean) =>
47
- `${profileName} profile is ${isEdited ? 'updated' : 'created'}`,
48
- PROFILE_NOT_FOUND: {
49
- title: 'Profile not found',
50
- subTitle: 'The profile you are looking for does not exist.',
51
- },
52
- INVALID_FORM_MESSAGE: 'Valid input is required for all mandatory fields.',
53
- } as const
54
-
55
- export const BUILD_INFRA_BREADCRUMB: UseBreadcrumbProps = {
56
- alias: {
57
- 'global-config': null,
58
- 'build-infra': {
59
- component: <h2 className="m-0 cn-9 fs-16 fw-6 lh-32">{BUILD_INFRA_TEXT.HEADING}</h2>,
60
- linked: false,
61
- },
62
- },
63
- }
64
-
65
- // TODO: move heading to component itself
66
- export const BUILD_INFRA_FORM_FIELDS: BuildInfraFormFieldType[] = [
67
- {
68
- heading: <h3 className="m-0 cn-9 fs-13 fw-6 lh-20 w-240 dc__no-shrink">CPU (Request - Limit)</h3>,
69
- marker: ICCpu,
70
- actions: [
71
- {
72
- actionType: BuildInfraConfigTypes.CPU_REQUEST,
73
- label: 'Request',
74
- placeholder: 'Type CPU request',
75
- },
76
- {
77
- actionType: BuildInfraConfigTypes.CPU_LIMIT,
78
- label: 'Limit',
79
- placeholder: 'Type CPU limit',
80
- },
81
- ],
82
- locator: BuildInfraLocators.CPU,
83
- },
84
- {
85
- heading: <h3 className="m-0 cn-9 fs-13 fw-6 lh-20 w-240 dc__no-shrink">Memory (Request - Limit)</h3>,
86
- marker: ICMemory,
87
- actions: [
88
- {
89
- actionType: BuildInfraConfigTypes.MEMORY_REQUEST,
90
- label: 'Request',
91
- placeholder: 'Type memory request',
92
- },
93
- {
94
- actionType: BuildInfraConfigTypes.MEMORY_LIMIT,
95
- label: 'Limit',
96
- placeholder: 'Type memory limit',
97
- },
98
- ],
99
- locator: BuildInfraLocators.MEMORY,
100
- },
101
- {
102
- heading: <h3 className="m-0 cn-9 fs-13 fw-6 lh-20 w-240 dc__no-shrink">Build timeout</h3>,
103
- marker: ICTimer,
104
- actions: [
105
- {
106
- actionType: BuildInfraConfigTypes.BUILD_TIMEOUT,
107
- label: 'Timeout',
108
- placeholder: 'Type build timeout',
109
- },
110
- ],
111
- locator: BuildInfraLocators.BUILD_TIMEOUT,
112
- },
113
- ]
114
-
115
- export const PROFILE_INPUT_ERROR_FIELDS = Object.fromEntries(
116
- Object.values({ ...BuildInfraConfigTypes, ...BuildInfraMetaConfigTypes }).map((value) => [value, null]),
117
- ) as ProfileInputErrorType
118
-
119
- // fields required to be filled before submitting the form in create view, since we pre-populate the form with default values so no need in configs
120
- export const CREATE_MODE_REQUIRED_INPUT_FIELDS = [BuildInfraMetaConfigTypes.NAME]
121
-
122
- export const DEFAULT_PROFILE_NAME = 'default' as const
123
-
124
- export const CREATE_PROFILE_BASE_VALUE: BuildInfraProfileBase = {
125
- name: '',
126
- description: '',
127
- type: BuildInfraProfileVariants.NORMAL,
128
- appCount: 0,
129
- }
130
-
131
- export const CREATE_VIEW_CHECKED_CONFIGS = {
132
- [BuildInfraConfigTypes.CPU_REQUEST]: true,
133
- [BuildInfraConfigTypes.CPU_LIMIT]: true,
134
- } as const
135
-
136
- export const BUILD_INFRA_TEST_IDS = {
137
- SUBMIT_BUTTON: 'build-infra-submit-button',
138
- CANCEL_BUTTON: 'build-infra-cancel-button',
139
- } as const
@@ -1,7 +0,0 @@
1
- export { default as BuildInfraDescriptor } from './Descriptor'
2
- export { default as BuildInfraFooter } from './Footer'
3
- export { default as BuildInfraConfigForm } from './BuildInfraConfigForm'
4
- export * from './services'
5
- export * from './utils'
6
- export * from './types'
7
- export * from './constants'