Skip to content

Commit 9fce690

Browse files
authored
Merge pull request #2663 from RedisInsight/revert-2650-feature/RI-4711_exact-match
Revert "#RI-4711 - add exact match option"
2 parents 92db72b + 13ae6f1 commit 9fce690

File tree

10 files changed

+10
-163
lines changed

10 files changed

+10
-163
lines changed

redisinsight/ui/src/components/multi-search/MultiSearch.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export interface Props {
3232
onDelete: (ids: string[]) => void
3333
loading?: boolean
3434
}
35-
optionalButton?: React.ReactNode
3635
onChange: (value: string) => void
3736
onChangeOptions?: (options: string[]) => void
3837
onClear?: () => void
@@ -53,7 +52,6 @@ const MultiSearch = (props: Props) => {
5352
onChange,
5453
onKeyDown,
5554
onClear = () => {},
56-
optionalButton,
5755
className,
5856
compressed,
5957
...rest
@@ -251,7 +249,6 @@ const MultiSearch = (props: Props) => {
251249
/>
252250
</EuiToolTip>
253251
)}
254-
{optionalButton}
255252
{!!suggestionOptions?.length && (
256253
<EuiToolTip
257254
content={suggestions?.buttonTooltipTitle}

redisinsight/ui/src/constants/storage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ enum BrowserStorageItem {
44
theme = 'theme',
55
browserViewType = 'browserViewType',
66
browserSearchMode = 'browserSearchMode',
7-
browserExactMatch = 'browserExactMatch',
87
cliClientUuid = 'cliClientUuid',
98
cliResizableContainer = 'cliResizableContainer',
109
cliInputHistory = 'cliInputHistory',

redisinsight/ui/src/pages/browser/components/search-key-list/SearchKeyList.spec.tsx

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,10 @@ import {
1010
screen,
1111
act,
1212
} from 'uiSrc/utils/test-utils'
13-
import {
14-
changeExactMatch,
15-
keysSelector,
16-
loadKeys,
17-
loadSearchHistory,
18-
setFilter,
19-
setPatternSearchMatch
20-
} from 'uiSrc/slices/browser/keys'
13+
import { keysSelector, loadKeys, loadSearchHistory, setFilter, setPatternSearchMatch } from 'uiSrc/slices/browser/keys'
2114

2215
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
2316
import { KeyViewType, SearchMode } from 'uiSrc/slices/interfaces/keys'
24-
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
2517
import SearchKeyList from './SearchKeyList'
2618

2719
jest.mock('uiSrc/slices/browser/keys', () => ({
@@ -55,11 +47,6 @@ jest.mock('uiSrc/slices/browser/redisearch', () => ({
5547
}),
5648
}))
5749

58-
jest.mock('uiSrc/telemetry', () => ({
59-
...jest.requireActual('uiSrc/telemetry'),
60-
sendEventTelemetry: jest.fn(),
61-
}))
62-
6350
let store: typeof mockedStore
6451
beforeEach(() => {
6552
cleanup()
@@ -150,51 +137,4 @@ describe('SearchKeyList', () => {
150137
clearStoreActions([...afterRenderActions])
151138
)
152139
})
153-
154-
it('should change exact match after click on button', () => {
155-
keysSelector.mockImplementation(() => ({
156-
searchMode: SearchMode.Pattern,
157-
viewType: KeyViewType.Browser,
158-
isSearch: false,
159-
isFiltered: false,
160-
}))
161-
162-
render(<SearchKeyList />)
163-
164-
const afterRenderActions = [...store.getActions()]
165-
166-
fireEvent.click(screen.getByTestId('exact-match-button'))
167-
168-
expect(clearStoreActions(store.getActions())).toEqual(
169-
clearStoreActions([...afterRenderActions, changeExactMatch(true)])
170-
)
171-
})
172-
173-
it('should call proper telemetry after click exact match button', () => {
174-
keysSelector.mockImplementation(() => ({
175-
searchMode: SearchMode.Pattern,
176-
viewType: KeyViewType.Browser,
177-
isSearch: false,
178-
isFiltered: false,
179-
}))
180-
181-
const sendEventTelemetryMock = jest.fn();
182-
(sendEventTelemetry as jest.Mock).mockImplementation(() => sendEventTelemetryMock)
183-
184-
render(<SearchKeyList />)
185-
186-
fireEvent.click(screen.getByTestId('exact-match-button'))
187-
188-
expect(sendEventTelemetry).toBeCalledWith({
189-
event: TelemetryEvent.BROWSER_FILTER_PER_PATTERN_CLICKED,
190-
eventData: {
191-
databaseId: 'instanceId',
192-
current: 'Exact',
193-
previous: 'Pattern',
194-
view: KeyViewType.Browser
195-
}
196-
});
197-
198-
(sendEventTelemetry as jest.Mock).mockRestore()
199-
})
200140
})

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

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { EuiButtonIcon, EuiToolTip, keys } from '@elastic/eui'
1+
import { keys } from '@elastic/eui'
22
import React, { useEffect, useState } from 'react'
33
import { useDispatch, useSelector } from 'react-redux'
44
import cx from 'classnames'
55

6-
import { useParams } from 'react-router-dom'
76
import MultiSearch from 'uiSrc/components/multi-search/MultiSearch'
87
import { SCAN_COUNT_DEFAULT, SCAN_TREE_COUNT_DEFAULT } from 'uiSrc/constants/api'
98
import { replaceSpaces } from 'uiSrc/utils'
109
import {
11-
changeExactMatch,
1210
deleteSearchHistoryAction,
1311
fetchKeys,
1412
fetchSearchHistoryAction,
@@ -17,11 +15,13 @@ import {
1715
setFilter,
1816
setSearchMatch
1917
} from 'uiSrc/slices/browser/keys'
20-
import { KeyViewType, SearchHistoryItem, SearchMode } from 'uiSrc/slices/interfaces/keys'
21-
import { redisearchHistorySelector, redisearchSelector } from 'uiSrc/slices/browser/redisearch'
18+
import { SearchMode, KeyViewType, SearchHistoryItem } from 'uiSrc/slices/interfaces/keys'
19+
import {
20+
redisearchHistorySelector,
21+
redisearchSelector
22+
} from 'uiSrc/slices/browser/redisearch'
2223

2324
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
24-
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
2525
import styles from './styles.module.scss'
2626

2727
const placeholders = {
@@ -31,7 +31,7 @@ const placeholders = {
3131

3232
const SearchKeyList = () => {
3333
const { id } = useSelector(connectedInstanceSelector)
34-
const { search, viewType, searchMode, exactMatch } = useSelector(keysSelector)
34+
const { search, viewType, searchMode } = useSelector(keysSelector)
3535
const { search: redisearchQuery, selectedIndex } = useSelector(redisearchSelector)
3636
const { data: rediSearchHistory, loading: rediSearchHistoryLoading } = useSelector(redisearchHistorySelector)
3737
const { data: searchHistory, loading: searchHistoryLoading } = useSelector(keysSearchHistorySelector)
@@ -40,7 +40,6 @@ const SearchKeyList = () => {
4040
const [disableSubmit, setDisableSubmit] = useState(false)
4141

4242
const dispatch = useDispatch()
43-
const { instanceId } = useParams<{ instanceId: string }>()
4443

4544
useEffect(() => {
4645
if (id) {
@@ -115,23 +114,6 @@ const SearchKeyList = () => {
115114
handleApply('')
116115
}
117116

118-
const handleChangeExactMatch = () => {
119-
sendEventTelemetry({
120-
event: TelemetryEvent.BROWSER_FILTER_PER_PATTERN_CLICKED,
121-
eventData: {
122-
databaseId: instanceId,
123-
view: viewType,
124-
previous: exactMatch ? 'Exact' : 'Pattern',
125-
current: exactMatch ? 'Pattern' : 'Exact',
126-
}
127-
})
128-
dispatch(changeExactMatch(!exactMatch))
129-
130-
if (value) {
131-
handleApply()
132-
}
133-
}
134-
135117
return (
136118
<div className={cx(styles.container, { [styles.redisearchMode]: searchMode === SearchMode.Redisearch })}>
137119
<MultiSearch
@@ -148,24 +130,6 @@ const SearchKeyList = () => {
148130
onApply: handleApplySuggestion,
149131
onDelete: handleDeleteSuggestions,
150132
}}
151-
optionalButton={searchMode === SearchMode.Pattern ? (
152-
<EuiToolTip
153-
title="Exact Search"
154-
content={exactMatch ? 'Disable to see keys matching your pattern' : 'Enable to see keys that exactly match your pattern'}
155-
position="bottom"
156-
>
157-
<EuiButtonIcon
158-
display="empty"
159-
iconType="bullseye"
160-
color="primary"
161-
size="xs"
162-
onClick={handleChangeExactMatch}
163-
aria-label="exact match button"
164-
className={cx(styles.exactSearchIcon, { [styles.disabled]: !exactMatch })}
165-
data-testid="exact-match-button"
166-
/>
167-
</EuiToolTip>
168-
) : null}
169133
disableSubmit={disableSubmit}
170134
placeholder={placeholders[searchMode]}
171135
className={styles.input}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,3 @@
3131
margin-right: 50px;
3232
word-break: break-all;
3333
}
34-
35-
.exactSearchIcon {
36-
margin-left: 8px;
37-
margin-right: -4px;
38-
39-
&.disabled {
40-
opacity: 0.5;
41-
}
42-
}

redisinsight/ui/src/slices/browser/keys.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export const initialState: KeysStore = {
8080
isBrowserFullScreen: false,
8181
searchMode: localStorageService?.get(BrowserStorageItem.browserSearchMode) ?? SearchMode.Pattern,
8282
viewType: localStorageService?.get(BrowserStorageItem.browserViewType) ?? KeyViewType.Browser,
83-
exactMatch: localStorageService?.get(BrowserStorageItem.browserExactMatch) ?? true,
8483
data: {
8584
total: 0,
8685
scanned: 0,
@@ -356,11 +355,6 @@ const keysSlice = createSlice({
356355
state.searchMode = payload
357356
},
358357

359-
changeExactMatch: (state, { payload }: { payload: boolean }) => {
360-
state.exactMatch = payload
361-
localStorageService?.set(BrowserStorageItem.browserExactMatch, payload)
362-
},
363-
364358
resetAddKey: (state) => {
365359
state.addKey = cloneDeep(initialState.addKey)
366360
},
@@ -463,7 +457,6 @@ export const {
463457
toggleBrowserFullScreen,
464458
setViewFormat,
465459
changeSearchMode,
466-
changeExactMatch,
467460
loadSearchHistory,
468461
loadSearchHistorySuccess,
469462
loadSearchHistoryFailure,
@@ -520,17 +513,16 @@ export function fetchPatternKeysAction(
520513
sourceKeysFetch = CancelToken.source()
521514

522515
const state = stateInit()
523-
const { search: match, filter: type, exactMatch } = state.browser.keys
516+
const { search: match, filter: type } = state.browser.keys
524517
const { encoding } = state.app.info
525-
const withExactMatch = exactMatch ? match : `*${match}*`
526518

527519
const { data, status } = await apiService.post<GetKeysWithDetailsResponse[]>(
528520
getUrl(
529521
state.connections.instances?.connectedInstance?.id ?? '',
530522
ApiEndpoints.KEYS
531523
),
532524
{
533-
cursor, count, type, match: withExactMatch || DEFAULT_SEARCH_MATCH, keysInfo: false,
525+
cursor, count, type, match: match || DEFAULT_SEARCH_MATCH, keysInfo: false,
534526
},
535527
{
536528
params: { encoding },

redisinsight/ui/src/slices/interfaces/keys.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export interface KeysStore {
3232
isBrowserFullScreen: boolean
3333
viewType: KeyViewType
3434
searchMode: SearchMode
35-
exactMatch: boolean
3635
data: KeysStoreData
3736
selectedKey: {
3837
loading: boolean

redisinsight/ui/src/telemetry/events.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ export enum TelemetryEvent {
7878
BROWSER_WORKBENCH_LINK_CLICKED = 'BROWSER_WORKBENCH_LINK_CLICKED',
7979
BROWSER_DATABASE_INDEX_CHANGED = 'BROWSER_DATABASE_INDEX_CHANGED',
8080
BROWSER_FILTER_MODE_CHANGE_FAILED = 'BROWSER_FILTER_MODE_CHANGE_FAILED',
81-
BROWSER_FILTER_PER_PATTERN_CLICKED = 'BROWSER_FILTER_PER_PATTERN_CLICKED',
8281
BROWSER_TUTORIAL_CLICKED = 'BROWSER_TUTORIAL_CLICKED',
8382
LIST_VIEW_OPENED = 'LIST_VIEW_OPENED',
8483
OVERVIEW_MENU_CLICKED = 'OVERVIEW_MENU_CLICKED',

tests/e2e/pageObjects/browser-page.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ export class BrowserPage extends InstancePage {
107107
clearFilterHistoryBtn = Selector('[data-testid=clear-history-btn]');
108108
guideLinksBtn = Selector('[data-testid^=guide-button-]');
109109
backToBrowserBtn = Selector('[data-testid=back-right-panel-btn]');
110-
exactSearchBtn = Selector('[data-testid=exact-match-button]');
111110
//CONTAINERS
112111
streamGroupsContainer = Selector('[data-testid=stream-groups-container]');
113112
streamConsumersContainer = Selector('[data-testid=stream-consumers-container]');

tests/e2e/tests/regression/browser/filtering.e2e.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ import { DatabaseAPIRequests } from '../../../helpers/api/api-database';
77
import { keyTypes } from '../../../helpers/keys';
88
import { Common } from '../../../helpers/common';
99
import { APIKeyRequests } from '../../../helpers/api/api-keys';
10-
import { BrowserActions } from '../../../common-actions/browser-actions';
1110

1211
const browserPage = new BrowserPage();
1312
const databaseHelper = new DatabaseHelper();
1413
const databaseAPIRequests = new DatabaseAPIRequests();
1514
const apiKeyRequests = new APIKeyRequests();
16-
const browserActions = new BrowserActions();
1715

1816
let keyName = Common.generateWord(20);
1917
let keyName2 = Common.generateWord(20);
@@ -60,39 +58,8 @@ test('Verify that user can filter per pattern with ? (matches keys with any char
6058
// Filter per pattern with ?
6159
await browserPage.searchByKeyName(searchedValue);
6260
// Verify that key was found
63-
// Verify that filter requests are sent as entered when Exact Search enabled
6461
await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyName)).ok('The key was not found');
6562
});
66-
test('Verify that filter requests are sent as entered when Exact Search enabled', async t => {
67-
const randomValue = Common.generateWord(10);
68-
const searchedValue = 'eyForSearch*?\\[]';
69-
const tooltipExactSearchEnabledText = 'Disable to see keys matching your pattern';
70-
const tooltipExactSearchDisabledText = 'Enable to see keys that exactly match your pattern';
71-
keyName = `KeyForSearch*?[]789${randomValue}`;
72-
73-
// Add new key
74-
await browserPage.addStringKey(keyName);
75-
// Filter by Exact Search
76-
await browserPage.searchByKeyName(searchedValue);
77-
// Verify that key was not found
78-
// Verify that Exact Search is enabled by default
79-
await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyName)).notOk('The key was found by Exact Search with not full name');
80-
81-
// Verify that user can see ”Exact Search Disable to see keys matching your pattern” text when hover over the icon with enabled Exact Search
82-
await t.hover(browserPage.exactSearchBtn);
83-
await browserActions.verifyTooltipContainsText(tooltipExactSearchEnabledText, true);
84-
85-
// Disable Exact Search
86-
await t.click(browserPage.exactSearchBtn);
87-
// Verify that user can see ”Exact Search Enable to see keys that exactly match your pattern” text when hover over the icon with disabled Exact Search
88-
await t.hover(browserPage.exactSearchBtn);
89-
await browserActions.verifyTooltipContainsText(tooltipExactSearchDisabledText, true);
90-
91-
await browserPage.searchByKeyName(searchedValue);
92-
// Verify that key was found
93-
// Verify that user can see results that fit into this pattern: *{request}* when Exact Search is disabled
94-
await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyName)).ok('The key was not found with disabled Exact Search');
95-
});
9663
test
9764
.after(async() => {
9865
// Clear and delete database

0 commit comments

Comments
 (0)