@devtron-labs/devtron-fe-common-lib 0.0.48-beta-9 → 0.0.48-beta-11

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 (127) hide show
  1. package/.eslintignore +75 -0
  2. package/.eslintrc.js +84 -16
  3. package/.github/pull_request_template.md +25 -0
  4. package/.github/workflows/ci.yml +31 -0
  5. package/.github/workflows/release-package.yml +2 -3
  6. package/.husky/pre-commit +5 -0
  7. package/.lintstagedrc +3 -0
  8. package/.nvmrc +1 -0
  9. package/dist/Common/BreadCrumb/BreadCrumb.d.ts +1 -1
  10. package/dist/Common/BreadCrumb/BreadcrumbStore.d.ts +2 -2
  11. package/dist/Common/Constants.d.ts +1 -5
  12. package/dist/Common/CustomInput/CustomInput.d.ts +1 -1
  13. package/dist/Common/CustomInput/Types.d.ts +2 -2
  14. package/dist/Common/CustomTagSelector/ResizableTagTextArea.d.ts +1 -1
  15. package/dist/Common/DeleteComponentModal/DeleteComponent.d.ts +1 -1
  16. package/dist/Common/DevtronProgressing/DevtronProgressing.d.ts +1 -1
  17. package/dist/Common/Dialogs/ConfirmationDialog.d.ts +6 -6
  18. package/dist/Common/Dialogs/DeleteDialog.d.ts +1 -1
  19. package/dist/Common/Dialogs/ForceDeleteDialog.d.ts +1 -1
  20. package/dist/Common/Dialogs/Types.d.ts +1 -1
  21. package/dist/Common/EmptyState/EmptyState.d.ts +20 -17
  22. package/dist/Common/EmptyState/GenericEmptyState.d.ts +1 -1
  23. package/dist/Common/Error.d.ts +2 -1
  24. package/dist/Common/ErrorScreenNotFound.d.ts +1 -1
  25. package/dist/Common/Helper.d.ts +1 -1
  26. package/dist/Common/ImageTags.d.ts +1 -1
  27. package/dist/Common/InfoColorBar/InfoColourbar.d.ts +1 -1
  28. package/dist/Common/Modals/Modal.d.ts +2 -2
  29. package/dist/Common/Modals/OpaqueModal.d.ts +3 -3
  30. package/dist/Common/Modals/VisibleModal.d.ts +3 -3
  31. package/dist/Common/Modals/VisibleModal2.d.ts +3 -3
  32. package/dist/Common/MultiSelectCustomization.d.ts +1 -1
  33. package/dist/Common/Policy.Types.d.ts +2 -2
  34. package/dist/Common/PopupMenu.d.ts +5 -5
  35. package/dist/Common/Progressing.d.ts +2 -2
  36. package/dist/Common/RadioGroup/RadioGroup.d.ts +1 -1
  37. package/dist/Common/ResizableTextarea.d.ts +1 -1
  38. package/dist/Common/TippyCustomized.d.ts +1 -1
  39. package/dist/Common/ToastBody.d.ts +5 -5
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.js +266 -351
  42. package/package.json +19 -2
  43. package/src/Common/AddCDButton/AddCDButton.tsx +1 -2
  44. package/src/Common/Api.ts +21 -26
  45. package/src/Common/AppStatus/AppStatus.tsx +12 -12
  46. package/src/Common/AppStatus/utils.ts +6 -5
  47. package/src/Common/BreadCrumb/BreadCrumb.tsx +32 -28
  48. package/src/Common/BreadCrumb/BreadcrumbStore.tsx +2 -2
  49. package/src/Common/BreadCrumb/Types.ts +11 -12
  50. package/src/Common/Checkbox.tsx +17 -19
  51. package/src/Common/ClipboardButton/ClipboardButton.tsx +1 -1
  52. package/src/Common/ClipboardButton/__tests__/ClipboardButton.test.tsx +0 -1
  53. package/src/Common/Common.service.ts +59 -64
  54. package/src/Common/Constants.ts +9 -14
  55. package/src/Common/CustomInput/CustomInput.tsx +22 -29
  56. package/src/Common/CustomInput/Types.ts +4 -4
  57. package/src/Common/CustomInput/index.ts +1 -1
  58. package/src/Common/CustomTagSelector/PropagateTagInfo.tsx +15 -18
  59. package/src/Common/CustomTagSelector/ResizableTagTextArea.tsx +9 -9
  60. package/src/Common/CustomTagSelector/TagDetails.tsx +9 -3
  61. package/src/Common/CustomTagSelector/TagLabelSelect.tsx +7 -9
  62. package/src/Common/CustomTagSelector/TagLabelValueSelector.tsx +31 -35
  63. package/src/Common/CustomTagSelector/TagSelector.utils.ts +2 -3
  64. package/src/Common/CustomTagSelector/Types.ts +1 -1
  65. package/src/Common/CustomTagSelector/ValidationRules.ts +18 -22
  66. package/src/Common/CustomTagSelector/index.ts +2 -2
  67. package/src/Common/DebouncedSearch/DebouncedSearch.tsx +2 -1
  68. package/src/Common/DebouncedSearch/__tests__/DebouncedSearch.test.tsx +0 -1
  69. package/src/Common/DeleteComponentModal/DeleteComponent.tsx +27 -32
  70. package/src/Common/DeleteComponentModal/types.ts +1 -1
  71. package/src/Common/DevtronProgressing/DevtronProgressing.tsx +5 -8
  72. package/src/Common/Dialogs/ConfirmationDialog.tsx +24 -24
  73. package/src/Common/Dialogs/DeleteDialog.tsx +3 -5
  74. package/src/Common/Dialogs/DialogForm.tsx +31 -35
  75. package/src/Common/Dialogs/ForceDeleteDialog.tsx +13 -7
  76. package/src/Common/Dialogs/Types.ts +12 -12
  77. package/src/Common/Dialogs/index.ts +1 -1
  78. package/src/Common/Drawer/Drawer.tsx +1 -1
  79. package/src/Common/EmptyState/EmptyState.tsx +13 -17
  80. package/src/Common/EmptyState/GenericEmptyState.tsx +7 -21
  81. package/src/Common/Error.tsx +5 -5
  82. package/src/Common/ErrorScreenNotFound.tsx +9 -12
  83. package/src/Common/Grid/Grid.tsx +1 -2
  84. package/src/Common/Helper.tsx +23 -24
  85. package/src/Common/Hooks/UseClickOutside/UseClickOutside.tsx +1 -1
  86. package/src/Common/Hooks/UseSuperAdmin/UseSuperAdmin.tsx +1 -1
  87. package/src/Common/ImageTags.Types.ts +2 -3
  88. package/src/Common/ImageTags.tsx +61 -66
  89. package/src/Common/InfoColorBar/InfoColourbar.tsx +10 -5
  90. package/src/Common/Modals/Modal.tsx +3 -3
  91. package/src/Common/Modals/OpaqueModal.tsx +25 -18
  92. package/src/Common/Modals/VisibleModal.tsx +7 -3
  93. package/src/Common/Modals/VisibleModal2.tsx +20 -15
  94. package/src/Common/MultiSelectCustomization.tsx +9 -13
  95. package/src/Common/Policy.Types.ts +38 -38
  96. package/src/Common/PopupMenu.tsx +10 -9
  97. package/src/Common/Progressing.tsx +15 -18
  98. package/src/Common/RJSF/Form.tsx +0 -1
  99. package/src/Common/RJSF/common/FieldRow.tsx +0 -1
  100. package/src/Common/RJSF/config.ts +0 -1
  101. package/src/Common/RJSF/templates/ArrayFieldItemTemplate.tsx +1 -1
  102. package/src/Common/RJSF/templates/ArrayFieldTemplate.tsx +0 -1
  103. package/src/Common/RJSF/templates/BaseInput.tsx +0 -1
  104. package/src/Common/RJSF/templates/ButtonTemplates/AddButton.tsx +0 -1
  105. package/src/Common/RJSF/templates/ButtonTemplates/RemoveButton.tsx +0 -1
  106. package/src/Common/RJSF/templates/ButtonTemplates/SubmitButton.tsx +1 -6
  107. package/src/Common/RJSF/templates/Description.tsx +0 -1
  108. package/src/Common/RJSF/templates/Field.tsx +14 -3
  109. package/src/Common/RJSF/templates/FieldErrorTemplate.tsx +6 -9
  110. package/src/Common/RJSF/templates/ObjectFieldTemplate.tsx +5 -7
  111. package/src/Common/RJSF/templates/TitleField.tsx +0 -1
  112. package/src/Common/RJSF/templates/WrapIfAdditionalTemplate.tsx +0 -1
  113. package/src/Common/RJSF/utils.ts +53 -57
  114. package/src/Common/RJSF/widgets/Checkbox.tsx +2 -2
  115. package/src/Common/RJSF/widgets/Select.tsx +0 -1
  116. package/src/Common/RadioGroup/RadioGroup.tsx +18 -23
  117. package/src/Common/RadioGroup.tsx +24 -23
  118. package/src/Common/Reload.tsx +0 -1
  119. package/src/Common/ResizableTextarea.tsx +18 -17
  120. package/src/Common/Security/ScanVulnerabilitiesTable.tsx +29 -34
  121. package/src/Common/ServerError.ts +5 -1
  122. package/src/Common/TippyCustomized.tsx +41 -38
  123. package/src/Common/ToastBody.tsx +6 -7
  124. package/src/Common/Toggle/Toggle.tsx +3 -3
  125. package/src/Common/Types.ts +12 -12
  126. package/src/custom.d.ts +7 -7
  127. package/src/index.ts +1 -1
