fix(notifications): Review link opens the Access requests tab, not the last-used one
The access-requests notice's Review link navigated to the Users page but the persisted tab (often Demo) loaded instead. Pre-select the access tab before navigating (focusAccessRequestsTab writes the persisted-tab key, which the page reads on its fresh mount).
This commit is contained in:
parent
6286dcc3c2
commit
04d3367c88
3 changed files with 24 additions and 4 deletions
|
|
@ -32,7 +32,7 @@ import Playlists from "./components/Playlists";
|
||||||
import Stats from "./components/Stats";
|
import Stats from "./components/Stats";
|
||||||
import Scheduler from "./components/Scheduler";
|
import Scheduler from "./components/Scheduler";
|
||||||
import ConfigPanel from "./components/ConfigPanel";
|
import ConfigPanel from "./components/ConfigPanel";
|
||||||
import AdminUsers from "./components/AdminUsers";
|
import AdminUsers, { focusAccessRequestsTab } from "./components/AdminUsers";
|
||||||
import SettingsPanel from "./components/SettingsPanel";
|
import SettingsPanel from "./components/SettingsPanel";
|
||||||
import NotificationsPanel from "./components/NotificationsPanel";
|
import NotificationsPanel from "./components/NotificationsPanel";
|
||||||
import Messages from "./components/Messages";
|
import Messages from "./components/Messages";
|
||||||
|
|
@ -372,7 +372,13 @@ export default function App() {
|
||||||
// Durable inbox link (survives reload, unlike a live action callback); the toast also
|
// Durable inbox link (survives reload, unlike a live action callback); the toast also
|
||||||
// gets a click via the action.
|
// gets a click via the action.
|
||||||
meta: { kind: "access-requests" },
|
meta: { kind: "access-requests" },
|
||||||
action: { label: t("common.accessRequestsReview"), onClick: () => setPage("users") },
|
action: {
|
||||||
|
label: t("common.accessRequestsReview"),
|
||||||
|
onClick: () => {
|
||||||
|
focusAccessRequestsTab();
|
||||||
|
setPage("users");
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,19 @@ import Tabs, { usePersistedTab } from "./Tabs";
|
||||||
// Admin-only user & access management: roles, access requests (the Invite whitelist), and the
|
// Admin-only user & access management: roles, access requests (the Invite whitelist), and the
|
||||||
// demo whitelist + reset. Each section is its own tab (persisted across reloads); the Access tab
|
// demo whitelist + reset. Each section is its own tab (persisted across reloads); the Access tab
|
||||||
// carries a badge with the count of pending requests so it's visible without switching to it.
|
// carries a badge with the count of pending requests so it's visible without switching to it.
|
||||||
|
// The persisted-tab storage key + the access-requests tab id, exported so a notification's
|
||||||
|
// "Review" link can pre-select that tab before navigating here (usePersistedTab reads the key
|
||||||
|
// on mount, and this page mounts fresh on navigation).
|
||||||
|
export const ADMIN_USERS_TAB_KEY = "siftlode.adminUsersTab";
|
||||||
|
export const ADMIN_USERS_ACCESS_TAB = "access";
|
||||||
|
|
||||||
|
export function focusAccessRequestsTab(): void {
|
||||||
|
localStorage.setItem(ADMIN_USERS_TAB_KEY, ADMIN_USERS_ACCESS_TAB);
|
||||||
|
}
|
||||||
|
|
||||||
export default function AdminUsers({ me }: { me: Me }) {
|
export default function AdminUsers({ me }: { me: Me }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [tab, setTab] = usePersistedTab("siftlode.adminUsersTab", "roles");
|
const [tab, setTab] = usePersistedTab(ADMIN_USERS_TAB_KEY, "roles");
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{ id: "roles", label: t("users.tabs.roles") },
|
{ id: "roles", label: t("users.tabs.roles") },
|
||||||
{ id: "access", label: t("users.tabs.access"), badge: me.pending_invites },
|
{ id: "access", label: t("users.tabs.access"), badge: me.pending_invites },
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
import { Activity, Bell, Check, CheckCheck, ExternalLink, Eye, RotateCcw, Search, Trash2, Tv, UserPlus, X } from "lucide-react";
|
import { Activity, Bell, Check, CheckCheck, ExternalLink, Eye, RotateCcw, Search, Trash2, Tv, UserPlus, X } from "lucide-react";
|
||||||
import { api, type AppNotification, type FeedFilters } from "../lib/api";
|
import { api, type AppNotification, type FeedFilters } from "../lib/api";
|
||||||
import { useLiveQuery } from "../lib/useLiveQuery";
|
import { useLiveQuery } from "../lib/useLiveQuery";
|
||||||
|
import { focusAccessRequestsTab } from "./AdminUsers";
|
||||||
import {
|
import {
|
||||||
clearAll as clearClient,
|
clearAll as clearClient,
|
||||||
dismiss as dismissClient,
|
dismiss as dismissClient,
|
||||||
|
|
@ -190,7 +191,10 @@ export default function NotificationsPanel({
|
||||||
onFind={locate}
|
onFind={locate}
|
||||||
onRevert={revertState}
|
onRevert={revertState}
|
||||||
onFocusChannel={onFocusChannel}
|
onFocusChannel={onFocusChannel}
|
||||||
onReviewAccess={() => setPage("users")}
|
onReviewAccess={() => {
|
||||||
|
focusAccessRequestsTab();
|
||||||
|
setPage("users");
|
||||||
|
}}
|
||||||
onRemove={() => removeClient(n.id)}
|
onRemove={() => removeClient(n.id)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue