chore(mac): align remote ssh controls
This commit is contained in:
@@ -113,9 +113,24 @@ struct GeneralSettings: View {
|
|||||||
.frame(width: 48, alignment: .leading)
|
.frame(width: 48, alignment: .leading)
|
||||||
TextField("user@host[:22]", text: self.$state.remoteTarget)
|
TextField("user@host[:22]", text: self.$state.remoteTarget)
|
||||||
.textFieldStyle(.roundedBorder)
|
.textFieldStyle(.roundedBorder)
|
||||||
.frame(width: 280)
|
.frame(maxWidth: .infinity)
|
||||||
|
Button {
|
||||||
|
Task { await self.testRemote() }
|
||||||
|
} label: {
|
||||||
|
if self.remoteStatus == .checking {
|
||||||
|
ProgressView().controlSize(.small)
|
||||||
|
} else {
|
||||||
|
Text("Test remote")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.buttonStyle(.borderedProminent)
|
||||||
|
.disabled(self.remoteStatus == .checking || self.state.remoteTarget
|
||||||
|
.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.remoteStatusView
|
||||||
|
.padding(.leading, 58)
|
||||||
|
|
||||||
DisclosureGroup(isExpanded: self.$showRemoteAdvanced) {
|
DisclosureGroup(isExpanded: self.$showRemoteAdvanced) {
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
LabeledContent("Identity file") {
|
LabeledContent("Identity file") {
|
||||||
@@ -135,44 +150,15 @@ struct GeneralSettings: View {
|
|||||||
.font(.callout.weight(.semibold))
|
.font(.callout.weight(.semibold))
|
||||||
}
|
}
|
||||||
|
|
||||||
HStack(spacing: 10) {
|
|
||||||
Button {
|
|
||||||
Task { await self.testRemote() }
|
|
||||||
} label: {
|
|
||||||
if self.remoteStatus == .checking {
|
|
||||||
ProgressView().controlSize(.small)
|
|
||||||
} else {
|
|
||||||
Text("Test remote")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.buttonStyle(.borderedProminent)
|
|
||||||
.disabled(self.remoteStatus == .checking || self.state.remoteTarget
|
|
||||||
.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
|
|
||||||
|
|
||||||
switch self.remoteStatus {
|
|
||||||
case .idle:
|
|
||||||
EmptyView()
|
|
||||||
case .checking:
|
|
||||||
Text("Checking…").font(.caption).foregroundStyle(.secondary)
|
|
||||||
case .ok:
|
|
||||||
Label("Ready", systemImage: "checkmark.circle.fill")
|
|
||||||
.font(.caption)
|
|
||||||
.foregroundStyle(.green)
|
|
||||||
case let .failed(message):
|
|
||||||
Text(message)
|
|
||||||
.font(.caption)
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
.lineLimit(2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Diagnostics
|
// Diagnostics
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
Text("Control channel")
|
Text("Control channel")
|
||||||
.font(.caption.weight(.semibold))
|
.font(.caption.weight(.semibold))
|
||||||
Text(self.controlStatusLine)
|
if !self.isControlStatusDuplicate {
|
||||||
.font(.caption)
|
Text(self.controlStatusLine)
|
||||||
.foregroundStyle(.secondary)
|
.font(.caption)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
}
|
||||||
if let ping = ControlChannel.shared.lastPingMs {
|
if let ping = ControlChannel.shared.lastPingMs {
|
||||||
Text("Last ping: \(Int(ping)) ms")
|
Text("Last ping: \(Int(ping)) ms")
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
@@ -203,6 +189,32 @@ struct GeneralSettings: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private var remoteStatusView: some View {
|
||||||
|
switch self.remoteStatus {
|
||||||
|
case .idle:
|
||||||
|
EmptyView()
|
||||||
|
case .checking:
|
||||||
|
Text("Testing…")
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
case .ok:
|
||||||
|
Label("Ready", systemImage: "checkmark.circle.fill")
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundStyle(.green)
|
||||||
|
case let .failed(message):
|
||||||
|
Text(message)
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
.lineLimit(2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var isControlStatusDuplicate: Bool {
|
||||||
|
guard case let .failed(message) = self.remoteStatus else { return false }
|
||||||
|
return message == self.controlStatusLine
|
||||||
|
}
|
||||||
|
|
||||||
private var cliInstaller: some View {
|
private var cliInstaller: some View {
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
HStack(spacing: 10) {
|
HStack(spacing: 10) {
|
||||||
|
|||||||
Reference in New Issue
Block a user