Skip to content

Commit c9bd6a4

Browse files
authored
fix: remove auto-install plugin on database type selection (#299)
* fix: remove auto-install plugin on database type selection * fix: show plugin install prompt on test connection with missing plugin
1 parent 826b4d7 commit c9bd6a4

1 file changed

Lines changed: 11 additions & 47 deletions

File tree

TablePro/Views/Connection/ConnectionFormView.swift

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ struct ConnectionFormView: View {
9292
@State private var isTesting: Bool = false
9393
@State private var testSucceeded: Bool = false
9494

95-
@State private var isInstallingPlugin = false
96-
@State private var pluginInstallProgress: Double = 0
97-
9895
@State private var pluginInstallConnection: DatabaseConnection?
9996

10097
// Tab selection
@@ -149,9 +146,6 @@ struct ConnectionFormView: View {
149146
if (newType == .sqlite || newType == .duckdb) && (selectedTab == .ssh || selectedTab == .ssl) {
150147
selectedTab = .general
151148
}
152-
if newType.isDownloadablePlugin && !PluginManager.shared.isDriverAvailable(for: newType) {
153-
installPluginForType(newType)
154-
}
155149
additionalFieldValues = [:]
156150
if newType != .postgresql && newType != .redshift {
157151
usePgpass = false
@@ -701,18 +695,6 @@ struct ConnectionFormView: View {
701695

702696
private var footer: some View {
703697
VStack(alignment: .leading, spacing: 8) {
704-
if isInstallingPlugin {
705-
HStack(spacing: 6) {
706-
ProgressView()
707-
.controlSize(.small)
708-
Text("Installing plugin...")
709-
.font(.caption)
710-
.foregroundStyle(.secondary)
711-
}
712-
.padding(.horizontal, 16)
713-
.padding(.top, 8)
714-
}
715-
716698
HStack {
717699
// Test connection
718700
Button(action: testConnection) {
@@ -727,7 +709,7 @@ struct ConnectionFormView: View {
727709
Text("Test Connection")
728710
}
729711
}
730-
.disabled(isTesting || isInstallingPlugin || !isValid)
712+
.disabled(isTesting || !isValid)
731713

732714
Spacer()
733715

@@ -749,7 +731,7 @@ struct ConnectionFormView: View {
749731
}
750732
.keyboardShortcut(.return)
751733
.buttonStyle(.borderedProminent)
752-
.disabled(!isValid || isInstallingPlugin)
734+
.disabled(!isValid)
753735
}
754736
.padding(.horizontal, 16)
755737
.padding(.vertical, 12)
@@ -790,28 +772,6 @@ struct ConnectionFormView: View {
790772
return basicValid
791773
}
792774

793-
private func installPluginForType(_ databaseType: DatabaseType) {
794-
isInstallingPlugin = true
795-
pluginInstallProgress = 0
796-
let window = NSApp.keyWindow
797-
798-
Task {
799-
do {
800-
try await PluginManager.shared.installMissingPlugin(for: databaseType) { progress in
801-
pluginInstallProgress = progress
802-
}
803-
isInstallingPlugin = false
804-
} catch {
805-
isInstallingPlugin = false
806-
AlertHelper.showErrorSheet(
807-
title: String(localized: "Plugin Installation Failed"),
808-
message: error.localizedDescription,
809-
window: window
810-
)
811-
}
812-
}
813-
}
814-
815775
private func updatePgpassStatus() {
816776
guard usePgpass, type == .postgresql || type == .redshift else {
817777
pgpassStatus = .notChecked
@@ -1151,11 +1111,15 @@ struct ConnectionFormView: View {
11511111
} catch {
11521112
await MainActor.run {
11531113
isTesting = false
1154-
AlertHelper.showErrorSheet(
1155-
title: String(localized: "Connection Test Failed"),
1156-
message: error.localizedDescription,
1157-
window: window
1158-
)
1114+
if case PluginError.pluginNotInstalled = error {
1115+
pluginInstallConnection = testConn
1116+
} else {
1117+
AlertHelper.showErrorSheet(
1118+
title: String(localized: "Connection Test Failed"),
1119+
message: error.localizedDescription,
1120+
window: window
1121+
)
1122+
}
11591123
}
11601124
}
11611125
}

0 commit comments

Comments
 (0)