Skip to content

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

Implement modal in upgrade page (#957)

Leendert de Borst3e82c6e5d008
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Modal.tsx b/apps/browser-extension/src/entrypoints/popup/components/Modal.tsx
index 8888b0af3..7844fd8c6 100644
--- a/apps/browser-extension/src/entrypoints/popup/components/Modal.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/components/Modal.tsx
@@ -20,8 +20,8 @@ const Modal: React.FC<IModalProps> = ({
onConfirm,
title,
message,
- confirmText = 'Confirm',
- cancelText = 'Cancel',
+ confirmText = '',
+ cancelText = '',
variant = 'default'
}) => {
if (!isOpen) {
@@ -75,20 +75,24 @@ const Modal: React.FC<IModalProps> = ({
{/* Actions */}
<div className="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
- <button
- type="button"
- className={`inline-flex w-full justify-center rounded-md px-3 py-2 text-sm font-semibold text-white shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-2 sm:ml-3 sm:w-auto ${confirmButtonClass}`}
- onClick={onConfirm}
- >
- {confirmText}
- </button>
- <button
- type="button"
- className="mt-3 inline-flex w-full justify-center rounded-md bg-white dark:bg-gray-700 px-3 py-2 text-sm font-semibold text-gray-900 dark:text-gray-200 shadow-sm ring-1 ring-inset ring-gray-300 dark:ring-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-primary-500 sm:mt-0 sm:w-auto"
- onClick={onClose}
- >
- {cancelText}
- </button>
+ {confirmText && (
+ <button
+ type="button"
+ className={`inline-flex w-full justify-center rounded-md px-3 py-2 text-sm font-semibold text-white shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-2 sm:ml-3 sm:w-auto ${confirmButtonClass}`}
+ onClick={onConfirm}
+ >
+ {confirmText}
+ </button>
+ )}
+ {cancelText && (
+ <button
+ type="button"
+ className="mt-3 inline-flex w-full justify-center rounded-md bg-white dark:bg-gray-700 px-3 py-2 text-sm font-semibold text-gray-900 dark:text-gray-200 shadow-sm ring-1 ring-inset ring-gray-300 dark:ring-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-primary-500 sm:mt-0 sm:w-auto"
+ onClick={onClose}
+ >
+ {cancelText}
+ </button>
+ )}
</div>
</div>
</div>
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/CredentialAddEdit.tsx b/apps/browser-extension/src/entrypoints/popup/pages/CredentialAddEdit.tsx
index 06347b87b..a2d52a6c8 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/CredentialAddEdit.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/CredentialAddEdit.tsx
@@ -502,6 +502,7 @@ const CredentialAddEdit: React.FC = () => {
title="Delete Credential"
message="Are you sure you want to delete this credential? This action cannot be undone."
confirmText="Delete"
+ cancelText="Cancel"
variant="danger"
/>
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/EmailDetails.tsx b/apps/browser-extension/src/entrypoints/popup/pages/EmailDetails.tsx
index eb8eecd2c..69563cb07 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/EmailDetails.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/EmailDetails.tsx
@@ -201,6 +201,7 @@ const EmailDetails: React.FC = (): React.ReactElement => {
title="Delete Email"
message="Are you sure you want to delete this email? This action cannot be undone."
confirmText="Delete"
+ cancelText="Cancel"
variant="danger"
/>
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/Upgrade.tsx b/apps/browser-extension/src/entrypoints/popup/pages/Upgrade.tsx
index 8836fc1b2..f63bdcb64 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/Upgrade.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/Upgrade.tsx
@@ -5,6 +5,7 @@ import Button from '@/entrypoints/popup/components/Button';
import HeaderButton from '@/entrypoints/popup/components/HeaderButton';
import { HeaderIconType } from '@/entrypoints/popup/components/Icons/HeaderIcons';
import LoadingSpinner from '@/entrypoints/popup/components/LoadingSpinner';
+import Modal from '@/entrypoints/popup/components/Modal';
import { useAuth } from '@/entrypoints/popup/context/AuthContext';
import { useDb } from '@/entrypoints/popup/context/DbContext';
import { useHeaderButtons } from '@/entrypoints/popup/context/HeaderButtonsContext';
@@ -29,6 +30,8 @@ const Upgrade: React.FC = () => {
const [currentVersion, setCurrentVersion] = useState<VaultVersion | null>(null);
const [latestVersion, setLatestVersion] = useState<VaultVersion | null>(null);
const [error, setError] = useState<string | null>(null);
+ const [showSelfHostedWarning, setShowSelfHostedWarning] = useState(false);
+ const [showVersionInfo, setShowVersionInfo] = useState(false);
const { setIsInitialLoading } = useLoading();
const webApi = useWebApi();
const { executeVaultMutation, isLoading: isVaultMutationLoading, syncStatus } = useVaultMutate();
@@ -87,14 +90,8 @@ const Upgrade: React.FC = () => {
// Check if this is a self-hosted instance and show warning if needed
if (await webApi.isSelfHosted()) {
- const confirmed = window.confirm(
- 'Self-Hosted Server\n\n' +
- "If you're using a self-hosted server, make sure to also update your self-hosted instance as otherwise logging in to the web client will stop working.\n\n" +
- 'Do you want to continue with the upgrade?'
- );
- if (!confirmed) {
- return;
- }
+ setShowSelfHostedWarning(true);
+ return;
}
await performUpgrade();
@@ -222,10 +219,7 @@ const Upgrade: React.FC = () => {
* Show version description dialog.
*/
const showVersionDialog = (): void => {
- alert(
- "What's New\n\n" +
- `An upgrade is required to support the following changes:\n\n${latestVersion?.description ?? 'No description available for this version.'}`
- );
+ setShowVersionInfo(true);
};
return (
@@ -240,6 +234,29 @@ const Upgrade: React.FC = () => {
</div>
)}
+ {/* Self-hosted warning modal */}
+ <Modal
+ isOpen={showSelfHostedWarning}
+ onClose={() => setShowSelfHostedWarning(false)}
+ onConfirm={() => {
+ setShowSelfHostedWarning(false);
+ void performUpgrade();
+ }}
+ title="Self-Hosted Server"
+ message="If you're using a self-hosted server, make sure to also update your self-hosted instance as otherwise logging in to the web client will stop working. Do you want to continue with the upgrade?"
+ confirmText="Continue"
+ cancelText="Cancel"
+ />
+
+ {/* Version info modal */}
+ <Modal
+ isOpen={showVersionInfo}
+ onClose={() => setShowVersionInfo(false)}
+ onConfirm={() => setShowVersionInfo(false)}
+ title="What's New"
+ message={`An upgrade is required to support the following changes:\n\n${latestVersion?.description ?? 'No description available for this version.'}`}
+ />
+
<form className="w-full px-2 pt-2 pb-2 mb-4">
{error && (
<div className="mb-4 text-red-500 dark:text-red-400 text-sm">