@@ -1,32 +1,32 @@
1
- import React from 'react'
2
1
  import { VisibleModal2 } from '../Modals/VisibleModal2'
3
- import { ConfirmationDialogBodyType, ConfirmationDialogButtonGroupType, ConfirmationDialogIconType, ConfirmationDialogType } from './Types'
2
+ import {
3
+ ConfirmationDialogBodyType,
4
+ ConfirmationDialogButtonGroupType,
5
+ ConfirmationDialogIconType,
6
+ ConfirmationDialogType,
7
+ } from './Types'
4
8
 
5
- function ConfirmationDialog({ className = '', children }: ConfirmationDialogType) {
6
- return (
7
- <VisibleModal2 className="confirmation-dialog">
8
- <div className={`confirmation-dialog__body ${className}`}>{children}</div>
9
- </VisibleModal2>
10
- )
11
- }
9
+ const ConfirmationDialog = ({ className = '', children }: ConfirmationDialogType) => (
10
+ <VisibleModal2 className="confirmation-dialog">
11
+ <div className={`confirmation-dialog__body ${className}`}>{children}</div>
12
+ </VisibleModal2>
13
+ )
12
14
 
13
- function Icon({ src, className = '' }: ConfirmationDialogIconType) {
14
- return <img src={src} className={`confirmation-dialog__icon ${className}`} alt="" />
15
- }
15
+ const Icon = ({ src, className = '' }: ConfirmationDialogIconType) => (
16
+ <img src={src} className={`confirmation-dialog__icon ${className}`} alt="" />
17
+ )
16
18
 
