@devtron-labs/devtron-fe-common-lib 0.0.42-beta-2 → 0.0.42-beta-3

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 (67) hide show
  1. package/dist/Common/DebouncedSearch/DebouncedSearch.d.ts +1 -1
  2. package/dist/Common/DebouncedSearch/Types.d.ts +0 -1
  3. package/dist/Common/Dialogs/Types.d.ts +0 -1
  4. package/dist/Common/Helper.d.ts +12 -0
  5. package/dist/Common/RJSF/Form.d.ts +4 -0
  6. package/dist/Common/RJSF/common/FieldRow.d.ts +6 -0
  7. package/dist/Common/RJSF/common/types.d.ts +8 -0
  8. package/dist/Common/RJSF/config.d.ts +4 -0
  9. package/dist/Common/RJSF/constants.d.ts +7 -0
  10. package/dist/Common/RJSF/index.d.ts +3 -0
  11. package/dist/Common/RJSF/templates/ArrayFieldItemTemplate.d.ts +3 -0
  12. package/dist/Common/RJSF/templates/ArrayFieldTemplate.d.ts +3 -0
  13. package/dist/Common/RJSF/templates/BaseInput.d.ts +3 -0
  14. package/dist/Common/RJSF/templates/ButtonTemplates/AddButton.d.ts +3 -0
  15. package/dist/Common/RJSF/templates/ButtonTemplates/RemoveButton.d.ts +3 -0
  16. package/dist/Common/RJSF/templates/ButtonTemplates/SubmitButton.d.ts +3 -0
  17. package/dist/Common/RJSF/templates/ButtonTemplates/index.d.ts +3 -0
  18. package/dist/Common/RJSF/templates/Description.d.ts +3 -0
  19. package/dist/Common/RJSF/templates/Field.d.ts +3 -0
  20. package/dist/Common/RJSF/templates/FieldErrorTemplate.d.ts +3 -0
  21. package/dist/Common/RJSF/templates/ObjectFieldTemplate.d.ts +3 -0
  22. package/dist/Common/RJSF/templates/TitleField.d.ts +3 -0
  23. package/dist/Common/RJSF/templates/WrapIfAdditionalTemplate.d.ts +3 -0
  24. package/dist/Common/RJSF/templates/index.d.ts +10 -0
  25. package/dist/Common/RJSF/types.d.ts +3 -0
  26. package/dist/Common/RJSF/utils.d.ts +25 -0
  27. package/dist/Common/RJSF/widgets/Checkbox.d.ts +3 -0
  28. package/dist/Common/RJSF/widgets/Select.d.ts +3 -0
  29. package/dist/Common/RJSF/widgets/index.d.ts +2 -0
  30. package/dist/Common/Types.d.ts +0 -137
  31. package/dist/Common/index.d.ts +1 -0
  32. package/dist/index.js +9615 -6894
  33. package/package.json +4 -1
  34. package/src/Assets/Icon/ic-chevron-down.svg +5 -0
  35. package/src/Common/DebouncedSearch/DebouncedSearch.tsx +2 -3
  36. package/src/Common/DebouncedSearch/Types.ts +0 -1
  37. package/src/Common/Dialogs/DeleteDialog.tsx +2 -18
  38. package/src/Common/Dialogs/Types.ts +0 -1
  39. package/src/Common/Helper.tsx +26 -4
  40. package/src/Common/RJSF/Form.tsx +29 -0
  41. package/src/Common/RJSF/common/FieldRow.tsx +35 -0
  42. package/src/Common/RJSF/common/types.ts +9 -0
  43. package/src/Common/RJSF/config.ts +37 -0
  44. package/src/Common/RJSF/constants.ts +10 -0
  45. package/src/Common/RJSF/index.ts +3 -0
  46. package/src/Common/RJSF/rjsfForm.scss +18 -0
  47. package/src/Common/RJSF/templates/ArrayFieldItemTemplate.tsx +31 -0
  48. package/src/Common/RJSF/templates/ArrayFieldTemplate.tsx +78 -0
  49. package/src/Common/RJSF/templates/BaseInput.tsx +16 -0
  50. package/src/Common/RJSF/templates/ButtonTemplates/AddButton.tsx +18 -0
  51. package/src/Common/RJSF/templates/ButtonTemplates/RemoveButton.tsx +10 -0
  52. package/src/Common/RJSF/templates/ButtonTemplates/SubmitButton.tsx +18 -0
  53. package/src/Common/RJSF/templates/ButtonTemplates/index.ts +3 -0
  54. package/src/Common/RJSF/templates/Description.tsx +12 -0
  55. package/src/Common/RJSF/templates/Field.tsx +30 -0
  56. package/src/Common/RJSF/templates/FieldErrorTemplate.tsx +25 -0
  57. package/src/Common/RJSF/templates/ObjectFieldTemplate.tsx +105 -0
  58. package/src/Common/RJSF/templates/TitleField.tsx +9 -0
  59. package/src/Common/RJSF/templates/WrapIfAdditionalTemplate.tsx +51 -0
  60. package/src/Common/RJSF/templates/index.ts +10 -0
  61. package/src/Common/RJSF/types.ts +4 -0
  62. package/src/Common/RJSF/utils.ts +110 -0
  63. package/src/Common/RJSF/widgets/Checkbox.tsx +44 -0
  64. package/src/Common/RJSF/widgets/Select.tsx +77 -0
  65. package/src/Common/RJSF/widgets/index.ts +2 -0
  66. package/src/Common/Types.ts +0 -150
  67. package/src/Common/index.ts +1 -0
