import { open } from '@tauri-apps/plugin-shell'; import { useRef } from 'react'; import { useActiveWorkspace } from '../hooks/useActiveWorkspace'; import { useAppInfo } from '../hooks/useAppInfo'; import { useAppRoutes } from '../hooks/useAppRoutes'; import { useCheckForUpdates } from '../hooks/useCheckForUpdates'; import { useExportData } from '../hooks/useExportData'; import { useImportData } from '../hooks/useImportData'; import { useListenToTauriEvent } from '../hooks/useListenToTauriEvent'; import { invokeCmd } from '../lib/tauri'; import type { DropdownRef } from './core/Dropdown'; import { Dropdown } from './core/Dropdown'; import { Icon } from './core/Icon'; import { IconButton } from './core/IconButton'; import { useDialog } from './DialogContext'; import { KeyboardShortcutsDialog } from './KeyboardShortcutsDialog'; export function SettingsDropdown() { const importData = useImportData(); const exportData = useExportData(); const appInfo = useAppInfo(); const dropdownRef = useRef(null); const dialog = useDialog(); const checkForUpdates = useCheckForUpdates(); const routes = useAppRoutes(); const workspace = useActiveWorkspace(); const showSettings = async () => { if (!workspace) return; await invokeCmd('cmd_new_nested_window', { url: routes.paths.workspaceSettings({ workspaceId: workspace.id }), label: 'settings', title: 'Yaak Settings', }); }; useListenToTauriEvent('settings', showSettings); return ( , onSelect: showSettings, }, { key: 'hotkeys', label: 'Keyboard shortcuts', hotKeyAction: 'hotkeys.showHelp', leftSlot: , onSelect: () => { dialog.show({ id: 'hotkey', title: 'Keyboard Shortcuts', size: 'dynamic', render: () => , }); }, }, { key: 'import-data', label: 'Import Data', leftSlot: , onSelect: () => importData.mutate(), }, { key: 'export-data', label: 'Export Data', leftSlot: , onSelect: () => exportData.mutate(), }, { type: 'separator', label: `Yaak v${appInfo.version}` }, { key: 'update-check', label: 'Check for Updates', leftSlot: , onSelect: () => checkForUpdates.mutate(), }, { key: 'feedback', label: 'Feedback', leftSlot: , rightSlot: , onSelect: () => open('https://yaak.app/roadmap'), }, { key: 'changelog', label: 'Changelog', leftSlot: , rightSlot: , onSelect: () => open(`https://yaak.app/changelog/${appInfo.version}`), }, ]} > ); }