Skip to content

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

Add generic layout components (#2413)

Leendert de Borst83ab2748419d
diff --git a/apps/web/src/components/layout/ClipboardCountdownBar.tsx b/apps/web/src/components/layout/ClipboardCountdownBar.tsx
new file mode 100644
index 000000000..2aecf5cce
--- /dev/null
+++ b/apps/web/src/components/layout/ClipboardCountdownBar.tsx
@@ -0,0 +1,80 @@
+import React, { useEffect, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { clipboardCopyService, type ClipboardStatus } from '@/utils/ClipboardCopyService';
+
+/**
+ * Thin bar at the top of the page counting down to the clipboard clear, with a manual clear button when the
+ * browser refused the automatic clear.
+ */
+const ClipboardCountdownBar: React.FC = () => {
+ const { t } = useTranslation();
+ const [isVisible, setIsVisible] = useState(false);
+ const [progress, setProgress] = useState(0);
+ const [status, setStatus] = useState<ClipboardStatus>('active');
+
+ useEffect(() => {
+ const unsubscribeProgress = clipboardCopyService.subscribeProgress((value) => {
+ setProgress(value);
+ if (value > 0) {
+ setIsVisible(true);
+ setStatus('active');
+ } else {
+ setStatus((current) => {
+ if (current !== 'cleared') {
+ setIsVisible(true);
+ setProgress(1);
+ return 'pending';
+ }
+ return current;
+ });
+ }
+ });
+ const unsubscribeStatus = clipboardCopyService.subscribeStatus((value) => {
+ setStatus(value);
+ if (value === 'cleared') {
+ setIsVisible(false);
+ setProgress(0);
+ } else if (value === 'pending' || value === 'manual_clear_required') {
+ setIsVisible(true);
+ setProgress(1);
+ }
+ });
+ return (): void => {
+ unsubscribeProgress();
+ unsubscribeStatus();
+ };
+ }, []);
+
+ /**
+ * Clear the clipboard on the user's request.
+ */
+ const handleManualClear = async (): Promise<void> => {
+ await clipboardCopyService.clearNow();
+ setStatus('active');
+ setIsVisible(true);
+ setProgress(0);
+ };
+
+ if (!isVisible) {
+ return null;
+ }
+
+ const barColorClass = status === 'pending' || status === 'manual_clear_required' ? 'bg-blue-500 dark:bg-blue-400' : 'bg-orange-500 dark:bg-orange-400';
+ const animationClass = status === 'pending' ? 'animate-pulse' : '';
+
+ return (
+ <div className="fixed top-0 left-0 right-0 z-50 h-1 bg-gray-200 dark:bg-gray-700">
+ <div className={`h-full ${barColorClass} transition-all duration-100 ease-linear ${animationClass}`} style={{ width: `${progress * 100}%` }}></div>
+ {status === 'manual_clear_required' && (
+ <div className="fixed top-2 left-1/2 transform -translate-x-1/2 z-50 bg-blue-500 dark:bg-blue-600 text-white px-4 py-2 rounded-md shadow-lg flex items-center gap-3">
+ <button type="button" onClick={() => void handleManualClear()} className="px-3 py-1 bg-white dark:bg-gray-800 text-blue-600 dark:text-blue-400 rounded text-sm font-medium hover:bg-gray-100 dark:hover:bg-gray-700">
+ {t('components.main.clipboardCountdownBar.ClearClipboardButton')}
+ </button>
+ </div>
+ )}
+ </div>
+ );
+};
+
+export default ClipboardCountdownBar;
diff --git a/apps/web/src/components/layout/CreateNewIdentityWidget.tsx b/apps/web/src/components/layout/CreateNewIdentityWidget.tsx
new file mode 100644
index 000000000..ebed7c7c5
--- /dev/null
+++ b/apps/web/src/components/layout/CreateNewIdentityWidget.tsx
@@ -0,0 +1,264 @@
+import { ItemTypes, type ItemType } from '@aliasvault/models/vault';
+import React, { useCallback, useEffect, useRef, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { useLocation, useNavigate } from 'react-router-dom';
+
+import { useDb } from '@/context/DbContext';
+import { useLoading } from '@/context/LoadingContext';
+import { useNotifications } from '@/context/NotificationContext';
+import { useClickOutside } from '@/hooks/useClickOutside';
+import { useIdentityGenerator } from '@/hooks/useIdentityGenerator';
+import { useKeyboardShortcut } from '@/hooks/useKeyboardShortcut';
+import { useSaveItem } from '@/hooks/useSaveItem';
+import { createNewItemEdit, type ItemEdit, setFieldValue } from '@/models/ItemEdit';
+import { itemRoute } from '@/utils/ItemRoute';
+
+import type { FolderRef } from '@aliasvault/client/database/repositories/FolderRepository';
+
+/** The URL prefilled in the website field. */
+const DEFAULT_SERVICE_URL = 'https://';
+
+/** The icon of each item type in the type selector. */
+const TYPE_ICON_PATHS: Record<ItemType, string> = {
+ [ItemTypes.Login]: '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',
+ [ItemTypes.Alias]: 'M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z',
+ [ItemTypes.CreditCard]: 'M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z',
+ [ItemTypes.Note]: 'M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z',
+};
+
+const ALL_TYPES: ItemType[] = [ItemTypes.Login, ItemTypes.Alias, ItemTypes.CreditCard, ItemTypes.Note];
+
+/**
+ * The "+ New" button in the top bar with its quick create popup: an alias is created in place with a random
+ * identity, the other types continue on the create page with the entered values.
+ */
+const CreateNewIdentityWidget: React.FC = () => {
+ const { t } = useTranslation();
+ const navigate = useNavigate();
+ const location = useLocation();
+ const dbContext = useDb();
+ const { showLoading, hideLoading } = useLoading();
+ const notifications = useNotifications();
+ const { generateIdentity } = useIdentityGenerator();
+ const { saveItem } = useSaveItem();
+ const [isCreating, setIsCreating] = useState(false);
+ const [isPopupVisible, setIsPopupVisible] = useState(false);
+ const [itemType, setItemType] = useState<ItemType>(ItemTypes.Login);
+ const [serviceName, setServiceName] = useState('');
+ const [serviceUrl, setServiceUrl] = useState(DEFAULT_SERVICE_URL);
+ const [nameError, setNameError] = useState('');
+ const containerRef = useRef<HTMLDivElement>(null);
+ const nameInputRef = useRef<HTMLInputElement>(null);
+
+ /**
+ * Close the popup.
+ */
+ const closePopup = useCallback((): void => setIsPopupVisible(false), []);
+ useClickOutside([containerRef], closePopup, isPopupVisible);
+
+ /**
+ * Open the popup with a fresh form.
+ */
+ const showPopup = useCallback((): void => {
+ setItemType(ItemTypes.Login);
+ setServiceName('');
+ setServiceUrl(DEFAULT_SERVICE_URL);
+ setNameError('');
+ setIsPopupVisible(true);
+ }, []);
+ useKeyboardShortcut('gc', showPopup);
+
+ useEffect(() => {
+ if (isPopupVisible) {
+ const timer = setTimeout(() => nameInputRef.current?.focus(), 100);
+ return (): void => clearTimeout(timer);
+ }
+ }, [isPopupVisible, itemType]);
+
+ /**
+ * The folder the user is looking at, if any.
+ */
+ const getCurrentFolderFromUrl = (): FolderRef | null => {
+ const match = /^\/items\/folder\/([^/]+)\/([^/]+)/.exec(location.pathname);
+ return match ? { ManifestId: decodeURIComponent(match[1]), Id: decodeURIComponent(match[2]) } : null;
+ };
+
+ /**
+ * Create an alias right away with a random identity.
+ */
+ const createAlias = async (): Promise<void> => {
+ if (isCreating) {
+ return;
+ }
+ setIsCreating(true);
+ showLoading(t('components.main.widgets.createNewIdentityWidget.CreatingNewAliasMessage'));
+ try {
+ let edit: ItemEdit = { ...createNewItemEdit(getCurrentFolderFromUrl(), dbContext.sqliteClient?.getPersonalManifestId() ?? null), ItemType: ItemTypes.Alias, ServiceName: serviceName.trim() };
+ if (serviceUrl !== DEFAULT_SERVICE_URL) {
+ edit = setFieldValue(edit, 'login.url', serviceUrl);
+ }
+ const identity = await generateIdentity();
+ if (identity) {
+ edit = setFieldValue(edit, 'login.username', identity.username);
+ edit = setFieldValue(edit, 'login.password', identity.password);
+ edit = setFieldValue(edit, 'login.email', identity.email);
+ edit = setFieldValue(edit, 'alias.first_name', identity.firstName);
+ edit = setFieldValue(edit, 'alias.last_name', identity.lastName);
+ edit = setFieldValue(edit, 'alias.gender', identity.gender);
+ edit = setFieldValue(edit, 'alias.birthdate', identity.birthdate);
+ }
+ const saved = await saveItem(edit);
+ notifications.addSuccessMessage(t('components.main.widgets.createNewIdentityWidget.ItemCreatedSuccessMessage'));
+ closePopup();
+ navigate(itemRoute(saved));
+ } catch (error) {
+ console.error('Error creating alias:', error);
+ notifications.addErrorMessage(t('components.main.widgets.createNewIdentityWidget.CreateItemErrorMessage'), true);
+ } finally {
+ hideLoading();
+ setIsCreating(false);
+ }
+ };
+
+ /**
+ * Create the alias in place, or continue to the create page with the entered values.
+ */
+ const handleSubmit = (e: React.FormEvent): void => {
+ e.preventDefault();
+ if (serviceName.trim().length === 0) {
+ setNameError(t('validationMessages.ServiceNameRequired'));
+ return;
+ }
+ if (itemType === ItemTypes.Alias) {
+ void createAlias();
+ return;
+ }
+ const params = new URLSearchParams();
+ params.set('type', itemType);
+ params.set('name', serviceName.trim());
+ if (serviceUrl !== DEFAULT_SERVICE_URL) {
+ params.set('url', serviceUrl);
+ }
+ const folder = getCurrentFolderFromUrl();
+ if (folder) {
+ params.set('folderId', folder.Id);
+ params.set('folderManifestId', folder.ManifestId);
+ }
+ closePopup();
+ navigate(`/items/create?${params.toString()}`);
+ };
+
+ /**
+ * The popup title for the selected type.
+ */
+ const getPopupTitle = (): string => {
+ switch (itemType) {
+ case ItemTypes.Alias: return t('components.main.widgets.createNewIdentityWidget.CreateNewAliasTitle');
+ case ItemTypes.CreditCard: return t('components.main.widgets.createNewIdentityWidget.CreateNewCreditCardTitle');
+ case ItemTypes.Note: return t('components.main.widgets.createNewIdentityWidget.CreateNewNoteTitle');
+ default: return t('components.main.widgets.createNewIdentityWidget.CreateNewLoginTitle');
+ }
+ };
+
+ /**
+ * The name placeholder for the selected type.
+ */
+ const getNamePlaceholder = (): string => {
+ switch (itemType) {
+ case ItemTypes.Alias: return t('components.main.widgets.createNewIdentityWidget.NamePlaceholderAlias');
+ case ItemTypes.CreditCard: return t('components.main.widgets.createNewIdentityWidget.NamePlaceholderCard');
+ case ItemTypes.Note: return t('components.main.widgets.createNewIdentityWidget.NamePlaceholderNote');
+ default: return t('components.main.widgets.createNewIdentityWidget.NamePlaceholderLogin');
+ }
+ };
+
+ /**
+ * The display name of an item type.
+ */
+ const getTypeDisplayName = (type: ItemType): string => {
+ switch (type) {
+ case ItemTypes.Alias: return t('components.main.widgets.createNewIdentityWidget.TypeAlias');
+ case ItemTypes.CreditCard: return t('components.main.widgets.createNewIdentityWidget.TypeCard');
+ case ItemTypes.Note: return t('components.main.widgets.createNewIdentityWidget.TypeNote');
+ default: return t('components.main.widgets.createNewIdentityWidget.TypeLogin');
+ }
+ };
+
+ const newAliasButtonText = t('components.main.widgets.createNewIdentityWidget.NewAliasButtonText');
+
+ return (
+ <div className="relative" ref={containerRef}>
+ <button onClick={() => (isPopupVisible ? closePopup() : showPopup())} id="quickIdentityButton" className="px-4 py-2 text-sm font-medium text-white bg-gradient-to-r from-primary-500 to-primary-600 hover:from-primary-600 hover:to-primary-700 focus:outline-none dark:from-primary-400 dark:to-primary-500 dark:hover:from-primary-500 dark:hover:to-primary-600 rounded-md shadow-sm transition duration-150 ease-in-out transform hover:scale-105 active:scale-95 focus:shadow-outline">
+ {t('components.main.widgets.createNewIdentityWidget.NewAliasButtonShort')} <span className="hidden md:inline">{newAliasButtonText.substring(1).trim()}</span>
+ </button>
+
+ {isPopupVisible && (
+ <div id="quickIdentityPopup" className="absolute right-0 z-50 mt-2 p-4 bg-white rounded-lg shadow-xl border border-gray-300 dark:bg-gray-800 dark:border-gray-400" style={{ width: 'min(400px, calc(100vw - 20px))' }}>
+ <div className="mb-4">
+ <div className="flex gap-1">
+ {ALL_TYPES.map(type => (
+ <button
+ key={type}
+ type="button"
+ id={`quickIdentityType_${type}`}
+ onClick={() => setItemType(type)}
+ className={`flex-1 px-2 py-2 text-xs font-medium rounded-md transition-colors flex flex-col items-center gap-1 ${itemType === type ? 'bg-primary-100 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300 border border-primary-300 dark:border-primary-700' : 'bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 border border-transparent'}`}>
+ <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d={TYPE_ICON_PATHS[type]} /></svg>
+ <span>{getTypeDisplayName(type)}</span>
+ </button>
+ ))}
+ </div>
+ </div>
+
+ <h3 className="text-lg font-semibold mb-4 text-gray-900 dark:text-white">{getPopupTitle()}</h3>
+ <form onSubmit={handleSubmit}>
+ <div className="mb-4">
+ <label htmlFor="serviceName" className="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{t('components.main.widgets.createNewIdentityWidget.NameLabel')}</label>
+ <input
+ ref={nameInputRef}
+ id="serviceName"
+ type="text"
+ value={serviceName}
+ onChange={(e) => {
+ setServiceName(e.target.value); setNameError('');
+ }}
+ placeholder={getNamePlaceholder()}
+ className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" />
+ {nameError && <div className="validation-message text-sm mt-1">{nameError}</div>}
+ </div>
+ {(itemType === ItemTypes.Login || itemType === ItemTypes.Alias) && (
+ <div className="mb-4">
+ <label htmlFor="serviceUrl" className="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{t('components.main.widgets.createNewIdentityWidget.WebsiteUrlLabel')}</label>
+ <input
+ id="serviceUrl"
+ type="text"
+ value={serviceUrl}
+ onChange={(e) => setServiceUrl(e.target.value)}
+ onFocus={(e) => {
+ if (e.target.value === DEFAULT_SERVICE_URL) {
+ setTimeout(() => e.target.setSelectionRange(DEFAULT_SERVICE_URL.length, DEFAULT_SERVICE_URL.length), 1);
+ }
+ }}
+ className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" />
+ </div>
+ )}
+ <div className="flex justify-between items-center">
+ <button id="quickIdentitySubmit" type="submit" className={`${itemType === ItemTypes.Alias ? 'bg-green-600 hover:bg-green-700' : 'bg-primary-600 hover:bg-primary-700'} text-white font-bold py-2 px-4 rounded flex items-center gap-2`}>
+ {itemType === ItemTypes.Alias ? t('components.main.widgets.createNewIdentityWidget.CreateButton') : (
+ <>
+ {t('components.main.widgets.createNewIdentityWidget.ContinueButton')}
+ <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M9 5l7 7-7 7" />
+ </svg>
+ </>
+ )}
+ </button>
+ </div>
+ </form>
+ </div>
+ )}
+ </div>
+ );
+};
+
+export default CreateNewIdentityWidget;
diff --git a/apps/web/src/components/layout/DbLockButton.tsx b/apps/web/src/components/layout/DbLockButton.tsx
new file mode 100644
index 000000000..6fbb9fad9
--- /dev/null
+++ b/apps/web/src/components/layout/DbLockButton.tsx
@@ -0,0 +1,36 @@
+import React from 'react';
+import { useTranslation } from 'react-i18next';
+import { useNavigate } from 'react-router-dom';
+
+import { useDb } from '@/context/DbContext';
+import { vaultStore } from '@/vault/VaultStore';
+
+/**
+ * Lock the vault and redirect to the unlock page.
+ */
+const DbLockButton: React.FC = () => {
+ const { t } = useTranslation();
+ const navigate = useNavigate();
+ const dbContext = useDb();
+
+ /**
+ * Lock the vault and redirect to the unlock page.
+ */
+ const onLockClick = async (): Promise<void> => {
+ await vaultStore.lockVault();
+ dbContext.clearDatabase();
+ navigate('/unlock/true');
+ };
+
+ return (
+ <div className="ms-2 items-center hidden lg:flex">
+ <button className="p-2 hover:bg-gray-200 rounded-2xl" onClick={onLockClick} title={t('sharedResources.LockVault')}>
+ <svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4 text-gray-400" viewBox="0 0 20 20" fill="currentColor">
+ <path fillRule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clipRule="evenodd" />
+ </svg>
+ </button>
+ </div>
+ );
+};
+
+export default DbLockButton;
diff --git a/apps/web/src/components/layout/DbStatusIndicator.tsx b/apps/web/src/components/layout/DbStatusIndicator.tsx
new file mode 100644
index 000000000..9a5c453ba
--- /dev/null
+++ b/apps/web/src/components/layout/DbStatusIndicator.tsx
@@ -0,0 +1,84 @@
+import React, { useCallback, useEffect, useRef, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import SmallLoadingIndicator from '@/components/loading/SmallLoadingIndicator';
+import { useDb } from '@/context/DbContext';
+import { useVaultSync } from '@/hooks/useVaultSync';
+
+/** How long the indicator keeps spinning after a sync started, so a fast sync is still visible. */
+const MIN_SPIN_MS = 600;
+
+/**
+ * Vault sync indicator in the top bar. Spins while syncing; otherwise a refresh button that pulls the latest vault.
+ */
+const DbStatusIndicator: React.FC = () => {
+ const { t } = useTranslation();
+ const dbContext = useDb();
+ const { syncVault } = useVaultSync();
+ const [isRefreshing, setIsRefreshing] = useState(false);
+ const [holdSpinning, setHoldSpinning] = useState(false);
+ const holdTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
+
+ const isBusy = dbContext.isSyncing || dbContext.isUploading || isRefreshing;
+
+ useEffect(() => {
+ if (isBusy) {
+ setHoldSpinning(true);
+ if (holdTimer.current) {
+ clearTimeout(holdTimer.current);
+ }
+ holdTimer.current = setTimeout(() => setHoldSpinning(false), MIN_SPIN_MS);
+ }
+ }, [isBusy]);
+
+ useEffect(() => {
+ return (): void => {
+ if (holdTimer.current) {
+ clearTimeout(holdTimer.current);
+ }
+ };
+ }, []);
+
+ const isSpinning = isBusy || holdSpinning;
+
+ /**
+ * Pull the latest vault from the server.
+ */
+ const onRefreshClick = useCallback(async (): Promise<void> => {
+ setIsRefreshing(true);
+ try {
+ await syncVault();
+ } finally {
+ setIsRefreshing(false);
+ }
+ }, [syncVault]);
+
+ /**
+ * The tooltip for the current state.
+ */
+ const getStatusTitle = (): string => {
+ if (dbContext.isUploading) {
+ return t('sharedResources.SyncingChanges');
+ }
+ if (dbContext.isSyncing) {
+ return t('sharedResources.LoadingVault');
+ }
+ return t('sharedResources.SyncVaultData');
+ };
+
+ return (
+ <div className="ms-1 items-center flex" id="vault-sync-indicator" data-syncing={isSpinning ? 'true' : 'false'}>
+ <SmallLoadingIndicator title={getStatusTitle()} spinning={isSpinning}>
+ {!isSpinning && (
+ <button className="absolute p-2 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-2xl" id="vault-refresh-btn" onClick={onRefreshClick}>
+ <svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4 text-gray-400" viewBox="0 0 20 20" fill="currentColor">
+ <path fillRule="evenodd" d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z" clipRule="evenodd" />
+ </svg>
+ </button>
+ )}
+ </SmallLoadingIndicator>
+ </div>
+ );
+};
+
+export default DbStatusIndicator;
diff --git a/apps/web/src/components/layout/Footer.tsx b/apps/web/src/components/layout/Footer.tsx
new file mode 100644
index 000000000..31328dbf1
--- /dev/null
+++ b/apps/web/src/components/layout/Footer.tsx
@@ -0,0 +1,37 @@
+import React, { useEffect, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { useLocation } from 'react-router-dom';
+
+import { getAppConfig } from '@/config/AppConfig';
+
+const TIP_KEYS = ['layout.footer.TipCreateShortcut', 'layout.footer.TipFindShortcut', 'layout.footer.TipHomeShortcut', 'layout.footer.TipLockShortcut'];
+
+/**
+ * Page footer.
+ */
+const Footer: React.FC = () => {
+ const { t } = useTranslation();
+ const location = useLocation();
+ const [tipKey, setTipKey] = useState(TIP_KEYS[0]);
+ const deploymentMode = getAppConfig().deploymentMode;
+
+ // Show a random UX tip on each page load.
+ useEffect(() => {
+ setTipKey(TIP_KEYS[Math.floor(Math.random() * TIP_KEYS.length)]);
+ }, [location.pathname]);
+
+ return (
+ <footer className="fixed -z-10 bottom-0 left-0 right-0 dark:bg-gray-900 border-t border-gray-200 dark:border-gray-700">
+ <div className="container mx-auto px-4 py-4">
+ <div className="flex flex-col lg:flex-row justify-between items-center">
+ <p className="text-sm text-center text-gray-500 mb-4 lg:mb-0">
+ © {new Date().getFullYear()} <span>AliasVault v{__APP_VERSION__}</span>{deploymentMode && <> <span className="ml-1">({deploymentMode})</span></>}. {t('layout.footer.CopyrightText')}
+ </p>
+ <div className="hidden lg:block text-center text-gray-400 text-sm">{t(tipKey)}</div>
+ </div>
+ </div>
+ </footer>
+ );
+};
+
+export default Footer;
diff --git a/apps/web/src/components/layout/FooterLogin.tsx b/apps/web/src/components/layout/FooterLogin.tsx
new file mode 100644
index 000000000..1d70726fd
--- /dev/null
+++ b/apps/web/src/components/layout/FooterLogin.tsx
@@ -0,0 +1,24 @@
+import React from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { getAppConfig } from '@/config/AppConfig';
+
+/**
+ * Footer shown on the auth pages.
+ */
+const FooterLogin: React.FC = () => {
+ const { t } = useTranslation();
+ const deploymentMode = getAppConfig().deploymentMode;
+
+ return (
+ <footer className="fixed -z-10 bottom-0 left-0 right-0 dark:bg-gray-900">
+ <div className="container mx-auto px-4 py-4">
+ <p className="text-sm text-center text-gray-400 dark:text-gray-500 mb-4 lg:mb-0">
+ © {new Date().getFullYear()} <span>AliasVault v{__APP_VERSION__}</span>{deploymentMode && <> <span className="ml-1">({deploymentMode})</span></>}. {t('layout.footer.CopyrightText')}
+ </p>
+ </div>
+ </footer>
+ );
+};
+
+export default FooterLogin;
diff --git a/apps/web/src/components/loading/BoldLoadingIndicator.tsx b/apps/web/src/components/loading/BoldLoadingIndicator.tsx
new file mode 100644
index 000000000..973450ab4
--- /dev/null
+++ b/apps/web/src/components/loading/BoldLoadingIndicator.tsx
@@ -0,0 +1,17 @@
+import React from 'react';
+
+/**
+ * The outlined pill spinner used on the logout, unlock and sync screens.
+ */
+const BoldLoadingIndicator: React.FC = () => (
+ <div className="aliasvault-spinner mx-auto">
+ <div className="cloud-shape-inverted">
+ <div className="dot-inverted delay-1"></div>
+ <div className="dot-inverted delay-2"></div>
+ <div className="dot-inverted delay-3"></div>
+ <div className="dot-inverted delay-4"></div>
+ </div>
+ </div>
+);
+
+export default BoldLoadingIndicator;
diff --git a/apps/web/src/components/loading/FullScreenLoadingIndicator.tsx b/apps/web/src/components/loading/FullScreenLoadingIndicator.tsx
new file mode 100644
index 000000000..dfbadb02d
--- /dev/null
+++ b/apps/web/src/components/loading/FullScreenLoadingIndicator.tsx
@@ -0,0 +1,35 @@
+import React from 'react';
+
+type FullScreenLoadingIndicatorProps = {
+ isVisible: boolean;
+ message?: string;
+};
+
+/**
+ * Full screen loading overlay with an optional message.
+ */
+const FullScreenLoadingIndicator: React.FC<FullScreenLoadingIndicatorProps> = ({ isVisible, message }) => {
+ if (!isVisible) {
+ return null;
+ }
+
+ return (
+ <div className="loading fixed inset-0 w-full h-full z-50 bg-gray-200 !m-0 !p-0 dark:bg-gray-500" style={{ zIndex: 2147483641 }}>
+ <div className="aliasvault-fullscreen-spinner mx-auto">
+ <div className="cloud-shape-inverted">
+ <div className="dot-inverted delay-1"></div>
+ <div className="dot-inverted delay-2"></div>
+ <div className="dot-inverted delay-3"></div>
+ <div className="dot-inverted delay-4"></div>
+ </div>
+ {message && (
+ <div className="loading-message mt-4 text-center text-gray-700 dark:text-gray-300">
+ {message}
+ </div>
+ )}
+ </div>
+ </div>
+ );
+};
+
+export default FullScreenLoadingIndicator;
diff --git a/apps/web/src/components/loading/LoadingIndicator.tsx b/apps/web/src/components/loading/LoadingIndicator.tsx
new file mode 100644
index 000000000..255af05f7
--- /dev/null
+++ b/apps/web/src/components/loading/LoadingIndicator.tsx
@@ -0,0 +1,20 @@
+import React from 'react';
+
+/**
+ * Inline loading indicator shown while a page loads its data.
+ */
+const LoadingIndicator: React.FC = () => (
+ <div role="status" className="px-4 mt-4">
+ <div className="aliasvault-spinner-inline">
+ <div className="cloud-shape-inline-enhanced">
+ <div className="dot-inline delay-1"></div>
+ <div className="dot-inline delay-2"></div>
+ <div className="dot-inline delay-3"></div>
+ <div className="dot-inline delay-4"></div>
+ </div>
+ </div>
+ <span className="sr-only">Loading...</span>
+ </div>
+);
+
+export default LoadingIndicator;
diff --git a/apps/web/src/components/loading/SkeletonBase.tsx b/apps/web/src/components/loading/SkeletonBase.tsx
new file mode 100644
index 000000000..11b3f81ba
--- /dev/null
+++ b/apps/web/src/components/loading/SkeletonBase.tsx
@@ -0,0 +1,19 @@
+import React from 'react';
+
+type SkeletonBaseProps = {
+ height?: number;
+ additionalClasses?: string;
+ children?: React.ReactNode;
+};
+
+/**
+ * Skeleton placeholder for loading states.
+ */
+const SkeletonBase: React.FC<SkeletonBaseProps> = ({ height = 60, additionalClasses = '', children }) => (
+ <div className={`skeleton-base ${additionalClasses}`} style={{ height: `${height}px` }}>
+ {children}
+ <div className="skeleton-shimmer"></div>
+ </div>
+);
+
+export default SkeletonBase;
diff --git a/apps/web/src/components/loading/SmallLoadingIndicator.tsx b/apps/web/src/components/loading/SmallLoadingIndicator.tsx
new file mode 100644
index 000000000..bfef02120
--- /dev/null
+++ b/apps/web/src/components/loading/SmallLoadingIndicator.tsx
@@ -0,0 +1,25 @@
+import React from 'react';
+
+type SmallLoadingIndicatorProps = {
+ title?: string;
+ spinning?: boolean;
+ children?: React.ReactNode;
+};
+
+/**
+ * Small circular spinner.
+ */
+const SmallLoadingIndicator: React.FC<SmallLoadingIndicatorProps> = ({ title = '', spinning = true, children }) => (
+ <div role="status" className="px-2 flex items-center" title={title}>
+ <div className="relative inline-flex items-center justify-center">
+ {children}
+ <svg aria-hidden="true" className={`inline w-8 h-8 text-gray-200 ${spinning ? 'animate-spin fill-primary-600' : ''} dark:text-gray-600`} viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor" />
+ <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill" />
+ </svg>
+ </div>
+ <span className="sr-only">Loading...</span>
+ </div>
+);
+
+export default SmallLoadingIndicator;
diff --git a/apps/web/src/components/settings/DefaultPasswordSettings.tsx b/apps/web/src/components/settings/DefaultPasswordSettings.tsx
new file mode 100644
index 000000000..a1211e763
--- /dev/null
+++ b/apps/web/src/components/settings/DefaultPasswordSettings.tsx
@@ -0,0 +1,38 @@
+import React, { useEffect, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import PasswordSettingsPopup from '@/components/settings/PasswordSettingsPopup';
+import { useDb } from '@/context/DbContext';
+
+import type { PasswordSettings } from '@aliasvault/models/vault';
+
+/**
+ * Button that opens the password generator settings popup for the vault defaults.
+ */
+const DefaultPasswordSettings: React.FC = () => {
+ const { t } = useTranslation();
+ const dbContext = useDb();
+ const [settings, setSettings] = useState<PasswordSettings | null>(null);
+ const [isVisible, setIsVisible] = useState(false);
+ const tk = 'components.main.settings.defaultPasswordSettings';
+
+ useEffect(() => {
+ setSettings(dbContext.sqliteClient?.settings.getPasswordSettings() ?? null);
+ }, [dbContext.sqliteClient]);
+
+ return (
+ <div className="mb-4">
+ <label htmlFor="password-generator-settings-modal" className="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{t(`${tk}.PasswordGeneratorSettingsLabel`)}</label>
+ <button type="button" id="password-generator-settings-modal" className="px-4 py-2 bg-primary-600 text-white rounded-md hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-primary-500 dark:bg-primary-700 dark:hover:bg-primary-600" onClick={() => setIsVisible(true)}>
+ {t(`${tk}.ConfigureButton`)}
+ </button>
+ <span className="block text-sm font-normal text-gray-500 truncate dark:text-gray-400 mt-2">{t(`${tk}.PasswordGeneratorSettingsDescription`)}</span>
+
+ {isVisible && settings && (
+ <PasswordSettingsPopup passwordSettings={settings} isTemporary={false} onSaveSettings={(saved) => setSettings(saved)} onClose={() => setIsVisible(false)} />
+ )}
+ </div>
+ );
+};
+
+export default DefaultPasswordSettings;
diff --git a/apps/web/src/components/shared/Breadcrumb.tsx b/apps/web/src/components/shared/Breadcrumb.tsx
new file mode 100644
index 000000000..e6a76bf9d
--- /dev/null
+++ b/apps/web/src/components/shared/Breadcrumb.tsx
@@ -0,0 +1,58 @@
+import React from 'react';
+import { Link } from 'react-router-dom';
+
+/**
+ * One breadcrumb entry.
+ */
+export type BreadcrumbItem = {
+ displayName: string;
+ /** Where the entry links to; the current page has none. */
+ url?: string;
+ /** Show the home icon (the first entry). */
+ showHomeIcon?: boolean;
+};
+
+/**
+ * Separator between breadcrumb entries.
+ */
+const ChevronIcon: React.FC = () => (
+ <svg className="w-6 h-6 text-gray-400 dark:text-gray-400" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fillRule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clipRule="evenodd"></path></svg>
+);
+
+/**
+ * Home icon of the first entry.
+ */
+const HomeIcon: React.FC<{ inline?: boolean }> = ({ inline = false }) => (
+ <svg className={`w-5 h-5 mr-2.5 ${inline ? 'inline' : ''}`} fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"></path></svg>
+);
+
+/**
+ * Breadcrumb trail.
+ */
+const Breadcrumb: React.FC<{ items: BreadcrumbItem[] }> = ({ items }) => (
+ <nav className="flex mb-4">
+ <ol className="inline-flex items-center space-x-1 text-sm font-medium md:space-x-2">
+ {items.map((item, index) => {
+ const isFirst = index === 0;
+ return (
+ <li key={`${item.displayName}-${index}`} className="inline-flex items-center">
+ {!isFirst && <ChevronIcon />}
+ {item.url !== undefined ? (
+ <Link to={item.url} className="inline-flex items-center text-gray-700 hover:text-primary-600 dark:text-gray-300 dark:hover:text-primary-500">
+ {isFirst && item.showHomeIcon && <HomeIcon />}
+ {item.displayName}
+ </Link>
+ ) : (
+ <span className="text-gray-400 dark:text-gray-400">
+ {isFirst && item.showHomeIcon && <HomeIcon inline />}
+ {item.displayName}
+ </span>
+ )}
+ </li>
+ );
+ })}
+ </ol>
+ </nav>
+);
+
+export default Breadcrumb;
diff --git a/apps/web/src/components/shared/Button.tsx b/apps/web/src/components/shared/Button.tsx
new file mode 100644
index 000000000..e5b9467e8
--- /dev/null
+++ b/apps/web/src/components/shared/Button.tsx
@@ -0,0 +1,50 @@
+import React from 'react';
+
+/** Button colors. */
+export type ButtonColor = 'primary' | 'secondary' | 'danger' | 'success';
+
+type ButtonProps = {
+ children: React.ReactNode;
+ onClick?: () => void;
+ isDisabled?: boolean;
+ type?: 'button' | 'submit' | 'reset';
+ color?: ButtonColor;
+ additionalClasses?: string;
+ display?: 'inline' | 'flex';
+ id?: string;
+};
+
+const BASE_CLASSES = 'center items-center px-3 py-2 text-sm font-medium text-white rounded-lg focus:outline-none focus:ring-4';
+const DISABLED_CLASSES = 'bg-gray-400 cursor-not-allowed';
+
+/**
+ * The color classes of a button.
+ * @param color - the color
+ */
+export const getButtonColorClasses = (color: ButtonColor): string => {
+ switch (color) {
+ case 'primary':
+ return 'bg-primary-700 hover:bg-primary-800 focus:ring-primary-300 dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800';
+ case 'danger':
+ return 'bg-red-700 hover:bg-red-800 focus:ring-red-300 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-800';
+ case 'success':
+ return 'bg-green-700 hover:bg-green-800 focus:ring-green-300 dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800';
+ default:
+ return 'bg-gray-700 hover:bg-gray-800 focus:ring-gray-300 dark:bg-gray-600 dark:hover:bg-gray-700 dark:focus:ring-gray-800';
+ }
+};
+
+/**
+ * Generic button (the shared Razor Button component).
+ */
+const Button: React.FC<ButtonProps> = ({ children, onClick, isDisabled = false, type = 'button', color = 'primary', additionalClasses = '', display = 'inline', id }) => {
+ const classes = `${display} ${BASE_CLASSES} ${getButtonColorClasses(color)} ${isDisabled ? DISABLED_CLASSES : ''} ${additionalClasses}`.trim();
+
+ return (
+ <button type={type} id={id} onClick={isDisabled ? undefined : onClick} disabled={isDisabled} className={classes}>
+ {children}
+ </button>
+ );
+};
+
+export default Button;
diff --git a/apps/web/src/components/shared/ConfirmModal.tsx b/apps/web/src/components/shared/ConfirmModal.tsx
new file mode 100644
index 000000000..e583eae59
--- /dev/null
+++ b/apps/web/src/components/shared/ConfirmModal.tsx
@@ -0,0 +1,42 @@
+import React from 'react';
+
+type ConfirmModalProps = {
+ title: string;
+ message: string;
+ confirmText: string;
+ cancelText: string;
+ onClose: (confirmed: boolean) => void;
+};
+
+/**
+ * Confirm dialog.
+ */
+const ConfirmModal: React.FC<ConfirmModalProps> = ({ title, message, confirmText, cancelText, onClose }) => (
+ <div id="confirm-modal" className="fixed inset-0 z-[1000] bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full flex items-center justify-center">
+ <div className="relative p-5 border w-96 shadow-lg rounded-md bg-white">
+ <div className="mt-3 text-center">
+ <h3 className="text-lg leading-6 font-medium text-gray-900">{title}</h3>
+ <div className="mt-2 px-7 py-3">
+ <p className="text-sm text-gray-500">
+ {message.split('\n').map((line, index) => (
+ <React.Fragment key={index}>
+ {index > 0 && <br />}
+ {line}
+ </React.Fragment>
+ ))}
+ </p>
+ </div>
+ <div className="items-center px-4 py-3">
+ <button id="confirmButton" className="px-4 py-2 bg-primary-500 text-white text-base font-medium rounded-md w-full shadow-sm hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-primary-300" onClick={() => onClose(true)}>
+ {confirmText}
+ </button>
+ <button id="cancelButton" className="mt-3 px-4 py-2 bg-gray-300 text-gray-800 text-base font-medium rounded-md w-full shadow-sm hover:bg-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-300" onClick={() => onClose(false)}>
+ {cancelText}
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
+);
+
+export default ConfirmModal;
diff --git a/apps/web/src/components/shared/DeleteAllSelectedButton.tsx b/apps/web/src/components/shared/DeleteAllSelectedButton.tsx
new file mode 100644
index 000000000..76357b5f2
--- /dev/null
+++ b/apps/web/src/components/shared/DeleteAllSelectedButton.tsx
@@ -0,0 +1,22 @@
+import React from 'react';
+
+import Button from '@/components/shared/Button';
+
+type DeleteAllSelectedButtonProps = {
+ onClick: () => void;
+ buttonText: string;
+};
+
+/**
+ * Danger button used for bulk deletes.
+ */
+const DeleteAllSelectedButton: React.FC<DeleteAllSelectedButtonProps> = ({ onClick, buttonText }) => (
+ <Button onClick={onClick} display="flex" color="danger">
+ <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path>
+ </svg>
+ <span className="ml-2">{buttonText}</span>
+ </Button>
+);
+
+export default DeleteAllSelectedButton;
diff --git a/apps/web/src/components/shared/FormModal.tsx b/apps/web/src/components/shared/FormModal.tsx
new file mode 100644
index 000000000..98f4f1bfd
--- /dev/null
+++ b/apps/web/src/components/shared/FormModal.tsx
@@ -0,0 +1,130 @@
+import React, { useEffect, useRef } from 'react';
+import { useTranslation } from 'react-i18next';
+
+type FormModalProps = {
+ isOpen: boolean;
+ title?: string;
+ icon?: React.ReactNode;
+ iconBackgroundClass?: string;
+ children?: React.ReactNode;
+ footerContent?: React.ReactNode;
+ showDefaultFooter?: boolean;
+ confirmText?: string;
+ cancelText?: string;
+ confirmDisabled?: boolean;
+ confirmButtonClass?: string;
+ isLoading?: boolean;
+ maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl';
+ closeOnOverlayClick?: boolean;
+ closeOnEscape?: boolean;
+ submitOnEnter?: boolean;
+ onClose: () => void;
+ onConfirm?: () => void;
+};
+
+/**
+ * The max width class of the modal panel.
+ * @param maxWidth - the size
+ */
+const getMaxWidthClass = (maxWidth: FormModalProps['maxWidth']): string => {
+ switch (maxWidth) {
+ case 'sm': return 'sm:max-w-sm';
+ case 'md': return 'sm:max-w-md';
+ case 'xl': return 'sm:max-w-xl';
+ case '2xl': return 'sm:max-w-2xl';
+ default: return 'sm:max-w-lg';
+ }
+};
+
+/**
+ * Generic modal for forms and content.
+ */
+const FormModal: React.FC<FormModalProps> = ({
+ isOpen, title = '', icon, iconBackgroundClass = 'bg-orange-100 dark:bg-orange-900/30', children, footerContent, showDefaultFooter = true,
+ confirmText, cancelText, confirmDisabled = false, confirmButtonClass = 'bg-primary-600 hover:bg-primary-700', isLoading = false, maxWidth = 'lg',
+ closeOnOverlayClick = true, closeOnEscape = true, submitOnEnter = true, onClose, onConfirm,
+}) => {
+ const { t } = useTranslation();
+ const panelRef = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ if (isOpen) {
+ panelRef.current?.focus();
+ }
+ }, [isOpen]);
+
+ if (!isOpen) {
+ return null;
+ }
+
+ /**
+ * Escape closes, Enter confirms.
+ */
+ const handleKeyDown = (e: React.KeyboardEvent): void => {
+ if (e.key === 'Escape' && closeOnEscape) {
+ onClose();
+ } else if (e.key === 'Enter' && submitOnEnter && !confirmDisabled && !isLoading && onConfirm) {
+ onConfirm();
+ }
+ };
+
+ return (
+ <div className="fixed inset-0 z-50 overflow-y-auto">
+ <div className="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
+ <div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity dark:bg-gray-900 dark:bg-opacity-75" onClick={() => closeOnOverlayClick && onClose()}></div>
+
+ <div ref={panelRef} onKeyDown={handleKeyDown} tabIndex={0} className={`relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full ${getMaxWidthClass(maxWidth)} dark:bg-gray-800`}>
+ <div className="bg-white px-4 pb-4 pt-5 sm:p-6 dark:bg-gray-800">
+ <div className="sm:flex sm:items-start">
+ {icon && (
+ <div className={`mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full ${iconBackgroundClass} sm:mx-0 sm:h-10 sm:w-10`}>
+ {icon}
+ </div>
+ )}
+ <div className={`${icon ? 'mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left' : ''} flex-1`}>
+ {title && (
+ <h3 className="text-lg font-semibold leading-6 text-gray-900 dark:text-white">
+ {title}
+ </h3>
+ )}
+ <div className={title ? 'mt-4' : ''}>
+ {children}
+ </div>
+ </div>
+ </div>
+ </div>
+
+ {footerContent ? (
+ <div className="bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6 gap-2 dark:bg-gray-800/50">
+ {footerContent}
+ </div>
+ ) : showDefaultFooter && (
+ <div className="bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6 gap-2 dark:bg-gray-800/50">
+ <button
+ type="button"
+ onClick={onConfirm}
+ disabled={isLoading || confirmDisabled}
+ className={`inline-flex w-full justify-center rounded-md ${confirmButtonClass} px-3 py-2 text-sm font-semibold text-white shadow-sm sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed`}>
+ {isLoading && (
+ <svg className="animate-spin -ml-1 mr-2 h-4 w-4 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
+ <circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
+ <path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
+ </svg>
+ )}
+ {confirmText ?? t('sharedResources.Confirm')}
+ </button>
+ <button
+ type="button"
+ onClick={onClose}
+ className="mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto dark:bg-gray-700 dark:text-white dark:ring-gray-600 dark:hover:bg-gray-600">
+ {cancelText ?? t('sharedResources.Cancel')}
+ </button>
+ </div>
+ )}
+ </div>
+ </div>
+ </div>
+ );
+};
+
+export default FormModal;
diff --git a/apps/web/src/components/shared/H1.tsx b/apps/web/src/components/shared/H1.tsx
new file mode 100644
index 000000000..40002c460
--- /dev/null
+++ b/apps/web/src/components/shared/H1.tsx
@@ -0,0 +1,10 @@
+import React from 'react';
+
+/**
+ * Page heading.
+ */
+const H1: React.FC<{ children: React.ReactNode }> = ({ children }) => (
+ <h1 className="text-xl font-semibold text-gray-900 sm:text-2xl dark:text-white">{children}</h1>
+);
+
+export default H1;
diff --git a/apps/web/src/components/shared/LinkButton.tsx b/apps/web/src/components/shared/LinkButton.tsx
new file mode 100644
index 000000000..55773a5b1
--- /dev/null
+++ b/apps/web/src/components/shared/LinkButton.tsx
@@ -0,0 +1,32 @@
+import React from 'react';
+import { Link } from 'react-router-dom';
+
+import { type ButtonColor, getButtonColorClasses } from '@/components/shared/Button';
+
+type LinkButtonProps = {
+ href: string;
+ text: string;
+ /** Shorter text shown on small screens. */
+ smallText?: string;
+ color?: ButtonColor;
+ additionalClasses?: string;
+};
+
+/** Base classes. */
+const BASE_CLASSES = 'inline center items-center px-3 py-2 text-sm font-medium text-white rounded-lg focus:outline-none focus:ring-4';
+
+/**
+ * A link styled as a button.
+ */
+const LinkButton: React.FC<LinkButtonProps> = ({ href, text, smallText = '', color = 'primary', additionalClasses = '' }) => (
+ <Link to={href} className={`${BASE_CLASSES} ${getButtonColorClasses(color)} ${additionalClasses}`.trim()}>
+ {smallText.length > 0 ? (
+ <>
+ <span className="md:hidden">{smallText}</span>
+ <span className="hidden md:inline">{text}</span>
+ </>
+ ) : text}
+ </Link>
+);
+
+export default LinkButton;
diff --git a/apps/web/src/components/shared/ModalHeaderAction.tsx b/apps/web/src/components/shared/ModalHeaderAction.tsx
new file mode 100644
index 000000000..cfdc9356f
--- /dev/null
+++ b/apps/web/src/components/shared/ModalHeaderAction.tsx
@@ -0,0 +1,25 @@
+import React from 'react';
+
+type ModalHeaderActionProps = {
+ children: React.ReactNode;
+ title?: string;
+ onClick: () => void;
+ variant?: 'default' | 'danger';
+};
+
+/**
+ * A single action button in the action cluster of a modal header.
+ */
+const ModalHeaderAction: React.FC<ModalHeaderActionProps> = ({ children, title, onClick, variant = 'default' }) => {
+ const buttonClass = variant === 'danger'
+ ? 'inline-flex items-center justify-center h-9 min-w-[2.25rem] px-2 rounded text-sm font-medium text-red-500 hover:text-red-600 hover:bg-gray-100 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-gray-700'
+ : 'inline-flex items-center justify-center h-9 min-w-[2.25rem] px-2 rounded text-sm font-medium text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700';
+
+ return (
+ <button type="button" onClick={onClick} title={title} className={buttonClass}>
+ {children}
+ </button>
+ );
+};
+
+export default ModalHeaderAction;
diff --git a/apps/web/src/components/shared/PageContent.tsx b/apps/web/src/components/shared/PageContent.tsx
new file mode 100644
index 000000000..f2a18927c
--- /dev/null
+++ b/apps/web/src/components/shared/PageContent.tsx
@@ -0,0 +1,12 @@
+import React from 'react';
+
+/**
+ * Page body wrapper with a minimum height so header dropdowns are not clipped on short pages.
+ */
+const PageContent: React.FC<{ children: React.ReactNode; className?: string }> = ({ children, className = '' }) => (
+ <div className={`min-h-[350px] ${className}`}>
+ {children}
+ </div>
+);
+
+export default PageContent;
diff --git a/apps/web/src/components/shared/PageHeader.tsx b/apps/web/src/components/shared/PageHeader.tsx
new file mode 100644
index 000000000..85b13c15f
--- /dev/null
+++ b/apps/web/src/components/shared/PageHeader.tsx
@@ -0,0 +1,40 @@
+import React from 'react';
+import { useTranslation } from 'react-i18next';
+
+import Breadcrumb, { type BreadcrumbItem } from '@/components/shared/Breadcrumb';
+import H1 from '@/components/shared/H1';
+
+type PageHeaderProps = {
+ breadcrumbItems?: BreadcrumbItem[];
+ title: string;
+ description?: string;
+ titleActions?: React.ReactNode;
+ customActions?: React.ReactNode;
+};
+
+/**
+ * Page header with breadcrumbs, title, description and actions.
+ */
+const PageHeader: React.FC<PageHeaderProps> = ({ breadcrumbItems = [], title, description = '', titleActions, customActions }) => {
+ const { t } = useTranslation();
+ const items: BreadcrumbItem[] = [{ displayName: t('sharedResources.Home'), url: '/', showHomeIcon: true }, ...breadcrumbItems];
+
+ return (
+ <div className="grid grid-cols-1 px-4 pt-6 xl:grid-cols-3 xl:gap-4 dark:bg-gray-900">
+ <div className="mb-4 col-span-full xl:mb-2">
+ <Breadcrumb items={items} />
+ <div className="flex flex-row items-center justify-between gap-4">
+ {titleActions ?? <H1>{title}</H1>}
+ {customActions && (
+ <div className="flex flex-wrap items-center gap-2">
+ {customActions}
+ </div>
+ )}
+ </div>
+ <p className="text-sm text-gray-600 dark:text-gray-400 mt-2">{description}</p>
+ </div>
+ </div>
+ );
+};
+
+export default PageHeader;
diff --git a/apps/web/src/components/shared/PasswordConfirmationModal.tsx b/apps/web/src/components/shared/PasswordConfirmationModal.tsx
new file mode 100644
index 000000000..b5d34b2d8
--- /dev/null
+++ b/apps/web/src/components/shared/PasswordConfirmationModal.tsx
@@ -0,0 +1,79 @@
+import React, { useEffect, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import AlertMessageError from '@/components/alerts/AlertMessageError';
+import PasswordInputField from '@/components/auth/PasswordInputField';
+import FormModal from '@/components/shared/FormModal';
+
+type PasswordConfirmationModalProps = {
+ isOpen: boolean;
+ title: string;
+ description: string;
+ errorMessage?: string;
+ onPasswordSubmitted: (password: string) => void;
+ onClose: () => void;
+};
+
+/**
+ * Asks for the master password before a sensitive action.
+ */
+const PasswordConfirmationModal: React.FC<PasswordConfirmationModalProps> = ({ isOpen, title, description, errorMessage = '', onPasswordSubmitted, onClose }) => {
+ const { t } = useTranslation();
+ const tk = 'components.main.shared.passwordConfirmationModal';
+ const [password, setPassword] = useState('');
+
+ // Start empty every time the modal opens.
+ useEffect(() => {
+ if (isOpen) {
+ setPassword('');
+ }
+ }, [isOpen]);
+
+ /**
+ * Hand the password to the parent.
+ */
+ const handleConfirm = (): void => {
+ if (password.length === 0) {
+ return;
+ }
+ onPasswordSubmitted(password);
+ setPassword('');
+ };
+
+ /**
+ * Close without submitting.
+ */
+ const handleClose = (): void => {
+ setPassword('');
+ onClose();
+ };
+
+ return (
+ <FormModal
+ isOpen={isOpen}
+ title={title}
+ maxWidth="sm"
+ confirmText={t(`${tk}.ConfirmButton`)}
+ cancelText={t('sharedResources.Cancel')}
+ confirmDisabled={password.length === 0}
+ onConfirm={handleConfirm}
+ onClose={handleClose}
+ submitOnEnter={true}
+ icon={(
+ <svg className="h-6 w-6 text-orange-600 dark:text-orange-400" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor">
+ <path strokeLinecap="round" strokeLinejoin="round" d="M16.5 10.5V6.75a4.5 4.5 0 10-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 002.25-2.25v-6.75a2.25 2.25 0 00-2.25-2.25H6.75a2.25 2.25 0 00-2.25 2.25v6.75a2.25 2.25 0 002.25 2.25z" />
+ </svg>
+ )}>
+ <p className="text-sm text-gray-500 dark:text-gray-400 mb-4">{description}</p>
+
+ {errorMessage.length > 0 && <AlertMessageError message={errorMessage} hasTopMargin={false} />}
+
+ <div className="mt-4">
+ <label htmlFor="password-confirm" className="block text-sm font-medium text-gray-900 dark:text-white mb-2">{t('sharedResources.Password')}</label>
+ <PasswordInputField id="password-confirm" value={password} onValueChange={setPassword} placeholder={t(`${tk}.EnterPasswordPlaceholder`)} autoFocus={true} />
+ </div>
+ </FormModal>
+ );
+};
+
+export default PasswordConfirmationModal;
diff --git a/apps/web/src/components/shared/PasswordStrengthIndicator.tsx b/apps/web/src/components/shared/PasswordStrengthIndicator.tsx
new file mode 100644
index 000000000..1b337ebe6
--- /dev/null
+++ b/apps/web/src/components/shared/PasswordStrengthIndicator.tsx
@@ -0,0 +1,54 @@
+import React from 'react';
+import { useTranslation } from 'react-i18next';
+
+/** Passwords shorter than this are rejected; it is also where the strength scale reaches "Fair". */
+export const MIN_PASSWORD_LENGTH = 12;
+
+/**
+ * Strength score of a password, 0 to 4, by length.
+ */
+export function getPasswordStrength(password: string): number {
+ const length = password.length;
+ if (length < 8) {
+ return 0;
+ }
+ if (length < MIN_PASSWORD_LENGTH) {
+ return 1;
+ }
+ if (length < 16) {
+ return 2;
+ }
+ if (length < 20) {
+ return 3;
+ }
+ return 4;
+}
+
+const LABEL_KEYS = ['StrengthVeryWeak', 'StrengthWeak', 'StrengthFair', 'StrengthGood', 'StrengthStrong'];
+const BAR_CLASSES = ['bg-orange-400 dark:bg-orange-500', 'bg-yellow-500 dark:bg-yellow-600', 'bg-green-500 dark:bg-green-600', 'bg-green-600 dark:bg-green-700', 'bg-green-700 dark:bg-green-800'];
+const TEXT_CLASSES = ['text-orange-600 dark:text-orange-400', 'text-yellow-600 dark:text-yellow-400', 'text-green-600 dark:text-green-400', 'text-green-700 dark:text-green-300', 'text-green-800 dark:text-green-200'];
+
+/**
+ * Bar showing how strong a password is.
+ */
+const PasswordStrengthIndicator: React.FC<{ password: string }> = ({ password }) => {
+ const { t } = useTranslation();
+ if (password.length === 0) {
+ return null;
+ }
+ const strength = getPasswordStrength(password);
+
+ return (
+ <div className="mt-3">
+ <div className="flex items-center justify-between mb-2">
+ <span className="text-xs font-medium text-gray-700 dark:text-gray-300">{t('components.main.shared.passwordStrengthIndicator.PasswordStrength')}</span>
+ <span className={`text-xs font-semibold ${TEXT_CLASSES[strength]}`}>{t(`components.main.shared.passwordStrengthIndicator.${LABEL_KEYS[strength]}`)}</span>
+ </div>
+ <div className="w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2.5 overflow-hidden shadow-inner">
+ <div className={`h-2.5 rounded-full transition-all duration-500 ease-out ${BAR_CLASSES[strength]}`} style={{ width: `${(strength + 1) * 20}%` }}></div>
+ </div>
+ </div>
+ );
+};
+
+export default PasswordStrengthIndicator;
diff --git a/apps/web/src/components/shared/RefreshButton.tsx b/apps/web/src/components/shared/RefreshButton.tsx
new file mode 100644
index 000000000..e865de732
--- /dev/null
+++ b/apps/web/src/components/shared/RefreshButton.tsx
@@ -0,0 +1,49 @@
+import React, { useCallback, useEffect, useRef, useState } from 'react';
+
+import Button, { type ButtonColor } from '@/components/shared/Button';
+
+type RefreshButtonProps = {
+ onClick: () => void | Promise<void>;
+ buttonText: string;
+ color?: ButtonColor;
+ additionalClasses?: string;
+};
+
+/**
+ * Refresh button that spins its icon for a moment after being clicked.
+ */
+const RefreshButton: React.FC<RefreshButtonProps> = ({ onClick, buttonText, color = 'primary', additionalClasses = '' }) => {
+ const [isRefreshing, setIsRefreshing] = useState(false);
+ const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
+
+ useEffect(() => {
+ return (): void => {
+ if (timerRef.current) {
+ clearTimeout(timerRef.current);
+ }
+ };
+ }, []);
+
+ /**
+ * Run the click handler and keep the icon spinning for half a second.
+ */
+ const handleClick = useCallback(async (): Promise<void> => {
+ if (isRefreshing) {
+ return;
+ }
+ setIsRefreshing(true);
+ await onClick();
+ timerRef.current = setTimeout(() => setIsRefreshing(false), 500);
+ }, [isRefreshing, onClick]);
+
+ return (
+ <Button onClick={handleClick} isDisabled={isRefreshing} display="flex" color={color} additionalClasses={additionalClasses}>
+ <svg className={`w-4 h-4 ${isRefreshing ? 'animate-spin-ccw' : ''}`} fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path>
+ </svg>
+ <span className="ml-2">{buttonText}</span>
+ </Button>
+ );
+};
+
+export default RefreshButton;
diff --git a/apps/web/src/components/shared/ResponsivePaginator.tsx b/apps/web/src/components/shared/ResponsivePaginator.tsx
new file mode 100644
index 000000000..a8c631cd6
--- /dev/null
+++ b/apps/web/src/components/shared/ResponsivePaginator.tsx
@@ -0,0 +1,85 @@
+import React from 'react';
+
+type ResponsivePaginatorProps = {
+ currentPage: number;
+ pageSize: number;
+ totalRecords: number;
+ onPageChanged: (page: number) => void;
+};
+
+/**
+ * Paginator with numbered pages on desktop and prev/next on mobile.
+ */
+const ResponsivePaginator: React.FC<ResponsivePaginatorProps> = ({ currentPage, pageSize, totalRecords, onPageChanged }) => {
+ const pageCount = Math.ceil(totalRecords / pageSize);
+
+ if (totalRecords <= pageSize) {
+ return null;
+ }
+
+ /**
+ * Go to a page, clamped to the valid range.
+ */
+ const setPage = (pageNumber: number): void => {
+ onPageChanged(Math.min(Math.max(pageNumber, 1), pageCount));
+ };
+
+ const pages = Array.from({ length: pageCount }, (_, i) => i + 1).filter(i => i === 1 || i === pageCount || Math.abs(currentPage - i) <= 2);
+ const pillClasses = 'px-3 py-2 bg-primary-100 text-primary-700 border border-primary-300 rounded hover:bg-primary-200 transition duration-300 shadow-sm';
+
+ return (
+ <>
+ <div className="hidden md:block">
+ <nav aria-label="Page navigation" className="mt-4 flex justify-end mb-5">
+ <ul className="flex space-x-2">
+ <li className={currentPage === 1 ? 'opacity-50 cursor-not-allowed' : ''}>
+ <a className={pillClasses} href="#" onClick={(e) => {
+ e.preventDefault(); setPage(currentPage - 1);
+ }}>Previous</a>
+ </li>
+ {pages.map(pageNum => (
+ <li key={pageNum}>
+ <a className={`px-3 py-2 ${currentPage === pageNum ? 'bg-primary-600 text-white' : 'bg-primary-100 text-primary-700'} border border-primary-300 rounded hover:bg-primary-200 transition duration-300 shadow-sm`} href="#" onClick={(e) => {
+ e.preventDefault(); setPage(pageNum);
+ }}>{pageNum}</a>
+ </li>
+ ))}
+ <li className={currentPage === pageCount ? 'opacity-50 cursor-not-allowed' : ''}>
+ <a className={pillClasses} href="#" onClick={(e) => {
+ e.preventDefault(); setPage(currentPage + 1);
+ }}>Next</a>
+ </li>
+ </ul>
+ </nav>
+ </div>
+
+ <div className="block md:hidden">
+ <nav aria-label="Page navigation" className="mt-4 flex justify-center mb-5">
+ <ul className="flex items-center space-x-2">
+ <li className={currentPage === 1 ? 'opacity-50 cursor-not-allowed' : ''}>
+ <button onClick={() => setPage(currentPage - 1)} disabled={currentPage === 1} className={`${pillClasses} disabled:opacity-50 disabled:cursor-not-allowed`}>
+ <svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
+ <path fillRule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clipRule="evenodd" />
+ </svg>
+ </button>
+ </li>
+ <li>
+ <span className="px-3 py-2 bg-primary-600 text-white border border-primary-300 rounded shadow-sm">
+ {currentPage} / {pageCount}
+ </span>
+ </li>
+ <li className={currentPage === pageCount ? 'opacity-50 cursor-not-allowed' : ''}>
+ <button onClick={() => setPage(currentPage + 1)} disabled={currentPage === pageCount} className={`${pillClasses} disabled:opacity-50 disabled:cursor-not-allowed`}>
+ <svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
+ <path fillRule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clipRule="evenodd" />
+ </svg>
+ </button>
+ </li>
+ </ul>
+ </nav>
+ </div>
+ </>
+ );
+};
+
+export default ResponsivePaginator;
diff --git a/apps/web/src/components/shared/SortableTable.tsx b/apps/web/src/components/shared/SortableTable.tsx
new file mode 100644
index 000000000..1e714784f
--- /dev/null
+++ b/apps/web/src/components/shared/SortableTable.tsx
@@ -0,0 +1,111 @@
+import React from 'react';
+
+/** Sort direction. */
+export type SortDirection = 'asc' | 'desc';
+
+/** A table column. */
+export type TableColumn = {
+ title: string;
+ propertyName?: string;
+ sortable?: boolean;
+};
+
+type SortableTableProps = {
+ columns: TableColumn[];
+ sortColumn: string;
+ sortDirection: SortDirection;
+ onSortChanged: (column: string, direction: SortDirection) => void;
+ children: React.ReactNode;
+};
+
+/**
+ * Table with sortable column headers.
+ */
+const SortableTable: React.FC<SortableTableProps> = ({ columns, sortColumn, sortDirection, onSortChanged, children }) => {
+ /**
+ * Toggle or switch the sort column.
+ */
+ const onSort = (columnName: string): void => {
+ if (sortColumn === columnName) {
+ onSortChanged(columnName, sortDirection === 'asc' ? 'desc' : 'asc');
+ } else {
+ onSortChanged(columnName, 'asc');
+ }
+ };
+
+ return (
+ <div className="rounded-lg border border-gray-200 dark:border-gray-700 shadow-sm overflow-x-auto">
+ <table className="w-full text-sm text-left text-gray-500 dark:text-gray-400 min-w-max">
+ <thead className="text-xs text-gray-700 bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
+ <tr>
+ {columns.map((column, index) => (
+ <th key={column.propertyName ?? index} scope="col" className="px-4 py-3">
+ {column.sortable !== false && column.propertyName ? (
+ <button className="flex items-center hover:text-gray-900 dark:hover:text-white" onClick={() => onSort(column.propertyName!)}>
+ {column.title}
+ <span className="ml-1">
+ {sortColumn === column.propertyName && (
+ sortDirection === 'asc' ? (
+ <svg className="w-3 h-3" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
+ <path fillRule="evenodd" d="M5.293 7.707a1 1 0 010-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 01-1.414 1.414L11 5.414V17a1 1 0 11-2 0V5.414L6.707 7.707a1 1 0 01-1.414 0z" clipRule="evenodd"></path>
+ </svg>
+ ) : (
+ <svg className="w-3 h-3" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
+ <path fillRule="evenodd" d="M14.707 12.293a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 111.414-1.414L9 14.586V3a1 1 0 012 0v11.586l2.293-2.293a1 1 0 011.414 0z" clipRule="evenodd"></path>
+ </svg>
+ )
+ )}
+ </span>
+ </button>
+ ) : column.title}
+ </th>
+ ))}
+ </tr>
+ </thead>
+ <tbody className="bg-white divide-y divide-gray-200 dark:bg-gray-800 dark:divide-gray-700">
+ {children}
+ </tbody>
+ </table>
+ </div>
+ );
+};
+
+type SortableTableRowProps = {
+ children: React.ReactNode;
+ className?: string;
+ onClick?: () => void;
+ onContextMenu?: (e: React.MouseEvent) => void;
+};
+
+/**
+ * A table row.
+ */
+export const SortableTableRow: React.FC<SortableTableRowProps> = ({ children, className = '', onClick, onContextMenu }) => (
+ <tr
+ onClick={onClick}
+ onContextMenu={onContextMenu ? (e: React.MouseEvent): void => {
+ e.preventDefault();
+ onContextMenu(e);
+ } : undefined}
+ className={`bg-white border-b dark:bg-gray-800 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700 ${onClick ? 'cursor-pointer' : ''} ${className}`}>
+ {children}
+ </tr>
+);
+
+type SortableTableColumnProps = {
+ children?: React.ReactNode;
+ isPrimary?: boolean;
+ title?: string;
+ padding?: boolean;
+};
+
+/**
+ * A table cell.
+ */
+export const SortableTableColumn: React.FC<SortableTableColumnProps> = ({ children, isPrimary = false, title, padding = true }) => (
+ <td className={`${padding ? 'px-4 py-3' : ''} ${isPrimary ? 'font-medium text-gray-900 dark:text-gray-200' : 'text-gray-500 dark:text-gray-400'}`} title={title}>
+ {children}
+ </td>
+);
+
+export default SortableTable;
diff --git a/apps/web/src/components/shared/StatusPill.tsx b/apps/web/src/components/shared/StatusPill.tsx
new file mode 100644
index 000000000..992174e65
--- /dev/null
+++ b/apps/web/src/components/shared/StatusPill.tsx
@@ -0,0 +1,32 @@
+import React from 'react';
+
+type StatusPillProps = {
+ enabled: boolean;
+ textTrue?: string;
+ textFalse?: string;
+ color?: 'green' | 'yellow' | 'red' | 'gray';
+};
+
+/**
+ * Small colored status label.
+ */
+const StatusPill: React.FC<StatusPillProps> = ({ enabled, textTrue = 'Enabled', textFalse = 'Disabled', color }) => {
+ /**
+ * The color classes of the pill.
+ */
+ const pillClass = (): string => {
+ if (color) {
+ switch (color) {
+ case 'green': return 'bg-green-100 text-green-800';
+ case 'yellow': return 'bg-yellow-100 text-yellow-800';
+ case 'red': return 'bg-red-100 text-red-800';
+ default: return 'bg-gray-100 text-gray-800';
+ }
+ }
+ return enabled ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800';
+ };
+
+ return <span className={`${pillClass()} px-2 py-1 text-xs font-medium rounded-full`}>{enabled ? textTrue : textFalse}</span>;
+};
+
+export default StatusPill;
diff --git a/apps/web/src/components/shared/StickyActionBar.tsx b/apps/web/src/components/shared/StickyActionBar.tsx
new file mode 100644
index 000000000..2f8b48ee7
--- /dev/null
+++ b/apps/web/src/components/shared/StickyActionBar.tsx
@@ -0,0 +1,52 @@
+import React, { useEffect, useState } from 'react';
+
+type StickyActionBarProps = {
+ children: React.ReactNode;
+ /** Scroll offset in pixels past which the bar shows. */
+ scrollThreshold?: number;
+};
+
+/**
+ * Action bar fixed to the bottom of the viewport, shown once the page is scrolled past a threshold.
+ */
+const StickyActionBar: React.FC<StickyActionBarProps> = ({ children, scrollThreshold = 75 }) => {
+ const [isVisible, setIsVisible] = useState(false);
+
+ useEffect(() => {
+ /**
+ * Show the bar when the page can scroll and is scrolled down.
+ */
+ const checkScroll = (): void => {
+ const scrollY = window.scrollY || document.documentElement.scrollTop;
+ const canScroll = document.documentElement.scrollHeight > window.innerHeight + 50;
+ setIsVisible(canScroll && scrollY > scrollThreshold);
+ };
+ window.addEventListener('scroll', checkScroll);
+ window.addEventListener('resize', checkScroll);
+ const timer = setTimeout(checkScroll, 100);
+ return (): void => {
+ window.removeEventListener('scroll', checkScroll);
+ window.removeEventListener('resize', checkScroll);
+ clearTimeout(timer);
+ };
+ }, [scrollThreshold]);
+
+ if (!isVisible) {
+ return null;
+ }
+
+ return (
+ <div className="sticky-action-bar-wrapper">
+ <div className="h-20"></div>
+ <div className="fixed bottom-0 left-0 right-0 z-30 bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 shadow-lg">
+ <div className="max-w-screen-2xl mx-auto px-4 py-3">
+ <div className="flex flex-wrap items-center justify-end gap-2">
+ {children}
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+};
+
+export default StickyActionBar;