Skip to content

Commit 7654911

Browse files
committed
#RIVS-286 - Support decompressors
1 parent 55c7bf7 commit 7654911

File tree

20 files changed

+530
-40
lines changed

20 files changed

+530
-40
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Redis for VS Code is the official Visual Studio Code extension that provides an intuitive and efficient GUI for Redis databases, developed by Redis.
44

5-
![Redis for VS Code](.github/Redis_for_VS_Code_main_screen.png)
5+
![Redis for VS Code](https://github.com/RedisInsight/Redis-for-VS-Code/blob/main/.github/Redis_for_VS_Code_main_screen.png)
66

77
## Key features:
88
* Universal Redis Support: Connect to any Redis instance, including Redis Community Edition, Redis Cloud, Redis Software, and Redis on Azure Cache.

Redis_for_VS_Code_main_screen.png

-1020 KB
Binary file not shown.

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
"@types/lodash": "^4.14.200",
180180
"@types/lodash-es": "^4.17.12",
181181
"@types/node": "^16.4.13",
182+
"@types/pako": "^2.0.3",
182183
"@types/react": "^18.2.0",
183184
"@types/react-dom": "^18.2.0",
184185
"@types/react-virtualized": "^9.21.28",
@@ -247,9 +248,11 @@
247248
"whatwg-fetch": "^3.6.19"
248249
},
249250
"dependencies": {
251+
"@stablelib/snappy": "^1.0.3",
250252
"@vscode/l10n": "^0.0.18",
251253
"@vscode/webview-ui-toolkit": "^1.4.0",
252254
"axios": "^1.5.1",
255+
"brotli-unicode": "^1.0.2",
253256
"buffer": "^6.0.3",
254257
"classnames": "^2.3.2",
255258
"connection-string": "^4.4.0",
@@ -259,6 +262,7 @@
259262
"dotenv": "^16.4.5",
260263
"file-saver": "^2.0.5",
261264
"formik": "^2.4.5",
265+
"fzstd": "^0.1.1",
262266
"history": "^5.3.0",
263267
"html-react-parser": "^5.0.6",
264268
"immer": "^9.0.21",
@@ -267,8 +271,10 @@
267271
"json-bigint": "^1.0.0",
268272
"jsonpath": "^1.1.1",
269273
"lodash": "^4.17.21",
274+
"lz4js": "^0.2.0",
270275
"monaco-editor": "^0.48.0",
271276
"msgpackr": "^1.10.1",
277+
"pako": "^2.1.0",
272278
"php-serialize": "^4.1.1",
273279
"pickleparser": "^0.2.1",
274280
"rawproto": "^0.7.15",

src/webviews/src/modules/key-details/components/hash-details/hash-details-table/HashDetailsTable.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
stringToBuffer,
2323
validateTTLNumber,
2424
truncateNumberToDuration,
25+
decompressingBuffer,
2526
} from 'uiSrc/utils'
2627
import { StopPropagation } from 'uiSrc/components/virtual-table'
2728
import {
@@ -76,7 +77,10 @@ export interface Props {
7677
const HashDetailsTable = (props: Props) => {
7778
const { isExpireFieldsAvailable, onRemoveKey } = props
7879

79-
const databaseId = useDatabasesStore((state) => state.connectedDatabase?.id)
80+
const { databaseId, compressor } = useDatabasesStore((state) => ({
81+
databaseId: state.connectedDatabase?.id,
82+
compressor: state.connectedDatabase?.compressor ?? null,
83+
}))
8084

8185
const viewFormatProp = useContextInContext((state) => state.browser.viewFormat)
8286

@@ -306,8 +310,7 @@ const HashDetailsTable = (props: Props) => {
306310
className: 'value-table-separate-border',
307311
headerClassName: 'value-table-separate-border',
308312
render: (_name: string, { field: fieldItem }: HashField, expanded?: boolean) => {
309-
// const { value: decompressedItem } = decompressingBuffer(fieldItem, compressor)
310-
const decompressedItem = fieldItem
313+
const { value: decompressedItem } = decompressingBuffer(fieldItem, compressor)
311314
const field = bufferToString(fieldItem) || ''
312315
// Better to cut the long string, because it could affect virtual scroll performance
313316
const { value } = formattingBuffer(decompressedItem, viewFormatProp, { expanded, skipVector: true })
@@ -339,10 +342,8 @@ const HashDetailsTable = (props: Props) => {
339342
expanded?: boolean,
340343
rowIndex = 0,
341344
) {
342-
// const { value: decompressedFieldItem } = decompressingBuffer(fieldItem, compressor)
343-
// const { value: decompressedValueItem } = decompressingBuffer(valueItem, compressor)
344-
const decompressedFieldItem = fieldItem
345-
const decompressedValueItem = valueItem
345+
const { value: decompressedFieldItem } = decompressingBuffer(fieldItem, compressor)
346+
const { value: decompressedValueItem } = decompressingBuffer(valueItem!, compressor)
346347
const value = bufferToString(valueItem)
347348
const field = bufferToString(decompressedFieldItem)
348349
// Better to cut the long string, because it could affect virtual scroll performance

src/webviews/src/modules/key-details/components/list-details/list-details-table/ListDetailsTable.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ import {
3232
sendEventTelemetry,
3333
TelemetryEvent,
3434
getColumnWidth,
35+
decompressingBuffer,
3536
} from 'uiSrc/utils'
3637
import { VirtualTable } from 'uiSrc/components'
37-
// import { getColumnWidth } from 'uiSrc/components/virtual-grid'
38-
// import { decompressingBuffer } from 'uiSrc/utils/decompressors'
3938
import { useContextApi, useContextInContext, useDatabasesStore, useSelectedKeyStore } from 'uiSrc/store'
4039
import { Nullable } from 'uiSrc/interfaces'
4140
import { EditableTextArea } from 'uiSrc/modules/key-details/shared'
@@ -60,7 +59,11 @@ export interface Props {
6059
const ListDetailsTable = (props: Props) => {
6160
const { isFooterOpen } = props
6261

63-
const databaseId = useDatabasesStore((state) => state.connectedDatabase?.id)
62+
const { databaseId, compressor } = useDatabasesStore((state) => ({
63+
databaseId: state.connectedDatabase?.id,
64+
compressor: state.connectedDatabase?.compressor ?? null,
65+
}))
66+
6467
const { [KeyTypes.List]: listSizes } = useContextInContext((state) => state.browser.keyDetailsSizes)
6568

6669
const viewFormatProp = useContextInContext((state) => state.browser.viewFormat)
@@ -257,8 +260,7 @@ const ListDetailsTable = (props: Props) => {
257260
expanded: boolean = false,
258261
rowIndex = 0,
259262
) {
260-
// const { value: decompressedElementItem } = decompressingBuffer(elementItem, compressor)
261-
const decompressedElementItem = elementItem
263+
const { value: decompressedElementItem } = decompressingBuffer(elementItem, compressor)
262264
const element = bufferToString(elementItem)
263265
const { value: formattedValue, isValid } = formattingBuffer(decompressedElementItem, viewFormatProp, { expanded })
264266

src/webviews/src/modules/key-details/components/set-details/set-details-table/SetDetailsTable.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
TelemetryEvent,
1515
getMatchType,
1616
getColumnWidth,
17+
decompressingBuffer,
1718
} from 'uiSrc/utils'
1819
import {
1920
KeyTypes,
@@ -52,7 +53,10 @@ export interface Props {
5253
export const SetDetailsTable = (props: Props) => {
5354
const { isFooterOpen, onRemoveKey } = props
5455

55-
const databaseId = useDatabasesStore((state) => state.connectedDatabase?.id)
56+
const { databaseId, compressor } = useDatabasesStore((state) => ({
57+
databaseId: state.connectedDatabase?.id,
58+
compressor: state.connectedDatabase?.compressor ?? null,
59+
}))
5660

5761
const viewFormatProp = useContextInContext((state) => state.browser.viewFormat)
5862

@@ -181,8 +185,7 @@ export const SetDetailsTable = (props: Props) => {
181185
className: cx('value-table-separate-border', styles.cellBody),
182186
headerClassName: cx('value-table-separate-border', styles.cellHeader),
183187
render: function Name(_name: string, memberItem: RedisString, expanded: boolean = false) {
184-
// const { value: decompressedMemberItem } = decompressingBuffer(memberItem, compressor)
185-
const decompressedMemberItem = memberItem
188+
const { value: decompressedMemberItem } = decompressingBuffer(memberItem, compressor)
186189
const member = bufferToString(memberItem || '')
187190
// Better to cut the long string, because it could affect virtual scroll performance
188191
const { value } = formattingBuffer(decompressedMemberItem, viewFormatProp, { expanded })

src/webviews/src/modules/key-details/components/string-details/string-details-value/StringDetailsValue.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
stringToBuffer,
2323
isFullStringLoaded,
2424
stringToSerializedBufferFormat,
25+
decompressingBuffer,
2526
} from 'uiSrc/utils'
2627
import {
2728
TEXT_DISABLED_COMPRESSED_VALUE,
@@ -30,10 +31,9 @@ import {
3031
TEXT_UNPRINTABLE_CHARACTERS,
3132
AddStringFormConfig as config,
3233
} from 'uiSrc/constants'
33-
// import { decompressingBuffer } from 'uiSrc/utils/decompressors'
3434
import { downloadFile } from 'uiSrc/utils/dom/downloadFile'
3535

36-
import { useContextInContext, useSelectedKeyStore } from 'uiSrc/store'
36+
import { useContextInContext, useDatabasesStore, useSelectedKeyStore } from 'uiSrc/store'
3737
import { IFetchKeyArgs, RedisString } from 'uiSrc/interfaces'
3838
import { TextArea, Tooltip } from 'uiSrc/ui'
3939
import { InlineEditor } from 'uiSrc/components'
@@ -52,7 +52,6 @@ export interface Props {
5252
}
5353

5454
const StringDetailsValue = (props: Props) => {
55-
const compressor = null
5655
const { isEditItem, setIsEdit, onRefresh, onDownloaded, onLoadAll, onUpdated } = props
5756

5857
const {
@@ -61,6 +60,8 @@ const StringDetailsValue = (props: Props) => {
6160
setIsStringCompressed,
6261
} = useStringStore(useShallow(useStringSelector))
6362

63+
const compressor = useDatabasesStore((state) => state.connectedDatabase?.compressor ?? null)
64+
6465
const viewFormatProp = useContextInContext((state) => state.browser.viewFormat)
6566

6667
const { key, length } = useSelectedKeyStore(useShallow((state) => ({
@@ -85,11 +86,7 @@ const StringDetailsValue = (props: Props) => {
8586
useEffect(() => {
8687
if (!initialValue) return
8788

88-
// const { value: decompressedValue, isCompressed } = decompressingBuffer(initialValue, compressor)
89-
const { value: decompressedValue, isCompressed } = {
90-
value: initialValue,
91-
isCompressed: false,
92-
}
89+
const { value: decompressedValue, isCompressed } = decompressingBuffer(initialValue, compressor)
9390

9491
const initialValueString = bufferToString(decompressedValue, viewFormat)
9592
const { value: formattedValue, isValid } = formattingBuffer(decompressedValue, viewFormatProp, { expanded: true })

src/webviews/src/modules/key-details/components/zset-details/zset-details-table/ZSetDetailsTable.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
formattingBuffer,
1818
isEqualBuffers,
1919
validateScoreNumber,
20+
decompressingBuffer,
2021
} from 'uiSrc/utils'
2122
import { StopPropagation } from 'uiSrc/components/virtual-table'
2223
import {
@@ -37,7 +38,6 @@ import {
3738
import { Nullable, RedisString } from 'uiSrc/interfaces'
3839
import { useContextApi, useContextInContext, useDatabasesStore, useSelectedKeyStore } from 'uiSrc/store'
3940

40-
import { Tooltip } from 'uiSrc/ui'
4141
import { EditableInput } from 'uiSrc/modules/key-details/shared'
4242
import {
4343
deleteZSetMembers,
@@ -70,7 +70,10 @@ export interface Props {
7070
const ZSetDetailsTable = (props: Props) => {
7171
const { isFooterOpen, onRemoveKey } = props
7272

73-
const databaseId = useDatabasesStore((state) => state.connectedDatabase?.id)
73+
const { databaseId, compressor } = useDatabasesStore((state) => ({
74+
databaseId: state.connectedDatabase?.id,
75+
compressor: state.connectedDatabase?.compressor ?? null,
76+
}))
7477

7578
const viewFormatProp = useContextInContext((state) => state.browser.viewFormat)
7679

@@ -278,8 +281,7 @@ const ZSetDetailsTable = (props: Props) => {
278281
className: 'p-0',
279282
headerClassName: 'value-table-separate-border',
280283
render: function Name(_name: string, { name: nameItem }: IZsetMember, expanded?: boolean) {
281-
// const { value: decompressedNameItem } = decompressingBuffer(nameItem, compressor)
282-
const decompressedNameItem = nameItem
284+
const { value: decompressedNameItem } = decompressingBuffer(nameItem, compressor)
283285
const name = bufferToString(nameItem)
284286
const { value } = formattingBuffer(decompressedNameItem, viewFormat, { expanded })
285287
const cellContent = (value as string)?.substring?.(0, 200) ?? value

src/webviews/src/modules/keys-tree/components/database-wrapper/DatabaseWrapper.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const mockedProps = {
1818
database: mockDatabase,
1919
}
2020
beforeEach(() => {
21-
apiService.get = vi.fn().mockResolvedValue({ status: 200 })
21+
apiService.get = vi.fn().mockResolvedValue({ status: 200, data: {} })
2222
})
2323

2424
vi.spyOn(utils, 'sendEventTelemetry')

src/webviews/src/modules/keys-tree/components/database-wrapper/DatabaseWrapper.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ export const DatabaseWrapper = ({ children, database }: Props) => {
8787
checkConnectToDatabase(id, connectToInstance)
8888
}
8989

90-
const connectToInstance = (id = '') => {
91-
keysApi.setDatabaseId(id)
90+
const connectToInstance = (database: Database) => {
91+
keysApi.setDatabaseId(database.id)
9292

9393
// todo: fix for cli first open
9494
set(window, 'ri.database', database)
@@ -145,7 +145,7 @@ export const DatabaseWrapper = ({ children, database }: Props) => {
145145
content={formatLongName(name, 100, 20)}
146146
position="bottom center"
147147
keepTooltipInside={false}
148-
mouseEnterDelay={1000}
148+
mouseEnterDelay={2_000}
149149
>
150150
<div className={styles.databaseName}>
151151
<div className="truncate">{name}</div>

src/webviews/src/store/hooks/use-databases-store/interface.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ConnectionType } from 'uiSrc/constants'
1+
import { ConnectionType, KeyValueCompressor } from 'uiSrc/constants'
22
import { Nullable } from 'uiSrc/interfaces'
33

44
export interface DatabasesStore {
@@ -19,6 +19,7 @@ export interface Database {
1919
endpoints?: Nullable<Endpoint[]>
2020
connectionType?: ConnectionType
2121
lastConnection?: Nullable<Date>
22+
compressor?: Nullable<KeyValueCompressor>
2223
password?: Nullable<string>
2324
username?: Nullable<string>
2425
name?: string
@@ -104,6 +105,7 @@ export interface DatabasesActions {
104105
processDatabase: () => void
105106
processDatabaseFinal: () => void
106107
loadDatabasesSuccess: (data: Database[]) => void
108+
setDatabaseToList: (database: Database) => void
107109
setEditDatabase: (data: Database) => void
108110
setConnectedDatabase: (data: Database) => void
109111
resetConnectedDatabase: () => void

0 commit comments

Comments
 (0)