Skip to content

Commit 37f07ac

Browse files
committed
* #RIVS-258 - Change analytics page text for vscode
* #RIVS-245 - [Regression] Cli does not connect to the database when opened for the first time * #RIVS-247 - [Regression] Invalid database is displayed for some period of time after installing the extension
1 parent cef1d17 commit 37f07ac

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

src/Webview.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ abstract class Webview {
112112
}
113113

114114
public abstract update(opts?: WebviewOptions): void
115+
public abstract setTitle(title: string): void
115116
}
116117

117118
export class WebviewPanel extends Webview implements vscode.Disposable {
@@ -206,6 +207,10 @@ export class WebviewPanel extends Webview implements vscode.Disposable {
206207
}
207208
}
208209

210+
public setTitle(title: string) {
211+
this.panel.title = title
212+
}
213+
209214
public dispose() {
210215
// Disposes of this instance
211216
// Next time getInstance() is called, it will construct a new instance

src/extension.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { startBackend, getBackendGracefulShutdown } from './server/bootstrapBack
66
import { startBackendE2E } from './server/bootstrapBackendE2E'
77
import { checkVersionUpdate, initWorkspaceState, setUIStorageField } from './lib'
88
import { WebViewProvider } from './WebViewProvider'
9-
import { handleMessage, truncateText } from './utils'
10-
import { MAX_TITLE_KEY_LENGTH, ViewId } from './constants'
9+
import { getTitleForKey, handleMessage } from './utils'
10+
import { ViewId } from './constants'
1111
import { logger } from './logger'
1212

1313
dotenv.config({ path: path.join(__dirname, '..', '.env') })
@@ -59,7 +59,7 @@ export async function activate(context: vscode.ExtensionContext) {
5959

6060
vscode.commands.registerCommand('RedisForVSCode.openKey', async (args) => {
6161
const keyInfo = args.data?.keyInfo
62-
const title = `${keyInfo?.displayedKeyType?.toLowerCase()}:${truncateText(keyInfo?.keyString, MAX_TITLE_KEY_LENGTH)}`
62+
const title = getTitleForKey(keyInfo?.displayedKeyType, keyInfo?.keyString)
6363

6464
await setUIStorageField('keyInfo', keyInfo)
6565
await setUIStorageField('database', args.data?.database)
@@ -184,6 +184,8 @@ export async function activate(context: vscode.ExtensionContext) {
184184

185185
vscode.commands.registerCommand('RedisForVSCode.editKeyName', (args) => {
186186
sidebarProvider.view?.webview.postMessage({ action: 'RefreshTree', data: args })
187+
const title = getTitleForKey(args.keyInfo?.displayedKeyType, args.keyInfo?.newKeyString)
188+
WebviewPanel.getInstance({ viewId: ViewId.Key }).setTitle(title)
187189
}),
188190

189191
vscode.commands.registerCommand('RedisForVSCode.resetSelectedKey', () => {

src/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as vscode from 'vscode'
22
import { getUIStorageField, setUIStorageField } from './lib'
3+
import { MAX_TITLE_KEY_LENGTH } from './constants'
34

45
export const getNonce = () => {
56
let text = ''
@@ -84,3 +85,6 @@ export const handleMessage = async (message: any = {}) => {
8485

8586
export const truncateText = (text = '', maxLength = 0, separator = '...') =>
8687
(text.length >= maxLength ? text.slice(0, maxLength) + separator : text)
88+
89+
export const getTitleForKey = (keyType: string, keyString: string): string =>
90+
`${keyType?.toLowerCase()}:${truncateText(keyString, MAX_TITLE_KEY_LENGTH)}`

src/webviews/src/interfaces/vscode/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface SelectedKeyAction {
5656
key?: RedisString,
5757
keyType?: KeyTypes,
5858
newKey?: RedisString,
59+
newKeyString?: string,
5960
keyString?: string
6061
displayedKeyType?: string
6162
}

src/webviews/src/modules/key-details/KeyDetails.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import cx from 'classnames'
33
import { useShallow } from 'zustand/react/shallow'
44

55
import { KeyTypes, SelectedKeyActionType, VscodeMessageAction } from 'uiSrc/constants'
6-
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/utils'
6+
import { bufferToString, getGroupTypeDisplay, sendEventTelemetry, TelemetryEvent } from 'uiSrc/utils'
77
import { RedisString } from 'uiSrc/interfaces'
88
import { useDatabasesStore, useSelectedKeyStore } from 'uiSrc/store'
99
import { vscodeApi } from 'uiSrc/services'
@@ -65,7 +65,12 @@ const KeyDetails = () => {
6565
data: {
6666
type: SelectedKeyActionType.Renamed,
6767
database: database!,
68-
keyInfo: { key, newKey },
68+
keyInfo: {
69+
key,
70+
newKey,
71+
displayedKeyType: getGroupTypeDisplay(keyType),
72+
newKeyString: bufferToString(newKey),
73+
},
6974
},
7075
})
7176
}

0 commit comments

Comments
 (0)