Skip to content

Commit c806532

Browse files
Merge pull request #181 from RedisInsight/feature/bugfix
Bugfix
2 parents fa68727 + 31af840 commit c806532

File tree

17 files changed

+75
-119
lines changed

17 files changed

+75
-119
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ RI_AUTO_BOOTSTRAP=false
1616
RI_MIGRATE_OLD_FOLDERS=false
1717
RI_BUILD_TYPE='VS_CODE'
1818
RI_ENCRYPTION_KEYTAR=false
19+
RI_ANALYTICS_START_EVENTS=true
1920
RI_AGREEMENTS_PATH='../../webviews/resources/agreements-spec.json'
2021
# RI_SEGMENT_WRITE_KEY='SEGMENT_WRITE_KEY'

l10n/bundle.l10n.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@
294294
"Database Name from Provider:": "Database Name from Provider:",
295295
"Host:": "Host:",
296296
"Database Index:": "Database Index:",
297+
"Modules:": "Modules:",
297298
"Select Logical Database": "Select Logical Database",
298299
"Database Index": "Database Index",
299300
"Enter Database Index": "Enter Database Index",
Lines changed: 1 addition & 1 deletion
Loading

src/webviews/src/components/database-form/DbInfo.tsx

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import cx from 'classnames'
44
import * as l10n from '@vscode/l10n'
55
// import { DatabaseListModules } from 'uiSrc/components'
66
import { VscInfo } from 'react-icons/vsc'
7-
import Popup from 'reactjs-popup'
87
import { ConnectionType, Nullable } from 'uiSrc/interfaces'
98
import { AdditionalRedisModule, Endpoint } from 'uiSrc/store'
109
import { DatabaseModules } from 'uiSrc/components'
10+
import { Tooltip } from 'uiSrc/ui'
1111
import styles from './styles.module.scss'
1212

