Skip to content

Commit 4474f35

Browse files
authored
Merge pull request #247 from RedisInsight/feature/RI-6514_Support_multiple_key_name_delimiter
#RI-6514 - Support multiple key name delimiters
2 parents 15d2c01 + c82b46b commit 4474f35

File tree

42 files changed

+675
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+675
-201
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ module.exports = {
4848
code: 140,
4949
},
5050
],
51+
'jsx-quotes': ['error', 'prefer-double'],
5152
'class-methods-use-this': 'off',
5253
// https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports
5354
'react-refresh/only-export-components': ['warn'],

l10n/bundle.l10n.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"Recommended": "Recommended",
1818
"Page was not found": "Page was not found",
1919
"Settings": "Settings",
20-
"Delimiter to separate namespaces": "Delimiter to separate namespaces",
20+
"Delimiter": "Delimiter",
2121
"key(s)": "key(s)",
2222
"({0}{1} Scanned)": "({0}{1} Scanned)",
2323
"All Key Types": "All Key Types",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
"dev:key": "cross-env RI_DATA_ROUTE=main/key vite dev",
146146
"dev:database": "cross-env RI_DATA_ROUTE=main/add_database vite dev",
147147
"dev:sidebar": "cross-env RI_DATA_ROUTE=sidebar vite dev",
148+
"dev:settings": "cross-env RI_DATA_ROUTE=main/settings vite dev",
148149
"l10n:collect": "npx @vscode/l10n-dev export -o ./l10n ./src",
149150
"watch": "tsc -watch -p ./",
150151
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",

src/webviews/src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ export { NoDatabases } from './no-databases/NoDatabases'
1111
export { MonacoLanguages } from './monaco-languages/MonacoLanguages'
1212
export { UploadFile } from './upload-file/UploadFile'
1313
export { SuperSelect } from './super-select/SuperSelect'
14+
export { MultiSelect } from './multi-select/MultiSelect'
1415
export { SuperSelectRemovableOption } from './super-select/components/removable-option/RemovableOption'
1516
export { AutoRefresh } from './auto-refresh/AutoRefresh'
1617
export * from './database-form'
1718
export * from './consents-option'
1819
export * from './consents-privacy'
1920

2021
export type { SuperSelectOption } from './super-select/SuperSelect'
22+
export type { MultiSelectOption } from './multi-select/MultiSelect'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react'
2+
import { instance, mock } from 'ts-mockito'
3+
4+
import { render, constants } from 'testSrc/helpers'
5+
import { MultiSelect, Props } from './MultiSelect'
6+
7+
const mockedProps = mock<Props>()
8+
9+
describe('MultiSelect', () => {
10+
it('should render', async () => {
11+
expect(render(
12+
<MultiSelect {...instance(mockedProps)} options={constants.SUPER_SELECT_OPTIONS} />),
13+
).toBeTruthy()
14+
})
15+
})
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React, { FC } from 'react'
2+
import cx from 'classnames'
3+
import Select, { CreatableProps } from 'react-select/creatable'
4+
import { GroupBase } from 'react-select'
5+
6+
import { Maybe } from 'uiSrc/interfaces'
7+
import styles from './styles.module.scss'
8+
9+
export interface MultiSelectOption {
10+
label: string
11+
value: string
12+
testid?: string
13+
}
14+
15+
export interface Props extends CreatableProps<MultiSelectOption, true, GroupBase<MultiSelectOption>> {
16+
options?: Maybe<MultiSelectOption[]>
17+
selectedOption?: Maybe<MultiSelectOption>
18+
containerClassName?: string
19+
itemClassName?: string
20+
testid?: string
21+
}
22+
23+
const components = {
24+
DropdownIndicator: null,
25+
}
26+
27+
const MultiSelect: FC<Props> = (props) => {
28+
const {
29+
containerClassName,
30+
testid,
31+
} = props
32+
33+
return (
34+
<div className={cx(styles.container, containerClassName)}>
35+
<Select<MultiSelectOption, true>
36+
{...props}
37+
isMulti
38+
isClearable
39+
components={components}
40+
menuIsOpen={false}
41+
inputId={testid}
42+
classNames={{
43+
container: () => styles.selectContainer,
44+
control: () => styles.control,
45+
multiValue: () => styles.multiValue,
46+
multiValueRemove: () => styles.multiValueRemove,
47+
menu: () => '!hidden',
48+
input: () => styles.input,
49+
indicatorsContainer: () => '!hidden',
50+
indicatorSeparator: () => '!hidden',
51+
}}
52+
/>
53+
</div>
54+
)
55+
}
56+
57+
export { MultiSelect }
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
.container {
2+
@apply min-w-[210px] #{!important};
3+
}
4+
5+
.selectContainer {
6+
@apply min-h-8 #{!important};
7+
}
8+
9+
.control {
10+
@apply bg-vscode-dropdown-background border-solid border border-vscode-input-border rounded-none min-h-8 max-h-40 cursor-pointer overflow-auto #{!important};
11+
12+
scroll-padding-bottom: 8px;
13+
}
14+
15+
.multiValue {
16+
background-color: var(--vscode-banner-background) !important;
17+
18+
div {
19+
color: var(--vscode-banner-iconForeground) !important;
20+
}
21+
}
22+
23+
.multiValueRemove {
24+
@apply h-[14px] w-[14px] pl-[2px] mt-1 ml-0.5 mr-1 #{!important};
25+
border-radius: 50% !important;
26+
background-color: var(--vscode-banner-iconForeground) !important;
27+
transition: transform 0.1s ease;
28+
29+
&:hover {
30+
transform: translateY(-1px);
31+
}
32+
33+
svg {
34+
@apply h-[10px] w-[10px] min-w-[10px] #{!important};
35+
path {
36+
fill: var(--vscode-inlineChat-background) #{!important};
37+
}
38+
}
39+
}
40+
41+
.input {
42+
@apply text-vscode-foreground max-w-full truncate #{!important};
43+
}
44+

src/webviews/src/components/super-select/components/removable-option/RemovableOption.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ const SuperSelectRemovableOption = (props: Props) => {
4747
text={l10n.t('will be removed from Redis for VS Code.')}
4848
item={(options[i] as SuperSelectOption).value}
4949
suffix={suffix}
50-
triggerClassName='absolute right-2.5'
51-
position='right center'
50+
triggerClassName="absolute right-2.5"
51+
position="right center"
5252
deleting={activeOptionId}
5353
showPopover={showPopover}
5454
handleDeleteItem={handleRemoveOption}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export enum EventKeys {
2+
ENTER = 'Enter',
3+
SPACE = ' ',
4+
ESCAPE = 'Escape',
5+
TAB = 'Tab',
6+
}

src/webviews/src/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export * from './core/apiErrors'
44
export * from './core/app'
55
export * from './core/storage'
66
export * from './core/commands'
7+
export * from './core/eventKeys'
78
export * from './connections/databases'
89
export * from './keys/types'
910
export * from './keys/tree'

0 commit comments

Comments
 (0)