Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add popout button to the credential and email pages via new methods (#953)
Leendert de Borst7b1cfd363c64
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/CredentialDetails.tsx b/apps/browser-extension/src/entrypoints/popup/pages/CredentialDetails.tsxindex 332d69df0..95b557d00 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/CredentialDetails.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/CredentialDetails.tsx@@ -14,6 +14,7 @@ import { HeaderIconType } from '@/entrypoints/popup/components/Icons/HeaderIconsimport { useDb } from '@/entrypoints/popup/context/DbContext';import { useHeaderButtons } from '@/entrypoints/popup/context/HeaderButtonsContext';import { useLoading } from '@/entrypoints/popup/context/LoadingContext';+import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';import type { Credential } from '@/utils/dist/shared/models/vault';@@ -28,30 +29,11 @@ const CredentialDetails: React.FC = (): React.ReactElement => {const { setIsInitialLoading } = useLoading();const { setHeaderButtons } = useHeaderButtons();- /**- * Check if the current page is an expanded popup.- */- const isPopup = (): boolean => {- const urlParams = new URLSearchParams(window.location.search);- return urlParams.get('expanded') === 'true';- };-/*** Open the credential details in a new expanded popup.*/const openInNewPopup = useCallback((): void => {- const width = 800;- const height = 1000;- const left = window.screen.width / 2 - width / 2;- const top = window.screen.height / 2 - height / 2;-- window.open(- `popup.html?expanded=true#/credentials/${id}`,- 'CredentialDetails',- `width=${width},height=${height},left=${left},top=${top},popup=true`- );-- window.close();+ PopoutUtility.openInNewPopup(`/credentials/${id}`);}, [id]);/**@@ -62,7 +44,7 @@ const CredentialDetails: React.FC = (): React.ReactElement => {}, [id, navigate]);useEffect(() => {- if (isPopup()) {+ if (PopoutUtility.isPopup()) {window.history.replaceState({}, '', `popup.html#/credentials`);window.history.pushState({}, '', `popup.html#/credentials/${id}`);}@@ -89,11 +71,13 @@ const CredentialDetails: React.FC = (): React.ReactElement => {useEffect((): (() => void) => {const headerButtonsJSX = (<div className="flex items-center gap-2">- <HeaderButton- onClick={openInNewPopup}- title="Open in new window"- iconType={HeaderIconType.EXPAND}- />+ {!PopoutUtility.isPopup() && (+ <HeaderButton+ onClick={openInNewPopup}+ title="Open in new window"+ iconType={HeaderIconType.EXPAND}+ />+ )}<HeaderButtononClick={handleEdit}title="Edit credential"diff --git a/apps/browser-extension/src/entrypoints/popup/pages/CredentialsList.tsx b/apps/browser-extension/src/entrypoints/popup/pages/CredentialsList.tsxindex 46c80a719..55f206108 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/CredentialsList.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/CredentialsList.tsx@@ -11,6 +11,7 @@ import { useHeaderButtons } from '@/entrypoints/popup/context/HeaderButtonsConteimport { useLoading } from '@/entrypoints/popup/context/LoadingContext';import { useWebApi } from '@/entrypoints/popup/context/WebApiContext';import { useVaultSync } from '@/entrypoints/popup/hooks/useVaultSync';+import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';import type { Credential } from '@/utils/dist/shared/models/vault';@@ -92,6 +93,13 @@ const CredentialsList: React.FC = () => {useEffect((): (() => void) => {const headerButtonsJSX = (<div className="flex items-center gap-2">+ {!PopoutUtility.isPopup() && (+ <HeaderButton+ onClick={() => PopoutUtility.openInNewPopup()}+ title="Open in new window"+ iconType={HeaderIconType.EXPAND}+ />+ )}<HeaderButtononClick={handleAddCredential}title="Add new credential"diff --git a/apps/browser-extension/src/entrypoints/popup/pages/EmailDetails.tsx b/apps/browser-extension/src/entrypoints/popup/pages/EmailDetails.tsxindex 65ee36e25..eb8eecd2c 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/EmailDetails.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/EmailDetails.tsx@@ -8,6 +8,7 @@ import { useHeaderButtons } from '@/entrypoints/popup/context/HeaderButtonsConteimport { useLoading } from '@/entrypoints/popup/context/LoadingContext';import { useWebApi } from '@/entrypoints/popup/context/WebApiContext';import ConversionUtility from '@/entrypoints/popup/utils/ConversionUtility';+import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';import type { EmailAttachment, Email } from '@/utils/dist/shared/models/webapi';import EncryptionUtility from '@/utils/EncryptionUtility';@@ -35,7 +36,7 @@ const EmailDetails: React.FC = (): React.ReactElement => {useEffect(() => {// For popup windows, ensure we have proper history state for navigation- if (isPopup()) {+ if (PopoutUtility.isPopup()) {// Clear existing history and create fresh entrieswindow.history.replaceState({}, '', `popup.html#/emails`);window.history.pushState({}, '', `popup.html#/emails/${id}`);@@ -76,7 +77,7 @@ const EmailDetails: React.FC = (): React.ReactElement => {const handleDelete = useCallback(async () : Promise<void> => {try {await webApi.delete(`Email/${id}`);- if (isPopup()) {+ if (PopoutUtility.isPopup()) {window.close();} else {navigate('/emails');@@ -87,30 +88,10 @@ const EmailDetails: React.FC = (): React.ReactElement => {}, [id, webApi, navigate]);/**- * Check if the current page is an expanded popup.- */- const isPopup = () : boolean => {- const urlParams = new URLSearchParams(window.location.search);- return urlParams.get('expanded') === 'true';- };-- /**- * Open the credential details in a new expanded popup.+ * Open the email details in a new expanded popup.*/const openInNewPopup = useCallback((): void => {- const width = 800;- const height = 1000;- const left = window.screen.width / 2 - width / 2;- const top = window.screen.height / 2 - height / 2;-- window.open(- `popup.html?expanded=true#/emails/${id}`,- 'EmailDetails',- `width=${width},height=${height},left=${left},top=${top},popup=true`- );-- // Close the current tab- window.close();+ PopoutUtility.openInNewPopup(`/emails/${id}`);}, [id]);/**@@ -165,11 +146,13 @@ const EmailDetails: React.FC = (): React.ReactElement => {if (!headerButtonsConfigured) {const headerButtonsJSX = (<div className="flex items-center gap-2">- <HeaderButton- onClick={openInNewPopup}- title="Open in new window"- iconType={HeaderIconType.EXPAND}- />+ {!PopoutUtility.isPopup() && (+ <HeaderButton+ onClick={openInNewPopup}+ title="Open in new window"+ iconType={HeaderIconType.EXPAND}+ />+ )}<HeaderButtononClick={() => setShowDeleteModal(true)}title="Delete email"diff --git a/apps/browser-extension/src/entrypoints/popup/pages/EmailsList.tsx b/apps/browser-extension/src/entrypoints/popup/pages/EmailsList.tsxindex 81dd43ec3..7fb116c1e 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/EmailsList.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/EmailsList.tsx@@ -1,11 +1,15 @@import React, { useEffect, useState, useCallback } from 'react';import { Link } from 'react-router-dom';+import HeaderButton from '@/entrypoints/popup/components/HeaderButton';+import { HeaderIconType } from '@/entrypoints/popup/components/Icons/HeaderIcons';import LoadingSpinner from '@/entrypoints/popup/components/LoadingSpinner';import ReloadButton from '@/entrypoints/popup/components/ReloadButton';import { 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 type { MailboxBulkRequest, MailboxBulkResponse, MailboxEmail } from '@/utils/dist/shared/models/webapi';import EncryptionUtility from '@/utils/EncryptionUtility';@@ -18,6 +22,7 @@ import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';const EmailsList: React.FC = () => {const dbContext = useDb();const webApi = useWebApi();+ const { setHeaderButtons } = useHeaderButtons();const [error, setError] = useState<string | null>(null);const [emails, setEmails] = useState<MailboxEmail[]>([]);const { setIsInitialLoading } = useLoading();@@ -73,6 +78,23 @@ const EmailsList: React.FC = () => {loadEmails();}, [loadEmails]);+ // 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]);+/*** Formats the date display for emails*/diff --git a/apps/browser-extension/src/entrypoints/popup/pages/Settings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/Settings.tsxindex 0baa59540..543d5eb65 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/Settings.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/Settings.tsx@@ -6,6 +6,7 @@ import { HeaderIconType } from '@/entrypoints/popup/components/Icons/HeaderIconsimport { useAuth } from '@/entrypoints/popup/context/AuthContext';import { useHeaderButtons } from '@/entrypoints/popup/context/HeaderButtonsContext';import { useTheme } from '@/entrypoints/popup/context/ThemeContext';+import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';import { AppInfo } from '@/utils/AppInfo';import { DISABLED_SITES_KEY, GLOBAL_AUTOFILL_POPUP_ENABLED_KEY, GLOBAL_CONTEXT_MENU_ENABLED_KEY, TEMPORARY_DISABLED_SITES_KEY } from '@/utils/Constants';@@ -69,6 +70,20 @@ const Settings: React.FC = () => {useEffect((): (() => void) => {const headerButtonsJSX = (<div className="flex items-center gap-2">+ {!PopoutUtility.isPopup() && (+ <>+ <HeaderButton+ onClick={() => PopoutUtility.openInNewPopup()}+ title="Open in new window"+ iconType={HeaderIconType.EXPAND}+ />+ <HeaderButton+ onClick={() => PopoutUtility.openInNewTab()}+ title="Open in new tab"+ iconType={HeaderIconType.TAB}+ />+ </>+ )}<HeaderButtononClick={openClientTab}title="Open web app"