1313
export interface Props {
@@ -25,20 +25,22 @@ const DbInfo = (props: Props) => {
2525
const { connectionType, nameFromProvider, nodes = null, host, port, db, modules, isFromCloud } = props
2626

2727
const AppendEndpoints = () => (
28-
<Popup
29-
position="top center"
30-
on={['hover']}
31-
trigger={<VscInfo />}
28+
<Tooltip
29+
content={(
30+
<>
31+
<h2 className="font-bold pb-1">{l10n.t('Host:port')}</h2>
32+
<ul className={styles.endpointsList}>
33+
{nodes?.map(({ host: eHost, port: ePort }) => (
34+
<li key={host + port}>
35+
<div>{eHost}:{ePort};</div>
36+
</li>
37+
))}
38+
</ul>
39+
</>
40+
)}
3241
>
33-
<span>{l10n.t('Host:port')}</span>
34-
<ul className={styles.endpointsList}>
35-
{nodes?.map(({ host: eHost, port: ePort }) => (
36-
<li key={host + port}>
37-
<div>{eHost}:{ePort};</div>
38-
</li>
39-
))}
40-
</ul>
41-
</Popup>
42+
<div className="pl-1 cursor-pointer"><VscInfo /></div>
43+
</Tooltip>
4244
)
4345

4446
return (
@@ -65,15 +67,13 @@ const DbInfo = (props: Props) => {
6567
</div>
6668
)}
6769
<div className="flex">
68-
<>
69-
{!!nodes?.length && <AppendEndpoints />}
70-
<div>
71-
{l10n.t('Host:')}
72-
</div>
73-
<div color="default" className={styles.dbInfoListValue} data-testid="db-info-host">
74-
{host}
75-
</div>
76-
</>
70+
<div>
71+
{l10n.t('Host:')}
72+
</div>
73+
<div color="default" className={styles.dbInfoListValue} data-testid="db-info-host">
74+
{host}
75+
</div>
76+
{!!nodes?.length && <AppendEndpoints />}
7777
</div>
7878

7979
{!!db && (
@@ -88,9 +88,9 @@ const DbInfo = (props: Props) => {
8888
)}
8989

9090
{!!modules?.length && (
91-
<div className="flex items-center">
91+
<div className="flex">
9292
<div>
93-
Modules:
93+
{l10n.t('Modules:')}
9494
</div>
9595
<div className={cx(styles.dbInfoListValue, styles.dbInfoModules)}>
9696
<DatabaseModules modules={modules} />

src/webviews/src/components/database-form/styles.module.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@
3232
padding: 16px;
3333
padding-bottom: 4px;
3434
border-radius: 4px;
35+
36+
> div {
37+
@apply mb-3 items-center;
38+
}
3539
}
3640

3741
.dbInfoListValue {
3842
margin-left: 12px;
39-
margin-bottom: 12px;
4043
@apply text-vscode-foreground;
4144
}
4245

@@ -47,7 +50,6 @@
4750
& > div {
4851
display: inline-block;
4952
line-height: 20px;
50-
margin-top: 5px;
5153
vertical-align: top;
5254
}
5355
}

src/webviews/src/components/no-keys-message/styles.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.addKey {
2-
@apply mr-4 min-w-[68px] max-h-[22px];
2+
@apply mr-4 min-w-[72px] max-h-[22px];
33

44
&::part(control) {
55
@apply px-2 py-0.5;

src/webviews/src/components/popover-delete/PopoverDelete.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const PopoverDelete = (props: Props) => {
6868
closeOnEscape
6969
closeOnDocumentClick
7070
repositionOnResize
71-
keepTooltipInside
71+
keepTooltipInside={false}
7272
position={position}
7373
onClose={() => closePopover?.()}
7474
onOpen={() => {

src/webviews/src/modules/cli/components/cli-body/CliBodyWrapper.tsx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
// Pages
1515
} from 'uiSrc/constants'
1616
import { getCommandRepeat, isRepeatCountCorrect, sendEventTelemetry, TelemetryEvent } from 'uiSrc/utils'
17-
import { ClusterNodeRole } from 'uiSrc/interfaces'
1817
import { checkUnsupportedCommand, clearOutput, cliCommandOutput } from 'uiSrc/modules/cli/utils/cliHelper'
1918
import { useDatabasesStore } from 'uiSrc/store'
2019

@@ -41,7 +40,7 @@ export const CliBodyWrapper = () => {
4140
resetCliSettings: state.resetCliSettings,
4241
}))
4342
const database = useDatabasesStore(useShallow((state) => state.connectedDatabase))
44-
const { id, host, port, connectionType } = database || {}
43+
const { id, connectionType } = database || {}
4544

4645
const data = useCliOutputStore((state) => state.data || [])
4746

@@ -62,7 +61,7 @@ export const CliBodyWrapper = () => {
6261
}
6362

6463
useEffect(() => {
65-
!cliClientUuid && host && createCliClientAction(database!)
64+
!cliClientUuid && database && createCliClientAction(database!)
6665
resetCommand()
6766
return () => {
6867
removeCliClient()
@@ -143,24 +142,19 @@ export const CliBodyWrapper = () => {
143142
return
144143
}
145144

146-
const options: any = {
147-
command,
148-
nodeOptions: {
149-
host,
150-
port,
151-
enableRedirection: true,
152-
},
153-
role: ClusterNodeRole.All,
154-
}
155-
sendCliClusterCommandAction(command, options, resetCommand)
145+
sendCliClusterCommandAction(command, resetCommand)
156146
}
157147

158148
const resetCommand = () => {
159149
setCommand('')
160150
}
161151

162152
return (
163-
<section ref={refHotkeys} className={styles.section}>
153+
<section
154+
ref={refHotkeys}
155+
className={styles.section}
156+
onContextMenu={(e) => e.preventDefault()}
157+
>
164158
<CliBody
165159
data={data}
166160
command={command}

src/webviews/src/modules/cli/hooks/cli-output/tests/useCliOutput.spec.tsx

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -216,62 +216,45 @@ describe('thunks', () => {
216216
})
217217

218218
describe('Single Node Cluster Cli command', () => {
219-
const options: any = {
220-
command: constants.COMMAND,
221-
nodeOptions: {
222-
host: 'localhost',
223-
port: 7000,
224-
enableRedirection: true,
225-
},
226-
role: ClusterNodeRole.All,
227-
}
228-
229219
it('call both sendCliClusterCommandAction and sendCliCommandSuccess when response status is successed', async () => {
230220
// Arrange
231221
const command = constants.COMMAND
232-
const data: any[] = [
233-
{
234-
response: '(nil)',
235-
status: CommandExecutionStatus.Success,
236-
node: { host: '127.0.0.1', port: 7002, slot: 6918 },
237-
},
238-
]
222+
const data: any = {
223+
response: '(nil)',
224+
status: CommandExecutionStatus.Success,
225+
node: { host: '127.0.0.1', port: 7002, slot: 6918 },
226+
}
239227
const responsePayload = { data, status: 200 }
240228

241229
apiService.post = vi.fn().mockResolvedValue(responsePayload)
242230

243231
// Act
244-
sendCliClusterCommandAction(command, options)
232+
sendCliClusterCommandAction(command)
245233
await waitForStack()
246234

247235
// Assert
248-
expect(useCliOutputStore.getState().data[0].toString()).toEqual(
249-
'-> Redirected to slot [6918] located at 127.0.0.1:7002'
250-
)
236+
expect((useCliOutputStore.getState().data[0] as any).props?.children).toEqual('"(nil)"')
251237
})
252238

253239
it('call both sendCliClusterCommandAction and sendCliCommandSuccess when response status is fail', async () => {
254240
// Arrange
255241
const command = constants.COMMAND
256-
const data: any[] = [
257-
{
258-
response: null,
259-
status: CommandExecutionStatus.Success,
260-
node: { host: '127.0.0.1', port: 7002, slot: 6918 },
261-
},
262-
]
242+
const data: any = {
243+
response: null,
244+
status: CommandExecutionStatus.Success,
245+
node: { host: '127.0.0.1', port: 7002, slot: 6918 },
246+
}
247+
263248
const responsePayload = { data, status: 200 }
264249

265250
apiService.post = vi.fn().mockResolvedValue(responsePayload)
266251

267252
// Act
268-
sendCliClusterCommandAction(command, options)
253+
sendCliClusterCommandAction(command)
269254
await waitForStack()
270255

271256
// Assert
272-
expect(useCliOutputStore.getState().data[0].toString()).toEqual(
273-
'-> Redirected to slot [6918] located at 127.0.0.1:7002'
274-
)
257+
expect((useCliOutputStore.getState().data[0] as any).props?.children).toEqual('(nil)')
275258
})
276259

277260
it('call both updateCliClientAction on ClientNotFound error', async () => {
@@ -287,7 +270,7 @@ describe('thunks', () => {
287270
apiService.post = vi.fn().mockRejectedValueOnce(responsePayload)
288271

289272
// Act
290-
sendCliClusterCommandAction(command, options)
273+
sendCliClusterCommandAction(command)
291274
await waitForStack()
292275

293276
// Assert

src/webviews/src/modules/cli/hooks/cli-output/useCliOutputThunks.ts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { useCliSettingsStore } from '../cli-settings/useCliSettingsStore'
1414
import { updateCliClientAction } from '../cli-settings/useCliSettingsThunks'
1515
import {
1616
cliParseTextResponseWithOffset,
17-
cliParseTextResponseWithRedirect,
1817
getDbIndexFromSelectQuery,
1918
} from '../../utils'
2019

@@ -24,7 +23,7 @@ export function sendCliCommandAction(
2423
onSuccessAction?: () => void,
2524
onFailAction?: () => void,
2625
) {
27-
return useCliOutputStore.setState(async (state) => {
26+
useCliOutputStore.setState(async (state) => {
2827
let cliClientUuid
2928
try {
3029
cliClientUuid = useCliSettingsStore.getState().cliClientUuid
@@ -80,11 +79,10 @@ export function sendCliCommandAction(
8079
// Asynchronous thunk action
8180
export function sendCliClusterCommandAction(
8281
command: string = '',
83-
options: any,
8482
onSuccessAction?: () => void,
8583
onFailAction?: () => void,
8684
) {
87-
return useCliOutputStore.setState(async (state) => {
85+
useCliOutputStore.setState(async (state) => {
8886
let cliClientUuid
8987
try {
9088
const outputFormat = CliOutputFormatterType.Raw
@@ -97,33 +95,18 @@ export function sendCliClusterCommandAction(
9795

9896
state.sendCliCommand()
9997

100-
const {
101-
data: [
102-
{ response, status: dataStatus, node: nodeOptionsResponse },
103-
] = [],
104-
status,
105-
} = await apiService.post<any[]>(
98+
const { data: { response, status: dataStatus }, status } = await apiService.post<any>(
10699
getUrl(
107100
ApiEndpoints.CLI,
108101
cliClientUuid,
109102
ApiEndpoints.SEND_CLUSTER_COMMAND,
110103
),
111-
{ ...options, command, outputFormat },
104+
{ command, outputFormat },
112105
)
113106

114107
if (isStatusSuccessful(status)) {
115-
let isRedirected = false
116-
if (options.nodeOptions && nodeOptionsResponse) {
117-
const requestNodeAddress = `${options.nodeOptions.host}:${options.nodeOptions.port}`
118-
const responseNodeAddress = `${nodeOptionsResponse.host}:${nodeOptionsResponse.port}`
119-
isRedirected = requestNodeAddress !== responseNodeAddress
120-
}
121108
onSuccessAction?.()
122-
const result = outputFormat === CliOutputFormatterType.Raw && isRedirected
123-
? cliParseTextResponseWithRedirect(response, command, dataStatus, nodeOptionsResponse)
124-
: cliParseTextResponseWithOffset(response, command, dataStatus)
125-
126-
state.concatToOutput(result)
109+
state.concatToOutput(cliParseTextResponseWithOffset(response, command, dataStatus))
127110
}
128111
} catch (error) {
129112
const errorMessage = getApiErrorMessage(error as AxiosError)

0 commit comments

Comments
 (0)