Skip to content

Commit 020ffaf

Browse files
authored
Merge pull request #196 from RedisInsight/feature/bugfix
#RIVS-287, #RIVS-288
2 parents 7654911 + 78bf145 commit 020ffaf

File tree

26 files changed

+142
-147
lines changed

26 files changed

+142
-147
lines changed

.circleci/config.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ aliases:
3535
when:
3636
not: *manual-build-conditions
3737

38+
licenses-generate: &licensesGenerate
39+
run:
40+
name: Generate license file for all vscode dependencies
41+
command: |
42+
npm i -g license-checker
43+
license-checker --json --out licenses.json
44+
shell: /bin/bash
45+
46+
licenses-generate-windows: &licensesGenerateWindows
47+
run:
48+
name: Generate license file for all vscode dependencies
49+
command: |
50+
npm i -g license-checker
51+
license-checker --json --out licenses.json
52+
shell: powershell.exe
53+
3854
orbs:
3955
node: circleci/node@5.3.0
4056
win: circleci/windows@5.0.0
@@ -179,6 +195,7 @@ jobs:
179195
name: Install dependencies
180196
command: |
181197
yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
198+
- <<: *licensesGenerate
182199
- run:
183200
name: Build .vsix package
184201
command: |
@@ -228,6 +245,7 @@ jobs:
228245
command: |
229246
yarn install
230247
no_output_timeout: 15m
248+
- <<: *licensesGenerate
231249
- run:
232250
name: Build .vsix package
233251
command: |
@@ -292,6 +310,7 @@ jobs:
292310
yarn install
293311
shell: bash.exe
294312
no_output_timeout: 15m
313+
- <<: *licensesGenerateWindows
295314
- run:
296315
name: Build .vsix package
297316
command: |
@@ -370,6 +389,15 @@ jobs:
370389
# Orchestrate jobs using workflows
371390
# See: https://circleci.com/docs/configuration-reference/#workflows
372391
workflows:
392+
license-checker:
393+
jobs:
394+
- licenses-check:
395+
name: Run License checker
396+
filters:
397+
branches:
398+
only:
399+
- /^license.*/
400+
373401
frontend-tests:
374402
<<: *ignore-for-manual-build
375403
jobs:

