Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ describe('DatabaseAnalytics', () => {
expect(sendEventSpy).toHaveBeenCalledWith(
TelemetryEvents.RedisInstanceEditedByUser,
{
host: cur.host,
port: cur.port,
databaseId: cur.id,
connectionType: cur.connectionType,
Expand Down Expand Up @@ -225,7 +224,6 @@ describe('DatabaseAnalytics', () => {
expect(sendEventSpy).toHaveBeenCalledWith(
TelemetryEvents.RedisInstanceEditedByUser,
{
host: cur.host,
port: cur.port,
databaseId: cur.id,
connectionType: cur.connectionType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export class DatabaseAnalytics extends TelemetryBaseService {
this.sendEvent(
TelemetryEvents.RedisInstanceEditedByUser,
{
host: cur.host,
port: cur.port,
databaseId: cur.id,
connectionType: cur.connectionType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('DatabaseService', () => {
it('should update existing database and send analytics event', async () => {
expect(await service.update(
mockDatabase.id,
{ password: 'password', port: 6380, host: '127.0.100.2' } as UpdateDatabaseDto,
{ password: 'password', port: 6380 } as UpdateDatabaseDto,
true,
)).toEqual(mockDatabase);
expect(analytics.sendInstanceEditedEvent).toHaveBeenCalledWith(
Expand All @@ -121,7 +121,6 @@ describe('DatabaseService', () => {
...mockDatabase,
password: 'password',
port: 6380,
host: '127.0.100.2',
},
true,
);
Expand Down
20 changes: 16 additions & 4 deletions redisinsight/ui/src/pages/home/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import {
import { optimizeLSInstances, setTitle } from 'uiSrc/utils'
import { PageHeader } from 'uiSrc/components'
import { BrowserStorageItem } from 'uiSrc/constants'
import { resetKeys } from 'uiSrc/slices/browser/keys'
import { resetCliHelperSettings, resetCliSettingsAction } from 'uiSrc/slices/cli/cli-settings'
import { resetRedisearchKeysData } from 'uiSrc/slices/browser/redisearch'
import { appContextSelector, setAppContextInitialState } from 'uiSrc/slices/app/context'
import { Instance } from 'uiSrc/slices/interfaces'
import { cloudSelector, resetSubscriptionsRedisCloud } from 'uiSrc/slices/instances/cloud'
import { editedInstanceSelector, fetchEditedInstanceAction, fetchInstancesAction, instancesSelector, setEditedInstance } from 'uiSrc/slices/instances/instances'
Expand Down Expand Up @@ -55,6 +59,8 @@ const HomePage = () => {

const { identified: analyticsIdentified } = useSelector(appAnalyticsInfoSelector)

const { contextInstanceId } = useSelector(appContextSelector)

!welcomeIsShow && setTitle('My Redis databases')

useEffect(() => {
Expand Down Expand Up @@ -127,7 +133,15 @@ const HomePage = () => {
}
}, [instances])

const onInstanceChanged = () => ({})
const onDbEdited = () => {
if (contextInstanceId && contextInstanceId === editedInstance?.id) {
dispatch(resetKeys())
dispatch(resetRedisearchKeysData())
dispatch(resetCliSettingsAction())
dispatch(resetCliHelperSettings())
dispatch(setAppContextInitialState())
}
}

const closeEditDialog = () => {
dispatch(setEditedInstance(null))
Expand Down Expand Up @@ -245,7 +259,7 @@ const HomePage = () => {
isResizablePanel
editedInstance={editedInstance}
onClose={closeEditDialog}
onDbAdded={onInstanceChanged}
onDbEdited={onDbEdited}
/>
)}

Expand All @@ -256,7 +270,6 @@ const HomePage = () => {
isResizablePanel
editedInstance={sentinelInstance ?? null}
onClose={handleClose}
onDbAdded={onInstanceChanged}
isFullWidth={!instances.length}
/>
)}
Expand Down Expand Up @@ -285,7 +298,6 @@ const HomePage = () => {
isResizablePanel
editedInstance={sentinelInstance ?? null}
onClose={handleClose}
onDbAdded={onInstanceChanged}
isFullWidth={!instances.length}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export interface Props {
editMode: boolean;
editedInstance: Nullable<Instance>;
onClose?: () => void;
onDbAdded: () => void;
onDbEdited?: () => void;
onAliasEdited?: (value: string) => void;
isFullWidth?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,39 +136,6 @@ describe('InstanceForm', () => {
)
})

it('should change host input properly', async () => {
const handleSubmit = jest.fn()
render(
<div id="footerDatabaseForm">
<InstanceForm
{...instance(mockedProps)}
isEditMode
formFields={{
...formFields,
connectionType: ConnectionType.Sentinel,
}}
onSubmit={handleSubmit}
/>
</div>
)

await act(() => {
fireEvent.change(screen.getByTestId('host'), {
target: { value: 'host_1' },
})
})

const submitBtn = screen.getByTestId(BTN_SUBMIT)
await act(() => {
fireEvent.click(submitBtn)
})
expect(handleSubmit).toBeCalledWith(
expect.objectContaining({
host: 'host_1',
})
)
})

it('should change port input properly', async () => {
const handleSubmit = jest.fn()
render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ const DatabaseForm = (props: Props) => {

return (
<>
{server?.buildType !== BuildType.RedisStack && (
<EuiFlexGroup className={flexGroupClassName}>
<EuiFlexGroup className={flexGroupClassName}>
{(!isEditMode || isCloneMode) && (
<EuiFlexItem className={flexItemClassName}>
<EuiFormRow label="Host*">
<EuiFieldText
Expand All @@ -105,7 +105,8 @@ const DatabaseForm = (props: Props) => {
/>
</EuiFormRow>
</EuiFlexItem>

)}
{server?.buildType !== BuildType.RedisStack && (
<EuiFlexItem className={flexItemClassName}>
<EuiFormRow label="Port*" helpText="Should not exceed 65535.">
<EuiFieldNumber
Expand All @@ -129,8 +130,8 @@ const DatabaseForm = (props: Props) => {
/>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
)}
)}
</EuiFlexGroup>

{(
(!isEditMode || isCloneMode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,33 +82,30 @@ const DbInfo = (props: Props) => {
)}
/>
)}
<EuiListGroupItem
label={(
<>
{!!nodes?.length && <AppendEndpoints />}
<EuiText color="subdued" size="s">
Host:
<EuiTextColor color="default" className={styles.dbInfoListValue}>
{host}
</EuiTextColor>
</EuiText>
</>
)}
/>
{server?.buildType === BuildType.RedisStack && (
<>
<EuiListGroupItem
label={(
<>
{!!nodes?.length && <AppendEndpoints />}
<EuiText color="subdued" size="s">
Host:
<EuiTextColor color="default" className={styles.dbInfoListValue}>
{host}
</EuiTextColor>
</EuiText>
</>
)}
/>

<EuiListGroupItem
label={(
<EuiText color="subdued" size="s">
Port:
<EuiTextColor color="default" className={styles.dbInfoListValue}>
{port}
</EuiTextColor>
</EuiText>
)}
/>
</>
<EuiListGroupItem
label={(
<EuiText color="subdued" size="s">
Port:
<EuiTextColor color="default" className={styles.dbInfoListValue}>
{port}
</EuiTextColor>
</EuiText>
)}
/>
)}

{!!db && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,6 @@ describe('InstanceFormWrapper', () => {
expect(onClose).toBeCalled()
})

it('should submit', () => {
const onSubmit = jest.fn()
render(
<InstanceFormWrapper
{...instance(mockedProps)}
editedInstance={mockedEditedInstance}
onDbAdded={onSubmit}
/>
)
fireEvent.click(screen.getByTestId('submit-form-btn'))
expect(onSubmit).toBeCalled()
})

it('should submit with editMode', () => {
const component = render(
<InstanceFormWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export interface Props {
instanceType: InstanceType
editMode: boolean
editedInstance: Nullable<Instance>
onDbAdded: () => void
onClose?: () => void
onDbEdited?: () => void
onAliasEdited?: (value: string) => void
Expand Down Expand Up @@ -77,7 +76,6 @@ const InstanceFormWrapper = (props: Props) => {
instanceType,
isResizablePanel = false,
onClose,
onDbAdded,
onDbEdited,
onAliasEdited,
editedInstance,
Expand Down Expand Up @@ -342,7 +340,6 @@ const InstanceFormWrapper = (props: Props) => {
BrowserStorageItem.instancesCount,
databasesCount + 1
)
onDbAdded()
}

const handleConnectionFormSubmit = (values: DbConnectionInfo) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ const EditConnection = () => {
editMode
width={600}
editedInstance={state.data}
onDbAdded={() => {}}
onDbEdited={onInstanceChanged}
onAliasEdited={onAliasChanged}
onClose={onClose}
Expand Down