mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 13:23:04 +00:00
94ac7673a5
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.
92 lines
3.4 KiB
TypeScript
92 lines
3.4 KiB
TypeScript
import { ChevronRight, Settings2, Sparkles } from 'lucide-react';
|
|
import React from 'react';
|
|
import { useTranslation } from '../../../i18n';
|
|
import { StatusPill } from '../../Settings/settingsKit';
|
|
import { fs } from '../../shared/DialogShell';
|
|
import AddonSubRow from '../AddonSubRow';
|
|
import AddonTile from '../AddonTile';
|
|
import { type Addon, getAddonLabel } from './addonModel';
|
|
import { AI_ADDON_ICONS, type AiAddonId } from './aiAddons';
|
|
import AiSettingsDialog from './AiAdminConfig';
|
|
import { useAiAddonTile } from './useAiAddonTile';
|
|
|
|
/**
|
|
* The AI addons as one tile at the head of the integration column: the
|
|
* assistant, AI parsing and MCP as switches in its shelf, and one button to
|
|
* the dialog that holds their settings, so a page with all three on stays as
|
|
* short as one with none.
|
|
*/
|
|
export default function AiAddonTile({
|
|
addons,
|
|
onToggle,
|
|
}: {
|
|
addons: Addon[];
|
|
onToggle: (addon: Addon) => void;
|
|
}): React.ReactElement {
|
|
const { t } = useTranslation();
|
|
const tile = useAiAddonTile(addons);
|
|
const anyOn = tile.enabledCount > 0;
|
|
return (
|
|
<>
|
|
<AddonTile
|
|
icon={<Sparkles size={15} />}
|
|
name={t('admin.addons.ai.name')}
|
|
description={t('admin.addons.ai.description')}
|
|
enabled={anyOn}
|
|
trailing={
|
|
<StatusPill tone={anyOn ? 'success' : 'neutral'}>
|
|
{tile.enabledCount}/{addons.length}
|
|
</StatusPill>
|
|
}
|
|
>
|
|
{addons.map((addon) => {
|
|
const Icon = AI_ADDON_ICONS[addon.id as AiAddonId];
|
|
const label = getAddonLabel(t, addon);
|
|
return (
|
|
<AddonSubRow
|
|
key={addon.id}
|
|
icon={<Icon size={14} />}
|
|
title={label.name}
|
|
description={label.description}
|
|
badge={addon.id === 'ai_assistant' ? <BetaBadge label={t('assistant.setup.beta')} /> : undefined}
|
|
enabled={addon.enabled}
|
|
onToggle={() => onToggle(addon)}
|
|
/>
|
|
);
|
|
})}
|
|
{tile.canSetUp && (
|
|
<li>
|
|
<button
|
|
type="button"
|
|
onClick={tile.openDialog}
|
|
className="flex min-h-[44px] w-full items-center gap-2.5 border-0 bg-transparent py-1.5 pe-4 ps-[60px] text-start transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover focus-visible:outline-none"
|
|
>
|
|
<span className="grid h-6 w-6 flex-none place-items-center text-content-muted">
|
|
<Settings2 size={14} />
|
|
</span>
|
|
<span className="min-w-0 flex-1 truncate font-medium text-content" style={fs(12.5, 'body')}>
|
|
{t('admin.addons.ai.setup')}
|
|
</span>
|
|
<ChevronRight size={15} strokeWidth={2.2} className="flex-none text-content-faint rtl:rotate-180" />
|
|
</button>
|
|
</li>
|
|
)}
|
|
</AddonTile>
|
|
{tile.dialogOpen && <AiSettingsDialog addons={addons} onClose={tile.closeDialog} />}
|
|
</>
|
|
);
|
|
}
|
|
|
|
/** The assistant is still young; its switch says so with a small accent pill. */
|
|
function BetaBadge({ label }: { label: string }): React.ReactElement {
|
|
return (
|
|
<span
|
|
className="inline-flex flex-none items-center gap-1 rounded-full bg-accent px-[7px] py-[2px] font-geist font-bold uppercase leading-none tracking-[.08em] text-accent-text shadow-sm"
|
|
style={fs(9)}
|
|
>
|
|
<Sparkles size={9} strokeWidth={2.6} aria-hidden />
|
|
{label}
|
|
</span>
|
|
);
|
|
}
|