Skip to content

Commit d07a82c

Browse files
committed
#RIVS-273 - [Regression] Cli stopes working after running command with enter
1 parent 44b6693 commit d07a82c

File tree

7 files changed

+21
-61
lines changed

7 files changed

+21
-61
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'

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 & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const CliBodyWrapper = () => {
4141
resetCliSettings: state.resetCliSettings,
4242
}))
4343
const database = useDatabasesStore(useShallow((state) => state.connectedDatabase))
44-
const { id, host, port, connectionType } = database || {}
44+
const { id, connectionType } = database || {}
4545

4646
const data = useCliOutputStore((state) => state.data || [])
4747

@@ -62,7 +62,7 @@ export const CliBodyWrapper = () => {
6262
}
6363

6464
useEffect(() => {
65-
!cliClientUuid && host && createCliClientAction(database!)
65+
!cliClientUuid && createCliClientAction(database!)
6666
resetCommand()
6767
return () => {
6868
removeCliClient()
@@ -143,24 +143,19 @@ export const CliBodyWrapper = () => {
143143
return
144144
}
145145

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)
146+
sendCliClusterCommandAction(command, resetCommand)
156147
}
157148

158149
const resetCommand = () => {
159150
setCommand('')
160151
}
161152

162153
return (
163-
<section ref={refHotkeys} className={styles.section}>
154+
<section
155+
ref={refHotkeys}
156+
className={styles.section}
157+
onContextMenu={(e) => e.preventDefault()}
158+
>
164159
<CliBody
165160
data={data}
166161
command={command}

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,7 @@ 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-
229-
it('call both sendCliClusterCommandAction and sendCliCommandSuccess when response status is successed', async () => {
219+
it.only('call both sendCliClusterCommandAction and sendCliCommandSuccess when response status is successed', async () => {
230220
// Arrange
231221
const command = constants.COMMAND
232222
const data: any[] = [
@@ -241,13 +231,13 @@ describe('thunks', () => {
241231
apiService.post = vi.fn().mockResolvedValue(responsePayload)
242232

243233
// Act
244-
sendCliClusterCommandAction(command, options)
234+
sendCliClusterCommandAction(command)
245235
await waitForStack()
246236

237+
console.log(useCliOutputStore.getState().data[0])
238+
247239
// Assert
248-
expect(useCliOutputStore.getState().data[0].toString()).toEqual(
249-
'-> Redirected to slot [6918] located at 127.0.0.1:7002'
250-
)
240+
expect(useCliOutputStore.getState().data[0]).toContain('(nil)')
251241
})
252242

253243
it('call both sendCliClusterCommandAction and sendCliCommandSuccess when response status is fail', async () => {
@@ -265,7 +255,7 @@ describe('thunks', () => {
265255
apiService.post = vi.fn().mockResolvedValue(responsePayload)
266256

267257
// Act
268-
sendCliClusterCommandAction(command, options)
258+
sendCliClusterCommandAction(command)
269259
await waitForStack()
270260

271261
// Assert
@@ -287,7 +277,7 @@ describe('thunks', () => {
287277
apiService.post = vi.fn().mockRejectedValueOnce(responsePayload)
288278

289279
// Act
290-
sendCliClusterCommandAction(command, options)
280+
sendCliClusterCommandAction(command)
291281
await waitForStack()
292282

293283
// Assert

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

Lines changed: 3 additions & 15 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

@@ -80,7 +79,6 @@ export function sendCliCommandAction(
8079
// Asynchronous thunk action
8180
export function sendCliClusterCommandAction(
8281
command: string = '',
83-
options: any,
8482
onSuccessAction?: () => void,
8583
onFailAction?: () => void,
8684
) {
@@ -99,7 +97,7 @@ export function sendCliClusterCommandAction(
9997

10098
const {
10199
data: [
102-
{ response, status: dataStatus, node: nodeOptionsResponse },
100+
{ response, status: dataStatus },
103101
] = [],
104102
status,
105103
} = await apiService.post<any[]>(
@@ -108,22 +106,12 @@ export function sendCliClusterCommandAction(
108106
cliClientUuid,
109107
ApiEndpoints.SEND_CLUSTER_COMMAND,
110108
),
111-
{ ...options, command, outputFormat },
109+
{ command, outputFormat },
112110
)
113111

114112
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-
}
121113
onSuccessAction?.()
122-
const result = outputFormat === CliOutputFormatterType.Raw && isRedirected
123-
? cliParseTextResponseWithRedirect(response, command, dataStatus, nodeOptionsResponse)
124-
: cliParseTextResponseWithOffset(response, command, dataStatus)
125-
126-
state.concatToOutput(result)
114+
state.concatToOutput(cliParseTextResponseWithOffset(response, command, dataStatus))
127115
}
128116
} catch (error) {
129117
const errorMessage = getApiErrorMessage(error as AxiosError)

src/webviews/src/modules/cli/utils/cliHelper.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,6 @@ export enum CliPrefix {
3434
// // status: CommandExecutionStatus
3535
// }
3636

37-
const cliParseTextResponseWithRedirect = (
38-
text: string = '',
39-
command: string = '',
40-
status: CommandExecutionStatus = CommandExecutionStatus.Success,
41-
redirectTo: ClusterNode | undefined,
42-
) => {
43-
let redirectMessage = ''
44-
if (redirectTo) {
45-
const { host, port, slot } = redirectTo
46-
redirectMessage = `-> Redirected to slot [${slot}] located at ${host}:${port}`
47-
}
48-
return [redirectMessage, '\n', cliParseTextResponse(text, command, status), '\n']
49-
}
50-
5137
const cliParseTextResponseWithOffset = (
5238
text: string = '',
5339
command: string = '',
@@ -244,7 +230,6 @@ const checkDeprecatedCommandGroup = (item: string) =>
244230
export {
245231
// cliParseTextResponse,
246232
cliParseTextResponseWithOffset,
247-
cliParseTextResponseWithRedirect,
248233
// cliParseCommandsGroupResult,
249234
cliCommandOutput,
250235
// bashTextValue,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export const DatabaseWrapper = ({ children, database }: Props) => {
167167
header={formatLongName(name, 50, 10, '...')}
168168
text={l10n.t('will be deleted from Redis for VS Code.')}
169169
item={id}
170+
position="bottom right"
170171
maxWidth={window.innerWidth - POPOVER_WINDOW_BORDER_WIDTH}
171172
disabled={false}
172173
triggerClassName={cx('hidden h-[22px] group-hover:!flex', { '!flex': showTree })}

0 commit comments

Comments
 (0)