-
Notifications
You must be signed in to change notification settings - Fork 44
feat: added a new field in settings screen, regarding maxConnection c… #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { useState, useEffect } from "react"; | ||
| import { useState, useEffect, useRef } from "react"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { | ||
| X, | ||
|
|
@@ -51,6 +51,7 @@ interface ConnectionParams { | |
| ssh_key_file?: string; | ||
| ssh_key_passphrase?: string; | ||
| save_in_keychain?: boolean; | ||
| max_connections?: number; | ||
| } | ||
|
|
||
| interface SavedConnection { | ||
|
|
@@ -124,6 +125,10 @@ export const NewConnectionModal = ({ | |
| ssh_enabled: false, | ||
| ssh_port: 22, | ||
| }); | ||
| // Stores form data per driver so switching tabs preserves per-driver values | ||
| const driverFormDataRef = useRef<Record<string, Partial<ConnectionParams>>>( | ||
| {}, | ||
| ); | ||
| const [selectedDatabasesState, setSelectedDatabasesState] = useState< | ||
| string[] | ||
| >([]); | ||
|
|
@@ -314,7 +319,25 @@ export const NewConnectionModal = ({ | |
| }, [isOpen, initialConnection]); | ||
|
|
||
| const handleDriverChange = (newDriver: string) => { | ||
| // Save current driver's form data before switching | ||
| driverFormDataRef.current[driver] = formData; | ||
|
|
||
| const saved = driverFormDataRef.current[newDriver]; | ||
| if (saved) { | ||
| setFormData(saved); | ||
| } else { | ||
| setFormData((prev) => ({ | ||
| ...prev, | ||
| driver: newDriver, | ||
| port: | ||
| drivers.find((d) => d.id === newDriver)?.default_port ?? undefined, | ||
| username: | ||
| drivers.find((d) => d.id === newDriver)?.default_username ?? "", | ||
| max_connections: undefined, | ||
| })); | ||
| } | ||
| setDriver(newDriver); | ||
|
|
||
| setFormData({ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CRITICAL: Logic bug - this The code should either:
|
||
| driver: newDriver, | ||
| host: "", | ||
|
|
@@ -761,6 +784,32 @@ export const NewConnectionModal = ({ | |
| {t("newConnection.saveKeychain")} | ||
| </span> | ||
| </label> | ||
|
|
||
| {/* Max connections */} | ||
| <div className="flex flex-col gap-1"> | ||
| <label className="text-[10px] uppercase font-semibold tracking-wider text-muted"> | ||
| {t("newConnection.maxConnections")} | ||
| </label> | ||
| <p className="text-xs text-muted"> | ||
| {t("newConnection.maxConnectionsDesc")} | ||
| </p> | ||
| <input | ||
| type="number" | ||
| value={formData.max_connections ?? ""} | ||
| onChange={(e) => { | ||
| const val = parseInt(e.target.value); | ||
| updateField("max_connections", isNaN(val) ? undefined : val); | ||
| }} | ||
| min="1" | ||
| max="100" | ||
| placeholder="10" | ||
| autoCorrect="off" | ||
| autoCapitalize="off" | ||
| autoComplete="off" | ||
| spellCheck={false} | ||
| className="w-32 px-2.5 py-1.5 bg-base border border-strong rounded-md text-sm text-primary placeholder:text-muted focus:border-blue-500 focus:outline-none transition-colors" | ||
| /> | ||
| </div> | ||
| </> | ||
| )} | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1149,6 +1149,7 @@ export const Settings = () => { | |
| </span> | ||
| </div> | ||
| </div> | ||
|
|
||
| </div> | ||
| </div> | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CRITICAL: Duplicate code - this
if config.plugins.is_some()block is identical to the one on lines 141-143. This appears to be an accidental duplication during the merge. Remove lines 145-147.