mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 19:40:34 +00:00
2f0b867685
API keys were split off from MCP to work without any addon, but the tab that holds them still hid unless a photo provider, MCP, AirTrail, AI Parsing or Dawarich was enabled. On a fresh install all of those are off, so there was no way to create a key. The desktop tab now always shows; the addon backed sections inside it keep their own gates. The phone layout has no API Keys section and keeps its gate. The wiki now says where keys are created and that no addon is needed. Refs #2561
99 lines
4.8 KiB
TypeScript
99 lines
4.8 KiB
TypeScript
import React from 'react'
|
|
import { Settings, SlidersHorizontal, Paintbrush, Map, Bell, Plug, CloudOff, User, Info, Blocks } from 'lucide-react'
|
|
import { useTranslation } from '../i18n'
|
|
import PageShell from '../components/Layout/PageShell'
|
|
import PageSidebar, { type PageSidebarTab } from '../components/Layout/PageSidebar'
|
|
import { SettingsHeader } from '../components/Settings/settingsKit'
|
|
import DisplaySettingsTab from '../components/Settings/DisplaySettingsTab'
|
|
import AppearanceSettingsTab from '../components/Settings/AppearanceSettingsTab'
|
|
import MapSettingsTab from '../components/Settings/MapSettingsTab'
|
|
import NotificationsTab from '../components/Settings/NotificationsTab'
|
|
import IntegrationsTab from '../components/Settings/IntegrationsTab'
|
|
import AccountTab from '../components/Settings/AccountTab'
|
|
import AboutTab from '../components/Settings/AboutTab'
|
|
import HelpAnchor from '../components/Help/HelpAnchor'
|
|
import { getHelpContext } from '../help/registry'
|
|
import OfflineTab from '../components/Settings/OfflineTab'
|
|
import PluginSettingsTab from '../components/Settings/PluginSettingsTab'
|
|
import { useSettings } from './settings/useSettings'
|
|
|
|
export default function SettingsPage(): React.ReactElement {
|
|
// ViewportRoute in App.tsx picks the branch now, so the phone screen is a
|
|
// chunk of its own instead of a dead limb in this one.
|
|
return <SettingsPageDesktop />
|
|
}
|
|
|
|
function SettingsPageDesktop(): React.ReactElement {
|
|
const { t } = useTranslation()
|
|
// Page = wiring container: addon/version loading + active-tab state in the hook.
|
|
const { hasPlugins, appVersion, activeTab, setActiveTab, managed } = useSettings()
|
|
// Every tab is its own help screen; a tab without one falls back to the settings overview.
|
|
const helpId = getHelpContext(`settings-${activeTab}`) ? `settings-${activeTab}` : 'settings'
|
|
|
|
const tabs: PageSidebarTab[] = [
|
|
{ id: 'display', label: t('settings.tabs.display'), icon: SlidersHorizontal },
|
|
{ id: 'appearance', label: t('settings.tabs.appearance'), icon: Paintbrush },
|
|
{ id: 'map', label: t('settings.tabs.map'), icon: Map },
|
|
{ id: 'notifications', label: t('settings.tabs.notifications'), icon: Bell },
|
|
// Always there: API keys sit in this tab and need no addon. The addon backed
|
|
// sections inside it gate themselves.
|
|
{ id: 'integrations', label: t('settings.tabs.integrations'), icon: Plug },
|
|
...(hasPlugins
|
|
? [{ id: 'plugins', label: t('settings.tabs.plugins'), icon: Blocks }]
|
|
: []),
|
|
{ id: 'offline', label: t('settings.tabs.offline'), icon: CloudOff },
|
|
{ id: 'account', label: t('settings.tabs.account'), icon: User },
|
|
// About is where the project lives: what TREK is, where to report a bug,
|
|
// where to support it. A customer of a hosted instance is the audience for
|
|
// none of that, so the tab goes and the sidebar footer below carries the one
|
|
// thing that has to stay — the link to the source (AGPL §13).
|
|
...(appVersion && !managed
|
|
? [{ id: 'about', label: t('settings.tabs.about'), icon: Info }]
|
|
: []),
|
|
]
|
|
|
|
return (
|
|
<PageShell background="var(--bg-primary)">
|
|
<div className="w-full px-4 sm:px-6 lg:px-8 py-6">
|
|
{/* Header */}
|
|
<HelpAnchor id={helpId} />
|
|
<SettingsHeader icon={Settings} title={t('settings.title')} subtitle={t('settings.subtitle')} />
|
|
|
|
{/* Sidebar layout */}
|
|
<PageSidebar
|
|
sidebarLabel={t('settings.title').toUpperCase()}
|
|
tabs={tabs}
|
|
activeTab={activeTab}
|
|
onTabChange={setActiveTab}
|
|
footer={
|
|
appVersion
|
|
? managed
|
|
// No About tab here, so this is the prominent source offer
|
|
// AGPL §13 asks for when people use it over a network.
|
|
? <a
|
|
href="https://github.com/liketrek/TREK"
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="no-underline text-content-faint hover:text-content-secondary"
|
|
>
|
|
v{appVersion}
|
|
</a>
|
|
: `v${appVersion}`
|
|
: ''
|
|
}
|
|
>
|
|
{activeTab === 'display' && <DisplaySettingsTab />}
|
|
{activeTab === 'appearance' && <AppearanceSettingsTab />}
|
|
{activeTab === 'map' && <MapSettingsTab />}
|
|
{activeTab === 'notifications' && <NotificationsTab />}
|
|
{activeTab === 'integrations' && <IntegrationsTab />}
|
|
{activeTab === 'plugins' && hasPlugins && <PluginSettingsTab />}
|
|
{activeTab === 'offline' && <OfflineTab />}
|
|
{activeTab === 'account' && <AccountTab />}
|
|
{activeTab === 'about' && appVersion && <AboutTab appVersion={appVersion} />}
|
|
</PageSidebar>
|
|
</div>
|
|
</PageShell>
|
|
)
|
|
}
|