Skip to content

Commit 6486dbe

Browse files
authored
RI-7399: fix instance not opening for electron (#5171)
1 parent e1adff4 commit 6486dbe

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

redisinsight/ui/src/Router.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ if (RIPROXYPATH !== '') {
1414
MOUNT_PATH = RIPROXYPATH
1515
}
1616

17-
export const history = createBrowserHistory({ basename: MOUNT_PATH })
17+
const history = createBrowserHistory({ basename: MOUNT_PATH })
18+
19+
export const navigate = (path: string) => {
20+
if (window.location.hash) {
21+
// Electron (HashRouter)
22+
window.location.hash = `#${path}`
23+
} else {
24+
// Web (BrowserRouter)
25+
history.push(path)
26+
}
27+
}
1828

1929
const Router = ({ children }: Props) => (
2030
<ReactRouter history={history}>{children}</ReactRouter>

redisinsight/ui/src/pages/home/components/databases-list/methods/handlers.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jest.mock('uiSrc/slices/app/context', () => ({
5959

6060
const mockHistoryPush = jest.fn()
6161
jest.mock('uiSrc/Router', () => ({
62-
history: { push: jest.fn((...args) => mockHistoryPush(...args)) },
62+
navigate: jest.fn((...args) => mockHistoryPush(...args)),
6363
}))
6464

6565
const mockLocalStorageSet = jest.fn()

redisinsight/ui/src/pages/home/components/databases-list/methods/handlers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import { appContextSelector, resetRdiContext } from 'uiSrc/slices/app/context'
1313
import { BrowserStorageItem, Pages } from 'uiSrc/constants'
1414
import { store, dispatch } from 'uiSrc/slices/store'
1515
import { SortingState } from 'uiSrc/components/base/layout/table'
16-
import { history } from 'uiSrc/Router'
16+
import { navigate } from 'uiSrc/Router'
1717
import { localStorageService } from 'uiSrc/services'
1818

1919
const connectToInstance = (id: string) => {
2020
dispatch(resetRdiContext())
2121
dispatch(setConnectedInstanceId(id))
2222

23-
history.push(Pages.browser(id))
23+
navigate(Pages.browser(id))
2424
}
2525

2626
export const handleCheckConnectToInstance = async (instance: Instance) => {

0 commit comments

Comments
 (0)