@devtron-labs/devtron-fe-common-lib 0.0.58-beta-3 → 0.0.58-beta-4

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 (70) hide show
  1. package/dist/Common/Constants.d.ts +9 -0
  2. package/dist/Common/CustomInput/CustomInput.d.ts +1 -1
  3. package/dist/Common/CustomInput/Types.d.ts +1 -0
  4. package/dist/Common/EmptyState/GenericEmptyState.d.ts +1 -1
  5. package/dist/Common/Helper.d.ts +1 -4
  6. package/dist/Common/Types.d.ts +4 -2
  7. package/dist/Pages/GlobalConfigurations/BuildInfra/BuildInfraConfigForm.d.ts +4 -0
  8. package/dist/Pages/GlobalConfigurations/BuildInfra/BuildInfraDescriptionField.d.ts +4 -0
  9. package/dist/Pages/GlobalConfigurations/BuildInfra/BuildInfraFormAction.d.ts +7 -0
  10. package/dist/Pages/GlobalConfigurations/BuildInfra/BuildInfraFormItem.d.ts +4 -0
  11. package/dist/Pages/GlobalConfigurations/BuildInfra/BuildInfraProfileNameField.d.ts +4 -0
  12. package/dist/Pages/GlobalConfigurations/BuildInfra/Descriptor.d.ts +4 -0
  13. package/dist/Pages/GlobalConfigurations/BuildInfra/Footer.d.ts +4 -0
  14. package/dist/Pages/GlobalConfigurations/BuildInfra/constants.d.ts +48 -0
  15. package/dist/Pages/GlobalConfigurations/BuildInfra/index.d.ts +7 -0
  16. package/dist/Pages/GlobalConfigurations/BuildInfra/services.d.ts +13 -0
  17. package/dist/Pages/GlobalConfigurations/BuildInfra/types.d.ts +281 -0
  18. package/dist/Pages/GlobalConfigurations/BuildInfra/utils.d.ts +12 -0
  19. package/dist/Pages/GlobalConfigurations/index.d.ts +1 -0
  20. package/dist/Pages/index.d.ts +1 -0
  21. package/dist/Shared/Components/APIResponseHandler/APIResponseHandler.d.ts +4 -0
  22. package/dist/Shared/Components/APIResponseHandler/index.d.ts +2 -0
  23. package/dist/Shared/Components/APIResponseHandler/types.d.ts +37 -0
  24. package/dist/Shared/Components/ReactSelect/index.d.ts +1 -0
  25. package/dist/Shared/Components/ReactSelect/utils.d.ts +12 -0
  26. package/dist/Shared/Components/index.d.ts +2 -0
  27. package/dist/Shared/index.d.ts +2 -0
  28. package/dist/Shared/validations.d.ts +7 -0
  29. package/dist/index.d.ts +3 -1
  30. package/dist/index.js +1160 -193
  31. package/package.json +1 -1
  32. package/src/Assets/Icon/ic-cpu.svg +4 -0
  33. package/src/Assets/Icon/ic-memory.svg +3 -0
  34. package/src/Assets/Icon/ic-timer.svg +3 -0
  35. package/src/Common/BreadCrumb/Types.ts +0 -1
  36. package/src/Common/Checkbox.tsx +1 -0
  37. package/src/Common/Constants.ts +11 -1
  38. package/src/Common/CustomInput/CustomInput.tsx +6 -5
  39. package/src/Common/CustomInput/Types.ts +1 -0
  40. package/src/Common/DraggableWrapper/DraggableWrapper.tsx +3 -1
  41. package/src/Common/EmptyState/GenericEmptyState.tsx +45 -13
  42. package/src/Common/Helper.tsx +16 -30
  43. package/src/Common/RJSF/utils.ts +3 -0
  44. package/src/Common/SearchBar/SearchBar.component.tsx +26 -13
  45. package/src/Common/SearchBar/searchBar.scss +1 -1
  46. package/src/Common/Types.ts +3 -1
  47. package/src/Pages/GlobalConfigurations/BuildInfra/BuildInfraConfigForm.tsx +121 -0
  48. package/src/Pages/GlobalConfigurations/BuildInfra/BuildInfraDescriptionField.tsx +44 -0
  49. package/src/Pages/GlobalConfigurations/BuildInfra/BuildInfraFormAction.tsx +99 -0
  50. package/src/Pages/GlobalConfigurations/BuildInfra/BuildInfraFormItem.tsx +55 -0
  51. package/src/Pages/GlobalConfigurations/BuildInfra/BuildInfraProfileNameField.tsx +32 -0
  52. package/src/Pages/GlobalConfigurations/BuildInfra/Descriptor.tsx +38 -0
  53. package/src/Pages/GlobalConfigurations/BuildInfra/Footer.tsx +45 -0
  54. package/src/Pages/GlobalConfigurations/BuildInfra/Readme.md +4 -0
  55. package/src/Pages/GlobalConfigurations/BuildInfra/constants.tsx +137 -0
  56. package/src/Pages/GlobalConfigurations/BuildInfra/index.ts +7 -0
  57. package/src/Pages/GlobalConfigurations/BuildInfra/services.tsx +183 -0
  58. package/src/Pages/GlobalConfigurations/BuildInfra/types.tsx +334 -0
  59. package/src/Pages/GlobalConfigurations/BuildInfra/utils.tsx +489 -0
  60. package/src/Pages/GlobalConfigurations/index.ts +1 -0
  61. package/src/Pages/index.ts +1 -0
  62. package/src/Shared/Components/APIResponseHandler/APIResponseHandler.tsx +39 -0
  63. package/src/Shared/Components/APIResponseHandler/index.ts +2 -0
  64. package/src/Shared/Components/APIResponseHandler/types.tsx +39 -0
  65. package/src/Shared/Components/ReactSelect/index.ts +1 -0
  66. package/src/Shared/Components/ReactSelect/utils.tsx +97 -0
  67. package/src/Shared/Components/index.ts +2 -0
  68. package/src/Shared/index.ts +2 -0
  69. package/src/Shared/validations.tsx +72 -0
  70. package/src/index.ts +3 -1
