Skip to content

Commit 1ddbf3c

Browse files
authored
Merge pull request #239 from datlechin/fix/hide-disabled-plugin-types
fix: hide disabled plugin database types from connection form picker
2 parents d76149f + 1f9c10b commit 1ddbf3c

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

TablePro/Views/Connection/ConnectionFormView.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ struct ConnectionFormView: View {
2323
// Computed property for isNew
2424
private var isNew: Bool { connectionId == nil }
2525

26+
private var availableDatabaseTypes: [DatabaseType] {
27+
let pluginManager = PluginManager.shared
28+
pluginManager.loadPendingPlugins()
29+
let enabled = DatabaseType.allCases.filter { dbType in
30+
pluginManager.plugins.contains { entry in
31+
entry.isEnabled && (entry.databaseTypeId == dbType.pluginTypeId
32+
|| entry.additionalTypeIds.contains(dbType.pluginTypeId))
33+
}
34+
}
35+
// When editing, always include the current type so the picker binding stays valid
36+
if !isNew, !enabled.contains(type) {
37+
return [type] + enabled
38+
}
39+
return enabled
40+
}
41+
2642
@State private var name: String = ""
2743
@State private var host: String = ""
2844
@State private var port: String = ""
@@ -178,7 +194,7 @@ struct ConnectionFormView: View {
178194
Form {
179195
Section {
180196
Picker(String(localized: "Type"), selection: $type) {
181-
ForEach(DatabaseType.allCases) { t in
197+
ForEach(availableDatabaseTypes) { t in
182198
Text(t.rawValue).tag(t)
183199
}
184200
}

0 commit comments

Comments
 (0)