Skip to content

Commit aacf7e6

Browse files
Ravjot BrarRavjot Brar
authored andcommitted
Add a redirect and fix sidebar when going to connections
Signed-off-by: Ravjot Brar <Ravjot.Brar@VAN-FM2FQ6NHXT.local>
1 parent ea4e2d0 commit aacf7e6

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

apps/frontend/src/components/ui/app-sidebar.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ export function AppSidebar() {
4545
<div className="mt-10 flex flex-col items-stretch w-full">
4646
<ul className="space-y-2">
4747
{[
48-
// Always show connect
49-
{ to: "/connect", title: "Connections", icon: HousePlug },
50-
// Rest of the menu items only if connected
5148
...(isConnected
5249
? [
50+
{ to: (clusterId ? `/${clusterId}/${id}/connect` : `${id}/connect`),
51+
title: "Connections",
52+
icon: HousePlug },
5353
{
5454
to: (clusterId ? `/${clusterId}/${id}/dashboard` : `${id}/dashboard`),
5555
title: "Dashboard",
@@ -75,7 +75,7 @@ export function AppSidebar() {
7575
: []),
7676

7777
]
78-
: []),
78+
: [{ to: "/connect", title: "Connections", icon: HousePlug }]),
7979
].map(({ to, title, icon: Icon }) => (
8080
<li key={to}>
8181
<Link

apps/frontend/src/main.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const AppWithHistory = () => {
4040

4141
{/* Routes with clusterId */}
4242
<Route element={<RequireConnection />}>
43+
<Route element={<Connection />} path="/:clusterId/:id/connect" />
4344
<Route element={<Dashboard />} path="/:clusterId/:id/dashboard" />
4445
<Route element={<SendCommand />} path="/:clusterId/:id/sendcommand" />
4546
<Route element={<KeyBrowser />} path="/:clusterId/:id/browse" />
@@ -49,6 +50,7 @@ const AppWithHistory = () => {
4950
{/* Routes without clusterId */}
5051
<Route element={<RequireConnection />}>
5152
<Route element={<ValkeyReconnect />} path="/:id/valkey-reconnect" />
53+
<Route element={<Connection />} path="/:id/connect" />
5254
<Route element={<Dashboard />} path="/:id/dashboard" />
5355
<Route element={<SendCommand />} path="/:id/sendcommand" />
5456
<Route element={<KeyBrowser />} path="/:id/browse" />

apps/frontend/src/state/epics/valkeyEpics.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { setData } from "../valkey-features/info/infoSlice"
1111
import { action$, select } from "../middleware/rxjsMiddleware/rxjsMiddlware"
1212
import { setClusterData } from "../valkey-features/cluster/clusterSlice"
1313
import { connectFulfilled as wsConnectFulfilled } from "../wsconnection/wsConnectionSlice"
14+
import history from "../../history.ts"
1415
import type { Store } from "@reduxjs/toolkit"
1516
import { atId } from "@/state/valkey-features/connection/connectionSelectors.ts"
1617

@@ -190,7 +191,14 @@ export const setDataEpic = () =>
190191
tap((action) => {
191192
const socket = getSocket()
192193
const { clusterId, connectionId } = action.payload
193-
if (clusterId) socket.next({ type: setClusterData.type, payload: { clusterId, connectionId } })
194+
if (clusterId) {
195+
socket.next({ type: setClusterData.type, payload: { clusterId, connectionId } })
196+
}
194197
socket.next({ type: setData.type, payload: { connectionId } })
198+
const dashboardPath = clusterId
199+
? `/${clusterId}/${connectionId}/dashboard`
200+
: `/${connectionId}/dashboard`
201+
202+
history.navigate(dashboardPath)
195203
}),
196204
)

apps/server/src/calculateHotKeys.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)