.eslintrc.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module.exports = {
1111
'plugin:react-hooks/recommended',
1212
'airbnb-base',
1313
'airbnb-typescript',
14-
'plugin:sonarjs/recommended',
1514
// TODO: in a separate pull request enable and fix all classes sorting issues for tailwind
1615
// 'plugin:tailwindcss/recommended',
1716
],
@@ -88,9 +87,6 @@ module.exports = {
8887
'prefer-regex-literals': 'off',
8988
'react/display-name': 'off',
9089
'no-promise-executor-return': 'off',
91-
'sonarjs/no-duplicate-string': 'off',
92-
'sonarjs/cognitive-complexity': [1, 20],
93-
'sonarjs/no-identical-functions': [0, 5],
9490
'import/order': [
9591
1,
9692
{

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"**/yarn.lock": true,
4242
"*.{css,sass,scss}.d.ts": true,
4343
"pnpm-lock.yaml": true,
44-
"**/pnpm-lock.yaml": true
44+
"**/pnpm-lock.yaml": true,
45+
"**/test-extensions": true
4546
},
4647
"cSpell.words": ["githubocto", "tailwindcss", "webviews", "zustand"],
4748
"testing.automaticallyOpenPeekView": "never",

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@
197197
"@vitest/ui": "^1.3.1",
198198
"@vscode/l10n-dev": "^0.0.35",
199199
"@vscode/vsce": "^3.0.0",
200-
"autoprefixer": "^10.4.16",
201200
"cross-env": "^7.0.3",
202201
"csv-parser": "^3.0.0",
203202
"csv-stringify": "^6.5.1",
@@ -213,12 +212,10 @@
213212
"eslint-plugin-react": "^7.35.0",
214213
"eslint-plugin-react-hooks": "^4.6.2",
215214
"eslint-plugin-react-refresh": "^0.4.4",
216-
"eslint-plugin-sonarjs": "^0.23.0",
217215
"eslint-plugin-tailwindcss": "^3.15.1",
218216
"googleapis": "^142.0.0",
219217
"html-entities": "^2.3.2",
220218
"husky": "^8.0.3",
221-
"identity-obj-proxy": "^3.0.0",
222219
"jsdom": "^22.1.0",
223220
"jsdom-worker": "^0.3.0",
224221
"lint-staged": "^15.0.2",

postcss.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ module.exports = {
55
'postcss-import': {},
66
'tailwindcss/nesting': {},
77
tailwindcss: {},
8-
autoprefixer: {},
98
},
109
}

src/Webview.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type WebviewOptions = {
1111
styleUri?: vscode.Uri
1212
nonce?: string
1313
message?: {
14+
action?: string
1415
data: object
1516
}
1617
column?: vscode.ViewColumn
@@ -113,6 +114,7 @@ abstract class Webview {
113114

114115
public abstract update(opts?: WebviewOptions): void
115116
public abstract setTitle(title: string): void
117+
public abstract postMessage(message: any): void
116118
}
117119

118120
export class WebviewPanel extends Webview implements vscode.Disposable {
@@ -211,6 +213,10 @@ export class WebviewPanel extends Webview implements vscode.Disposable {
211213
this.panel.title = title
212214
}
213215

216+
public postMessage(message: any) {
217+
this.panel.webview.postMessage(message)
218+
}
219+
214220
public dispose() {
215221
// Disposes of this instance
216222
// Next time getInstance() is called, it will construct a new instance

src/extension.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,21 @@ export async function activate(context: vscode.ExtensionContext) {
165165
vscode.commands.registerCommand('RedisForVSCode.editDatabaseClose', (args) => {
166166
WebviewPanel.getInstance({ viewId: ViewId.EditDatabase }).dispose()
167167
sidebarProvider.view?.webview.postMessage({ action: 'RefreshTree', data: args })
168+
169+
const keyDetailsWebview = WebviewPanel.instances[ViewId.Key]
170+
if (keyDetailsWebview) {
171+
keyDetailsWebview.postMessage({ action: 'SetDatabase', data: args })
172+
}
168173
}),
169174

170175
vscode.commands.registerCommand('RedisForVSCode.closeAddKeyAndRefresh', (args) => {
171176
WebviewPanel.getInstance({ viewId: ViewId.AddKey })?.dispose()
172-
sidebarProvider.view?.webview.postMessage({ action: 'RefreshTree', data: args })
177+
sidebarProvider.view?.webview.postMessage({ action: 'SetSelectedKeyAction', data: args })
173178
vscode.commands.executeCommand('RedisForVSCode.openKey', { action: 'SelectKey', data: args })
174179
}),
175180

176181
vscode.commands.registerCommand('RedisForVSCode.closeKeyAndRefresh', (args) => {
177-
sidebarProvider.view?.webview.postMessage({ action: 'RefreshTree', data: args })
182+
sidebarProvider.view?.webview.postMessage({ action: 'SetSelectedKeyAction', data: args })
178183
WebviewPanel.getInstance({ viewId: ViewId.Key })?.dispose()
179184
}),
180185

@@ -183,7 +188,7 @@ export async function activate(context: vscode.ExtensionContext) {
183188
}),
184189

185190
vscode.commands.registerCommand('RedisForVSCode.editKeyName', (args) => {
186-
sidebarProvider.view?.webview.postMessage({ action: 'RefreshTree', data: args })
191+
sidebarProvider.view?.webview.postMessage({ action: 'SetSelectedKeyAction', data: args })
187192
const title = getTitleForKey(args.keyInfo?.displayedKeyType, args.keyInfo?.newKeyString)
188193
WebviewPanel.getInstance({ viewId: ViewId.Key }).setTitle(title)
189194
}),

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const handleMessage = async (message: any = {}) => {
5656
vscode.commands.executeCommand('RedisForVSCode.addDatabaseClose')
5757
break
5858
case 'CloseEditDatabase':
59-
vscode.commands.executeCommand('RedisForVSCode.editDatabaseClose', message)
59+
vscode.commands.executeCommand('RedisForVSCode.editDatabaseClose', message.data)
6060
break
6161
case 'UpdateSettings':
6262
await setUIStorageField('appInfo', {

src/webviews/src/actions/addKeyAction.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/webviews/src/actions/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export { selectKeyAction } from './selectKeyAction'
2-
export { addKeyAction } from './addKeyAction'
3-
export { refreshTreeAction } from './refreshTreeAction'
2+
export { setSelectedKeyAction } from './setSelectedKeyAction'
3+
export { setDatabaseAction } from './setDatabaseAction'
44
export { processCliAction } from './processCliAction'
5+
export { refreshTreeAction } from './refreshTreeAction'

src/webviews/src/actions/processCliAction.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
import { VscodeMessageAction } from 'uiSrc/constants'
2-
import { PostMessage } from 'uiSrc/interfaces'
1+
import { CliAction } from 'uiSrc/interfaces'
32
import { addCli } from 'uiSrc/modules/cli/hooks/cli-settings/useCliSettingsThunks'
43
import { useDatabasesStore } from 'uiSrc/store'
54

6-
export const processCliAction = (message: PostMessage) => {
7-
if (
8-
message.action !== VscodeMessageAction.AddCli
9-
&& message.action !== VscodeMessageAction.OpenCli) {
10-
return
11-
}
12-
5+
export const processCliAction = (message: CliAction) => {
136
const prevDatabaseId = useDatabasesStore.getState().connectedDatabase?.id
147
const database = message?.data?.database
158

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
import { VscodeMessageAction } from 'uiSrc/constants'
2-
import { PostMessage } from 'uiSrc/interfaces'
3-
import { fetchDatabases, useSelectedKeyStore } from 'uiSrc/store'
1+
import { fetchDatabases, useDatabasesStore } from 'uiSrc/store'
42

5-
export const refreshTreeAction = (message: PostMessage) => {
6-
if (message.action !== VscodeMessageAction.RefreshTree) {
7-
return
8-
}
9-
if (message.data?.keyInfo?.key) {
10-
useSelectedKeyStore.getState().setSelectedKeyAction(message.data)
11-
} else {
12-
fetchDatabases()
13-
}
3+
export const refreshTreeAction = (message: any) => {
4+
fetchDatabases(() => {
5+
if (message.data?.database?.id) {
6+
useDatabasesStore.getState().setDatabaseToList(message.data?.database!)
7+
}
8+
})
149
}

src/webviews/src/actions/selectKeyAction.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import { VscodeMessageAction } from 'uiSrc/constants'
2-
import { PostMessage } from 'uiSrc/interfaces'
3-
import { fetchDatabaseOverview, fetchKeyInfo, setInitialStateByType, useDatabasesStore, useSelectedKeyStore } from 'uiSrc/store'
1+
import { SelectKeyAction } from 'uiSrc/interfaces'
2+
import {
3+
fetchDatabaseOverview,
4+
fetchKeyInfo,
5+
setInitialStateByType,
6+
useDatabasesStore,
7+
useSelectedKeyStore,
8+
} from 'uiSrc/store'
49
import { TelemetryEvent, isEqualBuffers, sendEventTelemetry } from 'uiSrc/utils'
510

6-
export const selectKeyAction = (message: PostMessage) => {
7-
if (message.action !== VscodeMessageAction.SelectKey) {
8-
return
9-
}
10-
11+
export const selectKeyAction = (message: SelectKeyAction) => {
1112
const { keyInfo, database } = message?.data
1213
const { key } = keyInfo || {}
1314
const prevKey = useSelectedKeyStore.getState().data?.name
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { SetDatabaseAction } from 'uiSrc/interfaces'
2+
import { useDatabasesStore } from 'uiSrc/store'
3+
4+
export const setDatabaseAction = (message: SetDatabaseAction) => {
5+
if (message.data?.database?.id) {
6+
window.ri.database = message.data.database
7+
useDatabasesStore.getState().setConnectedDatabase(message.data.database)
8+
}
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { SelectedKeyAction } from 'uiSrc/interfaces'
2+
import { useSelectedKeyStore } from 'uiSrc/store'
3+
4+
export const setSelectedKeyAction = (message: SelectedKeyAction) => {
5+
if (message.data?.keyInfo?.key) {
6+
useSelectedKeyStore.getState().setSelectedKeyAction(message.data)
7+
}
8+
}

src/webviews/src/components/database-modules/DatabaseModules.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable sonarjs/no-nested-template-literals */
21
import React from 'react'
32
import cx from 'classnames'
43
import Popup from 'reactjs-popup'
@@ -39,7 +38,6 @@ const DatabaseModules = React.memo((props: Props) => {
3938
const { abbreviation = '', name = moduleName } = getModule(moduleName)
4039

4140
const moduleAlias = truncateText(name, 50)
42-
// eslint-disable-next-line sonarjs/no-nested-template-literals
4341
let icon = DEFAULT_MODULES_INFO[propName as RedisDefaultModules]?.icon
4442
const content = `${moduleAlias}${semanticVersion || version ? ` v. ${semanticVersion || version}` : ''}`
4543

src/webviews/src/components/virtual-table/styles.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ $borderColor: var(--vscode-tree-tableColumnsBorder);
118118
}
119119

120120
:global(.key-details-table) {
121-
@apply relative;
121+
@apply relative w-full;
122122
:global(.ReactVirtualized__Table__row) {
123123
font-size: 13px;
124124

src/webviews/src/constants/vscode/vscode.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ export enum VscodeMessageAction {
99
ErrorMessage = 'ErrorMessage',
1010
AddCli = 'AddCli',
1111
SelectKey = 'SelectKey',
12-
OpenCli = 'OpenCli',
1312
RefreshTree = 'RefreshTree',
1413
CloseKey = 'CloseKey',
1514
CloseKeyAndRefresh = 'CloseKeyAndRefresh',
1615
EditKeyName = 'EditKeyName',
1716
OpenAddDatabase = 'OpenAddDatabase',
1817
CloseAddDatabase = 'CloseAddDatabase',
1918
CloseEditDatabase = 'CloseEditDatabase',
19+
SetSelectedKeyAction = 'SetSelectedKeyAction',
20+
SetDatabase = 'SetDatabase',
2021
CloseAddKey = 'CloseAddKey',
2122
CloseAddKeyAndRefresh = 'CloseAddKeyAndRefresh',
2223
ResetSelectedKey = 'ResetSelectedKey',

src/webviews/src/index.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import { MemoryRouter as Router } from 'react-router-dom'
55
import {
66
useSelectedKeyStore,
77
fetchEditedDatabase,
8-
Database,
98
fetchCerts,
109
} from 'uiSrc/store'
1110
import { Config } from 'uiSrc/modules'
1211
import { AppRoutes } from 'uiSrc/Routes'
13-
import { PostMessage } from 'uiSrc/interfaces'
12+
import { PostMessage, SelectKeyAction, SetDatabaseAction } from 'uiSrc/interfaces'
1413
import { VscodeMessageAction } from 'uiSrc/constants'
1514
import { useAppInfoStore } from './store/hooks/use-app-info-store/useAppInfoStore'
1615
import {
17-
addKeyAction,
1816
processCliAction,
19-
refreshTreeAction,
17+
setSelectedKeyAction,
2018
selectKeyAction,
19+
setDatabaseAction,
20+
refreshTreeAction,
2121
} from './actions'
2222
import { MonacoLanguages } from './components'
2323

@@ -33,10 +33,7 @@ document.addEventListener('DOMContentLoaded', () => {
3333
switch (message.action) {
3434
// Key details
3535
case VscodeMessageAction.SelectKey:
36-
selectKeyAction(message)
37-
break
38-
case VscodeMessageAction.AddKey:
39-
addKeyAction(message)
36+
selectKeyAction(message as SelectKeyAction)
4037
break
4138
case VscodeMessageAction.ResetSelectedKey:
4239
useSelectedKeyStore.getState().resetSelectedKeyStore()
@@ -46,12 +43,18 @@ document.addEventListener('DOMContentLoaded', () => {
4643
case VscodeMessageAction.CloseEula:
4744
useAppInfoStore.getState().setIsShowConcepts(false)
4845
break
46+
case VscodeMessageAction.SetDatabase:
47+
setDatabaseAction(message as SetDatabaseAction)
48+
break
49+
case VscodeMessageAction.SetSelectedKeyAction:
50+
setSelectedKeyAction(message)
51+
break
4952
case VscodeMessageAction.RefreshTree:
5053
refreshTreeAction(message)
5154
break
5255
case VscodeMessageAction.EditDatabase:
5356
fetchCerts(() => {
54-
fetchEditedDatabase(message?.data?.database)
57+
fetchEditedDatabase(message?.data?.database as SetDatabaseAction['data']['database'])
5558
})
5659
break
5760

@@ -65,7 +68,6 @@ document.addEventListener('DOMContentLoaded', () => {
6568

6669
// CLI
6770
case VscodeMessageAction.AddCli:
68-
case VscodeMessageAction.OpenCli:
6971
processCliAction(message)
7072
break
7173
default:

0 commit comments

Comments
 (0)