Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add popout button to login and unlock page (#953)
Leendert de Borst5e965d7b3fce
diff --git a/apps/browser-extension/src/entrypoints/popup/App.tsx b/apps/browser-extension/src/entrypoints/popup/App.tsxindex 24a94cfea..28ec36f39 100644--- a/apps/browser-extension/src/entrypoints/popup/App.tsx+++ b/apps/browser-extension/src/entrypoints/popup/App.tsx@@ -21,6 +21,7 @@ import Logout from '@/entrypoints/popup/pages/Logout';import Settings from '@/entrypoints/popup/pages/Settings';import Unlock from '@/entrypoints/popup/pages/Unlock';import UnlockSuccess from '@/entrypoints/popup/pages/UnlockSuccess';+import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';diff --git a/apps/browser-extension/src/entrypoints/popup/components/Icons/HeaderIcons.tsx b/apps/browser-extension/src/entrypoints/popup/components/Icons/HeaderIcons.tsxindex 450c538ce..8fb9d4d47 100644--- a/apps/browser-extension/src/entrypoints/popup/components/Icons/HeaderIcons.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/Icons/HeaderIcons.tsx@@ -8,7 +8,8 @@ export enum HeaderIconType {RELOAD = 'reload',EXTERNAL_LINK = 'external_link',SAVE = 'save',- PLUS = 'plus'+ PLUS = 'plus',+ TAB = 'tab'}type HeaderIconProps = {@@ -156,6 +157,28 @@ export const HeaderIcon: React.FC<HeaderIconProps> = ({ type, className = 'w-5 h><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" /></svg>+ ),+ [HeaderIconType.TAB]: (+ <svg+ className={className}+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth={2}+ d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2H5a2 2 0 00-2-2z"+ />+ <path+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth={2}+ d="M8 5a2 2 0 012-2h4a2 2 0 012 2v2H8V5z"+ />+ </svg>)};diff --git a/apps/browser-extension/src/entrypoints/popup/components/Layout/Header.tsx b/apps/browser-extension/src/entrypoints/popup/components/Layout/Header.tsxindex 82a827f9e..3704c9e37 100644--- a/apps/browser-extension/src/entrypoints/popup/components/Layout/Header.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/Layout/Header.tsx@@ -94,16 +94,19 @@ const Header: React.FC<HeaderProps> = ({<div className="flex items-center gap-2">{!authContext.isLoggedIn ? (- <button- id="settings"- onClick={(handleSettings)}- className="p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700"- >- <span className="sr-only">Settings</span>- <svg className="w-5 h-5" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">- <path fillRule="evenodd" d="M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z" clipRule="evenodd" />- </svg>- </button>+ <>+ {rightButtons}+ <button+ id="settings"+ onClick={(handleSettings)}+ className="p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700"+ >+ <span className="sr-only">Settings</span>+ <svg className="w-5 h-5" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">+ <path fillRule="evenodd" d="M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z" clipRule="evenodd" />+ </svg>+ </button>+ </>) : (rightButtons)}diff --git a/apps/browser-extension/src/entrypoints/popup/pages/Login.tsx b/apps/browser-extension/src/entrypoints/popup/pages/Login.tsxindex 8ab8f3a55..38e071531 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/Login.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/Login.tsx@@ -3,11 +3,15 @@ import { Buffer } from 'buffer';import React, { useEffect, useState } from 'react';import Button from '@/entrypoints/popup/components/Button';+import HeaderButton from '@/entrypoints/popup/components/HeaderButton';+import { HeaderIconType } from '@/entrypoints/popup/components/Icons/HeaderIcons';import LoginServerInfo from '@/entrypoints/popup/components/LoginServerInfo';import { useAuth } from '@/entrypoints/popup/context/AuthContext';import { useDb } from '@/entrypoints/popup/context/DbContext';+import { useHeaderButtons } from '@/entrypoints/popup/context/HeaderButtonsContext';import { useLoading } from '@/entrypoints/popup/context/LoadingContext';import { useWebApi } from '@/entrypoints/popup/context/WebApiContext';+import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';import SrpUtility from '@/entrypoints/popup/utils/SrpUtility';import { AppInfo } from '@/utils/AppInfo';@@ -25,6 +29,7 @@ import { storage } from '#imports';const Login: React.FC = () => {const authContext = useAuth();const dbContext = useDb();+ const { setHeaderButtons } = useHeaderButtons();const [credentials, setCredentials] = useState({username: '',password: '',@@ -58,6 +63,30 @@ const Login: React.FC = () => {loadClientUrl();}, [setIsInitialLoading]);+ // Set header buttons on mount and clear on unmount+ useEffect((): (() => void) => {+ const headerButtonsJSX = !PopoutUtility.isPopup() ? (+ <>+ <HeaderButton+ onClick={() => PopoutUtility.openInNewPopup()}+ title="Open in new window"+ iconType={HeaderIconType.EXPAND}+ />+ <HeaderButton+ onClick={() => PopoutUtility.openInNewTab()}+ title="Open in new tab"+ iconType={HeaderIconType.TAB}+ />+ </>+ ) : null;++ setHeaderButtons(headerButtonsJSX);++ return () => {+ setHeaderButtons(null);+ };+ }, [setHeaderButtons]);+/*** Handle submit*/@@ -235,7 +264,7 @@ const Login: React.FC = () => {if (twoFactorRequired) {return (- <div className="max-w-md">+ <div><form onSubmit={handleTwoFactorSubmit} className="bg-white dark:bg-gray-700 w-full shadow-md rounded px-8 pt-6 pb-8 mb-4">{error && (<div className="mb-4 text-red-500 dark:text-red-400 text-sm">@@ -292,7 +321,7 @@ const Login: React.FC = () => {}return (- <div className="max-w-md">+ <div><form onSubmit={handleSubmit} className="bg-white dark:bg-gray-700 w-full shadow-md rounded px-8 pt-6 pb-8 mb-4">{error && (<div className="mb-4 text-red-500 dark:text-red-400 text-sm">diff --git a/apps/browser-extension/src/entrypoints/popup/pages/Unlock.tsx b/apps/browser-extension/src/entrypoints/popup/pages/Unlock.tsxindex 3109e319d..b58d3d2e4 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/Unlock.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/Unlock.tsx@@ -4,10 +4,14 @@ import React, { useEffect, useState } from 'react';import { useNavigate } from 'react-router-dom';import Button from '@/entrypoints/popup/components/Button';+import HeaderButton from '@/entrypoints/popup/components/HeaderButton';+import { HeaderIconType } from '@/entrypoints/popup/components/Icons/HeaderIcons';import { useAuth } from '@/entrypoints/popup/context/AuthContext';import { useDb } from '@/entrypoints/popup/context/DbContext';+import { useHeaderButtons } from '@/entrypoints/popup/context/HeaderButtonsContext';import { useLoading } from '@/entrypoints/popup/context/LoadingContext';import { useWebApi } from '@/entrypoints/popup/context/WebApiContext';+import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';import SrpUtility from '@/entrypoints/popup/utils/SrpUtility';import { VAULT_LOCKED_DISMISS_UNTIL_KEY } from '@/utils/Constants';@@ -23,6 +27,7 @@ const Unlock: React.FC = () => {const authContext = useAuth();const dbContext = useDb();const navigate = useNavigate();+ const { setHeaderButtons } = useHeaderButtons();const webApi = useWebApi();const srpUtil = new SrpUtility(webApi);@@ -47,6 +52,23 @@ const Unlock: React.FC = () => {checkStatus();}, [webApi, authContext, setIsInitialLoading]);+ // Set header buttons on mount and clear on unmount+ useEffect((): (() => void) => {+ const headerButtonsJSX = !PopoutUtility.isPopup() ? (+ <HeaderButton+ onClick={() => PopoutUtility.openInNewPopup()}+ title="Open in new window"+ iconType={HeaderIconType.EXPAND}+ />+ ) : null;++ setHeaderButtons(headerButtonsJSX);++ return () => {+ setHeaderButtons(null);+ };+ }, [setHeaderButtons]);+/*** Handle submit*/@@ -101,7 +123,7 @@ const Unlock: React.FC = () => {};return (- <div className="max-w-md">+ <div><form onSubmit={handleSubmit} className="bg-white dark:bg-gray-700 w-full shadow-md rounded px-8 pt-6 pb-8 mb-4"><h2 className="text-2xl font-bold text-gray-900 dark:text-white break-all overflow-hidden mb-4">{authContext.username}</h2>diff --git a/apps/browser-extension/src/entrypoints/popup/utils/PopoutUtility.ts b/apps/browser-extension/src/entrypoints/popup/utils/PopoutUtility.tsnew file mode 100644index 000000000..4b99a44e2--- /dev/null+++ b/apps/browser-extension/src/entrypoints/popup/utils/PopoutUtility.ts@@ -0,0 +1,44 @@+/**+ * Utility class for handling popup window operations+ */+export class PopoutUtility {+ /**+ * Check if the current page is an expanded popup.+ * Uses both URL parameter detection and window width as fallback.+ */+ public static isPopup(): boolean {+ // Primary method: Check URL parameter+ const urlParams = new URLSearchParams(window.location.search);+ if (urlParams.get('expanded') === 'true') {+ return true;+ }++ /**+ * Fallback method: Check window width (popout windows are 800px wide)+ * Regular popup extension windows are typically narrower (around 375-400px)+ */+ return window.innerWidth > 390;+ }++ /**+ * Open the current page in a new expanded popup window.+ * @param path - The path to open in the popup (defaults to current path)+ */+ public static openInNewPopup(path?: string): void {+ const width = 800;+ const height = 1000;+ const left = window.screen.width / 2 - width / 2;+ const top = window.screen.height / 2 - height / 2;++ const currentPath = path || window.location.hash.replace('#', '');+ const popupUrl = `popup.html?expanded=true#${currentPath}`;++ window.open(+ popupUrl,+ 'AliasVaultPopup',+ `width=${width},height=${height},left=${left},top=${top},popup=true`+ );++ window.close();+ }+}