This commit is contained in:
2026-08-29 10:44:51 +07:00
parent 52f1606193
commit 0548018426
2 changed files with 23 additions and 10 deletions
@@ -25,8 +25,6 @@ fn commit_row(
cx: &App, cx: &App,
) -> AnyElement { ) -> AnyElement {
let view = view.clone(); let view = view.clone();
// Only the id is needed by the click handler: the diff panel fetches
// the full commit itself.
let id = commit.id.clone(); let id = commit.id.clone();
h_flex() h_flex()
+23 -8
View File
@@ -1057,7 +1057,9 @@ impl RepoDetailView {
let commits_count = self.all_commits.as_ref().map(|list| list.total); let commits_count = self.all_commits.as_ref().map(|list| list.total);
let worktree_empty = self.switching_ref || self.worktree.is_none(); let worktree_empty = self.switching_ref || self.worktree.is_none();
let ngit_command = ngit_clone_command(announcement, cx); let nostr_url = nostr_clone_url(announcement, cx);
let ngit_command = SharedString::from(format!("git clone {nostr_url}"));
let nak_command = SharedString::from(format!("nak git clone {nostr_url}"));
let git_commands = announcement.clone_urls(); let git_commands = announcement.clone_urls();
v_flex() v_flex()
@@ -1240,6 +1242,7 @@ impl RepoDetailView {
.child({ .child({
let view = cx.entity(); let view = cx.entity();
let ngit_command = ngit_command.clone(); let ngit_command = ngit_command.clone();
let nak_command = nak_command.clone();
let git_commands = git_commands.clone(); let git_commands = git_commands.clone();
Popover::new("clone") Popover::new("clone")
@@ -1255,6 +1258,7 @@ impl RepoDetailView {
.content(move |_, _window, cx| { .content(move |_, _window, cx| {
let state = cx.entity(); let state = cx.entity();
let ngit_row = command_row("copy-ngit", &ngit_command, cx); let ngit_row = command_row("copy-ngit", &ngit_command, cx);
let nak_row = command_row("copy-nak", &nak_command, cx);
v_flex() v_flex()
.w(px(440.)) .w(px(440.))
@@ -1282,7 +1286,19 @@ impl RepoDetailView {
.text_xs() .text_xs()
.font_semibold() .font_semibold()
.text_color(cx.theme().muted_foreground) .text_color(cx.theme().muted_foreground)
.child("Git"), .child("Clone with nak"),
)
.child(nak_row),
)
.child(
v_flex()
.gap_1()
.child(
div()
.text_xs()
.font_semibold()
.text_color(cx.theme().muted_foreground)
.child("Grasp Servers"),
) )
.when(!git_commands.is_empty(), |this| { .when(!git_commands.is_empty(), |this| {
this.children( this.children(
@@ -1312,7 +1328,6 @@ impl RepoDetailView {
.icon(CustomIconName::GitClone) .icon(CustomIconName::GitClone)
.label("Download") .label("Download")
.primary() .primary()
.small()
.on_click(move |_event, window, cx| { .on_click(move |_event, window, cx| {
state.update(cx, |state, cx| { state.update(cx, |state, cx| {
state.dismiss(window, cx); state.dismiss(window, cx);
@@ -1613,10 +1628,10 @@ fn load_repo_data(repo: &Repository) -> Result<RepoData, Error> {
}) })
} }
/// The `ngit clone nostr://...` command for an announcement (NIP-34): the /// The `nostr://...` clone URL of an announcement (NIP-34): the owner as a
/// owner as a NIP-05 identifier when known (npub otherwise), the first /// NIP-05 identifier when known (npub otherwise), the first announced relay
/// announced relay as a hint, and the repository identifier. /// as a hint, and the repository identifier.
fn ngit_clone_command(announcement: &Announcement, cx: &App) -> SharedString { fn nostr_clone_url(announcement: &Announcement, cx: &App) -> SharedString {
let owner = announcement.owner; let owner = announcement.owner;
let user = ProfileStore::global(cx) let user = ProfileStore::global(cx)
.read(cx) .read(cx)
@@ -1636,7 +1651,7 @@ fn ngit_clone_command(announcement: &Announcement, cx: &App) -> SharedString {
url.push('/'); url.push('/');
url.push_str(&announcement.id); url.push_str(&announcement.id);
SharedString::from(format!("ngit clone {url}")) SharedString::from(url)
} }
fn command_row<E>(copy_id: E, command: &SharedString, cx: &mut App) -> Div fn command_row<E>(copy_id: E, command: &SharedString, cx: &mut App) -> Div