@devtron-labs/devtron-fe-common-lib 0.0.53-beta-5 → 0.0.53-beta-6

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.53-beta-5",
3
+ "version": "0.0.53-beta-6",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -133,6 +133,8 @@ const cdMaterialListModal = (artifacts: any[], offset: number, artifactId?: numb
133
133
  isVirtualEnvironment: material.isVirtualEnvironment,
134
134
  imageComment: material.imageComment,
135
135
  imageReleaseTags: material.imageReleaseTags,
136
+ hasDuplicateImages: material.hasDuplicateImages,
137
+ isSuperseded: material.isSuperseded,
136
138
  // It is going to be null but required in type so can't remove
137
139
  lastExecution: material.lastExecution,
138
140
  materialInfo: material.material_info
@@ -4,8 +4,6 @@ import { ReactComponent as ICClear } from '../../Assets/Icon/ic-error-cross.svg'
4
4
  import { DebouncedSearchProps } from './Types'
5
5
 
6
6
  /**
7
- * @deprecated Use `SearchBar` component instead.
8
- *
9
7
  * @param onSearch - Callback function to be called on search
10
8
  * @param Icon - (Optional) Icon to be shown before the input
11
9
  * @param iconClass - (Optional) Class for the icon
@@ -559,18 +559,3 @@ export function getLockedJSON(json, jsonPathArray: string[]) {
559
559
  return resultJson['$']
560
560
  }
561
561
 
562
- /**
563
- * Returns a debounced variant of the function
564
- */
565
- export const debounce = (func, timeout = 500) => {
566
- let timer
567
-
568
- return function (this, ...args) {
569
- const context = this
570
- if (timer) clearTimeout(timer)
571
- timer = setTimeout(() => {
572
- timer = null
573
- func.apply(context, args)
574
- }, timeout)
575
- }
576
- }
@@ -3,23 +3,10 @@ import { Placement } from 'tippy.js'
3
3
  import { ImageComment, ReleaseTag } from './ImageTags.Types'
4
4
  import { DockerConfigOverrideType, TaskErrorObj } from '.'
5
5
 
6
- /**
7
- * Generic response type object with support for overriding the result type
8
- *
9
- * @example Default usage:
10
- * ```ts
11
- * interface UserResponse extends ResponseType {}
12
- * ```
13
- *
14
- * @example Override the response type:
15
- * ```ts
16
- * interface UserResponse extends ResponseType<Record<string, string>> {}
17
- * ```
18
- */
19
- export interface ResponseType<T = any> {
6
+ export interface ResponseType {
20
7
  code: number
21
8
  status: string
22
- result?: T
9
+ result?: any
23
10
  errors?: any
24
11
  }
25
12
 
@@ -274,6 +261,8 @@ export interface CDMaterialType {
274
261
  registryType?: string;
275
262
  imagePath?: string
276
263
  registryName?: string
264
+ hasDuplicateImages?: boolean
265
+ isSuperseded?: boolean
277
266
  // Not even coming from API but required in CDMaterials for Security which makes its own api call but stores data in CDMaterials
278
267
  scanToolId?: number
279
268
  appliedFiltersTimestamp?: string
@@ -26,7 +26,6 @@ export * from './Common.service'
26
26
  export * from './Checkbox'
27
27
  export { default as EmptyState } from './EmptyState/EmptyState'
28
28
  export { default as GenericEmptyState } from './EmptyState/GenericEmptyState'
29
- export * from './SearchBar'
30
29
  export { default as Toggle } from './Toggle/Toggle'
31
30
  export { default as ScanVulnerabilitiesTable } from './Security/ScanVulnerabilitiesTable'
32
31
  export { default as StyledRadioGroup } from './RadioGroup/RadioGroup'
@@ -1,39 +0,0 @@
1
- /// <reference types="react" />
2
- import { SearchBarProps } from './types';
3
- import './searchBar.scss';
4
- /**
5
- * Generic search input component with support for enter based and debounced search
6
- * Note: The component is uncontrolled
7
- *
8
- * @example Usage with default debounced search
9
- * ```tsx
10
- * <SearchBar handleSearchChange={triggerSearchApi} shouldDebounce />
11
- * ```
12
- *
13
- * @example Initial search text
14
- * ```tsx
15
- * <SearchBar initialSearchText="Keyword" />
16
- * ```
17
- *
18
- * @example Custom width
19
- * ```tsx
20
- * <SearchBar containerClassName="w-300" />
21
- * ```
22
- *
23
- * @example Trigger search on enter key press
24
- * ```tsx
25
- * <SearchBar handleEnter={triggerSearchApi} />
26
- * ```
27
- *
28
- * @example Custom timeout for debounced search
29
- * ```tsx
30
- * <SearchBar handleSearchChange={triggerSearchApi} shouldDebounce debounceTimeout={500} />
31
- * ```
32
- *
33
- * @example Placeholder for the search
34
- * ```tsx
35
- * <SearchBar inputProps={{ placeholder: 'Enter search text' }} />
36
- * ```
37
- */
38
- declare const SearchBar: ({ initialSearchText, handleSearchChange, handleEnter, inputProps, containerClassName, shouldDebounce, debounceTimeout, }: SearchBarProps) => JSX.Element;
39
- export default SearchBar;
@@ -1,2 +0,0 @@
1
- export { default as SearchBar } from './SearchBar.component';
2
- export type { SearchBarProps } from './types';
@@ -1,35 +0,0 @@
1
- import { InputHTMLAttributes } from 'react';
2
- export interface SearchBarProps {
3
- /**
4
- * Initial search text
5
- *
6
- * @default ''
7
- */
8
- initialSearchText?: string;
9
- /**
10
- * Search handler for the search input
11
- */
12
- handleSearchChange?: (searchText: string) => void;
13
- /**
14
- * Enter event handler for the search input
15
- */
16
- handleEnter?: (searchText: string) => void;
17
- /**
18
- * Input props for the search input
19
- */
20
- inputProps?: InputHTMLAttributes<HTMLInputElement>;
21
- /**
22
- * Class name for the container; can be used for handling width
23
- */
24
- containerClassName?: string;
25
- /**
26
- * If true, the change handler would be triggered with debounce
27
- *
28
- * @default false
29
- */
30
- shouldDebounce?: boolean;
31
- /**
32
- * Timeout for the debounce handler to be triggered
33
- */
34
- debounceTimeout?: number;
35
- }
@@ -1,6 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
- <g fill="none" fill-rule="evenodd">
3
- <path d="M0 0h24v24H0z"/>
4
- <path fill="#959BA1" d="M10 2a8 8 0 0 1 6.32 12.905l5.044 5.045a1 1 0 1 1-1.414 1.414l-5.045-5.043A8 8 0 1 1 10 2zm0 2a6 6 0 1 0 0 12 6 6 0 0 0 0-12z"/>
5
- </g>
6
- </svg>
@@ -1,120 +0,0 @@
1
- import { ChangeEvent, useCallback, useRef, useState, KeyboardEvent } from 'react'
2
- import { ReactComponent as Search } from '../../Assets/Icon/ic-search.svg'
3
- import { ReactComponent as Clear } from '../../Assets/Icon/ic-error-cross.svg'
4
- import { SearchBarProps } from './types'
5
- import './searchBar.scss'
6
- import { debounce } from '../Helper'
7
-
8
- /**
9
- * Generic search input component with support for enter based and debounced search
10
- * Note: The component is uncontrolled
11
- *
12
- * @example Usage with default debounced search
13
- * ```tsx
14
- * <SearchBar handleSearchChange={triggerSearchApi} shouldDebounce />
15
- * ```
16
- *
17
- * @example Initial search text
18
- * ```tsx
19
- * <SearchBar initialSearchText="Keyword" />
20
- * ```
21
- *
22
- * @example Custom width
23
- * ```tsx
24
- * <SearchBar containerClassName="w-300" />
25
- * ```
26
- *
27
- * @example Trigger search on enter key press
28
- * ```tsx
29
- * <SearchBar handleEnter={triggerSearchApi} />
30
- * ```
31
- *
32
- * @example Custom timeout for debounced search
33
- * ```tsx
34
- * <SearchBar handleSearchChange={triggerSearchApi} shouldDebounce debounceTimeout={500} />
35
- * ```
36
- *
37
- * @example Placeholder for the search
38
- * ```tsx
39
- * <SearchBar inputProps={{ placeholder: 'Enter search text' }} />
40
- * ```
41
- */
42
- const SearchBar = ({
43
- initialSearchText = '',
44
- handleSearchChange = () => {},
45
- handleEnter = () => {},
46
- inputProps = {},
47
- containerClassName,
48
- shouldDebounce = false,
49
- debounceTimeout = 300,
50
- }: SearchBarProps) => {
51
- const [showClearButton, setShowClearButton] = useState(!!initialSearchText)
52
- const inputRef = useRef<HTMLInputElement>()
53
- const debouncedSearchChange = useCallback(debounce(handleSearchChange, debounceTimeout), [
54
- handleSearchChange,
55
- debounceTimeout,
56
- ])
57
-
58
- const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
59
- const { value } = e.target
60
- setShowClearButton(!!value)
61
- if (shouldDebounce) {
62
- debouncedSearchChange(value)
63
- } else {
64
- handleSearchChange(value)
65
- }
66
- }
67
-
68
- const _applySearch = (value: string) => {
69
- handleSearchChange(value)
70
- handleEnter(value)
71
- }
72
-
73
- const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
74
- const { key } = e
75
-
76
- if (key === 'Enter') {
77
- const inputTarget = e.target as HTMLInputElement
78
- const value = inputTarget.value.trim()
79
- _applySearch(value)
80
- }
81
- }
82
-
83
- const clearSearch = () => {
84
- inputRef.current.value = ''
85
- _applySearch('')
86
- }
87
-
88
- return (
89
- <div className={containerClassName}>
90
- <div className="search-bar bcn-0 dc__block w-100 min-w-200 dc__position-rel en-2 bw-1 br-4 h-32">
91
- <Search className="search-bar__icon dc__position-abs icon-color-n6 icon-dim-18" />
92
- <input
93
- placeholder="Search"
94
- data-testid="search-bar"
95
- type="text"
96
- {...inputProps}
97
- defaultValue={initialSearchText}
98
- className={`search-bar__input bcn-0 dc__position-abs w-100 h-100 br-4 dc__no-border pt-6 pr-10 pb-6 pl-30 fs-13 lh-20 fw-4 cn-9 placeholder-cn5 ${
99
- showClearButton ? 'pr-30' : 'pr-10'
100
- }`}
101
- onChange={handleChange}
102
- onKeyDown={handleKeyDown}
103
- ref={inputRef}
104
- />
105
- {showClearButton && (
106
- <button
107
- className="flex search-bar__clear-button dc__position-abs dc__transparent mt-0 mb-0 mr-5 ml-5"
108
- type="button"
109
- onClick={clearSearch}
110
- aria-label="Clear search"
111
- >
112
- <Clear className="icon-dim-18 icon-n4 dc__vertical-align-middle" />
113
- </button>
114
- )}
115
- </div>
116
- </div>
117
- )
118
- }
119
-
120
- export default SearchBar
@@ -1,2 +0,0 @@
1
- export { default as SearchBar } from './SearchBar.component'
2
- export type { SearchBarProps } from './types'
@@ -1,31 +0,0 @@
1
- .search-bar {
2
-
3
- &:focus,
4
- &:focus-within {
5
- outline: none;
6
- border: solid 1px var(--B500);
7
- }
8
-
9
- &__input {
10
-
11
- &:focus,
12
- &:focus-visible {
13
- border: none;
14
- outline: none;
15
- }
16
- }
17
-
18
- &__icon {
19
- z-index: 1;
20
- top: 50%;
21
- left: 8px;
22
- transform: translateY(-50%);
23
- }
24
-
25
- &__clear-button {
26
- right: 0;
27
- top: 50%;
28
- transform: translateY(-50%);
29
- z-index: 1;
30
- }
31
- }
@@ -1,36 +0,0 @@
1
- import { InputHTMLAttributes } from 'react'
2
-
3
- export interface SearchBarProps {
4
- /**
5
- * Initial search text
6
- *
7
- * @default ''
8
- */
9
- initialSearchText?: string
10
- /**
11
- * Search handler for the search input
12
- */
13
- handleSearchChange?: (searchText: string) => void
14
- /**
15
- * Enter event handler for the search input
16
- */
17
- handleEnter?: (searchText: string) => void
18
- /**
19
- * Input props for the search input
20
- */
21
- inputProps?: InputHTMLAttributes<HTMLInputElement>
22
- /**
23
- * Class name for the container; can be used for handling width
24
- */
25
- containerClassName?: string
26
- /**
27
- * If true, the change handler would be triggered with debounce
28
- *
29
- * @default false
30
- */
31
- shouldDebounce?: boolean
32
- /**
33
- * Timeout for the debounce handler to be triggered
34
- */
35
- debounceTimeout?: number
36
- }