17
- function Body({ title, subtitle = null, children = null }: ConfirmationDialogBodyType) {
18
- return (
19
- <div className="flex left column ">
20
- <h3 className="confirmation-dialog__title lh-1-5 dc__break-word w-100">{title}</h3>
21
- {subtitle && <div className="confirmation-dialog__subtitle">{subtitle}</div>}
22
- {children}
23
- </div>
24
- )
25
- }
19
+ const Body = ({ title, subtitle = null, children = null }: ConfirmationDialogBodyType) => (
20
+ <div className="flex left column ">
21
+ <h3 className="confirmation-dialog__title lh-1-5 dc__break-word w-100">{title}</h3>
22
+ {subtitle && <div className="confirmation-dialog__subtitle">{subtitle}</div>}
23
+ {children}
24
+ </div>
25
+ )
26
26
 
27
- function ButtonGroup({ children }: ConfirmationDialogButtonGroupType) {
28
- return <div className="flex right confirmation-dialog__button-group">{children}</div>
29
- }
27
+ const ButtonGroup = ({ children }: ConfirmationDialogButtonGroupType) => (
28
+ <div className="flex right confirmation-dialog__button-group">{children}</div>
29
+ )
30
30
 
31
31
  ConfirmationDialog.Icon = Icon
32
32
  ConfirmationDialog.Body = Body
@@ -1,10 +1,10 @@
1
- import React from 'react'
1
+ import * as React from 'react'
2
2
  import warn from '../../Assets/Img/delete-medium.svg'
3
3
  import { Progressing } from '../Progressing'
4
4
  import ConfirmationDialog from './ConfirmationDialog'
5
5
  import { DeleteDialogProps } from './Types'
6
6
 
