quality / commitlint (push) Skipped
CD / update-wiki (push) Failing after 7s
quality / changes (push) Successful in 4s
quality / docker-check (push) Skipped
quality / web (push) Failing after 38s
quality / api (push) Successful in 49s
CD / quality (push) Failing after 1m36s
CD / publish (push) Skipped
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import {
|
|
ChartBarIcon,
|
|
CloudIcon,
|
|
GlobeIcon,
|
|
LayoutDashboardIcon,
|
|
ServerIcon,
|
|
type LucideIcon,
|
|
} from 'lucide-react'
|
|
import type { AppSwitcherConfig, AppSwitcherEntry } from '@cdnmanager/shared'
|
|
|
|
/** JWT / portal app id for this product */
|
|
export const CURRENT_APP_ID = 'cdn'
|
|
|
|
export type AppSwitcherIconName = keyof typeof APP_SWITCHER_ICONS
|
|
|
|
export const APP_SWITCHER_ICONS: Record<
|
|
'server' | 'cloud' | 'globe' | 'dashboard' | 'chart',
|
|
LucideIcon
|
|
> = {
|
|
server: ServerIcon,
|
|
cloud: CloudIcon,
|
|
globe: GlobeIcon,
|
|
dashboard: LayoutDashboardIcon,
|
|
chart: ChartBarIcon,
|
|
}
|
|
|
|
/** Offline fallback when auth-portal is unreachable */
|
|
export const DEFAULT_APP_SWITCHER_CONFIG: AppSwitcherConfig = {
|
|
menuLabel: 'Приложения',
|
|
apps: [
|
|
{
|
|
id: 'vps',
|
|
name: 'VPS Tracker',
|
|
subtitle: 'Учёт виртуальных серверов',
|
|
url: 'https://vps.shnt.top',
|
|
icon: 'server',
|
|
},
|
|
{
|
|
id: 'cdn',
|
|
name: 'CDN Manager',
|
|
subtitle: 'Управление CDN',
|
|
url: 'https://cdn.shnt.top',
|
|
icon: 'cloud',
|
|
},
|
|
{
|
|
id: 'bgp',
|
|
name: 'EvoBGP',
|
|
subtitle: 'BGP маршрутизация',
|
|
url: 'https://bgp.shnt.top',
|
|
icon: 'globe',
|
|
},
|
|
],
|
|
}
|
|
|
|
export function getAppUrl(
|
|
appId: string,
|
|
config: AppSwitcherConfig = DEFAULT_APP_SWITCHER_CONFIG,
|
|
): string | undefined {
|
|
return config.apps.find((app) => app.id === appId)?.url
|
|
}
|
|
|
|
export function getCurrentApp(
|
|
config: AppSwitcherConfig = DEFAULT_APP_SWITCHER_CONFIG,
|
|
): AppSwitcherEntry {
|
|
return config.apps.find((app) => app.id === CURRENT_APP_ID) ?? config.apps[0]!
|
|
}
|