mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-03 18:17:56 -05:00
60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
// Readable addresses for the settings tabs: /settings/<slug> and /settings/admin/<slug>.
|
|
const SETTINGS_SLUGS: Record<string, string> = {
|
|
general: 'preferences',
|
|
shortcuts: 'keyboard',
|
|
audio: 'audio',
|
|
account: 'profile',
|
|
personalization: 'personalization',
|
|
notifications: 'notifications',
|
|
archived_chats: 'archived-chats',
|
|
data_controls: 'data-controls',
|
|
usage: 'usage',
|
|
about: 'about',
|
|
'admin:general': 'admin/general',
|
|
'admin:authentication': 'admin/authentication',
|
|
'admin:features': 'admin/features',
|
|
'admin:tasks': 'admin/tasks',
|
|
'admin:interface': 'admin/interface',
|
|
'admin:analytics': 'admin/analytics',
|
|
'admin:db': 'admin/database',
|
|
'admin:connections': 'admin/connections',
|
|
'admin:models': 'admin/models',
|
|
'admin:subagents': 'admin/sub-agents',
|
|
'admin:integrations': 'admin/integrations',
|
|
'admin:web': 'admin/web-search',
|
|
'admin:documents': 'admin/documents',
|
|
'admin:images': 'admin/images',
|
|
'admin:audio': 'admin/audio',
|
|
'admin:code-execution': 'admin/code-execution',
|
|
'admin:pipelines': 'admin/pipelines'
|
|
};
|
|
|
|
// Older admin addresses that point at tabs that were merged or renamed.
|
|
const SETTINGS_ALIASES: Record<string, string> = {
|
|
'admin/apps': 'admin:integrations',
|
|
'admin/videos': 'admin:images',
|
|
'admin/db': 'admin:db',
|
|
'admin/web': 'admin:web',
|
|
'admin/subagents': 'admin:subagents'
|
|
};
|
|
|
|
export const settingsPath = (tab: string) =>
|
|
`/settings/${SETTINGS_SLUGS[tab] ?? SETTINGS_SLUGS.general}`;
|
|
|
|
/** The tab (and model, for /settings/admin/models/<id>) a settings address points at. */
|
|
export const parseSettingsPath = (pathname: string): { tab: string; modelId?: string } | null => {
|
|
const match = pathname.match(/^\/settings(?:\/(.*?))?\/?$/);
|
|
if (!match) return null;
|
|
const rest = match[1] ?? '';
|
|
if (!rest) return { tab: 'general' };
|
|
|
|
const model = rest.match(/^admin\/models\/(.+)$/);
|
|
if (model) return { tab: 'admin:models', modelId: decodeURIComponent(model[1]) };
|
|
|
|
const tab =
|
|
Object.keys(SETTINGS_SLUGS).find((id) => SETTINGS_SLUGS[id] === rest) ??
|
|
SETTINGS_ALIASES[rest] ??
|
|
Object.keys(SETTINGS_SLUGS).find((id) => id === rest || id === rest.replace('/', ':'));
|
|
return { tab: tab ?? 'general' };
|
|
};
|