Skip to content

RI-7195: Add search screen #4788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from 'uiSrc/utils/test-utils'
import { TelemetryEvent, sendEventTelemetry } from 'uiSrc/telemetry'
import { INSTANCE_ID_MOCK } from 'uiSrc/mocks/handlers/instances/instancesHandlers'
import QueryCardHeader, { Props } from './QueryCardHeader'
import QueryCardHeader, { HIDE_FIELDS, Props } from './QueryCardHeader'

const mockedProps = mock<Props>()

Expand All @@ -34,7 +34,16 @@ jest.mock('uiSrc/services', () => ({
jest.mock('uiSrc/slices/app/plugins', () => ({
...jest.requireActual('uiSrc/slices/app/plugins'),
appPluginsSelector: jest.fn().mockReturnValue({
visualizations: [],
visualizations: [
{
id: '1',
uniqId: '1',
name: 'test',
plugin: '',
activationMethod: 'render',
matchCommands: ['FT.SEARCH'],
}
],
}),
}))

Expand Down Expand Up @@ -80,6 +89,32 @@ describe('QueryCardHeader', () => {
expect(screen.getByTestId('copy-command')).toBeDisabled()
})

it('should hide Profiler button', async () => {
render(
<QueryCardHeader
{...instance(mockedProps)}
query="FT.GET something"
isOpen
hideFields={[HIDE_FIELDS.profiler]}
/>,
)

expect(screen.queryByTestId('run-profile-type')).not.toBeInTheDocument()
})

it('should hide Change View Type button', async () => {
render(
<QueryCardHeader
{...instance(mockedProps)}
query="FT.SEARCH index somethingCool"
isOpen
hideFields={[HIDE_FIELDS.viewType]}
/>,
)

expect(screen.queryByTestId('select-view-type')).not.toBeInTheDocument()
})

it('event telemetry WORKBENCH_COMMAND_COPIED should be call after click on copy btn', async () => {
const command = 'info'
const sendEventTelemetryMock = jest.fn()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
executionTime?: number
emptyCommand?: boolean
db?: number
hideFields?: string[]
toggleOpen: () => void
toggleFullScreen: () => void
setSelectedValue: (type: WBQueryType, value: string) => void
Expand All @@ -80,6 +81,11 @@
onQueryProfile: (type: ProfileQueryType) => void
}

export const HIDE_FIELDS = {
viewType: 'viewType',
profiler: 'profiler',
}

const getExecutionTimeString = (value: number): string => {
if (value < 1) {
return '0.001 msec'
Expand Down Expand Up @@ -137,6 +143,7 @@
onQueryReRun,
onQueryProfile,
db,
hideFields = [],
} = props

const { visualizations = [] } = useSelector(appPluginsSelector)
Expand Down Expand Up @@ -410,54 +417,58 @@
</RiTooltip>
)}
</FlexItem>
<FlexItem
className={cx(styles.buttonIcon, styles.viewTypeIcon)}
onClick={onDropDownViewClick}
>
{isOpen && canCommandProfile && !summaryText && (
<div className={styles.dropdownWrapper}>
<div className={styles.dropdown}>
<ProfileSelect
placeholder={profileOptions[0].inputDisplay}
onChange={(value: ProfileQueryType | string) =>
onQueryProfile(value as ProfileQueryType)
}
options={profileOptions}
data-testid="run-profile-type"
valueRender={({ option, isOptionValue }) => {
if (isOptionValue) {
return option.dropdownDisplay as JSX.Element
{!hideFields?.includes(HIDE_FIELDS.profiler) && (
<FlexItem
className={cx(styles.buttonIcon, styles.viewTypeIcon)}
onClick={onDropDownViewClick}
>
{isOpen && canCommandProfile && !summaryText && (
<div className={styles.dropdownWrapper}>
<div className={styles.dropdown}>
<ProfileSelect
placeholder={profileOptions[0].inputDisplay}
onChange={(value: ProfileQueryType | string) =>

Check warning on line 430 in redisinsight/ui/src/components/query/query-card/QueryCardHeader/QueryCardHeader.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
onQueryProfile(value as ProfileQueryType)

Check warning on line 431 in redisinsight/ui/src/components/query/query-card/QueryCardHeader/QueryCardHeader.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
return option.inputDisplay as JSX.Element
}}
/>
options={profileOptions}
data-testid="run-profile-type"
valueRender={({ option, isOptionValue }) => {
if (isOptionValue) {
return option.dropdownDisplay as JSX.Element
}
return option.inputDisplay as JSX.Element

Check warning on line 439 in redisinsight/ui/src/components/query/query-card/QueryCardHeader/QueryCardHeader.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}}
/>
</div>
</div>
</div>
)}
</FlexItem>
<FlexItem
className={cx(styles.buttonIcon, styles.viewTypeIcon)}
onClick={onDropDownViewClick}
>
{isOpen && options.length > 1 && !summaryText && (
<div className={styles.dropdownWrapper}>
<div className={styles.dropdown}>
<ProfileSelect
options={modifiedOptions}
valueRender={({ option, isOptionValue }) => {
if (isOptionValue) {
return option.dropdownDisplay as JSX.Element
}
return option.inputDisplay as JSX.Element
}}
value={selectedValue}
onChange={(value: string) => onChangeView(value)}
data-testid="select-view-type"
/>
)}
</FlexItem>
)}
{!hideFields?.includes(HIDE_FIELDS.viewType) && (
<FlexItem
className={cx(styles.buttonIcon, styles.viewTypeIcon)}
onClick={onDropDownViewClick}
>
{isOpen && options.length > 1 && !summaryText && (

Check warning on line 452 in redisinsight/ui/src/components/query/query-card/QueryCardHeader/QueryCardHeader.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
<div className={styles.dropdownWrapper}>
<div className={styles.dropdown}>
<ProfileSelect
options={modifiedOptions}
valueRender={({ option, isOptionValue }) => {

Check warning on line 457 in redisinsight/ui/src/components/query/query-card/QueryCardHeader/QueryCardHeader.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
if (isOptionValue) {
return option.dropdownDisplay as JSX.Element

Check warning on line 459 in redisinsight/ui/src/components/query/query-card/QueryCardHeader/QueryCardHeader.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 460 in redisinsight/ui/src/components/query/query-card/QueryCardHeader/QueryCardHeader.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 460 in redisinsight/ui/src/components/query/query-card/QueryCardHeader/QueryCardHeader.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
return option.inputDisplay as JSX.Element

Check warning on line 461 in redisinsight/ui/src/components/query/query-card/QueryCardHeader/QueryCardHeader.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}}
value={selectedValue}
onChange={(value: string) => onChangeView(value)}

Check warning on line 464 in redisinsight/ui/src/components/query/query-card/QueryCardHeader/QueryCardHeader.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 464 in redisinsight/ui/src/components/query/query-card/QueryCardHeader/QueryCardHeader.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
data-testid="select-view-type"
/>
</div>
</div>

Check warning on line 468 in redisinsight/ui/src/components/query/query-card/QueryCardHeader/QueryCardHeader.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
</div>
)}
</FlexItem>
)}
</FlexItem>
)}
<FlexItem
className={styles.buttonIcon}
onClick={onDropDownViewClick}
Expand Down
4 changes: 1 addition & 3 deletions redisinsight/ui/src/pages/vector-search/VectorSearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import { VectorSearchCreateIndex } from './create-index/VectorSearchCreateIndex'
import { VectorSearchQuery } from './query/VectorSearchQuery'

export const VectorSearchPage = () => {
const hasIndexes = false
const hasIndexes = true

if (!hasIndexes) {
return <VectorSearchCreateIndex />
}

// TODO: QueryScreen

return <VectorSearchQuery />
}
Loading
Loading