@@ -0,0 +1,334 @@
1
+ import { FormEvent, FunctionComponent, ReactNode } from 'react'
2
+ import { Breadcrumb } from '../../../Common/BreadCrumb/Types'
3
+ import { ValidationResponseType } from '../../../Shared'
4
+ import { ServerErrors } from '../../../Common'
5
+
6
+ /**
7
+ * Unique actions that will be dispatched and,
8
+ * Keeping some values (cpu_limit, etc) in sync with backend
9
+ */
10
+ export enum BuildInfraConfigTypes {
11
+ CPU_LIMIT = 'cpu_limit',
12
+ CPU_REQUEST = 'cpu_request',
13
+ MEMORY_LIMIT = 'memory_limit',
14
+ MEMORY_REQUEST = 'memory_request',
15
+ BUILD_TIMEOUT = 'timeout',
16
+ }
17
+
18
+ /**
19
+ * Combination of BuildInfraConfigTypes and BuildInfraMetaConfigTypes is going to derive error state and actions(actions will also be derived with BuildInfraInheritActions)
20
+ */
21
+ export enum BuildInfraMetaConfigTypes {
22
+ NAME = 'name',
23
+ DESCRIPTION = 'description',
24
+ }
25
+
26
+ /**
27
+ * Would be used as key for few components and would be appending activate and de_activate actions to it
28
+ */
29
+ export enum BuildInfraLocators {
30
+ CPU = 'cpu',
31
+ MEMORY = 'memory',
32
+ // This name can be also different from BuildInfraConfigTypes[BUILD_TIMEOUT] in case we want to show different label
33
+ BUILD_TIMEOUT = 'timeout',
34
+ }
35
+
36
+ // FIXME: Derive this from BuildInfraLocators
37
+ // Appending the locators from above
38
+ export enum BuildInfraInheritActions {
39
+ ACTIVATE_CPU = `activate_cpu`,
40
+ DE_ACTIVATE_CPU = `de_activate_cpu`,
41
+ ACTIVATE_MEMORY = `activate_memory`,
42
+ DE_ACTIVATE_MEMORY = `de_activate_memory`,
43
+ ACTIVATE_BUILD_TIMEOUT = `activate_build_timeout`,
44
+ DE_ACTIVATE_BUILD_TIMEOUT = `de_activate_build_timeout`,
45
+ }
46
+
47
+ // TODO: Better name would be BuildInfraConfigActionMap
48
+ export const BuildInfraLocatorsActionMap = {
49
+ [BuildInfraConfigTypes.BUILD_TIMEOUT]: BuildInfraLocators.BUILD_TIMEOUT,
50
+ [BuildInfraConfigTypes.CPU_LIMIT]: BuildInfraLocators.CPU,
51
+ [BuildInfraConfigTypes.CPU_REQUEST]: BuildInfraLocators.CPU,
52
+ [BuildInfraConfigTypes.MEMORY_LIMIT]: BuildInfraLocators.MEMORY,
53
+ [BuildInfraConfigTypes.MEMORY_REQUEST]: BuildInfraLocators.MEMORY,
54
+ }
55
+
56
+ export enum BuildInfraProfileVariants {
57
+ DEFAULT = 'DEFAULT',
58
+ NORMAL = 'NORMAL',
59
+ CUSTOM = 'CUSTOM',
60
+ }
61
+
62
+ export interface DescriptorProps {
63
+ /**
64
+ * In case we want to restrict the max-width
65
+ */
66
+ additionalContainerClasses?: string
67
+ breadCrumbs: Breadcrumb[]
68
+ /**
69
+ * Would stick at right of div
70
+ */
71
+ children?: ReactNode
72
+ }
73
+
74
+ export interface BuildInfraActionType {
75
+ /**
76
+ * Type of action to be dispatched, would be suffixed with type of change
77
+ */
78
+ actionType: BuildInfraConfigTypes
79
+ /**
80
+ * Label to be shown above input
81
+ */
82
+ label: string
83
+ /**
84
+ * Placeholder for input, can be optional
85
+ */
86
+ placeholder?: string
87
+ // Can add a prop for variant, if there is a need to show different types of inputs
88
+ }
89
+
90
+ export interface BuildInfraConfigurationMarkerProps {
91
+ className?: string
92
+ }
93
+
94
+ export interface BuildInfraFormFieldType {
95
+ /**
96
+ * Heading of the form item
97
+ */
98
+ heading: ReactNode
99
+ /**
100
+ * Icon/Checkbox to be shown in front of heading
101
+ */
102
+ marker: FunctionComponent<BuildInfraConfigurationMarkerProps>
103
+ /**
104
+ * Actions to be shown in the form item
105
+ */
106
+ actions: BuildInfraActionType[]
107
+ /**
108
+ * Unique identifier for the form item used for key
109
+ */
110
+ locator: BuildInfraLocators
111
+ }
112
+
113
+ export interface ConfigurationUnitType {
114
+ name: string
115
+ conversionFactor: number
116
+ }
117
+
118
+ // key would be the name of ConfigurationUnitType
119
+ export type ConfigurationUnitMapType = {
120
+ [key: ConfigurationUnitType['name']]: ConfigurationUnitType
121
+ }
122
+
123
+ export type BuildInfraUnitsMapType = {
124
+ [key in BuildInfraConfigTypes]: ConfigurationUnitMapType
125
+ }
126
+
127
+ export interface BuildInfraConfigValuesType {
128
+ value: string
129
+ unit?: ConfigurationUnitType['name']
130
+ }
131
+
132
+ interface BuildInfraProfileConfigBase {
133
+ id?: number
134
+ key: BuildInfraConfigTypes
135
+ profileName: string
136
+ active: boolean
137
+ }
138
+
139
+ export interface BuildInfraProfileConfigResponseDataType
140
+ extends BuildInfraConfigValuesType,
141
+ BuildInfraProfileConfigBase {}
142
+
143
+ export interface BuildInfraConfigurationType extends BuildInfraConfigValuesType, BuildInfraProfileConfigBase {
144
+ defaultValue: BuildInfraConfigValuesType
145
+ }
146
+
147
+ export type BuildInfraConfigurationMapType = {
148
+ [key in BuildInfraConfigTypes]: BuildInfraConfigurationType
149
+ }
150
+
151
+ export interface BuildInfraProfileBase {
152
+ id?: number
153
+ name: string
154
+ description: string
155
+ type: BuildInfraProfileVariants
156
+ appCount: number
157
+ }
158
+
159
+ export interface BuildInfraProfileResponseDataType extends BuildInfraProfileBase {
160
+ configurations: BuildInfraProfileConfigResponseDataType[]
161
+ }
162
+
163
+ export interface BuildInfraProfileData extends BuildInfraProfileBase {
164
+ configurations: BuildInfraConfigurationMapType
165
+ }
166
+
167
+ export interface GetBuildInfraProfileType {
168
+ name: string
169
+ fromCreateView?: boolean
170
+ }
171
+
172
+ export interface BuildInfraProfileResponseType {
173
+ configurationUnits: BuildInfraUnitsMapType | null
174
+ profile: BuildInfraProfileData | null
175
+ }
176
+
177
+ export interface UseBuildInfraFormProps {
178
+ /**
179
+ * Name of the profile, if not provided assumption would be for create view
180
+ */
181
+ name?: string
182
+ /**
183
+ * If true, would send put request else would create profile via post
184
+ */
185
+ editProfile?: boolean
186
+ /**
187
+ * If true, call this on form submission success
188
+ */
189
+ handleSuccessRedirection?: () => void
190
+ }
191
+
192
+ export type ProfileInputErrorType = {
193
+ [key in BuildInfraConfigTypes | BuildInfraMetaConfigTypes]: string
194
+ }
195
+
196
+ export interface ProfileInputDispatchDataType {
197
+ value: string
198
+ unit?: string
199
+ }
200
+
201
+ export interface HandleProfileInputChangeType {
202
+ action: BuildInfraConfigTypes | BuildInfraInheritActions | BuildInfraMetaConfigTypes
203
+ data?: ProfileInputDispatchDataType
204
+ }
205
+
206
+ export interface UseBuildInfraFormResponseType {
207
+ isLoading: boolean
208
+ profileResponse: BuildInfraProfileResponseType | null
209
+ responseError: ServerErrors | null
210
+ reloadRequest: () => void
211
+ profileInput: BuildInfraProfileData
212
+ profileInputErrors: ProfileInputErrorType
213
+ handleProfileInputChange: ({ action, data }: HandleProfileInputChangeType) => void
214
+ loadingActionRequest: boolean
215
+ handleSubmit: (e: FormEvent<HTMLFormElement>) => Promise<void>
216
+ }
217
+
218
+ export interface BuildInfraFormItemProps extends Pick<BuildInfraFormFieldType, 'marker' | 'heading'> {
219
+ children?: ReactNode
220
+ /**
221
+ * If true, means profile is inheriting values from other profile (e.g, default)
222
+ */
223
+ isInheriting?: boolean
224
+ /**
225
+ * Would be false for last item
226
+ */
227
+ showDivider?: boolean
228
+
229
+ /**
230
+ * Would be used to dispatch inherit actions (activate_cpu, de_activate_cpu, etc)
231
+ */
232
+ handleProfileInputChange: UseBuildInfraFormResponseType['handleProfileInputChange']
233
+ locator: BuildInfraFormFieldType['locator']
234
+ isDefaultProfile: boolean
235
+ }
236
+
237
+ export interface ValidateRequestLimitType {
238
+ request: BuildInfraConfigValuesType
239
+ limit: BuildInfraConfigValuesType
240
+ unitsMap: ConfigurationUnitMapType
241
+ }
242
+
243
+ export interface ValidateRequestLimitResponseType {
244
+ request: ValidationResponseType
245
+ limit: ValidationResponseType
246
+ }
247
+
248
+ export interface BuildInfraConfigFormProps
249
+ extends Pick<UseBuildInfraFormResponseType, 'profileInput' | 'profileInputErrors' | 'handleProfileInputChange'> {
250
+ isDefaultProfile?: boolean
251
+ unitsMap?: BuildInfraProfileResponseType['configurationUnits']
252
+ configurationContainerLabel?: ReactNode
253
+ }
254
+
255
+ export interface BuildInfraFormActionProps extends BuildInfraActionType {
256
+ handleProfileInputChange: UseBuildInfraFormResponseType['handleProfileInputChange']
257
+ currentValue: BuildInfraConfigValuesType['value']
258
+ error?: string
259
+ isRequired?: boolean
260
+ profileUnitsMap?: ConfigurationUnitMapType
261
+ currentUnitName?: BuildInfraConfigValuesType['unit']
262
+ }
263
+
264
+ export interface FooterProps {
265
+ /**
266
+ * If true, means form contains errors
267
+ */
268
+ disabled?: boolean
269
+ hideCancelButton?: boolean
270
+ /**
271
+ * If true would show save changes else would show save for submit button
272
+ */
273
+ editProfile?: boolean
274
+ loading?: boolean
275
+ }
276
+
277
+ export interface UpdateBuildInfraProfileType extends Pick<UseBuildInfraFormResponseType, 'profileInput'> {
278
+ name: string
279
+ }
280
+
281
+ export interface CreateBuildInfraProfileType extends Pick<UseBuildInfraFormResponseType, 'profileInput'> {}
282
+
283
+ export interface CreateBuildInfraServiceConfigurationType {
284
+ key: BuildInfraConfigTypes
285
+ value: string
286
+ active: boolean
287
+ unit?: string
288
+ /**
289
+ * Would send for those that are available in profileInput
290
+ */
291
+ id?: number
292
+ }
293
+
294
+ export interface CreateBuildInfraServicePayloadType {
295
+ name: string
296
+ description: string
297
+ type: BuildInfraProfileVariants
298
+ configurations: CreateBuildInfraServiceConfigurationType[]
299
+ }
300
+
301
+ export interface BuildInfraInputFieldComponentProps {
302
+ handleProfileInputChange: UseBuildInfraFormResponseType['handleProfileInputChange']
303
+ currentValue: BuildInfraConfigValuesType['value']
304
+ error?: string
305
+ }
306
+
307
+ export interface InheritingHeaderProps {
308
+ defaultHeading: BuildInfraFormFieldType['heading']
309
+ inheritingData: BuildInfraConfigValuesType[]
310
+ isInheriting: boolean
311
+ isDefaultProfile: boolean
312
+ }
313
+
314
+ export interface BuildInfraConfigResponseDataType {
315
+ name: BuildInfraConfigTypes
316
+ units: ConfigurationUnitType[]
317
+ }
318
+
319
+ interface BaseBuildInfraProfileResponseType {
320
+ defaultConfigurations: BuildInfraProfileConfigResponseDataType[]
321
+ configurationUnits: BuildInfraUnitsMapType
322
+ }
323
+
324
+ export interface BuildInfraListResponseType extends BaseBuildInfraProfileResponseType {
325
+ profiles: BuildInfraProfileResponseDataType[]
326
+ }
327
+
328
+ export interface BuildInfraProfileAPIResponseType extends BaseBuildInfraProfileResponseType {
329
+ profile: BuildInfraProfileResponseDataType
330
+ }
331
+
332
+ export interface BuildInfraProfileTransformerType
333
+ extends BuildInfraProfileAPIResponseType,
334
+ Pick<GetBuildInfraProfileType, 'fromCreateView'> {}