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 @@ -35,7 +35,6 @@ const defaultMockHook = () => ({
usedMemoryPercent: undefined,
handleEnableAutoRefresh: jest.fn(),
handleRefresh: jest.fn(),
handleRefreshClick: jest.fn(),
})

describe('DatabaseOverview', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const DatabaseOverview = () => {
isBdbPackages,
lastRefreshTime,
handleEnableAutoRefresh,
handleRefreshClick,
handleRefresh,
} = useDatabaseOverview()

Expand Down Expand Up @@ -102,7 +101,6 @@ const DatabaseOverview = () => {
DATABASE_OVERVIEW_MINIMUM_REFRESH_INTERVAL,
)}
onRefresh={handleRefresh}
onRefreshClicked={handleRefreshClick}
onEnableAutoRefresh={handleEnableAutoRefresh}
/>
</FlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
renderHook,
} from 'uiSrc/utils/test-utils'
import { getDatabaseConfigInfo } from 'uiSrc/slices/instances/instances'
import { setConnectivityError } from 'uiSrc/slices/app/connectivity'
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
import { useDatabaseOverview } from './useDatabaseOverview'

Expand Down Expand Up @@ -97,7 +96,6 @@ describe('useDatabaseOverview', () => {
expect(data.isBdbPackages).toBeUndefined()
expect(data.usedMemoryPercent).toBeUndefined()
expect(typeof data.handleRefresh).toBe('function')
expect(typeof data.handleRefreshClick).toBe('function')
expect(typeof data.handleEnableAutoRefresh).toBe('function')
})

Expand Down Expand Up @@ -158,19 +156,6 @@ describe('useDatabaseOverview', () => {
expect(actions).toContainEqual(getDatabaseConfigInfo())
})

it('should handle refresh click correctly', () => {
// Clear previous actions
mockedStore.clearActions()

const data = renderHelper(mockedStore)
act(() => {
data.handleRefreshClick()
})

const actions = mockedStore.getActions()
expect(actions).toContainEqual(setConnectivityError(null))
})

it('should send telemetry event when auto-refresh is enabled', () => {
const data = renderHelper(mockedStore)
act(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,16 @@ export const useDatabaseOverview = () => {
} = {},
} = overview

const loadData = (forceDataReload = false) => {
if (connectedInstanceId && (!connectivityError || forceDataReload)) {
dispatch(getDatabaseConfigInfoAction(connectedInstanceId))
const loadData = () => {
if (connectedInstanceId) {
dispatch(
getDatabaseConfigInfoAction(connectedInstanceId, () => {
// Clear connectivity error on successful API call.
// Always dispatch to avoid stale closure issues - dispatching null
// when there's no error is a safe no-op.
dispatch(setConnectivityError(null))
}),
)
setLastRefreshTime(Date.now())
}
}
Expand All @@ -75,12 +82,8 @@ export const useDatabaseOverview = () => {
},
})

const handleRefresh = (forceRefresh?: boolean) => {
loadData(forceRefresh)
}
const handleRefreshClick = () => {
// clear error, if connectivity is broken, the interceptor will set it again
dispatch(setConnectivityError(null))
const handleRefresh = () => {
loadData()
}
const usedMemoryPercent = getUsedMemoryPercent(
planMemoryLimit,
Expand Down Expand Up @@ -109,6 +112,5 @@ export const useDatabaseOverview = () => {
usedMemoryPercent,
handleEnableAutoRefresh,
handleRefresh,
handleRefreshClick,
}
}
2 changes: 2 additions & 0 deletions redisinsight/ui/src/pages/instance/InstancePage.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import * as rdiInstanceSlice from 'uiSrc/slices/rdi/instances'
import { loadInstances as loadRdiInstances } from 'uiSrc/slices/rdi/instances'

import { clearExpertChatHistory } from 'uiSrc/slices/panels/aiAssistant'
import { setConnectivityError } from 'uiSrc/slices/app/connectivity'
import { getAllPlugins } from 'uiSrc/slices/app/plugins'
import { DEFAULT_RDI_SHOWN_COLUMNS, FeatureFlags } from 'uiSrc/constants'
import { getDatabasesApiSpy } from 'uiSrc/mocks/handlers/instances/instancesHandlers'
Expand Down Expand Up @@ -158,6 +159,7 @@ describe('InstancePage', () => {
getRecommendations(),
...resetContextActions,
clearExpertChatHistory(),
setConnectivityError(null),
setAppContextConnectedInstanceId(INSTANCE_ID_MOCK),
setDbConfig(undefined),
]
Expand Down
2 changes: 2 additions & 0 deletions redisinsight/ui/src/slices/app/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
setPipelineJobs,
} from 'uiSrc/slices/rdi/pipeline'
import { resetOutput } from 'uiSrc/slices/cli/cli-output'
import { setConnectivityError } from 'uiSrc/slices/app/connectivity'
import { SearchMode } from '../interfaces/keys'
import {
AppWorkspace,
Expand Down Expand Up @@ -448,6 +449,7 @@ export function resetDatabaseContext() {
dispatch(setRedisearchInitialState())
dispatch(setInitialRecommendationsState())
dispatch(clearExpertChatHistory())
dispatch(setConnectivityError(null))
setTimeout(() => {
dispatch(resetOutput())
}, 0)
Expand Down
Loading