Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion TablePro/Views/Connection/ConnectionFormView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ struct ConnectionFormView: View {
// Computed property for isNew
private var isNew: Bool { connectionId == nil }

private var availableDatabaseTypes: [DatabaseType] {
let pluginManager = PluginManager.shared
pluginManager.loadPendingPlugins()
let enabled = DatabaseType.allCases.filter { dbType in
pluginManager.plugins.contains { entry in
entry.isEnabled && (entry.databaseTypeId == dbType.pluginTypeId
|| entry.additionalTypeIds.contains(dbType.pluginTypeId))
}
}
// When editing, always include the current type so the picker binding stays valid
if !isNew, !enabled.contains(type) {
return [type] + enabled
}
return enabled
Comment on lines +36 to +39

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reset new-form type when default plugin is disabled

This logic only preserves picker validity for edit mode; in new mode it returns enabled even when the bound type (default .mysql) is no longer present. If MySQL is disabled and the user opens a new connection, the picker options omit MySQL but saveConnection()/testConnection() still read type, so the form can operate on a hidden disabled type unless the user manually changes it. Please ensure new forms also reconcile type to an enabled value when the current selection is missing.

Useful? React with 👍 / 👎.

}

@State private var name: String = ""
@State private var host: String = ""
@State private var port: String = ""
Expand Down Expand Up @@ -178,7 +194,7 @@ struct ConnectionFormView: View {
Form {
Section {
Picker(String(localized: "Type"), selection: $type) {
ForEach(DatabaseType.allCases) { t in
ForEach(availableDatabaseTypes) { t in
Text(t.rawValue).tag(t)
}
}
Expand Down