Skip to content
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

#RI-31 - Logical databases #223

Merged
merged 23 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6577d79
#RI-31 - Logical databases
zalenskiSofteq Dec 10, 2024
ca02933
#RI-31 - Logical databases
zalenskiSofteq Dec 10, 2024
3f481a8
#RI-31 - Logical databases
zalenskiSofteq Dec 10, 2024
2c91e15
#RI-31 - Logical databases
zalenskiSofteq Dec 10, 2024
d39a583
#RI-31 - Logical databases
zalenskiSofteq Dec 10, 2024
7c69e8d
#RI-31 - Logical databases
zalenskiSofteq Dec 10, 2024
cc61be2
#RI-31 - Logical databases
zalenskiSofteq Dec 10, 2024
2da5cdc
#RI-31 - fix pr comments
zalenskiSofteq Dec 10, 2024
1fddabf
#RI-31 - fix pr comments
zalenskiSofteq Dec 10, 2024
73460be
#RI-31 - fix pr comments
zalenskiSofteq Dec 10, 2024
5b2b3f3
#RIVS-299 - Add the changes from the main project
zalenskiSofteq Dec 12, 2024
9aea8d8
#RIVS-313 - Keys scanned value overlapped for small screen width
zalenskiSofteq Dec 12, 2024
ce5df8e
#RIVS-304 - Auto refresh
zalenskiSofteq Dec 13, 2024
de8c107
#RIVS-304 - Auto refresh
zalenskiSofteq Dec 13, 2024
14c5489
#RIVS-305 - Do not collapse the list of keys when going to another ex…
zalenskiSofteq Dec 13, 2024
3d6b7a2
#RIVS-305 - Turn on keytar encryption for new users
zalenskiSofteq Dec 13, 2024
9f8dd25
default
zalenskiSofteq Dec 13, 2024
f3e73a9
add html ui tests report
zalenskiSofteq Dec 13, 2024
1a1f928
fix builds
zalenskiSofteq Dec 13, 2024
b86d53f
Merge pull request #225 from RedisInsight/feature/bugfix
vlad-dargel Dec 16, 2024
31c9472
Merge pull request #226 from RedisInsight/feature/stories
vlad-dargel Dec 17, 2024
9330dea
Merge remote-tracking branch 'origin/feature/RIVS-31_Logical_database…
zalenskiSofteq Dec 17, 2024
0736188
Merge pull request #224 from RedisInsight/feature/RIVS-299_Add_featur…
vlad-dargel Dec 17, 2024
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
599 changes: 7 additions & 592 deletions .circleci/config.yml

Large diffs are not rendered by default.

