Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add folder support scaffolding (#1404)

Leendert de Borstdbc59112576b
diff --git a/apps/browser-extension/src/entrypoints/popup/App.tsx b/apps/browser-extension/src/entrypoints/popup/App.tsx
index e13433d9c..ccc568050 100644
--- a/apps/browser-extension/src/entrypoints/popup/App.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/App.tsx
@@ -22,6 +22,7 @@ import CredentialsList from '@/entrypoints/popup/pages/credentials/CredentialsLi
import ItemAddEdit from '@/entrypoints/popup/pages/credentials/ItemAddEdit';
import ItemDetails from '@/entrypoints/popup/pages/credentials/ItemDetails';
import ItemTypeSelector from '@/entrypoints/popup/pages/credentials/ItemTypeSelector';
+import ItemsList from '@/entrypoints/popup/pages/items/ItemsList';
import EmailDetails from '@/entrypoints/popup/pages/emails/EmailDetails';
import EmailsList from '@/entrypoints/popup/pages/emails/EmailsList';
import Index from '@/entrypoints/popup/pages/Index';
@@ -185,6 +186,7 @@ const App: React.FC = () => {
{ path: '/unlock-success', element: <UnlockSuccess />, showBackButton: false },
{ path: '/upgrade', element: <Upgrade />, showBackButton: false },
{ path: '/auth-settings', element: <AuthSettings />, showBackButton: true, title: t('settings.title') },
+ { path: '/items', element: <ItemsList />, showBackButton: false },
{ path: '/credentials', element: <CredentialsList />, showBackButton: false },
{ path: '/credentials/add', element: <CredentialAddEdit />, showBackButton: true, title: t('credentials.addCredential') },
{ path: '/credentials/:id', element: <CredentialDetails />, showBackButton: true, title: t('credentials.credentialDetails') },
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Folders/FolderModal.tsx b/apps/browser-extension/src/entrypoints/popup/components/Folders/FolderModal.tsx
new file mode 100644
index 000000000..ca79d29cd
--- /dev/null
+++ b/apps/browser-extension/src/entrypoints/popup/components/Folders/FolderModal.tsx
@@ -0,0 +1,132 @@
+import React, { useState, useEffect } from 'react';
+import { useTranslation } from 'react-i18next';
+
+type FolderModalProps = {
+ isOpen: boolean;
+ onClose: () => void;
+ onSave: (folderName: string) => Promise<void>;
+ initialName?: string;
+ mode: 'create' | 'edit';
+};
+
+/**
+ * Modal for creating or editing a folder
+ */
+const FolderModal: React.FC<FolderModalProps> = ({
+ isOpen,
+ onClose,
+ onSave,
+ initialName = '',
+ mode
+}) => {
+ const { t } = useTranslation();
+ const [folderName, setFolderName] = useState(initialName);
+ const [isSubmitting, setIsSubmitting] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+
+ useEffect(() => {
+ if (isOpen) {
+ setFolderName(initialName);
+ setError(null);
+ }
+ }, [isOpen, initialName]);
+
+ const handleSubmit = async (e: React.FormEvent) => {
+ e.preventDefault();
+
+ const trimmedName = folderName.trim();
+ if (!trimmedName) {
+ setError(t('items.folderNameRequired'));
+ return;
+ }
+
+ setIsSubmitting(true);
+ setError(null);
+
+ try {
+ await onSave(trimmedName);
+ onClose();
+ } catch (err) {
+ setError(t('items.folderSaveError'));
+ console.error('Error saving folder:', err);
+ } finally {
+ setIsSubmitting(false);
+ }
+ };
+
+ const handleKeyDown = (e: React.KeyboardEvent) => {
+ if (e.key === 'Escape') {
+ onClose();
+ }
+ };
+
+ if (!isOpen) {
+ return null;
+ }
+
+ return (
+ <div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
+ <div
+ className="bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md mx-4"
+ onKeyDown={handleKeyDown}
+ >
+ {/* Header */}
+ <div className="px-6 py-4 border-b border-gray-200 dark:border-gray-700">
+ <h2 className="text-xl font-semibold text-gray-900 dark:text-white">
+ {mode === 'create' ? t('items.createFolder') : t('items.editFolder')}
+ </h2>
+ </div>
+
+ {/* Body */}
+ <form onSubmit={handleSubmit}>
+ <div className="px-6 py-4">
+ <label
+ htmlFor="folderName"
+ className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"
+ >
+ {t('items.folderName')}
+ </label>
+ <input
+ id="folderName"
+ type="text"
+ value={folderName}
+ onChange={(e) => setFolderName(e.target.value)}
+ placeholder={t('items.folderNamePlaceholder')}
+ autoFocus
+ className="w-full p-2 border dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 focus:ring-blue-500 focus:border-blue-500"
+ />
+ {error && (
+ <p className="mt-2 text-sm text-red-600 dark:text-red-400">{error}</p>
+ )}
+ </div>
+
+ {/* Footer */}
+ <div className="px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex justify-end gap-3">
+ <button
+ type="button"
+ onClick={onClose}
+ disabled={isSubmitting}
+ className="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50"
+ >
+ {t('common.cancel')}
+ </button>
+ <button
+ type="submit"
+ disabled={isSubmitting}
+ className="px-4 py-2 text-sm font-medium text-white bg-orange-600 hover:bg-orange-700 rounded focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-orange-500 disabled:opacity-50"
+ >
+ {isSubmitting
+ ? t('common.saving')
+ : mode === 'create'
+ ? t('common.create')
+ : t('common.save')
+ }
+ </button>
+ </div>
+ </form>
+ </div>
+ </div>
+ );
+};
+
+export default FolderModal;
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Items/FolderCard.tsx b/apps/browser-extension/src/entrypoints/popup/components/Items/FolderCard.tsx
new file mode 100644
index 000000000..94918dd35
--- /dev/null
+++ b/apps/browser-extension/src/entrypoints/popup/components/Items/FolderCard.tsx
@@ -0,0 +1,66 @@
+import React from 'react';
+
+type FolderWithCount = {
+ id: string;
+ name: string;
+ itemCount: number;
+};
+
+type FolderCardProps = {
+ folder: FolderWithCount;
+ onClick: () => void;
+};
+
+/**
+ * FolderCard component
+ *
+ * This component displays a folder card with a folder icon, name, and item count.
+ * It allows the user to navigate into the folder when clicked.
+ */
+const FolderCard: React.FC<FolderCardProps> = ({ folder, onClick }) => {
+ return (
+ <li>
+ <button
+ onClick={onClick}
+ className="w-full p-2 border dark:border-gray-600 rounded flex items-center bg-white dark:bg-gray-800 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500"
+ >
+ {/* Folder Icon */}
+ <div className="w-8 h-8 mr-2 flex-shrink-0 flex items-center justify-center">
+ <svg
+ className="w-7 h-7 text-orange-500 dark:text-orange-400"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z" />
+ </svg>
+ </div>
+
+ <div className="text-left flex-1">
+ <p className="font-medium text-gray-900 dark:text-white">{folder.name}</p>
+ <p className="text-sm text-gray-600 dark:text-gray-400">
+ {folder.itemCount} {folder.itemCount === 1 ? 'item' : 'items'}
+ </p>
+ </div>
+
+ {/* Chevron Right Icon */}
+ <svg
+ className="w-5 h-5 text-gray-400 dark:text-gray-500 flex-shrink-0"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <polyline points="9 18 15 12 9 6" />
+ </svg>
+ </button>
+ </li>
+ );
+};
+
+export default FolderCard;
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Items/ItemCard.tsx b/apps/browser-extension/src/entrypoints/popup/components/Items/ItemCard.tsx
new file mode 100644
index 000000000..391d9ec5c
--- /dev/null
+++ b/apps/browser-extension/src/entrypoints/popup/components/Items/ItemCard.tsx
@@ -0,0 +1,141 @@
+import React from 'react';
+import { useNavigate } from 'react-router-dom';
+
+import type { Item } from '@/utils/dist/shared/models/vault';
+import SqliteClient from '@/utils/SqliteClient';
+import { FieldKey } from '@/utils/dist/shared/models/vault';
+
+type ItemCardProps = {
+ item: Item;
+ showFolderPath?: boolean;
+};
+
+/**
+ * ItemCard component
+ *
+ * This component displays an item card with a name, logo, and fields.
+ * It allows the user to navigate to the item details page when clicked.
+ *
+ */
+const ItemCard: React.FC<ItemCardProps> = ({ item, showFolderPath = false }) => {
+ const navigate = useNavigate();
+
+ /**
+ * Get the display text for the item (username or email)
+ * @param itm - The item to get the display text for
+ * @returns The display text for the item
+ */
+ const getDisplayText = (itm: Item): string => {
+ let returnValue = '';
+
+ // Try to find username field
+ const usernameField = itm.Fields?.find(f => f.FieldKey === FieldKey.LoginUsername);
+ if (usernameField && usernameField.Value) {
+ returnValue = Array.isArray(usernameField.Value) ? usernameField.Value[0] : usernameField.Value;
+ }
+
+ // Try to find email field if no username
+ if (!returnValue) {
+ const emailField = itm.Fields?.find(f => f.FieldKey === FieldKey.AliasEmail);
+ if (emailField && emailField.Value) {
+ returnValue = Array.isArray(emailField.Value) ? emailField.Value[0] : emailField.Value;
+ }
+ }
+
+ // Trim the return value to max. 33 characters.
+ return returnValue.length > 33 ? returnValue.slice(0, 30) + '...' : returnValue;
+ };
+
+ /**
+ * Get the item name, trimming it to maximum length so it doesn't overflow the UI.
+ */
+ const getItemName = (itm: Item): string => {
+ let returnValue = 'Untitled';
+
+ if (itm.Name) {
+ returnValue = itm.Name;
+ }
+
+ // Trim the return value to max. 33 characters.
+ return returnValue.length > 33 ? returnValue.slice(0, 30) + '...' : returnValue;
+ };
+
+ return (
+ <li>
+ <button
+ onClick={() => navigate(`/items/${item.Id}`)}
+ className="w-full p-2 border dark:border-gray-600 rounded flex items-center bg-white dark:bg-gray-800 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500"
+ >
+ <img
+ src={SqliteClient.imgSrcFromBytes(item.Logo)}
+ alt={item.Name || 'Item'}
+ className="w-8 h-8 mr-2 flex-shrink-0"
+ onError={(e) => {
+ const target = e.target as HTMLImageElement;
+ target.src = '/assets/images/service-placeholder.webp';
+ }}
+ />
+ <div className="text-left flex-1">
+ <div className="flex items-center gap-1.5">
+ <p className="font-medium text-gray-900 dark:text-white">
+ {showFolderPath && item.FolderPath ? (
+ <>
+ <span className="text-gray-500 dark:text-gray-400 text-sm">{item.FolderPath} &gt; </span>
+ {getItemName(item)}
+ </>
+ ) : (
+ getItemName(item)
+ )}
+ </p>
+ {item.HasPasskey && (
+ <svg
+ className="w-3.5 h-3.5 text-gray-500 dark:text-gray-400"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ aria-label="Has passkey"
+ >
+ <path d="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4" />
+ </svg>
+ )}
+ {item.HasAttachment && (
+ <svg
+ className="w-3.5 h-3.5 text-gray-500 dark:text-gray-400"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ aria-label="Has attachments"
+ >
+ <path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" />
+ </svg>
+ )}
+ {item.HasTotp && (
+ <svg
+ className="w-3.5 h-3.5 text-gray-500 dark:text-gray-400"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ aria-label="Has 2FA"
+ >
+ <circle cx="12" cy="12" r="10" />
+ <polyline points="12 6 12 12 16 14" />
+ </svg>
+ )}
+ </div>
+ <p className="text-sm text-gray-600 dark:text-gray-400">{getDisplayText(item)}</p>
+ </div>
+ </button>
+ </li>
+ );
+};
+
+export default ItemCard;
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Layout/BottomNav.tsx b/apps/browser-extension/src/entrypoints/popup/components/Layout/BottomNav.tsx
index a65ab1e3b..34f6fcea7 100644
--- a/apps/browser-extension/src/entrypoints/popup/components/Layout/BottomNav.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/components/Layout/BottomNav.tsx
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate, useLocation } from 'react-router-dom';
-type TabName = 'credentials' | 'emails' | 'settings';
+type TabName = 'items' | 'emails' | 'settings';
/**
* Bottom nav component.
@@ -11,12 +11,12 @@ const BottomNav: React.FC = () => {
const { t } = useTranslation();
const navigate = useNavigate();
const location = useLocation();
- const [currentTab, setCurrentTab] = useState<TabName>('credentials');
+ const [currentTab, setCurrentTab] = useState<TabName>('items');
// Add effect to update currentTab based on route
useEffect(() => {
const path = location.pathname.substring(1); // Remove leading slash
- const tabNames: TabName[] = ['credentials', 'emails', 'settings'];
+ const tabNames: TabName[] = ['items', 'emails', 'settings'];
// Find the first tab name that matches the start of the path
const matchingTab = tabNames.find(tab => path === tab || path.startsWith(`${tab}/`));
@@ -54,15 +54,15 @@ const BottomNav: React.FC = () => {
<div className="fixed bottom-0 left-0 right-0 bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700">
<div className="flex justify-around items-center h-14">
<button
- onClick={() => handleTabChange('credentials')}
+ onClick={() => handleTabChange('items')}
className={`flex flex-col items-center justify-center w-1/3 h-full ${
- currentTab === 'credentials' ? 'text-primary-600 dark:text-primary-500' : 'text-gray-500 dark:text-gray-400'
+ currentTab === 'items' ? 'text-primary-600 dark:text-primary-500' : 'text-gray-500 dark:text-gray-400'
}`}
>
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z" />
</svg>
- <span className="text-sm mt-1">{t('menu.credentials')}</span>
+ <span className="text-sm mt-1">{t('menu.vault')}</span>
</button>
<button
onClick={() => handleTabChange('emails')}
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/Reinitialize.tsx b/apps/browser-extension/src/entrypoints/popup/pages/Reinitialize.tsx
index 90f3b5923..3c34c56da 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/Reinitialize.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/Reinitialize.tsx
@@ -74,8 +74,8 @@ const Reinitialize: React.FC = () => {
sendMessage('CLEAR_PERSISTED_FORM_VALUES', null, 'background'),
]);
- // Navigate to the credentials page as default entry page
- navigate('/credentials', { replace: true });
+ // Navigate to the items page as default entry page
+ navigate('/items', { replace: true });
}, [navigate]);
useEffect(() => {
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/credentials/ItemAddEdit.tsx b/apps/browser-extension/src/entrypoints/popup/pages/credentials/ItemAddEdit.tsx
index 7df9eab46..bafaf032f 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/credentials/ItemAddEdit.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/credentials/ItemAddEdit.tsx
@@ -66,6 +66,9 @@ const ItemAddEdit: React.FC = () => {
const [newCustomFieldLabel, setNewCustomFieldLabel] = useState('');
const [newCustomFieldType, setNewCustomFieldType] = useState<FieldType>('Text');
+ // Folder selection state
+ const [folders, setFolders] = useState<Array<{ Id: string; Name: string }>>([]);
+
/**
* Get all applicable system fields for the current item type.
* These are sorted by DefaultDisplayOrder.
@@ -113,10 +116,18 @@ const ItemAddEdit: React.FC = () => {
Id: crypto.randomUUID().toUpperCase(),
Name: itemNameParam || '',
ItemType: itemTypeParam,
+ FolderId: null,
Fields: [],
CreatedAt: new Date().toISOString(),
UpdatedAt: new Date().toISOString()
});
+
+ // Load folders
+ if (dbContext?.sqliteClient) {
+ const allFolders = dbContext.sqliteClient.getAllFolders();
+ setFolders(allFolders);
+ }
+
setLocalLoading(false);
setIsInitialLoading(false);
return;
@@ -127,6 +138,10 @@ const ItemAddEdit: React.FC = () => {
if (result) {
setItem(result);
+ // Load folders
+ const allFolders = dbContext.sqliteClient.getAllFolders();
+ setFolders(allFolders);
+
// Initialize field values from existing fields
const initialValues: Record<string, string | string[]> = {};
const existingCustomFields: CustomFieldDefinition[] = [];
@@ -461,6 +476,29 @@ const ItemAddEdit: React.FC = () => {
/>
</div>
+ {/* Folder Selection */}
+ <div>
+ <label
+ htmlFor="folderSelect"
+ className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"
+ >
+ {t('items.folder')}
+ </label>
+ <select
+ id="folderSelect"
+ value={item.FolderId || ''}
+ onChange={(e) => setItem({ ...item, FolderId: e.target.value || null })}
+ className="w-full p-2 border dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-blue-500 focus:border-blue-500"
+ >
+ <option value="">{t('items.noFolder')}</option>
+ {folders.map(folder => (
+ <option key={folder.Id} value={folder.Id}>
+ {folder.Name}
+ </option>
+ ))}
+ </select>
+ </div>
+
{/* Render fields grouped by category */}
{Object.keys(groupedSystemFields).map(category => (
<div key={category} className="space-y-4">
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx b/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx
new file mode 100644
index 000000000..4387384f4
--- /dev/null
+++ b/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx
@@ -0,0 +1,588 @@
+import React, { useState, useEffect, useCallback } from 'react';
+import { useTranslation } from 'react-i18next';
+import { useNavigate } from 'react-router-dom';
+
+import ItemCard from '@/entrypoints/popup/components/Items/ItemCard';
+import FolderCard from '@/entrypoints/popup/components/Items/FolderCard';
+import FolderModal from '@/entrypoints/popup/components/Folders/FolderModal';
+import HeaderButton from '@/entrypoints/popup/components/HeaderButton';
+import { HeaderIconType } from '@/entrypoints/popup/components/Icons/HeaderIcons';
+import LoadingSpinner from '@/entrypoints/popup/components/LoadingSpinner';
+import ReloadButton from '@/entrypoints/popup/components/ReloadButton';
+import { useApp } from '@/entrypoints/popup/context/AppContext';
+import { useDb } from '@/entrypoints/popup/context/DbContext';
+import { useHeaderButtons } from '@/entrypoints/popup/context/HeaderButtonsContext';
+import { useLoading } from '@/entrypoints/popup/context/LoadingContext';
+import { useVaultSync } from '@/entrypoints/popup/hooks/useVaultSync';
+import { useVaultMutate } from '@/entrypoints/popup/hooks/useVaultMutate';
+import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';
+
+import type { Item } from '@/utils/dist/shared/models/vault';
+
+import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';
+
+type FilterType = 'all' | 'passkeys' | 'attachments';
+
+const FILTER_STORAGE_KEY = 'items-filter';
+const FILTER_EXPIRY_MS = 5 * 60 * 1000; // 5 minutes
+
+/**
+ * Get stored filter from localStorage if not expired
+ */
+const getStoredFilter = (): FilterType => {
+ try {
+ const stored = localStorage.getItem(FILTER_STORAGE_KEY);
+ if (!stored) {
+ return 'all';
+ }
+
+ const { filter, timestamp } = JSON.parse(stored);
+ const now = Date.now();
+
+ // Check if expired (5 minutes)
+ if (now - timestamp > FILTER_EXPIRY_MS) {
+ localStorage.removeItem(FILTER_STORAGE_KEY);
+ return 'all';
+ }
+
+ return filter as FilterType;
+ } catch {
+ return 'all';
+ }
+};
+
+/**
+ * Store filter in localStorage with timestamp
+ */
+const storeFilter = (filter: FilterType): void => {
+ try {
+ localStorage.setItem(FILTER_STORAGE_KEY, JSON.stringify({
+ filter,
+ timestamp: Date.now()
+ }));
+ } catch {
+ // Ignore storage errors
+ }
+};
+
+/**
+ * Represents a folder with item count
+ */
+type FolderWithCount = {
+ id: string;
+ name: string;
+ itemCount: number;
+};
+
+/**
+ * Items list page with folder support.
+ */
+const ItemsList: React.FC = () => {
+ const { t } = useTranslation();
+ const dbContext = useDb();
+ const app = useApp();
+ const navigate = useNavigate();
+ const { syncVault } = useVaultSync();
+ const { executeVaultMutation, isLoading: isSaving } = useVaultMutate();
+ const { setHeaderButtons } = useHeaderButtons();
+ const [items, setItems] = useState<Item[]>([]);
+ const [searchTerm, setSearchTerm] = useState('');
+ const [filterType, setFilterType] = useState<FilterType>(getStoredFilter());
+ const [showFilterMenu, setShowFilterMenu] = useState(false);
+ const [currentFolderId, setCurrentFolderId] = useState<string | null>(null);
+ const [folderPath, setFolderPath] = useState<string>('');
+ const [showFolderModal, setShowFolderModal] = useState(false);
+ const { setIsInitialLoading } = useLoading();
+
+ /**
+ * Loading state with minimum duration for more fluid UX.
+ */
+ const [isLoading, setIsLoading] = useMinDurationLoading(true, 100);
+
+ /**
+ * Handle add new item.
+ * Navigate to item type selector for new item-based flow.
+ */
+ const handleAddItem = useCallback(() : void => {
+ navigate('/items/select-type');
+ }, [navigate]);
+
+ /**
+ * Handle add new folder.
+ */
+ const handleAddFolder = useCallback(() : void => {
+ setShowFolderModal(true);
+ }, []);
+
+ /**
+ * Handle save folder.
+ */
+ const handleSaveFolder = useCallback(async (folderName: string) : Promise<void> => {
+ if (!dbContext?.sqliteClient) {
+ console.error('[FOLDER DEBUG] No sqliteClient available');
+ return;
+ }
+
+ console.log('[FOLDER DEBUG] Creating folder:', folderName, 'in parent:', currentFolderId);
+
+ await executeVaultMutation(
+ async () => {
+ const folderId = await dbContext.sqliteClient!.createFolder(folderName, currentFolderId);
+ console.log('[FOLDER DEBUG] Folder created with ID:', folderId);
+ },
+ {
+ onSuccess: () => {
+ console.log('[FOLDER DEBUG] Vault mutation successful, refreshing items...');
+ // Refresh items to show the new folder
+ const results = dbContext.sqliteClient!.getAllItems();
+ console.log('[FOLDER DEBUG] getAllItems returned:', results.length, 'items');
+ console.log('[FOLDER DEBUG] Items with FolderId:', results.filter(i => i.FolderId).map(i => ({ id: i.Id, name: i.Name, folderId: i.FolderId, folderPath: i.FolderPath })));
+ setItems(results);
+
+ // Also try to get folders directly
+ const folders = dbContext.sqliteClient!.getAllFolders();
+ console.log('[FOLDER DEBUG] getAllFolders returned:', folders);
+ },
+ onError: (error) => {
+ console.error('[FOLDER DEBUG] Error creating folder:', error);
+ throw error;
+ }
+ }
+ );
+ }, [dbContext, currentFolderId, executeVaultMutation]);
+
+ /**
+ * Retrieve latest vault and refresh the items list.
+ */
+ const onRefresh = useCallback(async () : Promise<void> => {
+ if (!dbContext?.sqliteClient) {
+ return;
+ }
+
+ try {
+ // Sync vault and load items
+ await syncVault({
+ /**
+ * On success.
+ */
+ onSuccess: async (_hasNewVault) => {
+ // Items list is refreshed automatically when the (new) sqlite client is available via useEffect hook below.
+ },
+ /**
+ * On offline.
+ */
+ _onOffline: () => {
+ // Not implemented for browser extension yet.
+ },
+ /**
+ * On error.
+ */
+ onError: async (error) => {
+ console.error('Error syncing vault:', error);
+ },
+ });
+ } catch (err) {
+ console.error('Error refreshing items:', err);
+ await app.logout('Error while syncing vault, please re-authenticate.');
+ }
+ }, [dbContext, app, syncVault]);
+
+ /**
+ * Get latest vault from server and refresh the items list.
+ */
+ const syncVaultAndRefresh = useCallback(async () : Promise<void> => {
+ setIsLoading(true);
+ await onRefresh();
+ setIsLoading(false);
+ }, [onRefresh, setIsLoading]);
+
+ // Set header buttons on mount and clear on unmount
+ useEffect((): (() => void) => {
+ const headerButtonsJSX = (
+ <div className="flex items-center gap-2">
+ {!PopoutUtility.isPopup() && (
+ <HeaderButton
+ onClick={() => PopoutUtility.openInNewPopup()}
+ title="Open in new window"
+ iconType={HeaderIconType.EXPAND}
+ />
+ )}
+ <HeaderButton
+ onClick={handleAddItem}
+ title="Add new item"
+ iconType={HeaderIconType.PLUS}
+ />
+ </div>
+ );
+
+ setHeaderButtons(headerButtonsJSX);
+ return () => setHeaderButtons(null);
+ }, [setHeaderButtons, handleAddItem]);
+
+ /**
+ * Load items list on mount and on sqlite client change.
+ */
+ useEffect(() => {
+ /**
+ * Refresh items list when a (new) sqlite client is available.
+ */
+ const refreshItems = async () : Promise<void> => {
+ if (dbContext?.sqliteClient) {
+ setIsLoading(true);
+ const results = dbContext.sqliteClient?.getAllItems() ?? [];
+ setItems(results);
+ setIsLoading(false);
+ setIsInitialLoading(false);
+ }
+ };
+
+ refreshItems();
+ }, [dbContext?.sqliteClient, setIsLoading, setIsInitialLoading]);
+
+ /**
+ * Get the title based on the active filter and current folder
+ */
+ const getFilterTitle = () : string => {
+ if (currentFolderId && folderPath) {
+ return folderPath;
+ }
+
+ switch (filterType) {
+ case 'passkeys':
+ return t('items.filters.passkeys');
+ case 'attachments':
+ return t('items.filters.attachments');
+ default:
+ return t('items.title');
+ }
+ };
+
+ /**
+ * Navigate into a folder
+ */
+ const handleFolderClick = useCallback((folderId: string, folderName: string) => {
+ setCurrentFolderId(folderId);
+ setFolderPath(folderName);
+ setSearchTerm(''); // Clear search when entering folder
+ }, []);
+
+ /**
+ * Navigate back to root or parent folder
+ */
+ const handleBackToRoot = useCallback(() => {
+ setCurrentFolderId(null);
+ setFolderPath('');
+ }, []);
+
+ /**
+ * Get folders with item counts (only for root level when not searching)
+ */
+ const getFoldersWithCounts = (): FolderWithCount[] => {
+ console.log('[FOLDER DEBUG] getFoldersWithCounts called. currentFolderId:', currentFolderId, 'searchTerm:', searchTerm);
+
+ if (currentFolderId || searchTerm) {
+ console.log('[FOLDER DEBUG] Returning empty folders (in folder view or searching)');
+ return [];
+ }
+
+ if (!dbContext?.sqliteClient) {
+ return [];
+ }
+
+ // Get all folders directly from the database
+ const allFolders = dbContext.sqliteClient.getAllFolders();
+ console.log('[FOLDER DEBUG] Got', allFolders.length, 'folders from database:', allFolders);
+
+ // Count items per folder
+ const folderCounts = new Map<string, number>();
+ items.forEach(item => {
+ if (item.FolderId) {
+ folderCounts.set(item.FolderId, (folderCounts.get(item.FolderId) || 0) + 1);
+ }
+ });
+
+ // Build result with counts
+ const result = allFolders.map(folder => ({
+ id: folder.Id,
+ name: folder.Name,
+ itemCount: folderCounts.get(folder.Id) || 0
+ })).sort((a, b) => a.name.localeCompare(b.name));
+
+ console.log('[FOLDER DEBUG] Returning', result.length, 'folders with counts:', result);
+ return result;
+ };
+
+ /**
+ * Filter items based on current view (folder, search, filter type)
+ */
+ const filteredItems = items.filter((item: Item) => {
+ // Filter by current folder (if in folder view)
+ if (currentFolderId !== null) {
+ if (item.FolderId !== currentFolderId) {
+ return false;
+ }
+ } else if (!searchTerm) {
+ // In root view without search, exclude items that are in folders
+ if (item.FolderId) {
+ return false;
+ }
+ }
+
+ // Apply type filter
+ let passesTypeFilter = true;
+ if (filterType === 'passkeys') {
+ passesTypeFilter = item.HasPasskey === true;
+ } else if (filterType === 'attachments') {
+ passesTypeFilter = item.HasAttachment === true;
+ }
+
+ if (!passesTypeFilter) {
+ return false;
+ }
+
+ // Apply search filter
+ const searchLower = searchTerm.toLowerCase().trim();
+ if (!searchLower) {
+ return true;
+ }
+
+ // Search in item name and fields
+ const itemName = item.Name?.toLowerCase() || '';
+ if (itemName.includes(searchLower)) {
+ return true;
+ }
+
+ // Search in field values
+ const fieldMatches = item.Fields?.some(field => {
+ const value = Array.isArray(field.Value)
+ ? field.Value.join(' ').toLowerCase()
+ : (field.Value || '').toLowerCase();
+ return value.includes(searchLower) || field.Label.toLowerCase().includes(searchLower);
+ });
+
+ if (fieldMatches) {
+ return true;
+ }
+
+ return false;
+ });
+
+ const folders = getFoldersWithCounts();
+
+ console.log('[FOLDER DEBUG] Render: folders:', folders.length, 'filteredItems:', filteredItems.length, 'isLoading:', isLoading);
+
+ if (isLoading) {
+ return (
+ <div className="flex justify-center items-center p-8">
+ <LoadingSpinner />
+ </div>
+ );
+ }
+
+ return (
+ <div>
+ <div className="flex justify-between items-center mb-4">
+ <div className="relative flex-1">
+ {currentFolderId ? (
+ <div className="flex items-center gap-2">
+ <button
+ onClick={handleBackToRoot}
+ className="text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"
+ title={t('common.back')}
+ >
+ <svg
+ className="w-5 h-5"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <path d="M19 12H5M12 19l-7-7 7-7" />
+ </svg>
+ </button>
+ <h2 className="flex items-baseline gap-1.5 text-gray-900 dark:text-white text-xl">
+ {getFilterTitle()}
+ <span className="text-sm text-gray-500 dark:text-gray-400">({filteredItems.length})</span>
+ </h2>
+ </div>
+ ) : (
+ <button
+ onClick={() => setShowFilterMenu(!showFilterMenu)}
+ className="flex items-center gap-1 text-gray-900 dark:text-white text-xl hover:text-gray-700 dark:hover:text-gray-300 focus:outline-none"
+ >
+ <h2 className="flex items-baseline gap-1.5">
+ {getFilterTitle()}
+ <span className="text-sm text-gray-500 dark:text-gray-400">
+ ({folders.length > 0 ? `${folders.length} ${t('items.folders')}, ` : ''}{filteredItems.length} {t('items.items')})
+ </span>
+ </h2>
+ <svg
+ className="w-4 h-4 mt-1"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <polyline points="6 9 12 15 18 9" />
+ </svg>
+ </button>
+ )}
+
+ {showFilterMenu && (
+ <>
+ <div
+ className="fixed inset-0 z-10"
+ onClick={() => setShowFilterMenu(false)}
+ />
+ <div className="absolute left-0 mt-2 w-56 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-20">
+ <div className="py-1">
+ <button
+ onClick={() => {
+ const newFilter = 'all';
+ setFilterType(newFilter);
+ storeFilter(newFilter);
+ setShowFilterMenu(false);
+ }}
+ className={`w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 ${
+ filterType === 'all' ? 'bg-orange-50 dark:bg-orange-900/20 text-orange-600 dark:text-orange-400' : 'text-gray-700 dark:text-gray-300'
+ }`}
+ >
+ {t('items.filters.all')}
+ </button>
+ <button
+ onClick={() => {
+ const newFilter = 'passkeys';
+ setFilterType(newFilter);
+ storeFilter(newFilter);
+ setShowFilterMenu(false);
+ }}
+ className={`w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 ${
+ filterType === 'passkeys' ? 'bg-orange-50 dark:bg-orange-900/20 text-orange-600 dark:text-orange-400' : 'text-gray-700 dark:text-gray-300'
+ }`}
+ >
+ {t('items.filters.passkeys')}
+ </button>
+ <button
+ onClick={() => {
+ const newFilter = 'attachments';
+ setFilterType(newFilter);
+ storeFilter(newFilter);
+ setShowFilterMenu(false);
+ }}
+ className={`w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 ${
+ filterType === 'attachments' ? 'bg-orange-50 dark:bg-orange-900/20 text-orange-600 dark:text-orange-400' : 'text-gray-700 dark:text-gray-300'
+ }`}
+ >
+ {t('items.filters.attachments')}
+ </button>
+ </div>
+ </div>
+ </>
+ )}
+ </div>
+ <ReloadButton onClick={syncVaultAndRefresh} />
+ </div>
+
+ {items.length > 0 ? (
+ <div className="mb-4">
+ <input
+ type="text"
+ value={searchTerm}
+ onChange={(e) => setSearchTerm(e.target.value)}
+ placeholder={`${t('content.searchVault')}`}
+ autoFocus
+ className="w-full p-2 border dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 focus:ring-blue-500 focus:border-blue-500"
+ />
+ </div>
+ ) : (
+ <></>
+ )}
+
+ {items.length === 0 ? (
+ <div className="text-gray-500 dark:text-gray-400 space-y-2 mb-10">
+ <p>
+ {t('items.welcomeTitle')}
+ </p>
+ <p>
+ {t('items.welcomeDescription')}
+ </p>
+ </div>
+ ) : filteredItems.length === 0 && folders.length === 0 ? (
+ <div className="text-gray-500 dark:text-gray-400 space-y-2 mb-10">
+ <p>
+ {filterType === 'passkeys'
+ ? t('items.noPasskeysFound')
+ : filterType === 'attachments'
+ ? t('items.noAttachmentsFound')
+ : t('items.noMatchingItems')
+ }
+ </p>
+ </div>
+ ) : (
+ <>
+ {/* Folders section (only show at root level when not searching) */}
+ {!currentFolderId && !searchTerm && (
+ <div className="space-y-2 mb-4">
+ <div className="flex items-center justify-between">
+ <h3 className="text-sm font-medium text-gray-700 dark:text-gray-300">
+ {t('items.folders')}
+ </h3>
+ <button
+ onClick={handleAddFolder}
+ className="text-xs text-orange-600 dark:text-orange-400 hover:text-orange-700 dark:hover:text-orange-300 focus:outline-none"
+ >
+ + {t('items.newFolder')}
+ </button>
+ </div>
+ {folders.length > 0 && (
+ <ul className="space-y-2">
+ {folders.map(folder => (
+ <FolderCard
+ key={folder.id}
+ folder={folder}
+ onClick={() => handleFolderClick(folder.id, folder.name)}
+ />
+ ))}
+ </ul>
+ )}
+ </div>
+ )}
+
+ {/* Items */}
+ {filteredItems.length > 0 && (
+ <div className="space-y-2">
+ {folders.length > 0 && (
+ <h3 className="text-sm font-medium text-gray-700 dark:text-gray-300">
+ {t('items.items')}
+ </h3>
+ )}
+ <ul className="space-y-2">
+ {filteredItems.map(item => (
+ <ItemCard
+ key={item.Id}
+ item={item}
+ showFolderPath={!!searchTerm && !!item.FolderPath}
+ />
+ ))}
+ </ul>
+ </div>
+ )}
+ </>
+ )}
+
+ {/* Folder Modal */}
+ <FolderModal
+ isOpen={showFolderModal}
+ onClose={() => setShowFolderModal(false)}
+ onSave={handleSaveFolder}
+ mode="create"
+ />
+ </div>
+ );
+};
+
+export default ItemsList;
diff --git a/apps/browser-extension/src/i18n/locales/en.json b/apps/browser-extension/src/i18n/locales/en.json
index 58d049d1a..c464cff6b 100644
--- a/apps/browser-extension/src/i18n/locales/en.json
+++ b/apps/browser-extension/src/i18n/locales/en.json
@@ -43,7 +43,7 @@
}
},
"menu": {
- "credentials": "Credentials",
+ "vault": "Vault",
"emails": "Emails",
"settings": "Settings"
},
@@ -59,6 +59,7 @@
"delete": "Delete",
"save": "Save",
"saving": "Saving...",
+ "create": "Create",
"or": "Or",
"close": "Close",
"copied": "Copied!",
@@ -252,6 +253,30 @@
"noHistoryAvailable": "No history available",
"tags": "Tags"
},
+ "items": {
+ "title": "Items",
+ "folders": "folders",
+ "items": "items",
+ "newFolder": "New Folder",
+ "createFolder": "Create Folder",
+ "editFolder": "Edit Folder",
+ "folderName": "Folder Name",
+ "folderNamePlaceholder": "Enter folder name",
+ "folderNameRequired": "Folder name is required",
+ "folderSaveError": "Failed to save folder. Please try again.",
+ "folder": "Folder",
+ "noFolder": "No Folder",
+ "welcomeTitle": "Welcome to AliasVault!",
+ "welcomeDescription": "To use the AliasVault browser extension: navigate to a website and use the AliasVault autofill popup to create a new credential.",
+ "noPasskeysFound": "No passkeys have been created yet. Passkeys are created by visiting a website that offers passkeys as an authentication method.",
+ "noAttachmentsFound": "No items with attachments found",
+ "noMatchingItems": "No matching items found",
+ "filters": {
+ "all": "(All) Items",
+ "passkeys": "Passkeys",
+ "attachments": "Attachments"
+ }
+ },
"itemTypes": {
"selectType": "Add New Item",
"selectTypeDescription": "Choose the type of item you want to create",
diff --git a/apps/browser-extension/src/utils/SqliteClient.ts b/apps/browser-extension/src/utils/SqliteClient.ts
index 18bb5e181..9a147a7b0 100644
--- a/apps/browser-extension/src/utils/SqliteClient.ts
+++ b/apps/browser-extension/src/utils/SqliteClient.ts
@@ -371,6 +371,7 @@ export class SqliteClient {
i.Name,
i.ItemType,
i.FolderId,
+ f.Name as FolderPath,
l.FileData as Logo,
CASE WHEN EXISTS (SELECT 1 FROM Passkeys pk WHERE pk.ItemId = i.Id AND pk.IsDeleted = 0) THEN 1 ELSE 0 END as HasPasskey,
CASE WHEN EXISTS (SELECT 1 FROM Attachments att WHERE att.ItemId = i.Id AND att.IsDeleted = 0) THEN 1 ELSE 0 END as HasAttachment,
@@ -379,6 +380,7 @@ export class SqliteClient {
i.UpdatedAt
FROM Items i
LEFT JOIN Logos l ON i.LogoId = l.Id
+ LEFT JOIN Folders f ON i.FolderId = f.Id
WHERE i.IsDeleted = 0
ORDER BY i.CreatedAt DESC`;
@@ -531,7 +533,7 @@ export class SqliteClient {
ItemType: row.ItemType,
Logo: row.Logo,
FolderId: row.FolderId,
- FolderPath: null,
+ FolderPath: row.FolderPath || null,
Tags: tagsByItem[row.Id] || [],
Fields: fieldsByItem[row.Id] || [],
HasPasskey: row.HasPasskey === 1,
@@ -2467,6 +2469,186 @@ export class SqliteClient {
throw error;
}
}
+
+ /**
+ * ===== FOLDER OPERATIONS =====
+ */
+
+ /**
+ * Create a new folder
+ * @param name - The name of the folder
+ * @param parentFolderId - Optional parent folder ID for nested folders
+ * @returns The ID of the created folder
+ */
+ public async createFolder(name: string, parentFolderId?: string | null): Promise<string> {
+ if (!this.db) {
+ throw new Error('Database not initialized');
+ }
+
+ try {
+ this.beginTransaction();
+
+ const folderId = crypto.randomUUID();
+ const currentDateTime = dateFormatter.now();
+
+ const query = `
+ INSERT INTO Folders (Id, Name, ParentFolderId, Weight, IsDeleted, CreatedAt, UpdatedAt)
+ VALUES (?, ?, ?, 0, 0, ?, ?)`;
+
+ this.executeUpdate(query, [
+ folderId,
+ name,
+ parentFolderId || null,
+ currentDateTime,
+ currentDateTime
+ ]);
+
+ await this.commitTransaction();
+ return folderId;
+ } catch (error) {
+ this.rollbackTransaction();
+ console.error('Error creating folder:', error);
+ throw error;
+ }
+ }
+
+ /**
+ * Get all folders
+ * @returns Array of folder objects
+ */
+ public getAllFolders(): Array<{ Id: string; Name: string; ParentFolderId: string | null; Weight: number }> {
+ const query = `
+ SELECT Id, Name, ParentFolderId, Weight
+ FROM Folders
+ WHERE IsDeleted = 0
+ ORDER BY Weight, Name`;
+
+ return this.executeQuery(query);
+ }
+
+ /**
+ * Update a folder's name
+ * @param folderId - The ID of the folder to update
+ * @param name - The new name for the folder
+ * @returns The number of rows updated
+ */
+ public async updateFolder(folderId: string, name: string): Promise<number> {
+ if (!this.db) {
+ throw new Error('Database not initialized');
+ }
+
+ try {
+ this.beginTransaction();
+
+ const currentDateTime = dateFormatter.now();
+
+ const query = `
+ UPDATE Folders
+ SET Name = ?,
+ UpdatedAt = ?
+ WHERE Id = ?`;
+
+ const result = this.executeUpdate(query, [name, currentDateTime, folderId]);
+
+ await this.commitTransaction();
+ return result;
+ } catch (error) {
+ this.rollbackTransaction();
+ console.error('Error updating folder:', error);
+ throw error;
+ }
+ }
+
+ /**
+ * Delete a folder (soft delete)
+ * Note: Items in the folder will have their FolderId set to NULL
+ * @param folderId - The ID of the folder to delete
+ * @returns The number of rows updated
+ */
+ public async deleteFolder(folderId: string): Promise<number> {
+ if (!this.db) {
+ throw new Error('Database not initialized');
+ }
+
+ try {
+ this.beginTransaction();
+
+ const currentDateTime = dateFormatter.now();
+
+ // 1. Remove folder reference from all items in this folder
+ const itemsQuery = `
+ UPDATE Items
+ SET FolderId = NULL,
+ UpdatedAt = ?
+ WHERE FolderId = ?`;
+
+ this.executeUpdate(itemsQuery, [currentDateTime, folderId]);
+
+ // 2. Soft delete the folder
+ const folderQuery = `
+ UPDATE Folders
+ SET IsDeleted = 1,
+ UpdatedAt = ?
+ WHERE Id = ?`;
+
+ const result = this.executeUpdate(folderQuery, [currentDateTime, folderId]);
+
+ await this.commitTransaction();
+ return result;
+ } catch (error) {
+ this.rollbackTransaction();
+ console.error('Error deleting folder:', error);
+ throw error;
+ }
+ }
+
+ /**
+ * Move an item to a folder
+ * @param itemId - The ID of the item to move
+ * @param folderId - The ID of the destination folder (null to remove from folder)
+ * @returns The number of rows updated
+ */
+ public async moveItemToFolder(itemId: string, folderId: string | null): Promise<number> {
+ if (!this.db) {
+ throw new Error('Database not initialized');
+ }
+
+ try {
+ this.beginTransaction();
+
+ const currentDateTime = dateFormatter.now();
+
+ const query = `
+ UPDATE Items
+ SET FolderId = ?,
+ UpdatedAt = ?
+ WHERE Id = ?`;
+
+ const result = this.executeUpdate(query, [folderId, currentDateTime, itemId]);
+
+ await this.commitTransaction();
+ return result;
+ } catch (error) {
+ this.rollbackTransaction();
+ console.error('Error moving item to folder:', error);
+ throw error;
+ }
+ }
+
+ /**
+ * Get folder by ID
+ * @param folderId - The ID of the folder to fetch
+ * @returns Folder object or null if not found
+ */
+ public getFolderById(folderId: string): { Id: string; Name: string; ParentFolderId: string | null } | null {
+ const query = `
+ SELECT Id, Name, ParentFolderId
+ FROM Folders
+ WHERE Id = ? AND IsDeleted = 0`;
+
+ const results = this.executeQuery<{ Id: string; Name: string; ParentFolderId: string | null }>(query, [folderId]);
+ return results.length > 0 ? results[0] : null;
+ }
}
export default SqliteClient;
\ No newline at end of file