Skip to content

Commit 1229fa0

Browse files
Merge pull request #2606 from RedisInsight/fe/feature/RI-4892
#RI-4892 - add refresh for list of indexes
2 parents 0154a29 + 1ba2723 commit 1229fa0

File tree

5 files changed

+90
-25
lines changed

5 files changed

+90
-25
lines changed

redisinsight/ui/src/pages/browser/components/redisearch-key-list/RediSearchIndexesList.spec.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,25 @@ describe('RediSearchIndexesList', () => {
200200

201201
expect(fetchKeysMock).toBeCalled()
202202
})
203+
204+
it('should load indexes after click on refresh', () => {
205+
(connectedInstanceSelector as jest.Mock).mockImplementation(() => ({
206+
host: '123.23.1.1',
207+
modules: [{ name: RedisDefaultModules.Search, }]
208+
}))
209+
210+
render(<RediSearchIndexesList {...instance(mockedProps)} />)
211+
212+
const afterRenderActions = [...store.getActions()]
213+
214+
fireEvent.click(screen.getByTestId('refresh-indexes-btn'))
215+
216+
const expectedActions = [
217+
...afterRenderActions,
218+
loadList(),
219+
]
220+
expect(clearStoreActions(store.getActions())).toEqual(
221+
clearStoreActions(expectedActions)
222+
)
223+
})
203224
})

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

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import {
22
EuiButtonEmpty,
3+
EuiButtonIcon,
34
EuiOutsideClickDetector,
45
EuiSuperSelect,
56
EuiSuperSelectOption,
7+
EuiToolTip,
68
} from '@elastic/eui'
79
import cx from 'classnames'
810
import React, { useEffect, useState } from 'react'
@@ -127,31 +129,53 @@ const RediSearchIndexesList = (props: Props) => {
127129
})
128130
}
129131

132+
const handleRefresh = (e: React.MouseEvent) => {
133+
e.stopPropagation()
134+
dispatch(fetchRedisearchListAction())
135+
}
136+
130137
return (
131138
<EuiOutsideClickDetector
132139
onOutsideClick={() => setIsSelectOpen(false)}
133140
>
134141
<div className={cx(styles.container)}>
135-
<EuiSuperSelect
136-
fullWidth
137-
itemClassName={cx('withColorDefinition', styles.searchMode)}
138-
disabled={loading}
139-
isLoading={loading}
140-
options={options}
141-
isOpen={isSelectOpen}
142-
valueOfSelected={index || ''}
143-
onChange={onChangeIndex}
144-
data-testid="select-search-mode"
145-
/>
146-
{!selectedIndex && (
147-
<EuiButtonEmpty
148-
className={styles.placeholder}
149-
onClick={() => setIsSelectOpen(true)}
150-
data-testid="select-index-placeholder"
142+
<div className={styles.select}>
143+
<EuiSuperSelect
144+
fullWidth
145+
itemClassName={cx('withColorDefinition', styles.searchMode)}
146+
disabled={loading}
147+
isLoading={loading}
148+
options={options}
149+
isOpen={isSelectOpen}
150+
valueOfSelected={index || ''}
151+
onChange={onChangeIndex}
152+
data-testid="select-search-mode"
153+
/>
154+
{!selectedIndex && (
155+
<EuiButtonEmpty
156+
className={styles.placeholder}
157+
onClick={() => setIsSelectOpen(true)}
158+
data-testid="select-index-placeholder"
159+
>
160+
Select Index
161+
</EuiButtonEmpty>
162+
)}
163+
</div>
164+
<div className={styles.refresh}>
165+
<EuiToolTip
166+
content="Refresh Indexes"
151167
>
152-
Select Index
153-
</EuiButtonEmpty>
154-
)}
168+
<EuiButtonIcon
169+
size="s"
170+
iconType="refresh"
171+
disabled={loading}
172+
className={styles.refreshBtn}
173+
onClick={handleRefresh}
174+
aria-label="refresh indexes list"
175+
data-testid="refresh-indexes-btn"
176+
/>
177+
</EuiToolTip>
178+
</div>
155179
</div>
156180
</EuiOutsideClickDetector>
157181
)

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

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.container {
22
height: 36px;
3-
width: 168px;
3+
width: 200px;
44
min-width: 80px;
55
overflow: hidden;
66
position: relative;
@@ -16,7 +16,7 @@
1616
border: 1px solid var(--controlsBorderColor) !important;
1717
border-left: 0 !important;
1818
border-right: 0 !important;
19-
padding: 0 25px 0 10px !important;
19+
padding: 0 55px 0 10px !important;
2020

2121
overflow: hidden;
2222
white-space: nowrap;
@@ -29,9 +29,6 @@
2929
&:focus {
3030
background-color: var(--euiColorEmptyShade) !important;
3131
}
32-
&:not(:disabled):hover {
33-
background-color: var(--hoverInListColorDarken) !important;
34-
}
3532
}
3633
}
3734
.euiPopover:not(.euiSuperSelect) {
@@ -51,6 +48,7 @@
5148
}
5249
.euiFormControlLayoutIcons {
5350
z-index: 6;
51+
right: 36px;
5452

5553
.euiLoadingSpinner {
5654
margin-right: -22px;
@@ -144,3 +142,23 @@
144142
background-color: transparent !important;
145143
}
146144
}
145+
146+
.refresh {
147+
display: flex;
148+
align-items: center;
149+
justify-content: center;
150+
151+
position: absolute;
152+
top: 50%;
153+
right: 1px;
154+
transform: translateY(-50%);
155+
z-index: 6;
156+
157+
.refreshBtn {
158+
width: 30px;
159+
160+
&:hover {
161+
transform: translateY(0) !important;
162+
}
163+
}
164+
}

tests/e2e/pageObjects/browser-page.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export class BrowserPage extends InstancePage {
138138
timestampOption = Selector('#time');
139139
formatSwitcher = Selector('[data-testid=select-format-key-value]', { timeout: 2000 });
140140
formatSwitcherIcon = Selector('[data-testid^=key-value-formatter-option-selected]');
141+
refreshIndexButton = Selector('[data-testid=refresh-indexes-btn]');
141142
selectIndexDdn = Selector('[data-testid=select-index-placeholder],[data-testid=select-search-mode]', { timeout: 1000 });
142143
createIndexBtn = Selector('[data-testid=create-index-btn]');
143144
cancelIndexCreationBtn = Selector('[data-testid=create-index-cancel-btn]');

tests/e2e/tests/critical-path/browser/search-capabilities.e2e.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,13 @@ test
129129
})('Search by index keys scanned for JSON', async t => {
130130
keyName = Common.generateWord(10);
131131
indexName = `idx:${keyName}`;
132+
await t.click(browserPage.redisearchModeBtn);
132133
const command = `FT.CREATE ${indexName} ON JSON PREFIX 1 "device:" SCHEMA id numeric`;
133134

134135
// Create index for JSON keys
135136
await browserPage.Cli.sendCommandInCli(command);
137+
await t.click(browserPage.refreshIndexButton);
136138
// Verify that user can can get 500 keys (limit 0 500) in Browser view
137-
await t.click(browserPage.redisearchModeBtn);
138139
await browserPage.selectIndexByName(indexName);
139140
// Verify that all keys are displayed according to selected index
140141
for (let i = 0; i < 15; i++) {

0 commit comments

Comments
 (0)