610 changes: 610 additions & 0 deletions .circleci/config.yml.backup

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RI_APP_PORT=5541
RI_APP_VERSION='1.0.0'
RI_APP_PREFIX='api'
RI_APP_FOLDER_NAME='.redis-for-vscode'
RI_CDN_PATH='https://s3.amazonaws.com/redisinsight.download/public/releases/2.54.1/web-mini'
RI_CDN_PATH='https://s3.us-east-1.amazonaws.com/redisinsight.test/public/zalenski/vscode/web-mini'
RI_WITHOUT_BACKEND=false
# RI_WITHOUT_BACKEND=true
RI_STDOUT_LOGGER=false
Expand Down
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ module.exports = {
'function-paren-newline': 'off',
'prefer-regex-literals': 'off',
'react/display-name': 'off',
'react/jsx-indent-props': [2, 2],
'react/jsx-indent': [2, 2],
'no-promise-executor-return': 'off',
'import/order': [
1,
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/install-all-build-libs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.15'
node-version: '20.18.0'

- name: Install dependencies for root package.js
shell: bash
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ coverage
/.nyc_output
**/coverage
reports
report

# IDEs and editors
/.idea
Expand Down
12 changes: 11 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"source.fixAll.eslint": "explicit"
},
"eslint.validate": ["javascript", "typescript"],
"eslint.workingDirectories": [
{ "directory": "./", "changeProcessCWD": true }
],
"files.associations": {
"*.css": "postcss",
"*.scss": "postcss"
Expand All @@ -35,6 +38,7 @@
".eslintcache": true,
"bower_components": true,
"release": true,
"src/webviews/public": true,
"npm-debug.log.*": true,
"tests/**/__snapshots__": true,
"yarn.lock": true,
Expand All @@ -44,7 +48,13 @@
"**/pnpm-lock.yaml": true,
"**/test-extensions": true
},
"cSpell.words": ["githubocto", "tailwindcss", "webviews", "zustand"],
"cSpell.words": [
"githubocto",
"keyspace",
"tailwindcss",
"webviews",
"zustand"
],
"testing.automaticallyOpenPeekView": "never",
"[typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
Expand Down
2 changes: 2 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ vite.config.mjs
# test
coverage
test
report
reports
tests
test-workspace
.vscode-test
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@
"@vitejs/plugin-react": "^4.2.1",
"@vitejs/plugin-react-swc": "^3.6.0",
"@vitest/coverage-v8": "^1.3.1",
"@vitest/ui": "^1.3.1",
"@vitest/ui": "^1.6.0",
"@vscode/l10n-dev": "^0.0.35",
"@vscode/vsce": "^3.0.0",
"@vscode/vsce": "^3.2.1",
"cross-env": "^7.0.3",
"csv-parser": "^3.0.0",
"csv-stringify": "^6.5.1",
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export async function activate(context: vscode.ExtensionContext) {

vscode.commands.registerCommand('RedisForVSCode.editDatabaseClose', (args) => {
WebviewPanel.getInstance({ viewId: ViewId.EditDatabase }).dispose()
sidebarProvider.view?.webview.postMessage({ action: 'RefreshTree', data: args })
sidebarProvider.view?.webview.postMessage({ action: 'UpdateDatabaseInList', data: args })

const keyDetailsWebview = WebviewPanel.instances[ViewId.Key]
if (keyDetailsWebview) {
Expand Down
4 changes: 3 additions & 1 deletion src/webviews/src/actions/processCliAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { useDatabasesStore } from 'uiSrc/store'

export const processCliAction = (message: CliAction) => {
const prevDatabaseId = useDatabasesStore.getState().connectedDatabase?.id
const prevDatabaseIndex = useDatabasesStore.getState().connectedDatabase?.db
const database = message?.data?.database
const dbIndex = database?.db ?? 0

if (prevDatabaseId === database?.id) {
if (prevDatabaseId! + prevDatabaseIndex === database?.id + dbIndex) {
return
}
window.ri.database = database
Expand Down
69 changes: 0 additions & 69 deletions src/webviews/src/components/database-form/DbIndex.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/webviews/src/components/database-form/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export { DbInfo } from './DbInfo'
export { MessageStandalone } from './Messages'
export { DbIndex } from './DbIndex'
export { DbCompressor } from './DbCompressor'
export { TlsDetails } from './TlsDetails'
export { DatabaseForm } from './DatabaseForm'
Expand Down
9 changes: 7 additions & 2 deletions src/webviews/src/components/no-keys-message/NoKeysMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { VSCodeButton } from '@vscode/webview-ui-toolkit/react'
import React, { FC } from 'react'

import { VscodeMessageAction } from 'uiSrc/constants'
import { Nullable } from 'uiSrc/interfaces'
import { Maybe, Nullable } from 'uiSrc/interfaces'
import { vscodeApi } from 'uiSrc/services'
import { Database } from 'uiSrc/store'
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/utils'
Expand All @@ -13,20 +13,25 @@ import styles from './styles.module.scss'
export interface Props {
total: Nullable<number>
database: Database
dbIndex: Maybe<number>
}

export const NoKeysMessage: FC<Props> = (props) => {
const {
total,
database,
dbIndex,
} = props

const handleAddKey = () => {
sendEventTelemetry({
event: TelemetryEvent.TREE_VIEW_KEY_ADD_BUTTON_CLICKED,
eventData: { databaseId: database.id },
})
vscodeApi.postMessage({ action: VscodeMessageAction.AddKey, data: { database } })
vscodeApi.postMessage({
action: VscodeMessageAction.AddKey,
data: { database: { ...database, db: dbIndex } },
})
}

// TODO: will be implemented in the future
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/src/components/scan-more/styles.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.container {
@apply flex flex-row pl-[15px];
@apply flex flex-row pl-[23px];

&:hover {
background: var(--vscode-merge-commonHeaderBackground);
Expand Down
37 changes: 37 additions & 0 deletions src/webviews/src/constants/cli/cliOutputComponents.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { describe, it, expect } from 'vitest'
import React from 'react'

import { render } from 'testSrc/helpers'
import { InitOutputText, cliTexts } from './cliOutputComponents'

describe('InitOutputText', () => {
it('should render correct output with valid inputs', () => {
const host = '127.0.0.1'
const port = 6379
const dbIndex = 1
const { container } = render(<>{InitOutputText(host, port, dbIndex, false)}</>)

expect(container).toHaveTextContent('Connecting...')
expect(container).toHaveTextContent('Pinging Redis server on ')
expect(container).toHaveTextContent(`${host}:${port}`)
})
})

describe('cliTexts', () => {
it('CLI_UNSUPPORTED_COMMANDS should format correctly', () => {
const commandLine = 'INFO'
const commands = 'AUTH, CONFIG'
const result = cliTexts.CLI_UNSUPPORTED_COMMANDS(commandLine, commands)

expect(result).toBe(
`${`${commandLine} is not supported by the Redis CLI. The list of all unsupported commands: ${commands}`}`,
)
})

it('CLI_ERROR_MESSAGE should render with the correct message', () => {
const message = 'An error occurred'
const result = cliTexts.CLI_ERROR_MESSAGE(message)
const { getByText } = render(<>{result}</>)
expect(getByText(message)).toHaveClass('text-vscode-errorForeground')
})
})
1 change: 1 addition & 0 deletions src/webviews/src/constants/core/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum StorageItem {
OAuthAgreement = 'OAuthAgreement',
cliDatabase = 'cliDatabase',
databaseId = 'databaseId',
openTreeNode = 'openTreeNode',
}

export { StorageItem }
Expand Down
1 change: 1 addition & 0 deletions src/webviews/src/constants/vscode/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export enum VscodeMessageAction {
SaveAppInfo = 'SaveAppInfo',
ShowEula = 'ShowEula',
CloseEula = 'CloseEula',
UpdateDatabaseInList = 'UpdateDatabaseInList',
}

export enum VscodeStateItem {
Expand Down
4 changes: 4 additions & 0 deletions src/webviews/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
useSelectedKeyStore,
fetchEditedDatabase,
fetchCerts,
useDatabasesStore,
} from 'uiSrc/store'
import { Config } from 'uiSrc/modules'
import { AppRoutes } from 'uiSrc/Routes'
Expand Down Expand Up @@ -53,6 +54,9 @@ document.addEventListener('DOMContentLoaded', () => {
case VscodeMessageAction.RefreshTree:
refreshTreeAction(message)
break
case VscodeMessageAction.UpdateDatabaseInList:
useDatabasesStore.getState().setDatabaseToList(message.data?.database)
break
case VscodeMessageAction.AddDatabase:
addDatabaseAction(message)
break
Expand Down
1 change: 1 addition & 0 deletions src/webviews/src/interfaces/vscode/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface SetDatabaseAction {
| VscodeMessageAction.SetDatabase
| VscodeMessageAction.CloseAddDatabase
| VscodeMessageAction.AddDatabase
| VscodeMessageAction.UpdateDatabaseInList
data: {
database: Database
}
Expand Down
14 changes: 7 additions & 7 deletions src/webviews/src/modules/keys-tree/KeysTree.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useEffect, useState } from 'react'
import * as l10n from '@vscode/l10n'
import cx from 'classnames'
import { isUndefined } from 'lodash'
import { isString, isUndefined } from 'lodash'

import { KeyInfo, Nullable, RedisString } from 'uiSrc/interfaces'
import { AllKeyTypes, VscodeMessageAction } from 'uiSrc/constants'
Expand Down Expand Up @@ -36,6 +35,7 @@ export const KeysTree = ({ database }: Props) => {

const keysState = useKeysInContext((state) => state.data)
const loading = useKeysInContext((state) => state.loading)
const dbIndex = useKeysInContext((state) => state.databaseIndex ?? 0)

const keysApi = useKeysApi()
const contextApi = useContextApi()
Expand All @@ -58,8 +58,8 @@ export const KeysTree = ({ database }: Props) => {

// open all parents for selected key
const openSelectedKey = (selectedKeyName: Nullable<string> = '') => {
if (selectedKeyName) {
const parts = selectedKeyName.split(delimiter)
if (selectedKeyName && isString(selectedKeyName)) {
const parts = selectedKeyName?.split(delimiter)
const parents = parts.map((_, index) => parts.slice(0, index + 1).join(delimiter) + delimiter)

// remove key name from parents
Expand Down Expand Up @@ -111,11 +111,11 @@ export const KeysTree = ({ database }: Props) => {
if (isUndefined(type)) {
return
}
fetchKeyInfo({ key: name, databaseId: database.id }, false, () => {
fetchKeyInfo({ key: name, databaseId: database.id, dbIndex }, false, () => {
vscodeApi.postMessage({
action: VscodeMessageAction.SelectKey,
data: {
database,
database: { ...database, db: dbIndex },
keyInfo: { key: name, keyString, keyType: type, displayedKeyType: getGroupTypeDisplay(type) },
},
})
Expand Down Expand Up @@ -152,7 +152,7 @@ export const KeysTree = ({ database }: Props) => {

return (
<div className="pl-8">
<NoKeysMessage total={keysState.total} database={database} />
<NoKeysMessage total={keysState.total} database={database} dbIndex={dbIndex} />
</div>
)
}
Expand Down
Loading
Loading