fix: remove bulk connectivity test controls

This commit is contained in:
Qiu Yuzhou
2026-10-15 21:08:29 +08:00
parent 4a85cf41f7
commit 3f900b7b03
9 changed files with 2 additions and 148 deletions
@@ -29,13 +29,6 @@ extension CatalogWorkflow {
return ProxyACLDocument.digest((try? JSONEncoder().encode(facts)) ?? Data())
}
/// Captures all descendants in catalog order, independently of UI collapse or sort.
func connectivityTargets(source: NodeSource?) -> [NodeID] {
let nodes = source == nil ? favorites : tree.roots.filter { $0.source == source }
var seen = Set<NodeID>()
return nodes.flatMap(\.connectivityServerIDs).filter { seen.insert($0).inserted }
}
/// This local state machine derives a single leaf without publishing activation.
func connectivityConfiguration(for id: NodeID) throws -> SslocalServerDocument {
let catalog = dependencies.coordinator.committedCatalog
@@ -86,40 +86,6 @@
}
}
},
"测试全部": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Test All"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "测试全部"
}
}
}
},
"已跳过冷却中的服务器": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Skipped servers in cooldown"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "已跳过冷却中的服务器"
}
}
}
},
"延迟测试": {
"extractionState": "manual",
"localizations": {
@@ -103,40 +103,6 @@
}
}
},
"测试整个目录中的服务器,不受折叠影响。": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Test every server in the catalog, including collapsed groups."
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "测试整个目录中的服务器,不受折叠影响。"
}
}
}
},
"测试收藏节点及其全部后代服务器,重复项只测试一次。": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Test favorites and all their descendant servers, once per server."
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "测试收藏节点及其全部后代服务器,重复项只测试一次。"
}
}
}
},
"目录为空,请到服务器页添加配置。": {
"extractionState": "manual",
"localizations": {
@@ -31,12 +31,6 @@ final class HomeTargetBrowser: ObservableObject {
func select(_ id: NodeID?) { selection = id }
func testTargets(in tree: CatalogTreeSnapshot, favorites: [CatalogTreeNode]) -> [NodeID] {
var seen = Set<NodeID>()
return (mode == .all ? tree.roots : favorites)
.flatMap(\.connectivityServerIDs).filter { seen.insert($0).inserted }
}
func reconcile(in tree: CatalogTreeSnapshot, favorites: [CatalogTreeNode]) {
let groups = Set(tree.visibleRows(collapsed: []).filter(\.node.isGroup).map(\.id))
expandedGroupIDs.formIntersection(groups)
@@ -74,17 +74,7 @@ struct HomeTargetCard: View {
}
.pickerStyle(.segmented)
.labelsHidden()
Spacer(minLength: 8)
if let module = workflow.connectivity {
ConnectivityBatchButton(
module: module,
targets: browser.testTargets(in: workflow.tree, favorites: workflow.favorites)
)
.help(
browser.mode == .all
? String(localized: "测试整个目录中的服务器,不受折叠影响。", table: "HomeTargets")
: String(localized: "测试收藏节点及其全部后代服务器,重复项只测试一次。", table: "HomeTargets"))
}
Spacer(minLength: 0)
}
.frame(maxWidth: .infinity, alignment: .leading)
}
@@ -65,26 +65,6 @@ struct ConnectivityCell: View {
}
}
struct ConnectivityBatchButton: View {
@ObservedObject var module: ServerConnectivity
let targets: [NodeID]
@State private var batchID: UUID?
var body: some View {
HStack(spacing: 6) {
Button {
batchID = module.test(targets)
} label: {
Label(ConnectivityCopy.text("测试全部"), systemImage: "waveform.path.ecg")
}
.disabled(targets.isEmpty)
if let batchID, let batch = module.batch(batchID), batch.completed < batch.targets.count {
ProgressView().controlSize(.mini)
}
}
}
}
struct ConnectivityTestButton: View {
@ObservedObject var module: ServerConnectivity
let node: CatalogTreeNode
@@ -305,12 +305,6 @@ extension ServersView {
@ToolbarContentBuilder
private var toolbarContent: some ToolbarContent {
if let module = workflow.connectivity {
ToolbarItem(placement: .primaryAction) {
ConnectivityBatchButton(
module: module, targets: workflow.connectivityTargets(source: section.source))
}
}
if section == .manual {
ToolbarItem(placement: .primaryAction) {
Button {
@@ -5,7 +5,7 @@ import Testing
@MainActor
struct ConnectivityCatalogTests {
@Test func targetScopesExpandFavoriteGroupsWithoutChangingCatalogOrActivation() async throws {
@Test func groupConnectivityIDsExpandAndConfigurationReadsCommittedCatalog() throws {
let subscription = try CatalogFixtures.makeSubscriptionFixture(prefix: UUID().uuidString)
var catalog = subscription.catalog
let credentials = InMemoryCredentialStore()
@@ -22,13 +22,6 @@ struct ConnectivityCatalogTests {
let runtime = FakeCatalogRuntime()
let coordinator = CatalogCommitCoordinator(fileStore: store, runtime: runtime)
let workflow = makeCatalogWorkflow(coordinator: coordinator, credentials: credentials)
try workflow.setFavorite(group, isFavorite: true)
try workflow.setFavorite(secondTarget, isFavorite: true)
#expect(workflow.connectivityTargets(source: .manual) == [secondTarget, firstTarget])
#expect(
workflow.connectivityTargets(source: .subscription)
== Array(subscription.serverIDs.reversed()))
#expect(workflow.connectivityTargets(source: nil) == [secondTarget, firstTarget])
#expect(
workflow.tree.node(withID: group)?.connectivityServerIDs == [secondTarget, firstTarget])
let before = try Data(contentsOf: store.fileURL)
@@ -108,26 +108,4 @@ struct HomeTargetBrowserTests {
browser.reconcile(in: tree, favorites: [])
#expect(browser.selection == nil)
}
@Test
func batchTargetsIncludeCollapsedDescendantsAndDeduplicateOverlappingFavorites() throws {
let domain = UUID().uuidString
let defaults = UserDefaults(suiteName: domain)!
defer { defaults.removePersistentDomain(forName: domain) }
let fixture = try CatalogFixtures.makeSubscriptionFixture()
let tree = CatalogTreeSnapshot.build(
from: fixture.catalog, credentials: InMemoryCredentialStore(),
plugins: NoManagedPluginProvider())
let favorites = [fixture.serverIDs[1], fixture.groupID].compactMap { tree.node(withID: $0) }
let browser = HomeTargetBrowser(defaults: defaults)
#expect(
browser.testTargets(in: tree, favorites: favorites)
== [fixture.serverIDs[1], fixture.serverIDs[0]])
browser.setMode(.favorites, in: tree, favorites: favorites)
#expect(browser.rows(in: tree, favorites: favorites).count == 2)
#expect(
browser.testTargets(in: tree, favorites: favorites)
== [fixture.serverIDs[1], fixture.serverIDs[0]])
#expect(browser.testTargets(in: tree, favorites: []).isEmpty)
}
}