Skip to content

Commit cec4d33

Browse files
committed
Merge branch 'develop' of github.com:devtron-labs/devtron-fe-common-lib into feat/plugin-policy-v2
2 parents 5763532 + 04a57e8 commit cec4d33

File tree

12 files changed

+65
-27
lines changed

12 files changed

+65
-27
lines changed

package-lock.json

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.6.4-beta-6",
3+
"version": "0.7.3-beta-4",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
@@ -66,7 +66,7 @@
6666
"react-mde": "^11.5.0",
6767
"react-toastify": "9.1.3",
6868
"typescript": "5.5.4",
69-
"vite": "5.4.6",
69+
"vite": "5.4.11",
7070
"vite-plugin-dts": "4.0.3",
7171
"vite-plugin-lib-inject-css": "2.1.1",
7272
"vite-plugin-svgr": "^2.4.0",
@@ -109,7 +109,7 @@
109109
"monaco-editor": "0.44.0"
110110
},
111111
"vite-plugin-svgr": {
112-
"vite": "5.4.6"
112+
"vite": "5.4.11"
113113
}
114114
}
115115
}

src/Common/CustomTagSelector/ResizableTagTextArea.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const ResizableTagTextArea = ({
3535
disabled,
3636
disableOnBlurResizeToMinHeight,
3737
}: ResizableTagTextAreaProps) => {
38-
const [text, setText] = useState('')
38+
const [text, setText] = useState(value ?? '')
3939

4040
useEffect(() => {
4141
setText(value)
@@ -47,7 +47,6 @@ export const ResizableTagTextArea = ({
4747
}
4848

4949
const reInitHeight = () => {
50-
if (document.activeElement !== refVar.current) return
5150
refVar.current.style.height = `${minHeight}px`
5251
if (dependentRef) {
5352
dependentRef.current.style.height = `${minHeight}px`
@@ -68,6 +67,10 @@ export const ResizableTagTextArea = ({
6867
}
6968
}
7069

70+
useEffect(() => {
71+
reInitHeight()
72+
}, [])
73+
7174
useThrottledEffect(reInitHeight, 500, [text])
7275

7376
const handleOnBlur = (event) => {

src/Common/Dialogs/ConfirmationDialog.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React from 'react'
17+
import { stopPropagation } from '@Common/Helper'
1818
import { VisibleModal2 } from '../Modals/VisibleModal2'
1919
import {
2020
ConfirmationDialogBodyType,
@@ -23,9 +23,9 @@ import {
2323
ConfirmationDialogType,
2424
} from './Types'
2525

26-
const ConfirmationDialog = ({ className = '', children }: ConfirmationDialogType) => (
27-
<VisibleModal2 className="confirmation-dialog">
28-
<div className={`confirmation-dialog__body ${className}`}>{children}</div>
26+
const ConfirmationDialog = ({ className = '', children, close }: ConfirmationDialogType) => (
27+
<VisibleModal2 className="confirmation-dialog" close={close}>
28+
<div onClick={stopPropagation} className={`confirmation-dialog__body ${className}`}>{children}</div>
2929
</VisibleModal2>
3030
)
3131

src/Common/Dialogs/DeleteDialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const DeleteDialog: React.FC<DeleteDialogProps> & { Description?: React.F
7575
)
7676

7777
return (
78-
<ConfirmationDialog className="confirmation-dialog__body--w-400">
78+
<ConfirmationDialog className="confirmation-dialog__body--w-400" close={props.closeDelete}>
7979
<ConfirmationDialog.Icon src={warn} />
8080
<ConfirmationDialog.Body title={props.title}>
8181
<div className="fs-13 cn-7 lh-1-54 w-100">
@@ -88,7 +88,7 @@ export const DeleteDialog: React.FC<DeleteDialogProps> & { Description?: React.F
8888
onChange={handleConfirmationTextChange}
8989
label={getLabel()}
9090
inputWrapClassName="mt-12 w-100"
91-
placeholder={`Type ${deleteConfirmationText} to confirm`}
91+
placeholder="Type to confirm"
9292
isRequiredField
9393
onKeyDown={handleKeyDown}
9494
autoFocus

src/Common/Dialogs/Types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface ForceDeleteDialogType {
5656
export interface ConfirmationDialogType {
5757
className?: string
5858
children: any
59+
close?: (e) => void
5960
}
6061
export interface ConfirmationDialogIconType {
6162
src: string

src/Common/Hooks/useUrlFilters/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface UseUrlFiltersProps<T, K> {
2525
* Callback function for parsing the search params
2626
*/
2727
parseSearchParams?: (searchParams: URLSearchParams) => K
28+
localStorageKey?: `${string}__${string}`
2829
}
2930

3031
export type UseUrlFiltersReturnType<T, K = unknown> = K & {

src/Common/Hooks/useUrlFilters/useUrlFilters.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { useMemo } from 'react'
17+
import { useEffect, useMemo } from 'react'
1818
import { useHistory, useLocation } from 'react-router-dom'
1919
import { DEFAULT_BASE_PAGE_SIZE, EXCLUDED_FALSY_VALUES, SortingOrder } from '../../Constants'
2020
import { DEFAULT_PAGE_NUMBER, URL_FILTER_KEYS } from './constants'
2121
import { UseUrlFiltersProps, UseUrlFiltersReturnType } from './types'
22+
import { setItemInLocalStorageIfKeyExists } from './utils'
2223

2324
const { PAGE_SIZE, PAGE_NUMBER, SEARCH_KEY, SORT_BY, SORT_ORDER } = URL_FILTER_KEYS
2425

@@ -42,11 +43,20 @@ const { PAGE_SIZE, PAGE_NUMBER, SEARCH_KEY, SORT_BY, SORT_ORDER } = URL_FILTER_K
4243
const useUrlFilters = <T = string, K = unknown>({
4344
initialSortKey,
4445
parseSearchParams,
46+
localStorageKey,
4547
}: UseUrlFiltersProps<T, K> = {}): UseUrlFiltersReturnType<T, K> => {
4648
const location = useLocation()
4749
const history = useHistory()
4850
const searchParams = new URLSearchParams(location.search)
4951

52+
const getParsedSearchParams: UseUrlFiltersProps<T, K>['parseSearchParams'] = (searchParamsToParse) => {
53+
if (parseSearchParams) {
54+
return parseSearchParams(searchParamsToParse)
55+
}
56+
57+
return {} as K
58+
}
59+
5060
const { pageSize, pageNumber, searchKey, sortBy, sortOrder, parsedParams } = useMemo(() => {
5161
const _pageSize = searchParams.get(PAGE_SIZE)
5262
const _pageNumber = searchParams.get(PAGE_NUMBER)
@@ -58,7 +68,7 @@ const useUrlFilters = <T = string, K = unknown>({
5868
// Fallback to ascending order
5969
const sortByOrder = Object.values(SortingOrder).includes(_sortOrder) ? _sortOrder : SortingOrder.ASC
6070

61-
const _parsedParams = parseSearchParams ? parseSearchParams(searchParams) : ({} as K)
71+
const _parsedParams = getParsedSearchParams(searchParams)
6272

6373
return {
6474
pageSize: Number(_pageSize) || DEFAULT_BASE_PAGE_SIZE,
@@ -126,6 +136,7 @@ const useUrlFilters = <T = string, K = unknown>({
126136

127137
const clearFilters = () => {
128138
history.replace({ search: '' })
139+
setItemInLocalStorageIfKeyExists(localStorageKey, '')
129140
}
130141

131142
const updateSearchParams = (paramsToSerialize: Partial<K>) => {
@@ -143,10 +154,24 @@ const useUrlFilters = <T = string, K = unknown>({
143154
searchParams.delete(key)
144155
}
145156
})
157+
// Skipping primary params => pageSize, pageNumber, searchKey, sortBy, sortOrder
158+
setItemInLocalStorageIfKeyExists(localStorageKey, JSON.stringify(getParsedSearchParams(searchParams)))
146159
// Not replacing the params as it is being done by _resetPageNumber
147160
_resetPageNumber()
148161
}
149162

163+
useEffect(() => {
164+
// if we have search string, set secondary params in local storage accordingly
165+
if (location.search) {
166+
localStorage.setItem(localStorageKey, JSON.stringify(parsedParams))
167+
return
168+
}
169+
const localStorageValue = localStorage.getItem(localStorageKey)
170+
if (localStorageValue) {
171+
updateSearchParams(JSON.parse(localStorageValue))
172+
}
173+
}, [])
174+
150175
return {
151176
pageSize,
152177
changePage,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const setItemInLocalStorageIfKeyExists = (localStorageKey: string, value: string) => {
2+
if (localStorageKey) {
3+
localStorage.setItem(localStorageKey, value)
4+
}
5+
}

src/Shared/Components/CICDHistory/History.components.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { ReactComponent as ZoomOut } from '../../../Assets/Icon/ic-exit-fullscre
3434
import './cicdHistory.scss'
3535

3636
export const LogResizeButton = ({
37-
shortcutCombo = ['F'],
37+
shortcutCombo = ['Shift', 'F'],
3838
showOnlyWhenPathIncludesLogs = true,
3939
fullScreenView,
4040
setFullScreenView,

0 commit comments

Comments
 (0)