Commit 9f7b9fe809
Verified · cmc
Layout: unified · split
gitbay/Views/Repos/RepoSettingsView.swift +63
| @@ -29,6 +29,7 @@ struct RepoSettingsView: View { | ||
| 29 | 29 | branchesSection(loaded) |
| 30 | 30 | mergeRulesSection(loaded) |
| 31 | 31 | daemonSection(loaded) |
| 32 | depsSection(loaded) | |
| 32 | 33 | } |
| 33 | 34 | } |
| 34 | 35 | .overlay { LoadStateOverlay(state: model.state) } |
| @@ -42,6 +43,7 @@ struct RepoSettingsView: View { | ||
| 42 | 43 | loadedOnce = true |
| 43 | 44 | } |
| 44 | 45 | } |
| 46 | .task { await model.loadDeps() } | |
| 45 | 47 | .refreshable { await model.load() } |
| 46 | 48 | } |
| 47 | 49 | |
| @@ -206,6 +208,67 @@ struct RepoSettingsView: View { | ||
| 206 | 208 | } |
| 207 | 209 | } |
| 208 | 210 | |
| 211 | private func depsSection(_ loaded: RepoSettingsViewModel.Loaded) -> some View { | |
| 212 | Section { | |
| 213 | SettingToggle(title: "Dependency checks", serverValue: model.deps?.enabled ?? false) { | |
| 214 | await model.setDepsEnabled($0) | |
| 215 | } | |
| 216 | .disabled(model.deps == nil || model.working) | |
| 217 | Text("Checks tell a public registry what this repository depends on.") | |
| 218 | .font(.gbSans(.caption)) | |
| 219 | .foregroundStyle(.secondary) | |
| 220 | ||
| 221 | if let deps = model.deps { | |
| 222 | if deps.enabled { | |
| 223 | if let lastCheck = deps.lastCheck { | |
| 224 | Text(lastCheck, format: .relative(presentation: .named)) | |
| 225 | .font(.gbSans(.caption)) | |
| 226 | .foregroundStyle(.secondary) | |
| 227 | } else { | |
| 228 | Text("Never checked") | |
| 229 | .font(.gbSans(.caption)) | |
| 230 | .foregroundStyle(.secondary) | |
| 231 | } | |
| 232 | if let lastError = deps.lastError { | |
| 233 | GBNotice(lastError, .gbWarn) | |
| 234 | } | |
| 235 | if let issueNumber = deps.issueNumber { | |
| 236 | NavigationLink(value: IssueRoute.issue(repo: model.repoPath, number: issueNumber)) { | |
| 237 | Text("Tracking issue #\(issueNumber)") | |
| 238 | } | |
| 239 | } | |
| 240 | if deps.behind.isEmpty { | |
| 241 | if deps.lastCheck != nil { | |
| 242 | Text("Everything is current.") | |
| 243 | .font(.gbSans(.caption)) | |
| 244 | .foregroundStyle(.secondary) | |
| 245 | } | |
| 246 | } else { | |
| 247 | ForEach(deps.behind) { dep in | |
| 248 | VStack(alignment: .leading, spacing: 2) { | |
| 249 | Text(dep.name) | |
| 250 | .font(.gbSans(.subheadline)) | |
| 251 | Text("\(dep.ecosystem) · \(dep.current) → \(dep.latest)") | |
| 252 | .font(.gbSans(.caption)) | |
| 253 | .foregroundStyle(.secondary) | |
| 254 | } | |
| 255 | } | |
| 256 | } | |
| 257 | } | |
| 258 | } else if let depsError = model.depsError { | |
| 259 | GBNotice(depsError, .gbWarn) | |
| 260 | } else { | |
| 261 | HStack { | |
| 262 | Spacer() | |
| 263 | ProgressView() | |
| 264 | Spacer() | |
| 265 | } | |
| 266 | } | |
| 267 | } header: { | |
| 268 | Text("Dependencies") | |
| 269 | } | |
| 270 | } | |
| 271 | ||
| 209 | 272 | private func toggle( |
| 210 | 273 | _ title: String, |
| 211 | 274 | _ value: Bool, |