diff options
| author | Christian Cleberg <[email protected]> | 2026-04-13 09:57:23 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-13 09:57:23 -0500 |
| commit | 0e461a382257979037e8927e5f6b468635b0a7fe (patch) | |
| tree | 0aa3a19f6f8f966b0e90f4874ed54359a7898107 /Hutch/Views/Repositories/RepositoryRowView.swift | |
| parent | ee9f2904aa319231b7047fca3cb069f0c07019cd (diff) | |
| download | hutch-0e461a382257979037e8927e5f6b468635b0a7fe.tar.gz hutch-0e461a382257979037e8927e5f6b468635b0a7fe.tar.bz2 hutch-0e461a382257979037e8927e5f6b468635b0a7fe.zip | |
feat: add power user actions
Implements: https://todo.sr.ht/~ccleberg/hutch/52
Implements: https://todo.sr.ht/~ccleberg/hutch/53
Implements: https://todo.sr.ht/~ccleberg/hutch/54
Diffstat (limited to 'Hutch/Views/Repositories/RepositoryRowView.swift')
| -rw-r--r-- | Hutch/Views/Repositories/RepositoryRowView.swift | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/Hutch/Views/Repositories/RepositoryRowView.swift b/Hutch/Views/Repositories/RepositoryRowView.swift index 814ea76..0da6cbc 100644 --- a/Hutch/Views/Repositories/RepositoryRowView.swift +++ b/Hutch/Views/Repositories/RepositoryRowView.swift @@ -1,7 +1,9 @@ import SwiftUI -import UIKit struct RepositoryRowView: View { + @Environment(AppState.self) private var appState + @Environment(\.openURL) private var openURL + let repository: RepositorySummary let buildStatus: RepositoryBuildStatus @@ -56,34 +58,45 @@ struct RepositoryRowView: View { } .padding(.vertical, 2) .contextMenu { + if let url = SRHTWebURL.repository(repository) { + Button { + openURL(url) + } label: { + Label("Open in Browser", systemImage: "safari") + } + } + + Button { + if let url = SRHTWebURL.repository(repository)?.absoluteString { + appState.copyToPasteboard(url, label: "repository URL") + } + } label: { + Label("Copy URL", systemImage: "doc.on.doc") + } + Button { - UIPasteboard.general.string = httpsCloneURL(for: repository) + if let url = SRHTWebURL.httpsCloneURL(repository) { + appState.copyToPasteboard(url, label: "HTTPS clone URL") + } } label: { Label("Copy HTTPS URL", systemImage: "doc.on.doc") } Button { - UIPasteboard.general.string = sshCloneURL(for: repository) + appState.copyToPasteboard(SRHTWebURL.sshCloneURL(repository), label: "SSH clone URL") } label: { Label("Copy SSH URL", systemImage: "terminal") } + + Button { + appState.copyToPasteboard(repository.rid, label: "repository RID") + } label: { + Label("Copy RID", systemImage: "number") + } } } } -private func httpsCloneURL(for repository: RepositorySummary) -> String { - let host = "\(repository.service.rawValue).sr.ht" - let owner = repository.owner.canonicalName - return "https://\(host)/\(owner)/\(repository.name)" -} - -private func sshCloneURL(for repository: RepositorySummary) -> String { - let host = "\(repository.service.rawValue).sr.ht" - let user = repository.service == .hg ? "hg" : "git" - let owner = repository.owner.canonicalName - return "\(user)@\(host):\(owner)/\(repository.name)" -} - private struct RepositoryBuildStatusIndicator: View { let status: RepositoryBuildStatus |
