Skip to content

Commit 0b5e7d7

Browse files
Merge pull request #384 from RedisInsight/feature/bugfix
#RI-2539, #RI-2540, #RI-2544, #RI-2545, #RI-2547, #RI-2548, #RI-2552, #RI-2554
2 parents 5055576 + dce481b commit 0b5e7d7

File tree

17 files changed

+265
-87
lines changed

17 files changed

+265
-87
lines changed

redisinsight/ui/src/components/virtual-table/styles.module.scss

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ $footerHeight: 38px;
5656
.tableRow {
5757
cursor: pointer;
5858
border-top-width: 0;
59-
& > div:last-of-type {
60-
border-right: 1px solid transparent;
59+
60+
& > div:first-of-type {
61+
border-left: 3px solid transparent;
6162
}
6263
}
6364

@@ -66,14 +67,10 @@ $footerHeight: 38px;
6667
}
6768

6869
:global(.table-row-selected) {
69-
background: var(--tableRowSelectedColor) !important;
70-
border-top: 1px solid var(--euiColorPrimary) !important;
71-
border-bottom: 1px solid var(--euiColorPrimary) !important;
70+
background: var(--browserViewTypeActive) !important;
7271
& > div:first-of-type {
73-
border-left: 1px solid var(--euiColorPrimary) !important;
74-
}
75-
& > div:last-of-type {
76-
border-right: 1px solid var(--euiColorPrimary) !important;
72+
border-left: 3px solid transparent;
73+
border-left-color: var(--euiColorPrimary) !important;
7774
}
7875
}
7976

