Skip to content

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

Add popout button to credential details page (#541)

Leendert de Borst48b6acb17408
diff --git a/browser-extensions/chrome/src/pages/CredentialDetails.tsx b/browser-extensions/chrome/src/pages/CredentialDetails.tsx
index b7e482dfd..fd3441d09 100644
--- a/browser-extensions/chrome/src/pages/CredentialDetails.tsx
+++ b/browser-extensions/chrome/src/pages/CredentialDetails.tsx
@@ -10,9 +10,37 @@ const CredentialDetails: React.FC = () => {
const navigate = useNavigate();
const dbContext = useDb();
const [credential, setCredential] = useState<Credential | null>(null);
- const [showPassword, setShowPassword] = useState(false);
+
+ const isPopup = () => {
+ const urlParams = new URLSearchParams(window.location.search);
+ return urlParams.get('popup') === 'true';
+ };
+
+ const openInNewPopup = () => {
+ const width = 380;
+ const height = 600;
+ const left = window.screen.width / 2 - width / 2;
+ const top = window.screen.height / 2 - height / 2;
+
+ window.open(
+ `index.html?popup=true#/credentials/${id}`,
+ 'CredentialDetails',
+ `width=${width},height=${height},left=${left},top=${top},popup=true`
+ );
+
+ // Close the current tab
+ window.close();
+ };
useEffect(() => {
+ // For popup windows, ensure we have proper history state for navigation
+ if (isPopup()) {
+ // Clear existing history and create fresh entries
+ console.log(window.location.href);
+ window.history.replaceState({}, '', `index.html#/credentials`);
+ window.history.pushState({}, '', `index.html#/credentials/${id}`);
+ }
+
if (!dbContext?.sqliteClient || !id) return;
try {
@@ -36,25 +64,41 @@ const CredentialDetails: React.FC = () => {
return (
<div className="">
<div className="space-y-6">
- <div className="flex items-center mb-6">
- <img
- src={credential.Logo ? `data:image/x-icon;base64,${Buffer.from(credential.Logo).toString('base64')}` : '/assets/images/service-placeholder.webp'}
- alt={credential.ServiceName}
- className="w-12 h-12 rounded-lg mr-4"
- />
- <div>
- <h1 className="text-2xl font-bold text-gray-900 dark:text-white">{credential.ServiceName}</h1>
- {credential.ServiceUrl && (
- <a
- href={credential.ServiceUrl}
- target="_blank"
- rel="noopener noreferrer"
- className="text-primary-600 hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300"
- >
- {credential.ServiceUrl}
- </a>
- )}
+ <div className="flex items-center justify-between mb-6">
+ <div className="flex items-center">
+ <img
+ src={credential.Logo ? `data:image/x-icon;base64,${Buffer.from(credential.Logo).toString('base64')}` : '/assets/images/service-placeholder.webp'}
+ alt={credential.ServiceName}
+ className="w-12 h-12 rounded-lg mr-4"
+ />
+ <div>
+ <h1 className="text-2xl font-bold text-gray-900 dark:text-white">{credential.ServiceName}</h1>
+ {credential.ServiceUrl && (
+ <a
+ href={credential.ServiceUrl}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-primary-600 hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300"
+ >
+ {credential.ServiceUrl}
+ </a>
+ )}
+ </div>
</div>
+ <button
+ onClick={openInNewPopup}
+ className="p-2 text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white"
+ title="Open in new window"
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ className="h-6 w-6"
+ viewBox="0 0 20 20"
+ fill="currentColor"
+ >
+ <path d="M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 11-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm13 0a1 1 0 00-1-1h-4a1 1 0 100 2h1.586l-2.293 2.293a1 1 0 001.414 1.414L14 6.414V8a1 1 0 102 0V4zM3 16a1 1 0 001 1h4a1 1 0 100-2H6.414l2.293-2.293a1 1 0 00-1.414-1.414L5 13.586V12a1 1 0 10-2 0v4zm13 0a1 1 0 01-1 1h-4a1 1 0 110-2h1.586l-2.293-2.293a1 1 0 011.414-1.414L14 13.586V12a1 1 0 112 0v4z" />
+ </svg>
+ </button>
</div>
<div className="grid gap-6 md:grid-cols-2">