mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 19:40:34 +00:00
feat(settings): one look for every user and admin settings page
The settings pages had grown into a mix of styles: folds, dialogs behind rows, full-width rows next to boxed ones, pills for every figure and buttons in four sizes. Every page now uses the same kit. - Cards keep their tinted head band; every part of a card is a rounded block with its own small head (SettingsBlock), and rows sit in rounded boxes. - Nothing folds and nothing hides behind a dialog: the MCP config, OAuth scopes, mail how-to, AI privacy note and addon sub-options are all shown. - Each page is split into two columns balanced by length (SettingsColumns). - Long explanations moved into an info mark next to the label (HintMark). - One button size everywhere (text-control); tab names are one word. - Admin: the old Settings tab is split into Security and Services (?tab=settings still opens Security, and the phone keeps its single Settings section for both); the Integration group is gone, live flights and mail import sit next to the addons they configure. - Addons: one card per type with rows, no search, filter or fold. - Quota, TREK API facts, mail import status and Google's daily limit are compact lines and strips instead of tiles and pills. - Language is a select; routing has its own card under the defaults; storage saves from the foot of its categories card. - Unused keys, FoldSummary and the page-width wrapper are removed.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { AiApiKeyKind, AiConnectionScope, AiParsingPrefill } from '@trek/shared';
|
||||
import { ChevronRight, KeyRound, Loader2, Server, ShieldCheck } from 'lucide-react';
|
||||
import { KeyRound, Loader2, Server, ShieldCheck } from 'lucide-react';
|
||||
import React, { useId, useState } from 'react';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import { useAssistantStore } from '../../../store/assistantStore';
|
||||
@@ -193,7 +193,6 @@ function KeyForm({ scope, keyConnect }: { scope: AiConnectionScope; keyConnect:
|
||||
onClick={() => void submit()}
|
||||
disabled={!kind || testing}
|
||||
className={`${SETTINGS_BUTTON_PRIMARY} whitespace-nowrap`}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
{testing && <Loader2 size={14} className="animate-spin" />}
|
||||
{testing ? t('assistant.connect.testing') : t('assistant.connect.save')}
|
||||
@@ -225,7 +224,6 @@ function KeyForm({ scope, keyConnect }: { scope: AiConnectionScope; keyConnect:
|
||||
onClick={() => void openrouter.start()}
|
||||
disabled={openrouter.busy}
|
||||
className={SETTINGS_BUTTON}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
{openrouter.busy ? (
|
||||
<Loader2 size={14} className="animate-spin" />
|
||||
@@ -298,7 +296,6 @@ function CustomForm({ custom }: { custom: ReturnType<typeof useCustomConnect> })
|
||||
onClick={() => void custom.submit()}
|
||||
disabled={!custom.ready || custom.saving}
|
||||
className={SETTINGS_BUTTON_PRIMARY}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
{custom.saving && <Loader2 size={14} className="animate-spin" />}
|
||||
{custom.saving ? t('assistant.connect.testing') : t('assistant.connect.save')}
|
||||
@@ -314,7 +311,6 @@ function CustomForm({ custom }: { custom: ReturnType<typeof useCustomConnect> })
|
||||
*/
|
||||
function PrivacyNote({ provider }: { provider: string }) {
|
||||
const { t } = useTranslation();
|
||||
const [open, setOpen] = useState(false);
|
||||
return (
|
||||
<div className="rounded-[12px] bg-surface-tertiary px-3 py-2.5">
|
||||
{provider && (
|
||||
@@ -322,28 +318,16 @@ function PrivacyNote({ provider }: { provider: string }) {
|
||||
{t('assistant.privacy.banner', { provider })}
|
||||
</p>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
aria-expanded={open}
|
||||
className="inline-flex items-center gap-1.5 font-medium text-content-muted hover:text-content"
|
||||
style={fs(12, 'body')}
|
||||
>
|
||||
{/* Said in full before anything is saved, not folded behind a link. */}
|
||||
<div className="inline-flex items-center gap-1.5 font-medium text-content-muted" style={fs(12, 'body')}>
|
||||
<ShieldCheck size={13} strokeWidth={2.2} />
|
||||
{t('assistant.privacy.what')}
|
||||
<ChevronRight
|
||||
size={13}
|
||||
strokeWidth={2.2}
|
||||
className={`transition-transform ${open ? 'rotate-90' : 'rtl:rotate-180'}`}
|
||||
/>
|
||||
</button>
|
||||
{open && (
|
||||
<ul className="m-0 mt-2 flex list-disc flex-col gap-1 ps-5 text-content-faint" style={fs(11.5)}>
|
||||
<li>{t('assistant.privacy.shared')}</li>
|
||||
<li>{t('assistant.privacy.notShared')}</li>
|
||||
{provider && <li>{t('assistant.privacy.provider', { provider })}</li>}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
<ul className="m-0 mt-2 flex list-disc flex-col gap-1 ps-5 text-content-faint" style={fs(11.5)}>
|
||||
<li>{t('assistant.privacy.shared')}</li>
|
||||
<li>{t('assistant.privacy.notShared')}</li>
|
||||
{provider && <li>{t('assistant.privacy.provider', { provider })}</li>}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import type { AiStatusResponse } from '@trek/shared';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { buildUser } from '../../../../tests/helpers/factories';
|
||||
import { render, screen } from '../../../../tests/helpers/render';
|
||||
import { openSettingsCards } from '../../../../tests/helpers/settingsCards';
|
||||
import { resetAllStores, seedStore } from '../../../../tests/helpers/store';
|
||||
import { useAddonStore } from '../../../store/addonStore';
|
||||
import { useAssistantStore } from '../../../store/assistantStore';
|
||||
@@ -31,8 +30,6 @@ const INSTANCE: AiStatusResponse = {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
// The cards start shut; these tests read into them.
|
||||
openSettingsCards();
|
||||
resetAllStores();
|
||||
vi.clearAllMocks();
|
||||
useAssistantStore.setState({ status: null });
|
||||
|
||||
@@ -4,7 +4,6 @@ import type { AiConnectionView, AiStatusResponse } from '@trek/shared';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { buildAdmin, buildUser } from '../../../../tests/helpers/factories';
|
||||
import { render, screen, waitFor } from '../../../../tests/helpers/render';
|
||||
import { openSettingsCards } from '../../../../tests/helpers/settingsCards';
|
||||
import { resetAllStores, seedStore } from '../../../../tests/helpers/store';
|
||||
import { useAddonStore } from '../../../store/addonStore';
|
||||
import { useAssistantStore } from '../../../store/assistantStore';
|
||||
@@ -49,8 +48,6 @@ function status(over: Partial<AiStatusResponse> = {}): AiStatusResponse {
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
// The cards start shut; these tests read into them.
|
||||
openSettingsCards();
|
||||
resetAllStores();
|
||||
vi.clearAllMocks();
|
||||
useAssistantStore.setState({ status: null });
|
||||
|
||||
@@ -65,7 +65,7 @@ function OpenAssistantButton({ S }: { S: AiConnections }) {
|
||||
const { t } = useTranslation();
|
||||
if (!S.canOpen) return null;
|
||||
return (
|
||||
<button type="button" onClick={S.openAssistant} className={SETTINGS_BUTTON_PRIMARY} style={fs(13, 'body')}>
|
||||
<button type="button" onClick={S.openAssistant} className={SETTINGS_BUTTON_PRIMARY}>
|
||||
<MessageCircle size={14} strokeWidth={2.2} /> {t('assistant.connect.openAssistant')}
|
||||
</button>
|
||||
);
|
||||
@@ -85,7 +85,6 @@ function OwnConnection({ S, own }: { S: AiConnections; own: AiConnectionView })
|
||||
type="button"
|
||||
onClick={() => S.repair(repairMode)}
|
||||
className={SETTINGS_BUTTON_PRIMARY}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
{t(repairMode === 'chatgpt' ? 'assistant.errorAction.signIn' : 'assistant.errorAction.replaceKey')}
|
||||
</button>
|
||||
@@ -98,7 +97,6 @@ function OwnConnection({ S, own }: { S: AiConnections; own: AiConnectionView })
|
||||
onClick={() => void signOut()}
|
||||
disabled={busy}
|
||||
className={SETTINGS_BUTTON}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
<LogOut size={14} strokeWidth={2} /> {t('assistant.connect.signOut')}
|
||||
</button>
|
||||
@@ -108,7 +106,6 @@ function OwnConnection({ S, own }: { S: AiConnections; own: AiConnectionView })
|
||||
onClick={askDisconnect}
|
||||
disabled={busy}
|
||||
className={SETTINGS_BUTTON_DANGER}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
<Unplug size={14} strokeWidth={2} /> {t('assistant.connect.disconnect')}
|
||||
</button>
|
||||
@@ -157,7 +154,7 @@ function InstanceConnection({ S }: { S: AiConnections }) {
|
||||
>
|
||||
<OpenAssistantButton S={S} />
|
||||
{S.status?.canConnectOwn && !S.panel && (
|
||||
<button type="button" onClick={S.connectOwn} className={SETTINGS_BUTTON} style={fs(13, 'body')}>
|
||||
<button type="button" onClick={S.connectOwn} className={SETTINGS_BUTTON}>
|
||||
{t('assistant.errorAction.connectOwn')}
|
||||
</button>
|
||||
)}
|
||||
@@ -213,7 +210,7 @@ function LockedOwnConnection() {
|
||||
<SettingRow
|
||||
label={t('demo.lock.aiTitle')}
|
||||
control={
|
||||
<button type="button" disabled className={SETTINGS_BUTTON} style={fs(13, 'body')}>
|
||||
<button type="button" disabled className={SETTINGS_BUTTON}>
|
||||
{t('assistant.errorAction.connectOwn')}
|
||||
</button>
|
||||
}
|
||||
@@ -230,7 +227,7 @@ function ConnectPanel({ S }: { S: AiConnections }) {
|
||||
<div className={`flex flex-col gap-3 ${S.view === 'setup' ? '' : 'border-t border-edge-faint pt-4'}`}>
|
||||
<AiConnectPanel key={S.panelMode ?? 'any'} scope="user" onConnected={S.onConnected} initialMode={S.panelMode} />
|
||||
{S.view !== 'setup' && (
|
||||
<button type="button" onClick={S.closePanel} className={`${SETTINGS_BUTTON} self-start`} style={fs(13, 'body')}>
|
||||
<button type="button" onClick={S.closePanel} className={`${SETTINGS_BUTTON} self-start`}>
|
||||
{t('common.cancel')}
|
||||
</button>
|
||||
)}
|
||||
@@ -283,7 +280,6 @@ export default function AiConnectionSection({
|
||||
return (
|
||||
<Section
|
||||
id="ai-connection"
|
||||
collapsible
|
||||
title={t(text.titleKey)}
|
||||
icon={Sparkles}
|
||||
hint={t(text.hintKey)}
|
||||
|
||||
@@ -113,7 +113,6 @@ export default function ChatGptPasteStep({
|
||||
}}
|
||||
aria-disabled={!flow}
|
||||
className={`${SETTINGS_BUTTON_PRIMARY} ${flow ? '' : 'pointer-events-none opacity-50'}`}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
{flow ? <ExternalLink size={14} strokeWidth={2.2} /> : <Loader2 size={14} className="animate-spin" />}
|
||||
{t('assistant.connect.chatgptOpen')}
|
||||
@@ -163,7 +162,6 @@ export default function ChatGptPasteStep({
|
||||
onClick={() => void submit()}
|
||||
disabled={busy || !flow}
|
||||
className={SETTINGS_BUTTON_PRIMARY}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
{busy && <Loader2 size={14} className="animate-spin" />}
|
||||
{t('assistant.connect.save')}
|
||||
@@ -174,7 +172,6 @@ export default function ChatGptPasteStep({
|
||||
onClick={pasteFromClipboard}
|
||||
disabled={!flow}
|
||||
className={`${SETTINGS_BUTTON} whitespace-nowrap`}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
<ClipboardPaste size={14} strokeWidth={2} />
|
||||
{t('assistant.connect.chatgptPaste')}
|
||||
|
||||
Reference in New Issue
Block a user