@@ -0,0 +1,9 @@
1
+ import React from 'react'
2
+ import { TitleFieldProps } from '@rjsf/utils'
3
+
4
+ export const TitleField = ({ id, title, required }: TitleFieldProps) => (
5
+ <legend className="fs-13 fw-6 cn-9 lh-20 pb-8 dc__border-bottom en-1 mb-12" id={id}>
6
+ <span>{title}</span>
7
+ {required && <span className="cr-5">&nbsp;*</span>}
8
+ </legend>
9
+ )
@@ -0,0 +1,51 @@
1
+ import React from 'react'
2
+ import { ADDITIONAL_PROPERTY_FLAG, WrapIfAdditionalTemplateProps } from '@rjsf/utils'
3
+
4
+ import { PLACEHOLDERS } from '../constants'
5
+
6
+ export const WrapIfAdditionalTemplate = ({
7
+ id,
8
+ disabled,
9
+ label,
10
+ onKeyChange,
11
+ onDropPropertyClick,
12
+ readonly,
13
+ schema,
14
+ children,
15
+ uiSchema,
16
+ registry,
17
+ }: WrapIfAdditionalTemplateProps) => {
18
+ const { templates } = registry
19
+ const { RemoveButton } = templates.ButtonTemplates
20
+ const additional = ADDITIONAL_PROPERTY_FLAG in schema
21
+
22
+ return (
23
+ <>
24
+ {additional ? (
25
+ <div className="rjsf-form-template__additional-fields display-grid dc__gap-8 flex-align-center">
26
+ <div>
27
+ <input
28
+ type="text"
29
+ className="form__input cn-9 fs-13 lh-20 fw-4"
30
+ id={`${id}-key`}
31
+ onBlur={(event) => onKeyChange(event.target.value)}
32
+ placeholder={PLACEHOLDERS.OBJECT_KEY}
33
+ defaultValue={label}
34
+ />
35
+ </div>
36
+ <div>{children}</div>
37
+ <div>
38
+ <RemoveButton
39
+ disabled={disabled || readonly}
40
+ onClick={onDropPropertyClick(label)}
41
+ uiSchema={uiSchema}
42
+ registry={registry}
43
+ />
44
+ </div>
45
+ </div>
46
+ ) : (
47
+ children
48
+ )}
49
+ </>
50
+ )
51
+ }
@@ -0,0 +1,10 @@
1
+ export { ArrayFieldTemplate } from './ArrayFieldTemplate'
2
+ export { ArrayFieldItemTemplate } from './ArrayFieldItemTemplate'
3
+ export { BaseInput as BaseInputTemplate } from './BaseInput'
4
+ export * from './ButtonTemplates'
5
+ export { Description as DescriptionFieldTemplate } from './Description'
6
+ export { Field as FieldTemplate } from './Field'
7
+ export { FieldErrorTemplate } from './FieldErrorTemplate'
8
+ export { ObjectFieldTemplate } from './ObjectFieldTemplate'
9
+ export { TitleField as TitleFieldTemplate } from './TitleField'
10
+ export { WrapIfAdditionalTemplate } from './WrapIfAdditionalTemplate'
@@ -0,0 +1,4 @@
1
+ import { ComponentProps } from 'react'
2
+ import RJSFForm from '@rjsf/core'
3
+
4
+ export type FormProps = Omit<ComponentProps<typeof RJSFForm>, 'validator'>
@@ -0,0 +1,110 @@
1
+ import { TranslatableString, englishStringTranslator } from '@rjsf/utils'
2
+
3
+ /**
4
+ * Override for the TranslatableString from RJSF
5
+ */
6
+ export const translateString = (stringToTranslate: TranslatableString, params?: string[]): string => {
7
+ switch (stringToTranslate) {
8
+ case TranslatableString.NewStringDefault:
9
+ // Use an empty string for the new additionalProperties string default value
10
+ return ''
11
+ default:
12
+ return englishStringTranslator(stringToTranslate, params)
13
+ }
14
+ }
15
+
16
+ export const getCommonSelectStyle = (styleOverrides = {}) => {
17
+ return {
18
+ menuList: (base) => ({
19
+ ...base,
20
+ paddingTop: 0,
21
+ paddingBottom: 0,
22
+ }),
23
+ control: (base, state) => ({
24
+ ...base,
25
+ minHeight: '32px',
26
+ boxShadow: 'none',
27
+ backgroundColor: 'var(--N50)',
28
+ border: state.isFocused ? '1px solid var(--B500)' : '1px solid var(--N200)',
29
+ cursor: 'pointer',
30
+ }),
31
+ option: (base, state) => ({
32
+ ...base,
33
+ color: 'var(--N900)',
34
+ backgroundColor: state.isFocused ? 'var(--N100)' : 'white',
35
+ padding: '10px 12px',
36
+ }),
37
+ dropdownIndicator: (base, state) => ({
38
+ ...base,
39
+ color: 'var(--N400)',
40
+ padding: '0 8px',
41
+ transition: 'all .2s ease',
42
+ transform: state.selectProps.menuIsOpen ? 'rotate(180deg)' : 'rotate(0deg)',
43
+ }),
44
+ valueContainer: (base) => ({
45
+ ...base,
46
+ padding: '0 8px',
47
+ fontWeight: '400',
48
+ }),
49
+ loadingMessage: (base) => ({
50
+ ...base,
51
+ color: 'var(--N600)',
52
+ }),
53
+ noOptionsMessage: (base) => ({
54
+ ...base,
55
+ color: 'var(--N600)',
56
+ }),
57
+ ...styleOverrides,
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Returns the redirection props for a url
63
+ */
64
+ export const getRedirectionProps = (
65
+ url: string,
66
+ ): React.AnchorHTMLAttributes<HTMLAnchorElement> & {
67
+ url: string
68
+ } => {
69
+ try {
70
+ // The URL is validated when added using the form
71
+ const isInternalUrl = new URL(url).origin === window.location.origin
72
+ return {
73
+ href: url,
74
+ target: isInternalUrl ? '_self' : '_blank',
75
+ rel: isInternalUrl ? undefined : 'external noreferrer',
76
+ url,
77
+ }
78
+ } catch (err) {
79
+ return {
80
+ href: url,
81
+ target: '_blank',
82
+ url: `${url} (Invalid URL)`,
83
+ }
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Infers the type for json schema from value type
89
+ */
90
+ export const getInferredTypeFromValueType = (value) => {
91
+ const valueType = typeof value
92
+
93
+ switch (valueType) {
94
+ case 'boolean':
95
+ case 'string':
96
+ case 'number':
97
+ return valueType
98
+ case 'object':
99
+ if (Array.isArray(value)) {
100
+ return 'array'
101
+ }
102
+ if (value === null) {
103
+ return 'null'
104
+ }
105
+ return valueType
106
+ default:
107
+ // Unsupported or undefined types
108
+ return 'null'
109
+ }
110
+ }
@@ -0,0 +1,44 @@
1
+ import React, { ChangeEvent } from 'react'
2
+ import Toggle from '../../Toggle/Toggle'
3
+ import { WidgetProps } from '@rjsf/utils'
4
+
5
+ export const Checkbox = ({
6
+ id,
7
+ onChange,
8
+ value,
9
+ required,
10
+ disabled,
11
+ readonly,
12
+ autofocus,
13
+ onBlur,
14
+ onFocus,
15
+ }: WidgetProps) => {
16
+ const handleEvent = (e: ChangeEvent<HTMLInputElement>, type: 'blur' | 'focus') => {
17
+ const { id, checked } = e.target
18
+ if (type === 'blur') {
19
+ onBlur(id, checked)
20
+ } else if (type === 'focus') {
21
+ onFocus(id, checked)
22
+ }
23
+ }
24
+
25
+ const isSelected: boolean = typeof value === 'undefined' ? false : value
26
+
27
+ return (
28
+ <div>
29
+ <Toggle
30
+ selected={isSelected}
31
+ onSelect={onChange}
32
+ id={id}
33
+ name={id}
34
+ required={required}
35
+ disabled={disabled || readonly}
36
+ autoFocus={autofocus}
37
+ rootClassName="w-32 mb-0 dc__height-inherit"
38
+ onBlur={(e) => handleEvent(e, 'blur')}
39
+ onFocus={(e) => handleEvent(e, 'focus')}
40
+ />
41
+ <span className="dc__capitalize ml-8">{isSelected.toString()}</span>
42
+ </div>
43
+ )
44
+ }
@@ -0,0 +1,77 @@
1
+ import React from 'react'
2
+ import isEqual from 'lodash/isEqual'
3
+ import { WidgetProps } from '@rjsf/utils'
4
+ import ReactSelect, { MenuListProps, components } from 'react-select'
5
+ import { PLACEHOLDERS } from '../constants'
6
+ import { getCommonSelectStyle } from '../utils'
7
+
8
+ import { ReactComponent as ArrowDown } from '../../../Assets/Icon/ic-chevron-down.svg'
9
+
10
+ const commonStyles = getCommonSelectStyle()
11
+
12
+ const MenuList = ({ children, ...props }: MenuListProps) => (
13
+ <components.MenuList {...props}>{Array.isArray(children) ? children.slice(0, 20) : children}</components.MenuList>
14
+ )
15
+
16
+ const DropdownIndicator = (props) => (
17
+ <components.DropdownIndicator {...props}>
18
+ <ArrowDown className="icon-dim-20 icon-n5" data-testid="overview-project-edit-dropdown" />
19
+ </components.DropdownIndicator>
20
+ )
21
+
22
+ export const Select = (props: WidgetProps) => {
23
+ const {
24
+ id,
25
+ multiple = false,
26
+ options,
27
+ value,
28
+ disabled,
29
+ readonly,
30
+ autofocus = false,
31
+ onChange,
32
+ onBlur,
33
+ onFocus,
34
+ placeholder,
35
+ } = props
36
+ const { enumOptions: selectOptions = [] } = options
37
+ const emptyValue = multiple ? [] : ''
38
+
39
+ const handleChange = (option) => {
40
+ onChange(multiple ? option.map((o) => o.value) : option.value)
41
+ }
42
+
43
+ const getOption = (value) =>
44
+ multiple
45
+ ? selectOptions.filter((option) => value.some((val) => isEqual(val, option.value)))
46
+ : selectOptions.find((option) => isEqual(value, option.value))
47
+
48
+ return (
49
+ <ReactSelect
50
+ id={id}
51
+ name={id}
52
+ isMulti={multiple}
53
+ value={typeof value === 'undefined' ? emptyValue : getOption(value)}
54
+ autoFocus={autofocus}
55
+ onChange={handleChange}
56
+ options={selectOptions}
57
+ onBlur={() => onBlur(id, value)}
58
+ onFocus={() => onFocus(id, value)}
59
+ placeholder={placeholder || PLACEHOLDERS.SELECT}
60
+ isDisabled={disabled || readonly}
61
+ styles={{
62
+ ...commonStyles,
63
+ control: (base) => ({
64
+ ...base,
65
+ ...commonStyles.control,
66
+ backgroundColor: 'var(--N50)',
67
+ }),
68
+ }}
69
+ components={{
70
+ IndicatorSeparator: null,
71
+ DropdownIndicator,
72
+ MenuList,
73
+ }}
74
+ menuPlacement="auto"
75
+ />
76
+ )
77
+ }
@@ -0,0 +1,2 @@
1
+ export { Checkbox as CheckboxWidget } from './Checkbox'
2
+ export { Select as SelectWidget } from './Select'
@@ -1,8 +1,6 @@
1
1
  import React, { ReactNode, CSSProperties } from 'react'
2
2
  import { Placement } from 'tippy.js'
3
3
  import { ImageComment, ReleaseTag } from './ImageTags.Types'
4
- import { DockerConfigOverrideType, TaskErrorObj } from '.'
5
-
6
4
  export interface ResponseType {
7
5
  code: number
8
6
  status: string
@@ -317,7 +315,6 @@ export interface CommonNodeAttr {
317
315
  colorCode?: string
318
316
  isExternalCI?: boolean
319
317
  isLinkedCI?: boolean
320
- isLinkedCD?: boolean
321
318
  isJobCI?: boolean // used for Job type CI in Devtron Apps
322
319
  environmentName?: string //used for CDs
323
320
  environmentId?: number
@@ -354,7 +351,6 @@ export interface CommonNodeAttr {
354
351
  }
355
352
  appReleaseTagNames?: string[]
356
353
  tagsEditable?: boolean
357
- isGitRequired?: boolean;
358
354
  }
359
355
 
360
356
  export enum DeploymentAppTypes {
@@ -478,149 +474,3 @@ export interface AsyncState<T> {
478
474
  export interface AsyncOptions {
479
475
  resetOnChange: boolean
480
476
  }
481
-
482
- export interface AppEnvironment {
483
- environmentId: number
484
- environmentName: string
485
- appMetrics: boolean
486
- infraMetrics: boolean
487
- prod: boolean
488
- chartRefId?: number
489
- lastDeployed?: string
490
- lastDeployedBy?: string
491
- lastDeployedImage?: string
492
- appStatus?: string
493
- deploymentAppDeleteRequest?: boolean
494
- isVirtualEnvironment?: boolean
495
- isProtected?: boolean
496
- pipelineId?: number
497
- latestCdWorkflowRunnerId?: number
498
- }
499
-
500
- export interface Strategy {
501
- deploymentTemplate: string
502
- config: any
503
- default?: boolean
504
- }
505
-
506
- export interface CDStage {
507
- status: string
508
- name: string
509
- triggerType: 'AUTOMATIC' | 'MANUAL'
510
- config: string
511
- }
512
-
513
- export interface CDStageConfigMapSecretNames {
514
- configMaps: any[]
515
- secrets: any[]
516
- }
517
-
518
- export interface PrePostDeployStageType {
519
- isValid: boolean
520
- steps: TaskErrorObj[]
521
- triggerType: string
522
- name: string
523
- status: string
524
- }
525
-
526
- export interface CdPipeline {
527
- id: number
528
- environmentId: number
529
- environmentName?: string
530
- description?: string
531
- ciPipelineId: number
532
- triggerType: 'AUTOMATIC' | 'MANUAL'
533
- name: string
534
- strategies?: Strategy[]
535
- namespace?: string
536
- appWorkflowId?: number
537
- deploymentTemplate?: string
538
- preStage?: CDStage
539
- postStage?: CDStage
540
- preStageConfigMapSecretNames?: CDStageConfigMapSecretNames
541
- postStageConfigMapSecretNames?: CDStageConfigMapSecretNames
542
- runPreStageInEnv?: boolean
543
- runPostStageInEnv?: boolean
544
- isClusterCdActive?: boolean
545
- parentPipelineId?: number
546
- parentPipelineType?: string
547
- deploymentAppDeleteRequest?: boolean
548
- deploymentAppCreated?: boolean
549
- userApprovalConfig?: UserApprovalConfigType
550
- isVirtualEnvironment?: boolean
551
- deploymentAppType: DeploymentAppTypes
552
- helmPackageName?: string
553
- preDeployStage?: PrePostDeployStageType
554
- postDeployStage?: PrePostDeployStageType
555
- isProdEnv?: boolean
556
- }
557
-
558
- export interface ExternalCiConfig {
559
- id: number
560
- webhookUrl: string
561
- payload: string
562
- accessKey: string
563
- }
564
-
565
- export interface Source {
566
- type: string
567
- value?: string
568
- regex?: string
569
- }
570
-
571
- export interface CiMaterial {
572
- source: Source
573
- gitMaterialId: number
574
- id: number
575
- gitMaterialName: string
576
- isRegex?: boolean
577
- }
578
-
579
- export interface Task {
580
- name?: string
581
- type?: string
582
- cmd?: string
583
- args?: Array<string>
584
- }
585
-
586
- export interface CiScript {
587
- id: number
588
- index: number
589
- name: string
590
- script: string
591
- outputLocation?: string
592
- }
593
-
594
- export interface CiPipeline {
595
- isManual: boolean
596
- dockerArgs?: Map<string, string>
597
- isExternal: boolean
598
- parentCiPipeline: number
599
- parentAppId: number
600
- externalCiConfig: ExternalCiConfig
601
- ciMaterial?: CiMaterial[]
602
- name?: string
603
- id?: number
604
- active?: boolean
605
- linkedCount: number
606
- scanEnabled: boolean
607
- deleted?: boolean
608
- version?: string
609
- beforeDockerBuild?: Array<Task>
610
- afterDockerBuild?: Array<Task>
611
- appWorkflowId?: number
612
- beforeDockerBuildScripts?: Array<CiScript>
613
- afterDockerBuildScripts?: Array<CiScript>
614
- isDockerConfigOverridden?: boolean
615
- dockerConfigOverride?: DockerConfigOverrideType
616
- appName?: string
617
- appId?: string
618
- componentId?: number
619
- isCITriggerBlocked?: boolean
620
- ciBlockState?: {
621
- action: any
622
- metadataField: string
623
- }
624
- isOffendingMandatoryPlugin?: boolean
625
- pipelineType?: string
626
- }
@@ -40,3 +40,4 @@ export { default as Grid } from './Grid/Grid'
40
40
  export { default as ClipboardButton } from './ClipboardButton/ClipboardButton'
41
41
  export * from './Hooks'
42
42
  export { AppStatus } from './AppStatus'
43
+ export * from './RJSF'