summaryrefslogtreecommitdiff
path: root/Hutch/Views/Home
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-12 22:06:16 -0500
committerChristian Cleberg <[email protected]>2026-04-12 22:06:16 -0500
commit86bcd9452d3107f68aca085e03e69b02667c0dbb (patch)
tree8b0adece5cb0f8ffb178eaab2cd12d025c9ebf0a /Hutch/Views/Home
parent31cbca674957eea7ae2529012e20a9d95158e561 (diff)
downloadhutch-86bcd9452d3107f68aca085e03e69b02667c0dbb.tar.gz
hutch-86bcd9452d3107f68aca085e03e69b02667c0dbb.tar.bz2
hutch-86bcd9452d3107f68aca085e03e69b02667c0dbb.zip
feat: polish read-only project views and home integration
Refs: https://todo.sr.ht/~ccleberg/hutch/36 Refs: https://todo.sr.ht/~ccleberg/hutch/37 Refs: https://todo.sr.ht/~ccleberg/hutch/38
Diffstat (limited to 'Hutch/Views/Home')
-rw-r--r--Hutch/Views/Home/HomeView.swift68
-rw-r--r--Hutch/Views/Home/HomeViewModel.swift11
2 files changed, 55 insertions, 24 deletions
diff --git a/Hutch/Views/Home/HomeView.swift b/Hutch/Views/Home/HomeView.swift
index 42a6737..426d351 100644
--- a/Hutch/Views/Home/HomeView.swift
+++ b/Hutch/Views/Home/HomeView.swift
@@ -179,7 +179,7 @@ struct HomeView: View {
@ViewBuilder
private func projectsSection(_ viewModel: HomeViewModel) -> some View {
- if !viewModel.pinnedProjects.isEmpty {
+ if viewModel.hasPinnedProjects {
HomeSectionView("Pinned Projects", isExpanded: $projectsExpanded) {
NavigationLink {
ProjectsListView()
@@ -189,11 +189,27 @@ struct HomeView: View {
}
.buttonStyle(.plain)
} content: {
- ForEach(viewModel.pinnedProjects.prefix(projectPreviewLimit)) { project in
- NavigationLink {
- ProjectDetailView(project: project)
- } label: {
- HomeProjectRow(project: project)
+ if viewModel.isLoadingProjects && viewModel.pinnedProjects.isEmpty {
+ HomeSectionLoadingRow(label: "Loading pinned projects")
+ } else if let error = viewModel.projectsError, viewModel.pinnedProjects.isEmpty {
+ HomeSectionMessageRow(
+ text: "Couldn’t load pinned projects.",
+ systemImage: "exclamationmark.triangle",
+ emphasized: true,
+ accessibilityHint: error
+ )
+ } else if viewModel.pinnedProjects.isEmpty {
+ HomeSectionMessageRow(
+ text: "Pinned projects will appear here when they’re available.",
+ systemImage: "pin"
+ )
+ } else {
+ ForEach(viewModel.pinnedProjects.prefix(projectPreviewLimit)) { project in
+ NavigationLink {
+ ProjectDetailView(project: project)
+ } label: {
+ HomeProjectRow(project: project)
+ }
}
}
}
@@ -388,26 +404,34 @@ private struct HomeProjectRow: View {
let project: Project
var body: some View {
- VStack(alignment: .leading, spacing: 4) {
- Text(project.name)
- .font(.subheadline.weight(.medium))
- .lineLimit(1)
+ VStack(alignment: .leading, spacing: 8) {
+ HStack(alignment: .top, spacing: 10) {
+ VStack(alignment: .leading, spacing: 4) {
+ Text(project.displayName)
+ .font(.subheadline.weight(.medium))
+ .foregroundStyle(.primary)
+ .lineLimit(1)
- if let description = project.description, !description.isEmpty {
- Text(description)
- .font(.caption)
- .foregroundStyle(.secondary)
- .lineLimit(1)
- }
+ if let description = project.displayDescription {
+ Text(description)
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ .lineLimit(2)
+ }
+ }
- if let summary = project.resourceSummary {
- Text(summary)
- .font(.caption)
- .foregroundStyle(.tertiary)
- .lineLimit(1)
+ Spacer(minLength: 8)
+
+ VisibilityBadge(visibility: project.visibility)
}
+
+ Text(project.metadataLine)
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ .lineLimit(1)
}
- .padding(.vertical, 2)
+ .contentShape(Rectangle())
+ .padding(.vertical, 4)
}
}
diff --git a/Hutch/Views/Home/HomeViewModel.swift b/Hutch/Views/Home/HomeViewModel.swift
index e9f0f50..682c94d 100644
--- a/Hutch/Views/Home/HomeViewModel.swift
+++ b/Hutch/Views/Home/HomeViewModel.swift
@@ -185,6 +185,7 @@ final class HomeViewModel {
private(set) var isLoadingProjects = false
private(set) var isLoadingAssignedTickets = false
private(set) var isLoadingRecentBuilds = false
+ private(set) var projectsError: String?
private(set) var assignedTicketsError: String?
private(set) var recentBuildsError: String?
@@ -332,6 +333,7 @@ final class HomeViewModel {
isLoadingAssignedTickets = true
isLoadingRecentBuilds = true
isLoadingSystemStatus = true
+ projectsError = nil
assignedTicketsError = nil
recentBuildsError = nil
isShowingStaleSystemStatus = false
@@ -347,8 +349,9 @@ final class HomeViewModel {
switch projectsResult {
case .success(let projects):
self.projects = projects
- case .failure:
- self.projects = []
+ self.projectsError = nil
+ case .failure(let error):
+ self.projectsError = error.userFacingMessage
}
isLoadingProjects = false
@@ -407,6 +410,10 @@ final class HomeViewModel {
return pinnedIDs.compactMap { projectsByID[$0] }
}
+ var hasPinnedProjects: Bool {
+ !ProjectPinStore.loadPinnedProjectIDs(for: currentUserKey).isEmpty
+ }
+
var failedBuildCount: Int {
recentBuilds.filter {
switch $0.job.status {