mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
fix(settings): the integrations tab is always there on desktop so api keys stay reachable
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
This commit is contained in:
@@ -4,9 +4,11 @@ import { useAuthStore } from '../../store/authStore';
|
||||
|
||||
/**
|
||||
* Which integrations the settings shells offer: the addon flags behind each
|
||||
* integration section, whether any of them is on (the Integrations tab only shows
|
||||
* then), and whether this is a managed install. With `reloadAddons` the addon list
|
||||
* is fetched again on mount, as the integrations tab on both shells does.
|
||||
* integration section, whether any of them is on, and whether this is a managed
|
||||
* install. The desktop Integrations tab shows regardless, since its API keys need
|
||||
* no addon; the mobile one has no API keys and only shows when `hasIntegrations`.
|
||||
* With `reloadAddons` the addon list is fetched again on mount, as the
|
||||
* integrations tab on both shells does.
|
||||
*/
|
||||
export function useIntegrationGates({ reloadAddons }: { reloadAddons: boolean }) {
|
||||
const { isEnabled: addonEnabled, loadAddons } = useAddonStore();
|
||||
|
||||
@@ -4,6 +4,7 @@ import userEvent from '@testing-library/user-event';
|
||||
import { resetAllStores, seedStore } from '../../tests/helpers/store';
|
||||
import { buildUser } from '../../tests/helpers/factories';
|
||||
import { useAuthStore } from '../store/authStore';
|
||||
import { useAddonStore } from '../store/addonStore';
|
||||
import SettingsPage from './SettingsPage';
|
||||
|
||||
// Mock heavy settings sub-tabs to focus on page-level concerns
|
||||
@@ -152,4 +153,27 @@ describe('SettingsPage', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('FE-PAGE-SETTINGS-007: Integrations tab without any integration addon', () => {
|
||||
// API keys live in the Integrations tab and need no addon, so the tab has to
|
||||
// be there on an instance where MCP, AirTrail, AI Parsing, Dawarich and the
|
||||
// photo providers are all switched off.
|
||||
it('still offers the Integrations tab and opens it', async () => {
|
||||
seedStore(useAddonStore, { isEnabled: () => false, loadAddons: vi.fn().mockResolvedValue(undefined) });
|
||||
const user = userEvent.setup();
|
||||
render(<SettingsPage />);
|
||||
|
||||
await user.click(await screen.findByRole('button', { name: /integrations/i }));
|
||||
|
||||
expect(await screen.findByTestId('integrations-tab')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('keeps it on a managed install too', async () => {
|
||||
seedStore(useAddonStore, { isEnabled: () => false, loadAddons: vi.fn().mockResolvedValue(undefined) });
|
||||
seedStore(useAuthStore, { managed: true });
|
||||
render(<SettingsPage />, { initialEntries: ['/settings?tab=integrations'] });
|
||||
|
||||
expect(await screen.findByTestId('integrations-tab')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ export default function SettingsPage(): React.ReactElement {
|
||||
function SettingsPageDesktop(): React.ReactElement {
|
||||
const { t } = useTranslation()
|
||||
// Page = wiring container: addon/version loading + active-tab state in the hook.
|
||||
const { hasIntegrations, hasPlugins, appVersion, activeTab, setActiveTab, managed } = useSettings()
|
||||
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'
|
||||
|
||||
@@ -35,9 +35,9 @@ function SettingsPageDesktop(): React.ReactElement {
|
||||
{ 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 },
|
||||
...(hasIntegrations
|
||||
? [{ id: 'integrations', label: t('settings.tabs.integrations'), icon: Plug }]
|
||||
: []),
|
||||
// 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 }]
|
||||
: []),
|
||||
@@ -86,7 +86,7 @@ function SettingsPageDesktop(): React.ReactElement {
|
||||
{activeTab === 'appearance' && <AppearanceSettingsTab />}
|
||||
{activeTab === 'map' && <MapSettingsTab />}
|
||||
{activeTab === 'notifications' && <NotificationsTab />}
|
||||
{activeTab === 'integrations' && hasIntegrations && <IntegrationsTab />}
|
||||
{activeTab === 'integrations' && <IntegrationsTab />}
|
||||
{activeTab === 'plugins' && hasPlugins && <PluginSettingsTab />}
|
||||
{activeTab === 'offline' && <OfflineTab />}
|
||||
{activeTab === 'account' && <AccountTab />}
|
||||
|
||||
Reference in New Issue
Block a user