Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

feat(desktop): show and reuse last used server URL in Setup Wizard (#5659)

Ludydc6daaad0dac
diff --git a/frontend/public/locales/en-GB/translation.toml b/frontend/public/locales/en-GB/translation.toml
index 6e9f217ab5..2fa1710b9b 100644
--- a/frontend/public/locales/en-GB/translation.toml
+++ b/frontend/public/locales/en-GB/translation.toml
@@ -6564,6 +6564,7 @@ link = "or connect to a self-hosted account"
title = "Connect to Server"
subtitle = "Enter your self-hosted server URL"
testing = "Testing connection..."
+useLast = "Last used server: {{serverUrl}}"
[setup.server.type]
saas = "Stirling PDF SaaS"
diff --git a/frontend/src/desktop/components/SetupWizard/ServerSelection.tsx b/frontend/src/desktop/components/SetupWizard/ServerSelection.tsx
index 091c01d1e9..4978750916 100644
--- a/frontend/src/desktop/components/SetupWizard/ServerSelection.tsx
+++ b/frontend/src/desktop/components/SetupWizard/ServerSelection.tsx
@@ -16,12 +16,13 @@ export const ServerSelection: React.FC<ServerSelectionProps> = ({ onSelect, load
const [testing, setTesting] = useState(false);
const [testError, setTestError] = useState<string | null>(null);
const [securityDisabled, setSecurityDisabled] = useState(false);
+ const serverUrl = localStorage.getItem('server_url') || '';
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
// Normalize and validate URL
- let url = customUrl.trim().replace(/\/+$/, '');
+ let url = customUrl.trim().replace(/\/+$/, '') || serverUrl;
if (!url) {
setTestError(t('setup.server.error.emptyUrl', 'Please enter a server URL'));
@@ -34,6 +35,7 @@ export const ServerSelection: React.FC<ServerSelectionProps> = ({ onSelect, load
url = `https://${url}`;
setCustomUrl(url); // Update the input field
}
+ localStorage.setItem('server_url', url);
// Validate URL format
try {
@@ -207,6 +209,21 @@ export const ServerSelection: React.FC<ServerSelectionProps> = ({ onSelect, load
</Alert>
)}
+ {serverUrl && (
+ <div className="navigation-link-container">
+ <button
+ type="button"
+ className="navigation-link-button"
+ disabled={testing || loading}
+ onClick={() => {
+ setCustomUrl(serverUrl);
+ }}
+ >
+ {t('setup.server.useLast', 'Last used server: {{serverUrl}}', { serverUrl: serverUrl })}
+ </button>
+ </div>
+ )}
+
<Button
type="submit"
loading={testing || loading}