From 1f9c10b9cc194ca34f13336d6e51eaf5598cfb47 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Mon, 9 Mar 2026 23:03:49 +0700 Subject: [PATCH] fix: hide disabled plugin database types from connection form picker --- .../Views/Connection/ConnectionFormView.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/TablePro/Views/Connection/ConnectionFormView.swift b/TablePro/Views/Connection/ConnectionFormView.swift index 88fe37e9..7249d388 100644 --- a/TablePro/Views/Connection/ConnectionFormView.swift +++ b/TablePro/Views/Connection/ConnectionFormView.swift @@ -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 + } + @State private var name: String = "" @State private var host: String = "" @State private var port: String = "" @@ -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) } }