7
- export const DeleteDialog: React.FC<DeleteDialogProps> & { Description?: React.FC<any> } = function (props) {
7
+ export const DeleteDialog: React.FC<DeleteDialogProps> & { Description?: React.FC<any> } = (props) => {
8
8
  const handleDelete = (e: React.MouseEvent) => {
9
9
  if (props.shouldStopPropagation) {
10
10
  e.stopPropagation()
@@ -62,8 +62,6 @@ export const DeleteDialog: React.FC<DeleteDialogProps> & { Description?: React.F
62
62
  )
63
63
  }
64
64
 
65
- function DeleteDialogDescription(props) {
66
- return <>{props.children}</>
67
- }
65
+ const DeleteDialogDescription = (props) => <>{props.children}</>
68
66
 
69
67
  DeleteDialog.Description = DeleteDialogDescription
@@ -1,28 +1,28 @@
1
- import React, { Component, createContext } from 'react';
2
- import { VisibleModal } from '../Modals/VisibleModal';
3
- import close from '../../Assets/Icon/ic-cross.svg';
1
+ import { Component, createContext } from 'react'
2
+ import { VisibleModal } from '../Modals/VisibleModal'
3
+ import close from '../../Assets/Icon/ic-cross.svg'
4
4
  import { Progressing } from '../Progressing'
5
- import { DialogFormProps } from './Types';
6
- //TODO: may not need context
7
- const DialogFormContext = createContext({ title: '', isLoading: false, close: (event) => {}, onSave: (event) => {} });
5
+ import { DialogFormProps } from './Types'
6
+ // TODO: may not need context
7
+ const DialogFormContext = createContext({ title: '', isLoading: false, close: (event) => {}, onSave: (event) => {} })
8
8
 
9
9
  export class DialogForm extends Component<DialogFormProps> {
10
10
  constructor(props) {
11
- super(props);
12
- this.escFunction = this.escFunction.bind(this);
11
+ super(props)
12
+ this.escFunction = this.escFunction.bind(this)
13
13
  }
14
14
 
15
15
  componentDidMount() {
16
- document.addEventListener('keydown', this.escFunction);
16
+ document.addEventListener('keydown', this.escFunction)
17
17
  }
18
18
 
19
19
  componentWillUnmount() {
20
- document.removeEventListener('keydown', this.escFunction);
20
+ document.removeEventListener('keydown', this.escFunction)
21
21
  }
22
22
 
23
23
  escFunction(event) {
24
24
  if (event.keyCode === 27 && this.props.closeOnESC) {
25
- this.props.close(event);
25
+ this.props.close(event)
26
26
  }
27
27
  }
28
28
 
@@ -46,26 +46,24 @@ export class DialogForm extends Component<DialogFormProps> {
46
46
  </button>
47
47
  </div>
48
48
  <DialogFormContext.Consumer>
49
- {(context) => {
50
- return (
51
- <form
52
- noValidate
53
- onSubmit={(e) => {
54
- e.preventDefault();
55
- if (!context.isLoading) {
56
- context.onSave(e);
57
- }
58
- }}
59
- >
60
- {this.props.children}
61
- </form>
62
- );
63
- }}
49
+ {(context) => (
50
+ <form
51
+ noValidate
52
+ onSubmit={(e) => {
53
+ e.preventDefault()
54
+ if (!context.isLoading) {
55
+ context.onSave(e)
56
+ }
57
+ }}
58
+ >
59
+ {this.props.children}
60
+ </form>
61
+ )}
64
62
  </DialogFormContext.Consumer>
65
63
  </div>
66
64
  </VisibleModal>
67
65
  </DialogFormContext.Provider>
68
- );
66
+ )
69
67
  }
70
68
  }
71
69
 
@@ -73,14 +71,12 @@ export class DialogFormSubmit extends Component<{ tabIndex: number }> {
73
71
  render() {
74
72
  return (
75
73
  <DialogFormContext.Consumer>
76
- {(context) => {
77
- return (
78
- <button type="submit" className="cta dc__align-right" tabIndex={this.props.tabIndex}>
79
- {context.isLoading ? <Progressing /> : this.props.children}
80
- </button>
81
- );
82
- }}
74
+ {(context) => (
75
+ <button type="submit" className="cta dc__align-right" tabIndex={this.props.tabIndex}>
76
+ {context.isLoading ? <Progressing /> : this.props.children}
77
+ </button>
78
+ )}
83
79
  </DialogFormContext.Consumer>
84
- );
80
+ )
85
81
  }
86
82
  }
@@ -1,15 +1,21 @@
1
- import React from 'react'
2
- import { ForceDeleteDialogType } from './Types';
3
- import { DeleteDialog } from './DeleteDialog';
1
+ import { ForceDeleteDialogType } from './Types'
2
+ import { DeleteDialog } from './DeleteDialog'
4
3
 
