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
58 changes: 11 additions & 47 deletions TablePro/Views/Connection/ConnectionFormView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ struct ConnectionFormView: View {
@State private var isTesting: Bool = false
@State private var testSucceeded: Bool = false

@State private var isInstallingPlugin = false
@State private var pluginInstallProgress: Double = 0

@State private var pluginInstallConnection: DatabaseConnection?

// Tab selection
Expand Down Expand Up @@ -149,9 +146,6 @@ struct ConnectionFormView: View {
if (newType == .sqlite || newType == .duckdb) && (selectedTab == .ssh || selectedTab == .ssl) {
selectedTab = .general
}
if newType.isDownloadablePlugin && !PluginManager.shared.isDriverAvailable(for: newType) {
installPluginForType(newType)
}
additionalFieldValues = [:]
if newType != .postgresql && newType != .redshift {
usePgpass = false
Expand Down Expand Up @@ -701,18 +695,6 @@ struct ConnectionFormView: View {

private var footer: some View {
VStack(alignment: .leading, spacing: 8) {
if isInstallingPlugin {
HStack(spacing: 6) {
ProgressView()
.controlSize(.small)
Text("Installing plugin...")
.font(.caption)
.foregroundStyle(.secondary)
}
.padding(.horizontal, 16)
.padding(.top, 8)
}

HStack {
// Test connection
Button(action: testConnection) {
Expand All @@ -727,7 +709,7 @@ struct ConnectionFormView: View {
Text("Test Connection")
}
}
.disabled(isTesting || isInstallingPlugin || !isValid)
.disabled(isTesting || !isValid)

Spacer()

Expand All @@ -749,7 +731,7 @@ struct ConnectionFormView: View {
}
.keyboardShortcut(.return)
.buttonStyle(.borderedProminent)
.disabled(!isValid || isInstallingPlugin)
.disabled(!isValid)
}
.padding(.horizontal, 16)
.padding(.vertical, 12)
Expand Down Expand Up @@ -790,28 +772,6 @@ struct ConnectionFormView: View {
return basicValid
}

private func installPluginForType(_ databaseType: DatabaseType) {
isInstallingPlugin = true
pluginInstallProgress = 0
let window = NSApp.keyWindow

Task {
do {
try await PluginManager.shared.installMissingPlugin(for: databaseType) { progress in
pluginInstallProgress = progress
}
isInstallingPlugin = false
} catch {
isInstallingPlugin = false
AlertHelper.showErrorSheet(
title: String(localized: "Plugin Installation Failed"),
message: error.localizedDescription,
window: window
)
}
}
}

private func updatePgpassStatus() {
guard usePgpass, type == .postgresql || type == .redshift else {
pgpassStatus = .notChecked
Expand Down Expand Up @@ -1151,11 +1111,15 @@ struct ConnectionFormView: View {
} catch {
await MainActor.run {
isTesting = false
AlertHelper.showErrorSheet(
title: String(localized: "Connection Test Failed"),
message: error.localizedDescription,
window: window
)
if case PluginError.pluginNotInstalled = error {
pluginInstallConnection = testConn
} else {
AlertHelper.showErrorSheet(
title: String(localized: "Connection Test Failed"),
message: error.localizedDescription,
window: window
)
}
}
}
}
Expand Down
Loading