@@ -3,7 +3,6 @@ import { EuiFieldText, EuiIcon, EuiPopover, EuiSpacer, EuiTab, EuiTabs, EuiText
3
3
import cx from 'classnames'
4
4
import { useSelector } from 'react-redux'
5
5
import { useHistory , useParams } from 'react-router-dom'
6
- import { orderBy } from 'lodash'
7
6
import { instancesSelector as rdiInstancesSelector } from 'uiSrc/slices/rdi/instances'
8
7
import { instancesSelector as dbInstancesSelector } from 'uiSrc/slices/instances/instances'
9
8
import Divider from 'uiSrc/components/divider/Divider'
@@ -12,8 +11,8 @@ import Down from 'uiSrc/assets/img/Down.svg?react'
12
11
import Search from 'uiSrc/assets/img/Search.svg'
13
12
import { Instance , RdiInstance } from 'uiSrc/slices/interfaces'
14
13
import { TelemetryEvent , sendEventTelemetry } from 'uiSrc/telemetry'
15
- import { getDbIndex } from 'uiSrc/utils'
16
14
import { localStorageService } from 'uiSrc/services'
15
+ import { filterAndSort } from 'uiSrc/utils'
17
16
import InstancesList from './components/instances-list'
18
17
import styles from './styles.module.scss'
19
18
@@ -40,35 +39,6 @@ const InstancesNavigationPopover = ({ name }: Props) => {
40
39
const history = useHistory ( )
41
40
42
41
useEffect ( ( ) => {
43
- const filterAndSort = (
44
- arr : Instance [ ] | RdiInstance [ ] ,
45
- search : string ,
46
- sort : { field : string , direction : 'asc' | 'desc' }
47
- ) : ( Instance | RdiInstance
48
- ) [ ] => {
49
- if ( ! arr ?. length ) return arr
50
- const filtered = arr . filter ( ( instance ) => {
51
- const label = `${ instance . name } ${ getDbIndex ( instance . db ) } `
52
- return label . toLowerCase ?.( ) . includes ( search )
53
- } )
54
-
55
- const sortingFunc = ( ins ) => {
56
- if ( sort . field === 'lastConnection' ) {
57
- return ins . lastConnection ? - new Date ( `${ ins . lastConnection } ` ) : - Infinity
58
- }
59
- if ( sort . field === 'host' ) {
60
- return `${ ins . host } :${ ins . port } `
61
- }
62
- return sort . field
63
- }
64
-
65
- return orderBy (
66
- filtered ,
67
- sortingFunc ,
68
- sort . direction
69
- )
70
- }
71
-
72
42
const dbSort = localStorageService . get ( BrowserStorageItem . instancesSorting ) ?? {
73
43
field : 'lastConnection' ,
74
44
direction : 'asc'
0 commit comments