Skip to content

Commit bbeb2e4

Browse files
committed
RI-6371 added loading, hide from redis-stack
1 parent 5f7e091 commit bbeb2e4

File tree

3 files changed

+55
-25
lines changed

3 files changed

+55
-25
lines changed

redisinsight/ui/src/components/instance-header/InstanceHeader.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ const InstanceHeader = ({ onChangeDbIndex }: Props) => {
7878
dispatch(fetchRdiInstancesAction())
7979
}, [])
8080

81+
const isRedisStack = server?.buildType === BuildType.RedisStack
82+
8183
const goHome = () => {
8284
history.push(Pages.home)
8385
}
@@ -168,7 +170,11 @@ const InstanceHeader = ({ onChangeDbIndex }: Props) => {
168170
/>
169171
)}
170172
<EuiFlexItem style={{ overflow: 'hidden' }}>
171-
<InstancesNavigationPopover name={name} />
173+
{isRedisStack ? (
174+
<b className={styles.dbName}>{name}</b>
175+
) : (
176+
<InstancesNavigationPopover name={name} />
177+
)}
172178
</EuiFlexItem>
173179
{databases > 1 && (
174180
<EuiFlexItem style={{ padding: '4px 0 4px 12px' }} grow={false}>

redisinsight/ui/src/components/instance-header/components/instances-navigation-popover/InstancesNavigationPopover.tsx

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { ChangeEvent, useEffect, useState } from 'react'
2-
import { EuiFieldText, EuiIcon, EuiListGroup, EuiListGroupItem, EuiPopover, EuiSpacer, EuiTab, EuiTabs, EuiText } from '@elastic/eui'
2+
import { EuiDescriptionListDescription, EuiFieldText, EuiIcon, EuiListGroup, EuiListGroupItem, EuiLoadingSpinner, EuiPopover, EuiSpacer, EuiTab, EuiTabs, EuiText } from '@elastic/eui'
33
import cx from 'classnames'
44
import { useDispatch, useSelector } from 'react-redux'
55
import { useHistory, useParams } from 'react-router-dom'
@@ -15,6 +15,7 @@ import Down from 'uiSrc/assets/img/Down.svg?react'
1515
import Search from 'uiSrc/assets/img/Search.svg'
1616
import { Instance, RdiInstance } from 'uiSrc/slices/interfaces'
1717
import { TelemetryEvent, getRedisModulesSummary, sendEventTelemetry } from 'uiSrc/telemetry'
18+
import { getDbIndex } from 'uiSrc/utils'
1819
import styles from './styles.module.scss'
1920

2021
export interface Props {
@@ -31,6 +32,8 @@ const InstancesNavigationPopover = ({ name }: Props) => {
3132
const [searchFilter, setSearchFilter] = useState('')
3233
const [filteredDbInstances, setFilteredDbInstances] = useState<Instance[]>([])
3334
const [filteredRdiInstances, setFilteredRdiInstances] = useState<RdiInstance[]>([])
35+
const [loading, setLoading] = useState<boolean>(false)
36+
const [selected, setSelected] = useState<string>('')
3437

3538
const { instanceId, rdiInstanceId } = useParams<{ instanceId: string, rdiInstanceId: string }>()
3639
const [selectedTab, setSelectedTab] = useState(rdiInstanceId ? InstancesTabs.RDI : InstancesTabs.Databases)
@@ -41,7 +44,10 @@ const InstancesNavigationPopover = ({ name }: Props) => {
4144
const dispatch = useDispatch()
4245

4346
useEffect(() => {
44-
const dbFiltered = dbInstances?.filter((db) => db.name?.toLowerCase?.().includes(searchFilter))
47+
const dbFiltered = dbInstances?.filter((db) => {
48+
const label = `${db.name} ${getDbIndex(db.db)}`
49+
return label.toLowerCase?.().includes(searchFilter)
50+
})
4551
const rdiFiltered = rdiInstances?.filter((rdi) => rdi.name?.toLowerCase?.().includes(searchFilter))
4652
setFilteredDbInstances(dbFiltered)
4753
setFilteredRdiInstances(rdiFiltered)
@@ -77,11 +83,11 @@ const InstancesNavigationPopover = ({ name }: Props) => {
7783
dispatch(setAppContextInitialState())
7884

7985
dispatch(setConnectedInstanceId(id))
80-
86+
setLoading(false)
8187
history.push(Pages.browser(id))
8288
}
8389

84-
const btnLabel = selectedTab === InstancesTabs.Databases ? 'All Databases' : 'All RDIs'
90+
const btnLabel = selectedTab === InstancesTabs.Databases ? 'Redis Databases page' : 'Redis Data Integration page'
8591

8692
const goHome = () => {
8793
history.push(selectedTab === InstancesTabs.Databases ? Pages.home : Pages.rdi)
@@ -94,6 +100,7 @@ const InstancesNavigationPopover = ({ name }: Props) => {
94100
// already connected so do nothing
95101
return
96102
}
103+
setLoading(true)
97104
const modulesSummary = getRedisModulesSummary(instance.modules)
98105
sendEventTelemetry({
99106
event: TelemetryEvent.CONFIG_DATABASES_OPEN_DATABASE,
@@ -104,18 +111,22 @@ const InstancesNavigationPopover = ({ name }: Props) => {
104111
...modulesSummary,
105112
}
106113
})
107-
dispatch(checkConnectToInstanceAction(instance.id, connectToInstance, () => {}, false))
114+
dispatch(checkConnectToInstanceAction(instance.id, connectToInstance, () => setLoading(false), false))
108115
}
109116

110117
const goToRdiInstance = (instance: RdiInstance) => {
111118
if (connectedRdiInstance?.id === instance.id) {
112119
// already connected so do nothing
113120
return
114121
}
122+
setLoading(true)
115123
dispatch(checkConnectToRdiInstanceAction(
116124
instance.id,
117-
(id: string) => history.push(Pages.rdiPipeline(id)),
118-
() => dispatch(setAppContextConnectedRdiInstanceId(''))
125+
(id: string) => {
126+
setLoading(false)
127+
history.push(Pages.rdiPipeline(id))
128+
},
129+
() => setLoading(false)
119130
))
120131
}
121132

@@ -127,15 +138,34 @@ const InstancesNavigationPopover = ({ name }: Props) => {
127138
}
128139
}
129140

141+
const isInstanceActive = (id: string) => {
142+
if (selectedTab === InstancesTabs.Databases) {
143+
return id === instanceId
144+
}
145+
return id === rdiInstanceId
146+
}
147+
130148
return (
131149
<div className={styles.listContainer}>
132150
<EuiListGroup flush maxWidth="none" gutterSize="none">
133151
{instances?.map((instance) => (
134152
<EuiListGroupItem
135153
className={styles.item}
154+
isActive={isInstanceActive(instance.id)}
155+
disabled={loading}
136156
key={instance.id}
137-
label={instance.name}
138-
onClick={() => goToPage(instance)}
157+
label={(
158+
<EuiText style={{ display: 'flex', alignItems: 'center' }}>
159+
{loading && instance?.id === selected && <EuiLoadingSpinner size="s" style={{ marginRight: '8px' }} />}
160+
{instance.name}
161+
{' '}
162+
{getDbIndex(instance.db)}
163+
</EuiText>
164+
)}
165+
onClick={() => {
166+
setSelected(instance.id)
167+
goToPage(instance)
168+
}}
139169
/>
140170
))}
141171
</EuiListGroup>

redisinsight/ui/src/components/instance-header/components/instances-navigation-popover/styles.module.scss

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,18 @@
6969
font-size: 14px !important;
7070
line-height: 16.8px !important;
7171
color: var(--euiTextSubduedColor) !important;
72-
&:hover, &:active {
73-
background-color: var(--hoverInListColorDarken) !important;
74-
color: var(--euiTextSubduedColorHover) !important;
75-
border-left-color: var(--externalLinkColor) !important;
76-
border-left-width: 3px !important;
77-
border-left-style: solid !important;
78-
text-decoration: none !important;
79-
80-
81-
:global {
82-
.euiListGroupItem__label:hover {
83-
text-decoration: none;
84-
}
85-
}
86-
}
8772
}
8873
}
8974

75+
.listContainer :global(.euiListGroupItem-isActive), :global(.euiListGroupItem:hover) {
76+
background-color: var(--hoverInListColorDarken) !important;
77+
color: var(--euiTextSubduedColorHover) !important;
78+
border-left-color: var(--externalLinkColor) !important;
79+
border-left-width: 3px !important;
80+
border-left-style: solid !important;
81+
text-decoration: none !important;
82+
}
83+
9084
.footerContainer {
9185
padding: 12px 16px;
9286
.homePageLink {

0 commit comments

Comments
 (0)