5
- export default function ForceDeleteDialog({ onClickDelete, closeDeleteModal, forceDeleteDialogTitle, forceDeleteDialogMessage }: ForceDeleteDialogType) {
4
+ export default function ForceDeleteDialog({
5
+ onClickDelete,
6
+ closeDeleteModal,
7
+ forceDeleteDialogTitle,
8
+ forceDeleteDialogMessage,
9
+ }: ForceDeleteDialogType) {
6
10
  return (
7
11
  <div>
8
- <DeleteDialog title={forceDeleteDialogTitle}
12
+ <DeleteDialog
13
+ title={forceDeleteDialogTitle}
9
14
  delete={onClickDelete}
10
15
  closeDelete={closeDeleteModal}
11
- deletePrefix="Force ">
12
- <DeleteDialog.Description >
16
+ deletePrefix="Force "
17
+ >
18
+ <DeleteDialog.Description>
13
19
  <p className="mt-12 mb-12 p-8 dc__break-word dc__window-bg">Error: {forceDeleteDialogMessage}</p>
14
20
  <p>Do you want to force delete?</p>
15
21
  </DeleteDialog.Description>
@@ -1,4 +1,4 @@
1
- import { ReactNode } from "react"
1
+ import { ReactNode } from 'react'
2
2
 
3
3
  export interface DeleteDialogProps {
4
4
  title: string
@@ -15,10 +15,10 @@ export interface DeleteDialogProps {
15
15
  }
16
16
 
17
17
  export interface ForceDeleteDialogType {
18
- onClickDelete: () => void
19
- closeDeleteModal: () => void
20
- forceDeleteDialogTitle: string
21
- forceDeleteDialogMessage: string
18
+ onClickDelete: () => void
19
+ closeDeleteModal: () => void
20
+ forceDeleteDialogTitle: string
21
+ forceDeleteDialogMessage: string
22
22
  }
23
23
  export interface ConfirmationDialogType {
24
24
  className?: string
@@ -37,11 +37,11 @@ export interface ConfirmationDialogButtonGroupType {
37
37
  children: any
38
38
  }
39
39
  export interface DialogFormProps {
40
- className: string;
41
- title: string;
42
- isLoading: boolean;
43
- closeOnESC?: boolean;
44
- close: (event) => void;
45
- onSave: (event) => void;
46
- headerClassName?: string;
40
+ className: string
41
+ title: string
42
+ isLoading: boolean
43
+ closeOnESC?: boolean
44
+ close: (event) => void
45
+ onSave: (event) => void
46
+ headerClassName?: string
47
47
  }
@@ -1,4 +1,4 @@
1
1
  export { default as ConfirmationDialog } from './ConfirmationDialog'
2
2
  export * from './DeleteDialog'
3
3
  export * from './DialogForm'
4
- export { default as ForceDeleteDialog } from './ForceDeleteDialog'
4
+ export { default as ForceDeleteDialog } from './ForceDeleteDialog'
@@ -1,4 +1,4 @@
1
- import React, { useRef, useEffect } from 'react'
1
+ import { useRef, useEffect } from 'react'
2
2
  import { VisibleModal } from '../Modals/VisibleModal'
3
3
  import './Drawer.scss'
4
4
 
@@ -1,14 +1,10 @@
1
- import React from 'react'
2
- import './emptyState.scss';
3
- import { ReactComponent as Progressing } from '../../Assets/Icon/ic-progressing.svg';
4
-
5
- function EmptyState({ children, className = '' }) {
6
- return (
7
- <div className={`flex column empty-state w-100 h-100 ${className}`}>
8
- {children}
9
- </div>
10
- )
11
- }
1
+ import * as React from 'react'
2
+ import './emptyState.scss'
3
+ import { ReactComponent as Progressing } from '../../Assets/Icon/ic-progressing.svg'
4
+
5
+ const EmptyState = ({ children, className = '' }) => (
6
+ <div className={`flex column empty-state w-100 h-100 ${className}`}>{children}</div>
7
+ )
12
8
 
13
9
  function Image({ children }) {
14
10
  return children
@@ -18,20 +14,20 @@ function Title({ children }) {
18
14
  return children
19
15
  }
20
16
 
21
- function Subtitle({ children, className }: { children: any; className?: string }) {
22
- return <p className={`subtitle ${className || ''}`}>{children}</p>
23
- }
17
+ const Subtitle = ({ children, className }: { children: any; className?: string }) => (
18
+ <p className={`subtitle ${className || ''}`}>{children}</p>
19
+ )
24
20
 
25
21
  function Button({ children }) {
26
22
  return children
27
23
  }
28
24
 
29
- const Loading: React.FC<{ text: string }> = function (props) {
30
- return <>
25
+ const Loading: React.FC<{ text: string }> = (props) => (
26
+ <>
31
27
  <Progressing className="dc__block empty-state__loader" />
32
28
  <p className="empty-state__loading-text">{props.text}</p>
33
29
  </>
34
- }
30
+ )
35
31
 
36
32
  EmptyState.Image = Image
37
33
  EmptyState.Title = Title
@@ -1,10 +1,9 @@
1
- import React from 'react'
2
1
  import AppNotDeployed from '../../Assets/Img/app-not-deployed.png'
3
2
  import { GenericEmptyStateType, ImageType } from '../Types'
4
3
 
5
4
  import './emptyState.scss'
6
5
 
7
- function GenericEmptyState({
6
+ const GenericEmptyState = ({
8
7
  title,
9
8
  image,
10
9
  subTitle,
@@ -20,25 +19,12 @@ function GenericEmptyState({
20
19
  noImage,
21
20
  layout = 'column',
22
21
  contentClassName = '',
23
- }: GenericEmptyStateType): JSX.Element {
22
+ }: GenericEmptyStateType): JSX.Element => {
24
23
  const isRowLayout = layout === 'row'
25
24
 
26
- const getImageSize = () => {
27
- switch (imageType) {
28
- case ImageType.Medium:
29
- return { width: '200', height: '160' }
30
- case ImageType.Large:
31
- return { width: '250', height: '200' }
32
- default:
33
- return { width: '200', height: '160' }
34
- }
35
- }
36
-
37
25
  return (
38
26
  <div
39
- className={`flex ${isRowLayout ? 'dc__gap-32' : 'column dc__gap-20'} empty-state ${
40
- classname ? classname : ''
41
- }`}
27
+ className={`flex ${isRowLayout ? 'dc__gap-32' : 'column dc__gap-20'} empty-state ${classname || ''}`}
42
28
  style={styles}
43
29
  data-testid="generic-empty-state"
44
30
  {...(heightToDeduct >= 0 && { style: { ...styles, height: `calc(100vh - ${heightToDeduct}px)` } })}
@@ -46,15 +32,15 @@ function GenericEmptyState({
46
32
  {!SvgImage ? (
47
33
  !noImage && (
48
34
  <img
49
- className={imageClassName ? imageClassName : ''}
35
+ className={imageClassName || ''}
50
36
  src={image || AppNotDeployed}
51
- width={getImageSize().width}
52
- height={getImageSize().height}
37
+ width={imageType === ImageType.Medium ? '200' : '250'}
38
+ height={imageType === ImageType.Medium ? '160' : '200'}
53
39
  alt="empty-state"
54
40
  />
55
41
  )
56
42
  ) : (
57
- <SvgImage style={{ width: `${getImageSize().width}px`, height: `${getImageSize().height}px` }} />
43
+ <SvgImage />
58
44
  )}
59
45
  <div
60
46
  className={`flex column dc__gap-10 dc__mxw-300 ${
@@ -1,4 +1,5 @@
1
- import React, { Component } from 'react'
1
+ import { Component } from 'react'
2
+ import * as React from 'react'
2
3
  import EmptyState from './EmptyState/EmptyState'
3
4
  import notAuthorized from '../Assets/Img/ic-not-authorized.svg'
4
5
  import ErrorScreenNotFound from './ErrorScreenNotFound'
@@ -20,9 +21,7 @@ export class ErrorScreenManager extends Component<{
20
21
  case 401:
21
22
  return 'Unauthorized'
22
23
  case 403:
23
- return (
24
- <ErrorScreenNotAuthorized subtitle={this.props.subtitle} />
25
- )
24
+ return <ErrorScreenNotAuthorized subtitle={this.props.subtitle} />
26
25
  case 404:
27
26
  return <ErrorScreenNotFound />
28
27
  case 500:
@@ -35,8 +34,9 @@ export class ErrorScreenManager extends Component<{
35
34
  return <Reload className={this.props.reloadClass} />
36
35
  }
37
36
  }
37
+
38
38
  render() {
39
- let msg = this.getMessage()
39
+ const msg = this.getMessage()
40
40
  return (
41
41
  <div>
42
42
  <h1>{msg}</h1>
@@ -1,28 +1,25 @@
1
- import React from 'react'
2
- import notFound from '../Assets/Img/ic-empty-error@2x.png'
3
1
  import { useHistory } from 'react-router-dom'
2
+ import notFound from '../Assets/Img/ic-empty-error@2x.png'
4
3
  import { ERROR_EMPTY_SCREEN } from './Constants'
5
4
  import GenericEmptyState from './EmptyState/GenericEmptyState'
6
5
 
7
- function ErrorScreenNotFound() {
8
- const {push} = useHistory()
6
+ const ErrorScreenNotFound = () => {
7
+ const { push } = useHistory()
9
8
  const redirectToHome = () => {
10
9
  push('/app/list')
11
10
  }
12
- const renderGenerateButton = () => {
13
- return (
14
- <button className="flex cta h-32" onClick={redirectToHome} data-testid="empty-screen-take-me-home">
15
- {ERROR_EMPTY_SCREEN.TAKE_BACK_HOME}
16
- </button>
17
- )
18
- }
11
+ const renderGenerateButton = () => (
12
+ <button className="flex cta h-32" onClick={redirectToHome} data-testid="empty-screen-take-me-home">
13
+ {ERROR_EMPTY_SCREEN.TAKE_BACK_HOME}
14
+ </button>
15
+ )
19
16
 
20
17
  return (
21
18
  <GenericEmptyState
22
19
  image={notFound}
23
20
  title={ERROR_EMPTY_SCREEN.PAGE_NOT_FOUND}
24
21
  subTitle={ERROR_EMPTY_SCREEN.PAGE_NOT_EXIST}
25
- isButtonAvailable={true}
22
+ isButtonAvailable
26
23
  renderButton={renderGenerateButton}
27
24
  />
28
25
  )
@@ -1,4 +1,3 @@
1
- import React from 'react'
2
1
  import { GridProps } from './types'
3
2
 
4
3
  // This is meant to be a reusable component that will provide a grid like dynamic layout where xs is the number of columns out of 12 that the item will take up
@@ -11,7 +10,7 @@ export default function Grid({
11
10
  itemClass = '',
12
11
  children,
13
12
  }: GridProps) {
14
- const containerStyles = container ? { gap: spacing + 'px' } : {}
13
+ const containerStyles = container ? { gap: `${spacing}px` } : {}
15
14
 
16
15
  if (item) {
17
16
  const getColumnWidth = () => {
@@ -1,6 +1,7 @@
1
1
  import * as Sentry from '@sentry/browser'
2
2
  import moment from 'moment'
3
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
4
+ import * as React from 'react'
4
5
  import { useLocation } from 'react-router-dom'
5
6
  import { toast } from 'react-toastify'
6
7
  import { ERROR_EMPTY_SCREEN, TOKEN_COOKIE_NAME } from './Constants'
@@ -77,16 +78,19 @@ export const stopPropagation = (event): void => {
77
78
  }
78
79
 
79
80
  export function useThrottledEffect(callback, delay, deps = []) {
80
- //function will be executed only once in a given time interval.
81
+ // function will be executed only once in a given time interval.
81
82
  const lastRan = useRef(Date.now())
82
83
 
83
84
  useEffect(() => {
84
- const handler = setTimeout(function () {
85
- if (Date.now() - lastRan.current >= delay) {
86
- callback()
87
- lastRan.current = Date.now()
88
- }
89
- }, delay - (Date.now() - lastRan.current))
85
+ const handler = setTimeout(
86
+ () => {
87
+ if (Date.now() - lastRan.current >= delay) {
88
+ callback()
89
+ lastRan.current = Date.now()
90
+ }
91
+ },
92
+ delay - (Date.now() - lastRan.current),
93
+ )
90
94
 
91
95
  return () => {
92
96
  clearTimeout(handler)
@@ -115,7 +119,7 @@ export function getRandomColor(email: string): string {
115
119
  return colors[sum % colors.length]
116
120
  }
117
121
 
118
- export const getAlphabetIcon = (str: string, rootClassName: string = "") => {
122
+ export const getAlphabetIcon = (str: string, rootClassName: string = '') => {
119
123
  if (!str) return null
120
124
  return (
121
125
  <span
@@ -127,9 +131,7 @@ export const getAlphabetIcon = (str: string, rootClassName: string = "") => {
127
131
  )
128
132
  }
129
133
 
130
- export const getEmptyArrayOfLength = (length: number) => {
131
- return Array.from({ length })
132
- }
134
+ export const getEmptyArrayOfLength = (length: number) => Array.from({ length })
133
135
 
134
136
  export function noop(...args): any {}
135
137
 
@@ -153,7 +155,7 @@ export function getCookie(sKey) {
153
155
  }
154
156
  return (
155
157
  document.cookie.replace(
156
- new RegExp('(?:(?:^|.*;)\\s*' + sKey.replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'),
158
+ new RegExp(`(?:(?:^|.*;)\\s*${sKey.replace(/[\-\.\+\*]/g, '\\$&')}\\s*\\=\\s*([^;]*).*$)|^.*$`),
157
159
  '$1',
158
160
  ) || null
159
161
  )
@@ -196,7 +198,7 @@ export function useForm(stateSchema, validationSchema = {}, callback) {
196
198
  // in every re-render in component
197
199
  const validateState = useCallback(
198
200
  (state) => {
199
- //check errors in all fields
201
+ // check errors in all fields
200
202
  const hasErrorInState = Object.keys(validationSchema).some((key) => {
201
203
  const isInputFieldRequired = validationSchema[key].required
202
204
  const stateValue = state[key].value // state value
@@ -223,7 +225,7 @@ export function useForm(stateSchema, validationSchema = {}, callback) {
223
225
  }
224
226
 
225
227
  // single validator
226
- let _validator = validationSchema[name].validator
228
+ const _validator = validationSchema[name].validator
227
229
  if (_validator && typeof _validator === 'object') {
228
230
  if (!_validateSingleValidator(_validator, value)) {
229
231
  return _validator.error
@@ -231,9 +233,9 @@ export function useForm(stateSchema, validationSchema = {}, callback) {
231
233
  }
232
234
 
233
235
  // multiple validators
234
- let _validators = validationSchema[name].validators
236
+ const _validators = validationSchema[name].validators
235
237
  if (_validators && typeof _validators === 'object' && Array.isArray(_validators)) {
236
- let errors = []
238
+ const errors = []
237
239
  _validators.forEach((_validator) => {
238
240
  if (!_validateSingleValidator(_validator, value)) {
239
241
  errors.push(_validator.error)
@@ -252,7 +254,7 @@ export function useForm(stateSchema, validationSchema = {}, callback) {
252
254
  setIsDirty(true)
253
255
 
254
256
  const { name, value } = event.target
255
- let error = validateField(name, value)
257
+ const error = validateField(name, value)
256
258
  setState((prevState) => ({
257
259
  ...prevState,
258
260
  [name]: { value, error },
@@ -280,7 +282,7 @@ export function handleUTCTime(ts: string, isRelativeTime = false) {
280
282
  let timestamp = ''
281
283
  try {
282
284
  if (ts && ts.length) {
283
- let date = moment(ts)
285
+ const date = moment(ts)
284
286
  if (isRelativeTime) timestamp = date.fromNow()
285
287
  else timestamp = date.format('ddd DD MMM YYYY HH:mm:ss')
286
288
  }
@@ -364,9 +366,7 @@ export function useAsync<T>(
364
366
  dependencies: dependencyArray,
365
367
  })
366
368
  const mounted = useRef(true)
367
- const dependencies: any[] = useMemo(() => {
368
- return [...dependencyArray, shouldRun]
369
- }, [...dependencyArray, shouldRun])
369
+ const dependencies: any[] = useMemo(() => [...dependencyArray, shouldRun], [...dependencyArray, shouldRun])
370
370
 
371
371
  const reload = () => {
372
372
  async function call() {
@@ -432,9 +432,8 @@ export function useAsync<T>(
432
432
  export const processDeployedTime = (lastDeployed, isArgoInstalled) => {
433
433
  if (lastDeployed) {
434
434
  return handleUTCTime(lastDeployed, true)
435
- } else {
436
- return isArgoInstalled ? '' : 'Not deployed'
437
435
  }
436
+ return isArgoInstalled ? '' : 'Not deployed'
438
437
  }
439
438
 
440
439
  /**
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from 'react'
1
+ import { useEffect } from 'react'
2
2
 
3
3
  export const useClickOutside = (ref: any, callback: () => void) => {
4
4
  useEffect(() => {
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from 'react'
1
+ import { useEffect, useState } from 'react'
2
2
  import { getUserRole } from '../../Common.service'
3
3
  import { useSuperAdminType } from './types'
4
4
  import { showError } from '../../Helper'
@@ -13,13 +13,12 @@ export interface ImageComment {
13
13
  artifactId: number
14
14
  }
15
15
 
16
-
17
16
  export interface ImageTaggingContainerType {
18
17
  ciPipelineId?: number
19
18
  artifactId?: number
20
19
  imageComment?: ImageComment
21
20
  imageReleaseTags?: ReleaseTag[]
22
- updateCurrentAppMaterial? : (matId:number, releaseTags?:ReleaseTag[], imageComment?:ImageComment) => void
21
+ updateCurrentAppMaterial?: (matId: number, releaseTags?: ReleaseTag[], imageComment?: ImageComment) => void
23
22
  appReleaseTagNames?: string[]
24
23
  tagsEditable?: boolean
25
24
  forceReInit?: boolean
@@ -41,4 +40,4 @@ export interface ImageButtonType {
41
40
  isSuperAdmin: any
42
41
  duplicateTag?: boolean
43
42
  hideHardDelete?: boolean
44
- }
43
+ }