Add beta request nav toggle
Magent CI/CD / verify (push) Successful in 10m47s
Magent CI/CD / deploy-prod (push) Has been skipped
Magent CI/CD / deploy-beta (push) Successful in 18s

This commit is contained in:
2026-06-21 12:32:03 +12:00
parent e163920e21
commit 0667a172d1
7 changed files with 69 additions and 7 deletions
+12
View File
@@ -50,6 +50,7 @@ const BOOL_SETTINGS = new Set([
'site_login_show_local_login',
'site_login_show_forgot_password',
'site_login_show_signup_link',
'site_nav_show_requests',
'magent_proxy_enabled',
'magent_proxy_trust_forwarded_headers',
'magent_ssl_bind_enabled',
@@ -272,6 +273,12 @@ const SITE_SECTION_GROUPS: Array<{
'site_login_show_signup_link',
],
},
{
key: 'site-navigation',
title: 'Beta Navigation',
description: 'Temporarily show or hide beta navigation entries while new request pipelines are built.',
keys: ['site_nav_show_requests'],
},
]
const SETTING_LABEL_OVERRIDES: Record<string, string> = {
@@ -319,6 +326,7 @@ const SETTING_LABEL_OVERRIDES: Record<string, string> = {
site_login_show_local_login: 'Login page: local Magent sign-in',
site_login_show_forgot_password: 'Login page: forgot password',
site_login_show_signup_link: 'Login page: invite signup link',
site_nav_show_requests: 'Top navigation: Requests',
log_file_max_bytes: 'Log file max size (bytes)',
log_file_backup_count: 'Rotated log files to keep',
log_http_client_level: 'Service HTTP log level',
@@ -349,6 +357,7 @@ const labelFromKey = (key: string) =>
.replace('site banner enabled', 'Sitewide banner enabled')
.replace('site banner message', 'Sitewide banner message')
.replace('site banner tone', 'Sitewide banner tone')
.replace('site nav show requests', 'Top navigation: Requests')
.replace('site changelog', 'Changelog text')
const formatBytes = (value?: number | null) => {
@@ -645,6 +654,7 @@ export default function SettingsPage({ section }: SettingsPageProps) {
'site_login_show_local_login',
'site_login_show_forgot_password',
'site_login_show_signup_link',
'site_nav_show_requests',
]
const sortByOrder = (items: AdminSetting[], order: string[]) => {
const position = new Map(order.map((key, index) => [key, index]))
@@ -853,6 +863,8 @@ export default function SettingsPage({ section }: SettingsPageProps) {
site_login_show_local_login: 'Show the local Magent login button on the login page.',
site_login_show_forgot_password: 'Show the forgot-password link on the login page.',
site_login_show_signup_link: 'Show the invite signup link on the login page.',
site_nav_show_requests:
'Show the Requests item in the top navigation. Disable during beta while request routing is being reworked.',
site_changelog: 'One update per line for the public changelog.',
}
+27 -7
View File
@@ -7,18 +7,23 @@ import { authFetch, clearToken, getApiBase, getToken } from '../lib/auth'
export default function HeaderActions() {
const [signedIn, setSignedIn] = useState(false)
const [role, setRole] = useState<string | null>(null)
const [showRequestsNav, setShowRequestsNav] = useState(true)
const pathname = usePathname()
useEffect(() => {
const token = getToken()
setSignedIn(Boolean(token))
if (!token) {
setShowRequestsNav(true)
return
}
const load = async () => {
try {
const baseUrl = getApiBase()
const response = await authFetch(`${baseUrl}/auth/me`)
const [response, siteResponse] = await Promise.all([
authFetch(`${baseUrl}/auth/me`),
fetch(`${baseUrl}/site/public`).catch(() => null),
])
if (!response.ok) {
clearToken()
setSignedIn(false)
@@ -27,8 +32,15 @@ export default function HeaderActions() {
}
const data = await response.json()
setRole(data?.role ?? null)
if (siteResponse?.ok) {
const siteData = await siteResponse.json()
setShowRequestsNav(siteData?.navigation?.showRequests !== false)
} else {
setShowRequestsNav(true)
}
} catch (err) {
console.error(err)
setShowRequestsNav(true)
}
}
void load()
@@ -62,18 +74,26 @@ export default function HeaderActions() {
},
]
const items = [
const commonItems = [
{ href: '/', label: 'Health', match: (path: string) => path === '/' },
{
href: '/portal/requests',
label: 'Requests',
match: (path: string) => path === '/portal/requests' || path.startsWith('/requests/'),
},
...(showRequestsNav
? [
{
href: '/portal/requests',
label: 'Requests',
match: (path: string) => path === '/portal/requests' || path.startsWith('/requests/'),
},
]
: []),
{
href: '/portal/issues',
label: 'Issues',
match: (path: string) => path === '/portal/issues' || path === '/admin/issues',
},
]
const items = [
...commonItems,
...roleItems,
]