redisinsight/ui/src/components/virtual-tree/VirtualTree.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ describe('VirtualTree', () => {
8888
render(
8989
<VirtualTree
9090
{...instance(mockedProps)}
91+
selectDefaultLeaf
9192
items={mockedItems}
9293
setConstructingTree={mockConstructingTreeFn}
9394
onStatusSelected={mockOnStatusSelected}

redisinsight/ui/src/components/virtual-tree/VirtualTree.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from 'react-vtree'
1010
import { EuiIcon, EuiLoadingSpinner } from '@elastic/eui'
1111

12+
import { Maybe } from 'uiSrc/utils'
1213
import { useDisposableWebworker } from 'uiSrc/services'
1314
import { IKeyPropTypes } from 'uiSrc/constants/prop-types/keys'
1415
import { ThemeContext } from 'uiSrc/contexts/themeContext'
@@ -26,6 +27,7 @@ export interface Props {
2627
separator?: string
2728
loadingIcon?: string
2829
loading: boolean
30+
selectDefaultLeaf?: boolean
2931
statusSelected: {
3032
[key: string]: IKeyPropTypes[]
3133
}
@@ -34,6 +36,7 @@ export interface Props {
3436
}
3537
webworkerFn: (...args: any) => any
3638
onSelectLeaf?: (items: any[]) => void
39+
disableSelectDefaultLeaf?: () => void
3740
onStatusOpen?: (name: string, value: boolean) => void
3841
onStatusSelected?: (id: string, keys: any) => void
3942
setConstructingTree: (status: boolean) => void
@@ -48,18 +51,17 @@ const VirtualTree = (props: Props) => {
4851
statusOpen = {},
4952
statusSelected = {},
5053
loading,
54+
selectDefaultLeaf,
5155
onStatusOpen,
5256
onStatusSelected,
5357
onSelectLeaf,
5458
setConstructingTree,
59+
disableSelectDefaultLeaf,
5560
webworkerFn = () => {}
5661
} = props
5762

5863
const { theme } = useContext(ThemeContext)
59-
6064
const [nodes, setNodes] = useState<TreeNode[]>([])
61-
const [firstConstruct, setFirstConstruct] = useState(false)
62-
6365
const { result, run: runWebworker } = useDisposableWebworker(webworkerFn)
6466

6567
useEffect(() =>
@@ -76,15 +78,21 @@ const VirtualTree = (props: Props) => {
7678

7779
setNodes(result)
7880
setConstructingTree?.(false)
81+
}, [result])
82+
83+
// select "root" Keys after render a new tree (construct a tree)
84+
useEffect(() => {
85+
if (nodes.length === 0 || !selectDefaultLeaf) {
86+
return
87+
}
7988

80-
// set "root" keys after first render (construct a tree)
81-
if (!firstConstruct && isArray(result) && isEmpty(statusSelected)) {
82-
const rootLeaf = result?.find(({ children = [] }) => children.length === 0) ?? {}
83-
setFirstConstruct(true)
84-
onStatusSelected?.(rootLeaf?.fullName, rootLeaf?.keys)
89+
if (isArray(nodes) && isEmpty(statusSelected)) {
90+
const rootLeaf: Maybe<TreeNode> = nodes?.find(({ children = [] }) => children.length === 0)
91+
disableSelectDefaultLeaf?.()
92+
onStatusSelected?.(rootLeaf?.fullName ?? '', rootLeaf?.keys)
8593
onSelectLeaf?.(rootLeaf?.keys ?? [])
8694
}
87-
}, [result])
95+
}, [nodes, selectDefaultLeaf])
8896

8997
useEffect(() => {
9098
if (!items?.length) {

redisinsight/ui/src/components/virtual-tree/components/Node/Node.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const Node = ({
6060
onFocus={() => {}}
6161
data-testid={fullName}
6262
>
63-
<div>
63+
<div className={styles.nodeName}>
6464
{!isLeaf && (
6565
<>
6666
<EuiIcon
@@ -78,17 +78,17 @@ const Node = ({
7878
)}
7979

8080
{isLeaf && (
81-
<>
82-
<EuiIcon
83-
type={leafIcon}
84-
className={cx(styles.nodeIcon, styles.nodeIconLeaf)}
85-
data-test-subj={`leaf-icon_${fullName}`}
86-
/>
87-
Keys
88-
</>
81+
<>
82+
<EuiIcon
83+
type={leafIcon}
84+
className={cx(styles.nodeIcon, styles.nodeIconLeaf)}
85+
data-test-subj={`leaf-icon_${fullName}`}
86+
/>
87+
Keys
88+
</>
8989
)}
9090
</div>
91-
<div data-testid={`count_${fullName}`}>
91+
<div className={styles.options} data-testid={`count_${fullName}`}>
9292
<span>{keyCount ?? ''}</span>
9393
<span className={styles.approximate} data-testid={`percentage_${fullName}`}>
9494
{keyApproximate ? `${keyApproximate < 1 ? '<1' : Math.round(keyApproximate)}%` : '' }

redisinsight/ui/src/components/virtual-tree/components/Node/styles.module.scss

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
}
2929

3030
.nodeSelected {
31-
// border-left: 3px solid transparent;
3231
border-left-color: var(--euiColorPrimary) !important;
3332
background-color: var(--browserTreeNodeOpen);
3433

@@ -37,6 +36,12 @@
3736
}
3837
}
3938

39+
.nodeName {
40+
position: relative;
41+
overflow: hidden;
42+
text-overflow: ellipsis;
43+
}
44+
4045
.nodeIcon {
4146
margin-right: 8px;
4247

@@ -60,3 +65,9 @@
6065
width: 36px;
6166
text-align: end;
6267
}
68+
69+
.options {
70+
padding-left: 12px;
71+
font-size: 12px;
72+
font-weight: 300;
73+
}

redisinsight/ui/src/pages/browser/BrowserPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const BrowserPage = () => {
170170
id={firstPanelId}
171171
scrollable={false}
172172
initialSize={sizes[firstPanelId] ?? 50}
173-
minSize="670px"
173+
minSize="600px"
174174
paddingSize="none"
175175
wrapperProps={{
176176
className: cx(styles.resizePanelLeft, {

redisinsight/ui/src/pages/browser/components/filter-key-type/FilterKeyType.spec.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { cloneDeep } from 'lodash'
22
import React from 'react'
3-
import { instance, mock } from 'ts-mockito'
43
import {
54
cleanup,
65
clearStoreActions,
@@ -12,7 +11,7 @@ import {
1211
import { loadKeys, setFilter } from 'uiSrc/slices/keys'
1312
import { connectedInstanceOverviewSelector } from 'uiSrc/slices/instances'
1413
import { KeyTypes } from 'uiSrc/constants'
15-
import { setBrowserTreeNodesOpen, setBrowserTreeSelectedLeaf } from 'uiSrc/slices/app/context'
14+
import { resetBrowserTree } from 'uiSrc/slices/app/context'
1615
import FilterKeyType from './FilterKeyType'
1716

1817
let store: typeof mockedStore
@@ -65,8 +64,7 @@ describe('FilterKeyType', () => {
6564
const expectedActions = [
6665
setFilter(KeyTypes.Hash),
6766
loadKeys(),
68-
setBrowserTreeNodesOpen({}),
69-
setBrowserTreeSelectedLeaf({})
67+
resetBrowserTree()
7068
]
7169
expect(clearStoreActions(store.getActions())).toEqual(
7270
clearStoreActions(expectedActions)

redisinsight/ui/src/pages/browser/components/filter-key-type/FilterKeyType.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { connectedInstanceOverviewSelector } from 'uiSrc/slices/instances'
1515
import { fetchKeys, keysSelector, setFilter } from 'uiSrc/slices/keys'
1616
import { isVersionHigherOrEquals } from 'uiSrc/utils'
1717
import HelpTexts from 'uiSrc/constants/help-texts'
18-
import { setBrowserTreeNodesOpen, setBrowserTreeSelectedLeaf } from 'uiSrc/slices/app/context'
18+
import { resetBrowserTree } from 'uiSrc/slices/app/context'
1919
import { KeyViewType } from 'uiSrc/slices/interfaces/keys'
2020
import { FILTER_KEY_TYPE_OPTIONS } from './constants'
2121

@@ -73,8 +73,7 @@ const FilterKeyType = () => {
7373
dispatch(fetchKeys('0', viewType === KeyViewType.Browser ? SCAN_COUNT_DEFAULT : SCAN_TREE_COUNT_DEFAULT))
7474

7575
// reset browser tree context
76-
dispatch(setBrowserTreeNodesOpen({}))
77-
dispatch(setBrowserTreeSelectedLeaf({}))
76+
dispatch(resetBrowserTree())
7877
}
7978

8079
const UnsupportedInfo = () => (

redisinsight/ui/src/pages/browser/components/key-list/KeyList.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,6 @@ const KeyList = (props: Props) => {
198198
)
199199
}
200200
},
201-
{
202-
id: 'actions',
203-
label: '',
204-
alignment: TableCellAlignment.Center,
205-
absoluteWidth: 50,
206-
minWidth: 50,
207-
render: () => (
208-
<span className={styles.action}>
209-
<EuiIcon style={{ cursor: 'pointer' }} type="arrowRight" />
210-
</span>
211-
),
212-
},
213201
]
214202

215203
return (

redisinsight/ui/src/pages/browser/components/key-list/styles.module.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.page {
22
height: 100%;
33
overflow: hidden;
4-
padding-right: 1px;
54
}
65

76
.tooltip {

0 commit comments

Comments
 (0)