mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 16:33:16 +00:00
a40ae60abb
- MApiKeysSection: the keys with what each may read, creating one in a sheet (name, the areas as chips, the key shown once with a copy button), deleting behind a confirm sheet, and the endpoint to copy. - The list and every action move from ApiKeysSection into useApiKeys, shared by both views; the calls go through a small online-only apiKeysRepo, so no view reaches the API (offline baseline loses ApiKeysSection and AdminSettingsTab). - The phone's Integrations tab is always there now, as on the desktop: the keys in it need no addon. - A test title no longer breaks on its apostrophe.
53 lines
2.1 KiB
TypeScript
53 lines
2.1 KiB
TypeScript
import { useEffect } from 'react';
|
|
import { useAddonStore } from '../../store/addonStore';
|
|
import { useAuthStore } from '../../store/authStore';
|
|
import { useSettingsStore } from '../../store/settingsStore';
|
|
|
|
/**
|
|
* Which integrations the settings shells offer: the addon flags behind each
|
|
* integration section, whether any of them is on, and whether this is a managed
|
|
* install. The Integrations tab shows regardless on both shells, since the API
|
|
* keys in it need no addon; `hasIntegrations` says whether any addon section is on.
|
|
* 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();
|
|
const managed = useAuthStore((s) => s.managed);
|
|
|
|
const memoriesEnabled = addonEnabled('memories');
|
|
const mcpEnabled = addonEnabled('mcp');
|
|
const airtrailEnabled = addonEnabled('airtrail');
|
|
const llmEnabled = addonEnabled('llm_parsing');
|
|
const aiAssistantEnabled = addonEnabled('ai_assistant');
|
|
const dawarichEnabled = addonEnabled('dawarich');
|
|
// The wanderer connection feeds the Tours workspace, while the admin allows it there.
|
|
const wandererEnabled = useAddonStore((s) => s.toursWanderer);
|
|
// The AI connection serves the assistant and AI parsing alike.
|
|
const aiConnectionEnabled = aiAssistantEnabled || llmEnabled;
|
|
// A personal parsing model saved before parsing read with the AI connection;
|
|
// its form stays for whoever has one, and is no longer offered to anyone else.
|
|
const ownParsing = useSettingsStore((s) => !!(s.settings.llm_provider && s.settings.llm_model));
|
|
const hasIntegrations =
|
|
memoriesEnabled || mcpEnabled || airtrailEnabled || llmEnabled || aiAssistantEnabled || dawarichEnabled;
|
|
|
|
useEffect(() => {
|
|
if (reloadAddons) loadAddons();
|
|
}, [loadAddons, reloadAddons]);
|
|
|
|
return {
|
|
memoriesEnabled,
|
|
mcpEnabled,
|
|
airtrailEnabled,
|
|
llmEnabled,
|
|
aiAssistantEnabled,
|
|
aiConnectionEnabled,
|
|
ownParsing,
|
|
dawarichEnabled,
|
|
wandererEnabled,
|
|
hasIntegrations,
|
|
managed,
|
|
loadAddons,
|
|
};
|
|
}
|