Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Render shared manifest folder anchor with shared folder icon (#2159)
Leendert de Borst587a6794e88a
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Folders/FolderIcon.tsx b/apps/browser-extension/src/entrypoints/popup/components/Folders/FolderIcon.tsxnew file mode 100644index 000000000..47adf2501--- /dev/null+++ b/apps/browser-extension/src/entrypoints/popup/components/Folders/FolderIcon.tsx@@ -0,0 +1,47 @@+import React from 'react';+import { useTranslation } from 'react-i18next';++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',+}) => {+ const { t } = useTranslation();++ return (+ <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={t('sharing.family.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/browser-extension/src/entrypoints/popup/components/Items/FolderPill.tsx b/apps/browser-extension/src/entrypoints/popup/components/Items/FolderPill.tsxindex b78d24001..3eed0c25e 100644--- a/apps/browser-extension/src/entrypoints/popup/components/Items/FolderPill.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/Items/FolderPill.tsx@@ -1,5 +1,7 @@import React from 'react';+import FolderIcon from '@/entrypoints/popup/components/Folders/FolderIcon';+type FolderWithCount = {id: string;name: string;@@ -34,22 +36,7 @@ const FolderPill: React.FC<IFolderPillProps> = ({ folder, onClick, isActive = fa: 'border-gray-200 dark:border-gray-600'}`}>- <span className="relative flex-shrink-0">- <svg- className="w-3.5 h-3.5 text-orange-500 dark:text-orange-400"- 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>- {isShared && (- <span className="absolute -bottom-1 -right-1 flex items-center justify-center w-2.5 h-2.5 rounded-full bg-white dark:bg-gray-800 ring-1 ring-gray-200 dark:ring-gray-600">- <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>+ <FolderIcon isShared={isShared} className="w-3.5 h-3.5 text-orange-500 dark:text-orange-400" /><span className="text-gray-700 dark:text-gray-200 font-medium truncate max-w-[120px]">{folder.name}</span>diff --git a/apps/browser-extension/src/entrypoints/popup/components/Items/ItemNameInput.tsx b/apps/browser-extension/src/entrypoints/popup/components/Items/ItemNameInput.tsxindex de5680e53..86ff65681 100644--- a/apps/browser-extension/src/entrypoints/popup/components/Items/ItemNameInput.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/Items/ItemNameInput.tsx@@ -1,13 +1,17 @@import React, { useState, useCallback, useMemo, useEffect } from 'react';import { useTranslation } from 'react-i18next';-import { buildFolderTree, getFolderIdPath, type FolderTreeNode } from '@/utils/FolderUtils';+import FolderIcon from '@/entrypoints/popup/components/Folders/FolderIcon';+import { useDb } from '@/entrypoints/popup/context/DbContext';++import { buildFolderTree, getFolderIdPath, isSharedFolder, type FolderTreeNode } from '@/utils/FolderUtils';type Folder = {Id: string;Name: string;ParentFolderId: string | null;Weight: number;+ ManifestId?: string | null;};type ItemNameInputProps = {@@ -37,10 +41,12 @@ const ItemNameInput: React.FC<ItemNameInputProps> = ({suggestions = []}) => {const { t } = useTranslation();+ const dbContext = useDb();const [showFolderModal, setShowFolderModal] = useState(false);const [expandedFolders, setExpandedFolders] = useState<Set<string>>(new Set());const selectedFolder = folders.find(f => f.Id === selectedFolderId);+ const personalManifestId = dbContext?.sqliteClient?.getPersonalManifestId() ?? null;// Build folder treeconst folderTree = useMemo(() => buildFolderTree(folders), [folders]);@@ -146,14 +152,12 @@ const ItemNameInput: React.FC<ItemNameInputProps> = ({)}{/* Folder icon */}- <svg- className={`w-5 h-5 shrink-0 ${isSelected ? 'text-primary-500' : 'text-gray-400'} ${!hasChildren ? 'ml-5' : ''}`}- 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={`w-5 h-5 ${isSelected ? 'text-primary-500' : 'text-gray-400'} ${!hasChildren ? 'ml-5' : ''}`}+ badgeClassName="bg-white dark:bg-gray-800 ring-gray-200 dark:ring-gray-600"+ />{/* Folder name */}<span className="font-medium flex-1">{node.Name}</span>@@ -174,7 +178,7 @@ const ItemNameInput: React.FC<ItemNameInputProps> = ({)}</div>);- }, [expandedFolders, selectedFolderId, handleSelectFolder, toggleFolder]);+ }, [expandedFolders, selectedFolderId, handleSelectFolder, toggleFolder, personalManifestId]);return (<>@@ -224,9 +228,12 @@ const ItemNameInput: React.FC<ItemNameInputProps> = ({}`}title={selectedFolder?.Name || '-'}>- <svg className="w-4 h-4 shrink-0" 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={selectedFolder !== undefined && isSharedFolder(selectedFolder, personalManifestId)}+ className="w-4 h-4"+ badgeClassName="bg-white dark:bg-gray-700 ring-gray-200 dark:ring-gray-600"+ />{selectedFolderId && (<span className="max-w-16 truncate">{selectedFolder?.Name}diff --git a/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx b/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsxindex 569f00588..795df9dcc 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx@@ -5,6 +5,7 @@ import { useLocation, useNavigate, useParams, useSearchParams } from 'react-routimport ConfirmDeleteModal from '@/entrypoints/popup/components/Dialogs/ConfirmDeleteModal';import DeleteFolderModal from '@/entrypoints/popup/components/Folders/DeleteFolderModal';import FolderBreadcrumb from '@/entrypoints/popup/components/Folders/FolderBreadcrumb';+import FolderIcon from '@/entrypoints/popup/components/Folders/FolderIcon';import FolderModal from '@/entrypoints/popup/components/Folders/FolderModal';import HeaderButton from '@/entrypoints/popup/components/HeaderButton';import { HeaderIconType } from '@/entrypoints/popup/components/Icons/HeaderIcons';@@ -28,7 +29,7 @@ import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';import type { Folder } from '@/utils/db/repositories/FolderRepository';import type { CredentialSortOrder } from '@/utils/db/repositories/SettingsRepository';import type { Item, ItemType } from '@/utils/dist/core/models/vault';-import { canHaveSubfolders, getDescendantFolderIds, getFolderPath, getRecursiveItemCount } from '@/utils/FolderUtils';+import { canHaveSubfolders, getDescendantFolderIds, getFolderPath, getRecursiveItemCount, isAnchorFolder, isSharedFolder } from '@/utils/FolderUtils';import { applyTypeFilter, isItemTypeFilter, parseItemFilterType, type ItemFilterType } from '@/utils/ItemFilters';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';@@ -99,6 +100,7 @@ type FolderWithCount = {id: string;name: string;itemCount: number;+ isShared: boolean;};/**@@ -158,6 +160,20 @@ const ItemsList: React.FC = () => {return folder?.Name ?? null;}, [currentFolderId, dbContext?.sqliteClient, folderRefreshKey]);+ // The folder being viewed, re-read when it changes+ const currentFolder = useMemo(() => {+ // folderRefreshKey is included in deps to force re-computation when the folder changes+ void folderRefreshKey;+ if (!currentFolderId || !dbContext?.sqliteClient) {+ return null;+ }++ return dbContext.sqliteClient.folders.getById(currentFolderId);+ }, [currentFolderId, dbContext?.sqliteClient, folderRefreshKey]);++ // Whether it is the folder a shared vault is rendered as: left or revoked in Family Sharing, never deleted here+ const currentFolderIsAnchor = currentFolder !== null && isAnchorFolder(currentFolder);+// Get current folder's full path (for relative path computation in search results)const currentFolderPath = useMemo(() => {if (!currentFolderId || !dbContext?.sqliteClient) {@@ -615,10 +631,12 @@ const ItemsList: React.FC = () => {};// Build result with recursive counts+ const personalManifestId = dbContext.sqliteClient.getPersonalManifestId();const result = relevantFolders.map((folder: Folder) => ({id: folder.Id,name: folder.Name,- itemCount: getRecursiveItemCountLocal(folder.Id)+ itemCount: getRecursiveItemCountLocal(folder.Id),+ isShared: isSharedFolder(folder, personalManifestId)})).sort((a: { name: string }, b: { name: string }) => a.name.localeCompare(b.name));return result;@@ -1012,6 +1030,7 @@ const ItemsList: React.FC = () => {onClick={() => handleFolderClick(folder.id, folder.name)}isActive={activeKind === 'folder' && activeIndex === index}optionId={folderIdFor(index)}+ isShared={folder.isShared}/>))}{canCreateSubfolder && (@@ -1049,6 +1068,7 @@ const ItemsList: React.FC = () => {onClick={() => handleFolderClick(folder.id, folder.name)}isActive={activeKind === 'folder' && activeIndex === index}optionId={folderIdFor(index)}+ isShared={folder.isShared}/>))}{canCreateSubfolder && (@@ -1175,6 +1195,7 @@ const ItemsList: React.FC = () => {onDeleteFolderOnly={handleDeleteFolderOnly}onDeleteFolderAndContents={handleDeleteFolderAndContents}itemCount={totalItemCountInFolderTree}+ sharedVault={currentFolderIsAnchor}/></div>);