diff options
Diffstat (limited to 'Hutch/Views/Repositories/RepositoryDetailView.swift')
| -rw-r--r-- | Hutch/Views/Repositories/RepositoryDetailView.swift | 75 |
1 files changed, 61 insertions, 14 deletions
diff --git a/Hutch/Views/Repositories/RepositoryDetailView.swift b/Hutch/Views/Repositories/RepositoryDetailView.swift index 0031e47..2715134 100644 --- a/Hutch/Views/Repositories/RepositoryDetailView.swift +++ b/Hutch/Views/Repositories/RepositoryDetailView.swift @@ -1,6 +1,8 @@ import SwiftUI struct RepositoryDetailView: View { + @Environment(\.openURL) private var openURL + let onRepositoryUpdated: ((RepositorySummary) -> Void)? var onDeleted: (() -> Void)? @@ -42,23 +44,11 @@ struct RepositoryDetailView: View { .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItemGroup(placement: .topBarTrailing) { + repositoryActionsMenu + SRHTShareButton(url: SRHTWebURL.repository(currentRepository), target: .repository) { Image(systemName: "square.and.arrow.up") } - - if canManageRepository { - Button { - showACLs = true - } label: { - Image(systemName: "person.2") - } - - Button { - showSettings = true - } label: { - Image(systemName: "gear") - } - } } } .sheet(isPresented: $showSettings) { @@ -137,4 +127,61 @@ struct RepositoryDetailView: View { let trimmed = value.trimmingCharacters(in: .whitespacesAndNewlines) return trimmed.hasPrefix("~") ? String(trimmed.dropFirst()) : trimmed } + + private var repositoryActionsMenu: some View { + Menu { + if let repositoryURL = SRHTWebURL.repository(currentRepository) { + Button { + openURL(repositoryURL) + } label: { + Label("Open in Browser", systemImage: "safari") + } + + Button { + appState.copyToPasteboard(repositoryURL.absoluteString, label: "repository URL") + } label: { + Label("Copy URL", systemImage: "doc.on.doc") + } + } + + if let httpsURL = SRHTWebURL.httpsCloneURL(currentRepository) { + Button { + appState.copyToPasteboard(httpsURL, label: "HTTPS clone URL") + } label: { + Label("Copy HTTPS URL", systemImage: "doc.on.doc") + } + } + + Button { + appState.copyToPasteboard(SRHTWebURL.sshCloneURL(currentRepository), label: "SSH clone URL") + } label: { + Label("Copy SSH URL", systemImage: "terminal") + } + + Button { + appState.copyToPasteboard(currentRepository.rid, label: "repository RID") + } label: { + Label("Copy RID", systemImage: "number") + } + + if canManageRepository { + Divider() + + Button { + showACLs = true + } label: { + Label("Manage ACLs", systemImage: "person.2") + } + + Button { + showSettings = true + } label: { + Label("Repository Settings", systemImage: "gear") + } + } + } label: { + Image(systemName: "ellipsis.circle") + } + .accessibilityLabel("Repository actions") + } } |
