Skip to content

Commit f73da2e

Browse files
Merge pull request #1395 from RedisInsight/feature/bugfix
#RI-3606, #RI-3608, #RI-3610
2 parents e25d3f3 + b114147 commit f73da2e

File tree

10 files changed

+80
-246
lines changed

10 files changed

+80
-246
lines changed

redisinsight/ui/src/pages/home/components/AddInstanceForm/InstanceForm/InstanceForm.spec.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const mockedDbConnectionInfo = mock<DbConnectionInfo>()
1818
const formFields = {
1919
...instance(mockedDbConnectionInfo),
2020
host: 'localhost',
21-
port: 6379,
21+
port: '6379',
2222
name: 'lala',
2323
caCertificates: [],
2424
certificates: [],
@@ -67,15 +67,15 @@ describe('InstanceForm', () => {
6767
).toBeTruthy()
6868
})
6969

70-
it('should render tooltip with endpoints', () => {
70+
it('should render tooltip with nodes', () => {
7171
expect(
7272
render(
7373
<InstanceForm
7474
{...instance(mockedProps)}
7575
isEditMode
7676
formFields={{
7777
...formFields,
78-
endpoints: [{ host: '1', port: 1 }],
78+
nodes: [{ host: '1', port: 1 }],
7979
connectionType: ConnectionType.Cluster,
8080
}}
8181
/>
@@ -91,12 +91,11 @@ describe('InstanceForm', () => {
9191
isEditMode={false}
9292
formFields={{
9393
...formFields,
94-
tls: {
95-
caCertId: '123',
96-
},
94+
tls: true,
95+
caCert: { id: '123' },
9796
host: '123',
9897
tlsClientAuthRequired: true,
99-
endpoints: [{ host: '1', port: 1 }],
98+
nodes: [{ host: '1', port: 1 }],
10099
connectionType: ConnectionType.Cluster,
101100
}}
102101
/>
@@ -241,7 +240,7 @@ describe('InstanceForm', () => {
241240
isEditMode
242241
formFields={{
243242
...formFields,
244-
tls: {},
243+
tls: true,
245244
connectionType: ConnectionType.Cluster,
246245
}}
247246
onSubmit={handleSubmit}
@@ -272,7 +271,7 @@ describe('InstanceForm', () => {
272271
isEditMode
273272
formFields={{
274273
...formFields,
275-
tls: {},
274+
tls: true,
276275
connectionType: ConnectionType.Cluster,
277276
}}
278277
onSubmit={handleSubmit}
@@ -309,7 +308,7 @@ describe('InstanceForm', () => {
309308
isEditMode
310309
formFields={{
311310
...formFields,
312-
tls: {},
311+
tls: true,
313312
connectionType: ConnectionType.Cluster,
314313
}}
315314
onSubmit={handleSubmit}
@@ -339,7 +338,7 @@ describe('InstanceForm', () => {
339338
isEditMode
340339
formFields={{
341340
...formFields,
342-
tls: {},
341+
tls: true,
343342
connectionType: ConnectionType.Cluster,
344343
}}
345344
onSubmit={handleSubmit}
@@ -390,7 +389,7 @@ describe('InstanceForm', () => {
390389
isEditMode
391390
formFields={{
392391
...formFields,
393-
tls: {},
392+
tls: true,
394393
connectionType: ConnectionType.Cluster,
395394
selectedCaCertName: 'ADD_NEW_CA_CERT',
396395
}}
@@ -432,7 +431,7 @@ describe('InstanceForm', () => {
432431
isEditMode
433432
formFields={{
434433
...formFields,
435-
tls: {},
434+
tls: true,
436435
connectionType: ConnectionType.Cluster,
437436
}}
438437
onSubmit={handleSubmit}
@@ -462,7 +461,7 @@ describe('InstanceForm', () => {
462461
isEditMode
463462
formFields={{
464463
...formFields,
465-
tls: {},
464+
tls: true,
466465
connectionType: ConnectionType.Standalone,
467466
selectedCaCertName: 'NO_CA_CERT',
468467
tlsClientAuthRequired: true,

redisinsight/ui/src/pages/home/components/AddInstanceForm/InstanceForm/InstanceForm.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const AddStandaloneForm = (props: Props) => {
149149
nameFromProvider,
150150
sentinelMaster,
151151
connectionType,
152-
endpoints = null,
152+
nodes = null,
153153
tlsClientAuthRequired,
154154
certificates,
155155
selectedTlsClientCertId = '',
@@ -472,7 +472,7 @@ const AddStandaloneForm = (props: Props) => {
472472
<EuiListGroupItem
473473
label={(
474474
<>
475-
{!!endpoints?.length && <AppendEndpoints />}
475+
{!!nodes?.length && <AppendEndpoints />}
476476
<EuiText color="subdued" size="s">
477477
Host:
478478
<EuiTextColor color="default" className={styles.dbInfoListValue}>
@@ -646,7 +646,7 @@ const AddStandaloneForm = (props: Props) => {
646646
anchorClassName={styles.anchorEndpoints}
647647
content={(
648648
<ul className={styles.endpointsList}>
649-
{endpoints?.map(({ host: ephost, port: epport }) => (
649+
{nodes?.map(({ host: ephost, port: epport }) => (
650650
<li key={ephost + epport}>
651651
<EuiText>
652652
{ephost}

redisinsight/ui/src/pages/home/components/AddInstanceForm/InstanceFormWrapper.spec.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import React from 'react'
22
import { instance, mock } from 'ts-mockito'
33
import { render, screen, fireEvent } from 'uiSrc/utils/test-utils'
4+
import { Instance } from 'uiSrc/slices/interfaces'
45
import InstanceFormWrapper, { Props } from './InstanceFormWrapper'
56
import InstanceForm, {
67
Props as InstanceProps,
78
} from './InstanceForm/InstanceForm'
89

910
const mockedProps = mock<Props>()
10-
const mockedEditedInstance = {
11+
const mockedEditedInstance: Instance = {
1112
name: 'name',
1213
host: 'host',
1314
port: 123,
14-
tls: {
15-
caCertId: 'zxc',
16-
clientCertPairId: 'zxc',
17-
},
15+
id: '123',
16+
modules: [],
17+
tls: true,
18+
caCert: { id: 'zxc' },
19+
clientCert: { id: 'zxc' },
1820
}
1921

2022
const mockedValues = {

redisinsight/ui/src/pages/home/components/AddInstanceForm/InstanceFormWrapper.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
updateInstanceAction,
1212
} from 'uiSrc/slices/instances/instances'
1313
import {
14-
cloneMasterSentinelAction,
1514
fetchMastersSentinelAction,
1615
sentinelSelector,
1716
} from 'uiSrc/slices/instances/sentinel'
@@ -117,7 +116,7 @@ const InstanceFormWrapper = (props: Props) => {
117116

118117
const handleSubmitDatabase = (payload: any) => {
119118
if (isCloneMode && connectionType === ConnectionType.Sentinel) {
120-
dispatch(cloneMasterSentinelAction(payload))
119+
dispatch(createInstanceStandaloneAction(payload))
121120
return
122121
}
123122

@@ -320,26 +319,20 @@ const InstanceFormWrapper = (props: Props) => {
320319
}
321320

322321
if (isCloneMode && connectionType === ConnectionType.Sentinel) {
323-
delete database.db
324-
delete database.name
325-
database.sentinelMaster = [
326-
{
327-
alias: name,
328-
db,
329-
name: sentinelMasterName,
330-
username: sentinelMasterUsername,
331-
password: sentinelMasterPassword,
332-
}
333-
]
322+
database.sentinelMaster = {
323+
name: sentinelMasterName,
324+
username: sentinelMasterUsername,
325+
password: sentinelMasterPassword,
326+
}
334327
}
335328

336329
handleSubmitDatabase(removeEmpty(database))
337330

338331
const databasesCount: number = JSON.parse(
339-
localStorageService.get(BrowserStorageItem.databasesCount) || `${0}`
332+
localStorageService.get(BrowserStorageItem.instancesCount) || `${0}`
340333
)
341334
localStorageService.set(
342-
BrowserStorageItem.databasesCount,
335+
BrowserStorageItem.instancesCount,
343336
databasesCount + 1
344337
)
345338
onDbAdded()

redisinsight/ui/src/pages/home/components/DatabaseAlias/DatabaseAlias.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import styles from './styles.module.scss'
2727

2828
export interface Props {
2929
alias: string
30-
database?: Nullable<number>
30+
database?: Nullable<string>
3131
onOpen: () => void
3232
onClone: () => void
3333
onCloneBack: () => void

redisinsight/ui/src/slices/instances/instances.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ const instancesSlice = createSlice({
8989
state.errorChanging = ''
9090
},
9191
changeInstanceAliasSuccess: (state, { payload }) => {
92-
const { id, newName } = payload
92+
const { id, name } = payload
9393
state.data = state.data.map((item: Instance) => {
9494
if (item.id === id) {
95-
item.name = newName
95+
item.name = name
9696
}
9797
return item
9898
})
@@ -245,7 +245,7 @@ export function fetchInstancesAction(onSuccess?: (data?: DatabaseInstanceRespons
245245
// Asynchronous thunk action
246246
export function createInstanceStandaloneAction(
247247
payload: Instance,
248-
onRedirectToSentinel: () => void
248+
onRedirectToSentinel?: () => void
249249
) {
250250
return async (dispatch: AppDispatch) => {
251251
dispatch(defaultInstanceChanging())
@@ -408,7 +408,7 @@ export function checkConnectToInstanceAction(
408408
const checkoutToSentinelFlow = (
409409
payload: Instance,
410410
dispatch: AppDispatch,
411-
onRedirectToSentinel: () => void
411+
onRedirectToSentinel?: () => void
412412
) => {
413413
const payloadSentinel = { ...payload }
414414
delete payloadSentinel.name
@@ -444,7 +444,7 @@ export function getDatabaseConfigInfoAction(
444444
// Asynchronous thunk action
445445
export function changeInstanceAliasAction(
446446
id: string = '',
447-
newName: string,
447+
name: string,
448448
onSuccessAction?: () => void,
449449
onFailAction?: () => void
450450
) {
@@ -456,18 +456,19 @@ export function changeInstanceAliasAction(
456456
const { CancelToken } = axios
457457
sourceInstance = CancelToken.source()
458458

459-
const { status } = await apiService.patch(
460-
`${ApiEndpoints.DATABASES}/${id}/name`,
461-
{ newName },
459+
const { status } = await apiService.put(
460+
`${ApiEndpoints.DATABASES}/${id}`,
461+
{ name },
462462
{ cancelToken: sourceInstance.token }
463463
)
464464

465465
sourceInstance = null
466466
if (isStatusSuccessful(status)) {
467-
dispatch(changeInstanceAliasSuccess({ id, newName }))
467+
dispatch(changeInstanceAliasSuccess({ id, name }))
468468
onSuccessAction?.()
469469
}
470-
} catch (error) {
470+
} catch (_err) {
471+
const error = _err as AxiosError
471472
if (!axios.isCancel(error)) {
472473
const errorMessage = getApiErrorMessage(error)
473474
dispatch(changeInstanceAliasFailure(errorMessage))

0 commit comments

Comments
 (0)