| @@ -259,35 +259,42 @@ struct SecurityEventListView: View { |
| 259 | 259 | ) |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | /// Why the list is empty: filtered out, below the severity floor, nothing |
| 263 | /// watched, or genuinely no alerts. |
| 264 | @ViewBuilder |
| 265 | private var emptyStatus: some View { |
| 266 | if store.filter.isActive && store.filteredOutCount > 0 { |
| 267 | StatusView( |
| 268 | systemImage: "line.3.horizontal.decrease.circle", |
| 269 | tint: .secondary, |
| 270 | message: "\(store.filteredOutCount) alert(s) hidden by the current filter" |
| 271 | ) |
| 272 | } else if store.totalFetchedCount > 0 { |
| 273 | StatusView( |
| 274 | systemImage: "line.3.horizontal.decrease.circle", |
| 275 | tint: .secondary, |
| 276 | message: "\(store.totalFetchedCount) alert(s) are below your minimum severity filter" |
| 277 | ) |
| 278 | } else if store.watchedRepos.isEmpty { |
| 279 | // "No open alerts" would be misleading when nothing is |
| 280 | // being watched in the first place. |
| 281 | StatusView( |
| 282 | systemImage: "plus.circle", |
| 283 | tint: .secondary, |
| 284 | message: "No repositories watched yet — add one from the gear menu" |
| 285 | ) |
| 286 | } else { |
| 287 | StatusView(systemImage: "checkmark.shield", tint: .green, message: "No open security alerts") |
| 288 | } |
| 289 | } |
| 290 | |
| 262 | 291 | @ViewBuilder |
| 263 | 292 | private var content: some View { |
| 264 | 293 | if store.events.isEmpty && !store.errorMessages.isEmpty { |
| 265 | 294 | StatusView(systemImage: "exclamationmark.triangle", tint: .orange, message: store.errorMessages.joined(separator: "\n\n")) |
| 266 | 295 | } else if store.events.isEmpty && !store.isLoading { |
| 267 | 296 | VStack(spacing: 8) { |
| 268 | | if store.filter.isActive && store.filteredOutCount > 0 { |
| 269 | | StatusView( |
| 270 | | systemImage: "line.3.horizontal.decrease.circle", |
| 271 | | tint: .secondary, |
| 272 | | message: "\(store.filteredOutCount) alert(s) hidden by the current filter" |
| 273 | | ) |
| 274 | | } else if store.totalFetchedCount > 0 { |
| 275 | | StatusView( |
| 276 | | systemImage: "line.3.horizontal.decrease.circle", |
| 277 | | tint: .secondary, |
| 278 | | message: "\(store.totalFetchedCount) alert(s) are below your minimum severity filter" |
| 279 | | ) |
| 280 | | } else if store.watchedRepos.isEmpty { |
| 281 | | // "No open alerts" would be misleading when nothing is |
| 282 | | // being watched in the first place. |
| 283 | | StatusView( |
| 284 | | systemImage: "plus.circle", |
| 285 | | tint: .secondary, |
| 286 | | message: "No repositories watched yet — add one from the gear menu" |
| 287 | | ) |
| 288 | | } else { |
| 289 | | StatusView(systemImage: "checkmark.shield", tint: .green, message: "No open security alerts") |
| 290 | | } |
| 297 | emptyStatus |
| 291 | 298 | if !store.unavailableNotices.isEmpty { |
| 292 | 299 | NoticeBanner(messages: store.unavailableNotices) |
| 293 | 300 | .padding(.horizontal) |
| @@ -599,33 +606,38 @@ private struct ErrorBanner: View { |
| 599 | 606 | let messages: [String] |
| 600 | 607 | |
| 601 | 608 | var body: some View { |
| 602 | | VStack(alignment: .leading, spacing: 4) { |
| 603 | | ForEach(messages, id: \.self) { message in |
| 604 | | Label(message, systemImage: "exclamationmark.triangle") |
| 605 | | .font(.caption) |
| 606 | | .foregroundStyle(.orange) |
| 607 | | } |
| 608 | | } |
| 609 | | .frame(maxWidth: .infinity, alignment: .leading) |
| 610 | | .padding(10) |
| 611 | | .background(.orange.opacity(0.1)) |
| 609 | MessageBanner(messages: messages, systemImage: "exclamationmark.triangle", font: .caption, |
| 610 | foreground: AnyShapeStyle(.orange), background: AnyShapeStyle(.orange.opacity(0.1))) |
| 612 | 611 | } |
| 613 | 612 | } |
| 614 | 613 | |
| 615 | 614 | private struct NoticeBanner: View { |
| 616 | 615 | let messages: [String] |
| 617 | 616 | |
| 617 | var body: some View { |
| 618 | MessageBanner(messages: messages, systemImage: "info.circle", font: .caption2, |
| 619 | foreground: AnyShapeStyle(.secondary), background: AnyShapeStyle(.secondary.opacity(0.08))) |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | private struct MessageBanner: View { |
| 624 | let messages: [String] |
| 625 | let systemImage: String |
| 626 | let font: Font |
| 627 | let foreground: AnyShapeStyle |
| 628 | let background: AnyShapeStyle |
| 629 | |
| 618 | 630 | var body: some View { |
| 619 | 631 | VStack(alignment: .leading, spacing: 4) { |
| 620 | 632 | ForEach(messages, id: \.self) { message in |
| 621 | | Label(message, systemImage: "info.circle") |
| 622 | | .font(.caption2) |
| 623 | | .foregroundStyle(.secondary) |
| 633 | Label(message, systemImage: systemImage) |
| 634 | .font(font) |
| 635 | .foregroundStyle(foreground) |
| 624 | 636 | } |
| 625 | 637 | } |
| 626 | 638 | .frame(maxWidth: .infinity, alignment: .leading) |
| 627 | 639 | .padding(10) |
| 628 | | .background(.secondary.opacity(0.08)) |
| 640 | .background(background) |
| 629 | 641 | } |
| 630 | 642 | } |
| 631 | 643 | |