Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add virtual folder (shared manifest) icon to web app (#2413)
Leendert de Borst29a786c130c0
diff --git a/apps/web/src/components/folders/FolderIcon.tsx b/apps/web/src/components/folders/FolderIcon.tsxnew file mode 100644index 000000000..fc39b2d21--- /dev/null+++ b/apps/web/src/components/folders/FolderIcon.tsx@@ -0,0 +1,35 @@+import { familySharingText } from '@aliasvault/client/sharing/FamilySharingView';+import React from 'react';++type FolderIconProps = {+ isShared?: boolean;+ variant?: 'filled' | 'outline';+ className?: string;+ badgeClassName?: string;+};++/**+ * Folder glyph, optionally carrying a small people badge that marks the folder as shared with other people.+ */+const FolderIcon: React.FC<FolderIconProps> = ({ isShared = false, variant = 'filled', className = 'w-4 h-4', badgeClassName = 'bg-white dark:bg-gray-800 ring-gray-200 dark:ring-gray-600' }) => (+ <span className="relative flex-shrink-0">+ {variant === 'filled' ? (+ <svg className={className} viewBox="0 0 24 24" fill="currentColor">+ <path d="M10 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-8l-2-2z" />+ </svg>+ ) : (+ <svg className={className} viewBox="0 0 24 24" fill="none" stroke="currentColor">+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z" />+ </svg>+ )}+ {isShared && (+ <span title={familySharingText.sharedVault} className={`absolute -bottom-1 -right-1 flex items-center justify-center w-2.5 h-2.5 rounded-full ring-1 ${badgeClassName}`}>+ <svg className="w-2 h-2 text-primary-500 dark:text-primary-400" viewBox="0 0 24 24" fill="currentColor">+ <path d="M4.5 6.375a4.125 4.125 0 118.25 0 4.125 4.125 0 01-8.25 0zM14.25 8.625a3.375 3.375 0 116.75 0 3.375 3.375 0 01-6.75 0zM1.5 19.125a7.125 7.125 0 0114.25 0v.003l-.001.119a.75.75 0 01-.363.63 13.067 13.067 0 01-6.761 1.873c-2.472 0-4.786-.684-6.76-1.873a.75.75 0 01-.364-.63l-.001-.122zM17.25 19.128l-.001.144a2.25 2.25 0 01-.233.96 10.088 10.088 0 005.06-1.01.75.75 0 00.42-.643 4.875 4.875 0 00-6.957-4.611 8.586 8.586 0 011.71 5.157v.003z" />+ </svg>+ </span>+ )}+ </span>+);++export default FolderIcon;diff --git a/apps/web/src/components/items/FolderPill.tsx b/apps/web/src/components/items/FolderPill.tsxindex a09045089..fd5918d89 100644--- a/apps/web/src/components/items/FolderPill.tsx+++ b/apps/web/src/components/items/FolderPill.tsx@@ -1,5 +1,7 @@import React from 'react';+import FolderIcon from '@/components/folders/FolderIcon';+/*** A folder with the number of items it (recursively) holds.*/@@ -9,6 +11,7 @@ export type FolderWithCount = {name: string;parentFolderId: string | null;itemCount: number;+ isShared: boolean;};/**@@ -16,9 +19,7 @@ export type FolderWithCount = {*/const FolderPill: React.FC<{ folder: FolderWithCount; onClick: () => void }> = ({ folder, onClick }) => (<button onClick={onClick} className="inline-flex items-center gap-2 px-5 py-2.5 text-sm rounded-lg bg-white dark:bg-gray-700/50 border border-gray-200 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600/50 hover:border-gray-300 dark:hover:border-gray-500 transition-colors focus:outline-none focus:ring-2 focus:ring-orange-500 focus:ring-offset-1 dark:focus:ring-offset-gray-800">- <svg className="w-4 h-4 text-orange-500 flex-shrink-0" viewBox="0 0 24 24" fill="currentColor">- <path d="M10 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-8l-2-2z" />- </svg>+ <FolderIcon isShared={folder.isShared} className="w-4 h-4 text-orange-500" badgeClassName="bg-white dark:bg-gray-700 ring-gray-200 dark:ring-gray-600" /><span className="text-gray-700 dark:text-gray-300 truncate max-w-[150px]" title={folder.name}>{folder.name}</span><span className="text-gray-400 dark:text-gray-500 text-xs">{folder.itemCount}</span></button>diff --git a/apps/web/src/components/items/FolderSelector.tsx b/apps/web/src/components/items/FolderSelector.tsxindex e3954df34..3afdd386f 100644--- a/apps/web/src/components/items/FolderSelector.tsx+++ b/apps/web/src/components/items/FolderSelector.tsx@@ -1,8 +1,9 @@import { scopedKey } from '@aliasvault/client/database/ItemRef';-import { buildFolderTree, getFolderIdPath, type FolderTreeNode } from '@aliasvault/client/items/FolderUtils';+import { buildFolderTree, getFolderIdPath, isSharedFolder, type FolderTreeNode } from '@aliasvault/client/items/FolderUtils';import React, { useEffect, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';+import FolderIcon from '@/components/folders/FolderIcon';import FormModal from '@/components/shared/FormModal';import { useDb } from '@/context/DbContext';@@ -30,6 +31,7 @@ const FolderSelector: React.FC<FolderSelectorProps> = ({ selectedFolder, onSelecconst [expandedFolderIds, setExpandedFolderIds] = useState<Set<string>>(new Set());const [showFolderModal, setShowFolderModal] = useState(false);const tk = 'components.main.items.folderSelector';+ const personalManifestId = dbContext.sqliteClient?.getPersonalManifestId() ?? null;useEffect(() => {const client = dbContext.sqliteClient;@@ -147,9 +149,7 @@ const FolderSelector: React.FC<FolderSelectorProps> = ({ selectedFolder, onSelec: 'text-gray-500 dark:text-gray-400 border border-dashed border-gray-300 dark:border-gray-600 hover:text-primary-600 dark:hover:text-primary-400 hover:border-primary-400 dark:hover:border-primary-500'}`}>{selectedFolder ? (- <svg className="w-4 h-4 text-orange-500 flex-shrink-0" viewBox="0 0 24 24" fill="currentColor">- <path d="M10 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-8l-2-2z" />- </svg>+ <FolderIcon isShared={selectedFolderRow !== undefined && isSharedFolder(selectedFolderRow, personalManifestId)} className="w-4 h-4 text-orange-500" badgeClassName="bg-gray-100 dark:bg-gray-700 ring-gray-200 dark:ring-gray-600" />) : (<svg className="w-4 h-4 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path strokeLinecap="round" strokeLinejoin="round" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z" />@@ -205,9 +205,7 @@ const FolderSelector: React.FC<FolderSelectorProps> = ({ selectedFolder, onSelec<button type="button" onClick={() => selectFolder(node)} disabled={isDisabled} className={buttonClass(key, isDisabled, hasChildren)}><div className="flex items-center gap-3 flex-1">- <svg className={iconClass(key, isDisabled)} fill="none" stroke="currentColor" viewBox="0 0 24 24">- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z" />- </svg>+ <FolderIcon variant="outline" isShared={isSharedFolder(node, personalManifestId)} className={iconClass(key, isDisabled)} /><span className="font-medium">{node.Name}</span>{count > 0 && <span className="text-xs text-gray-400 dark:text-gray-500">({count})</span>}</div>diff --git a/apps/web/src/pages/items/Home.tsx b/apps/web/src/pages/items/Home.tsxindex e63f1862c..4d2312a4f 100644--- a/apps/web/src/pages/items/Home.tsx+++ b/apps/web/src/pages/items/Home.tsx@@ -1,6 +1,6 @@import { scopedKey } from '@aliasvault/client/database/ItemRef';import { CredentialSortOrder } from '@aliasvault/client/database/repositories/SettingsRepository';-import { canHaveSubfolders, getDescendantFolderIds, getFolderPath, isItemInFolder } from '@aliasvault/client/items/FolderUtils';+import { canHaveSubfolders, getDescendantFolderIds, getFolderPath, isItemInFolder, isSharedFolder } from '@aliasvault/client/items/FolderUtils';import { ItemFilter, applyTypeFilter, type ItemFilterType, parseItemFilterType } from '@aliasvault/client/items/ItemFilters';import { multiManifestRendering } from '@aliasvault/client/sharing/MultiManifestRendering';import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';@@ -229,6 +229,7 @@ const ItemsHome: React.FC = () => {* Folders at the current level with their (recursive) filtered item counts.*/const currentLevelFolders = useMemo((): FolderWithCount[] => {+ const personalManifestId = dbContext.sqliteClient?.getPersonalManifestId() ?? null;const typeFiltered = new Set(applyTypeFilter(items.map(e => e.item), filterType).map(i => scopedKey(i.ManifestId, i.Id)));// At the root the top-level folders of every manifest show; inside a folder its children, which share its manifest.return allFolders@@ -241,9 +242,10 @@ const ItemsHome: React.FC = () => {name: f.Name,parentFolderId: f.ParentFolderId ?? null,itemCount: items.filter(e => e.manifestId === f.ManifestId && e.folderId !== null && folderIds.has(e.folderId) && typeFiltered.has(scopedKey(e.manifestId, e.id))).length,+ isShared: isSharedFolder(f, personalManifestId),};});- }, [allFolders, folderRef, items, filterType]);+ }, [allFolders, folderRef, items, filterType, dbContext.sqliteClient]);const canCreateSubfolder = !folderRef || (allFolders.length > 0 && canHaveSubfolders(folderRef, allFolders));diff --git a/apps/web/src/pages/items/View.tsx b/apps/web/src/pages/items/View.tsxindex 17709fc55..af7ac139a 100644--- a/apps/web/src/pages/items/View.tsx+++ b/apps/web/src/pages/items/View.tsx@@ -1,3 +1,4 @@+import { isSharedFolder } from '@aliasvault/client/items/FolderUtils';import { FieldCategories, FieldKey, ItemTypes, TRASH_RETENTION_DEFAULT_DAYS, getFieldValue, type Attachment, type Item, type Passkey, type TotpCode } from '@aliasvault/models/vault';import React, { useCallback, useEffect, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -5,6 +6,7 @@ import { Link, useNavigate, useParams } from 'react-router-dom';import AttachmentViewer from '@/components/attachments/AttachmentViewer';import RecentEmails from '@/components/email/RecentEmails';+import FolderIcon from '@/components/folders/FolderIcon';import CopyPasteFormRow from '@/components/forms/CopyPasteFormRow';import { type DisplayField, getUrlValues, groupDisplayFields, shouldBeFullWidth } from '@/components/items/DisplayField';import FieldBlock from '@/components/items/FieldBlock';@@ -200,9 +202,7 @@ const ItemView: React.FC = () => {))}{folder && (<Link to={folderRoute(folder)} className="inline-flex items-center gap-2 mt-2 px-3 py-1.5 text-sm font-medium text-gray-600 dark:text-gray-400 bg-gray-100 dark:bg-gray-700 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors">- <svg className="w-4 h-4 text-orange-500" viewBox="0 0 24 24" fill="currentColor">- <path d="M10 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-8l-2-2z" />- </svg>+ <FolderIcon isShared={isSharedFolder(folder, dbContext.sqliteClient?.getPersonalManifestId())} className="w-4 h-4 text-orange-500" badgeClassName="bg-gray-100 dark:bg-gray-700 ring-gray-200 dark:ring-gray-600" /><span>{folder.Name}</span></Link>)}