redesign repo header and drop share menu
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
This commit is contained in:
@@ -10,7 +10,7 @@ use gpui::{
|
|||||||
use gpui_native_kit::avatar::Avatar;
|
use gpui_native_kit::avatar::Avatar;
|
||||||
use gpui_native_kit::button::{Button, ButtonVariant};
|
use gpui_native_kit::button::{Button, ButtonVariant};
|
||||||
use gpui_native_kit::clipboard::ClipboardButton;
|
use gpui_native_kit::clipboard::ClipboardButton;
|
||||||
use gpui_native_kit::common::{h_flex, v_flex};
|
use gpui_native_kit::common::{Sizable, h_flex, v_flex};
|
||||||
use gpui_native_kit::dropdown_menu::DropdownMenu;
|
use gpui_native_kit::dropdown_menu::DropdownMenu;
|
||||||
use gpui_native_kit::icons::{Icon, IconRole};
|
use gpui_native_kit::icons::{Icon, IconRole};
|
||||||
use gpui_native_kit::menu::MenuItem;
|
use gpui_native_kit::menu::MenuItem;
|
||||||
@@ -108,7 +108,7 @@ impl RepoDetailView {
|
|||||||
|
|
||||||
pub(super) fn render_about(&mut self, cx: &mut Context<Self>) -> AnyElement {
|
pub(super) fn render_about(&mut self, cx: &mut Context<Self>) -> AnyElement {
|
||||||
if self.store.read(cx).addr().is_none() {
|
if self.store.read(cx).addr().is_none() {
|
||||||
return self.render_local_header(cx);
|
return self.render_init_banner(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
let backend = Backend::global(cx);
|
let backend = Backend::global(cx);
|
||||||
@@ -148,7 +148,7 @@ impl RepoDetailView {
|
|||||||
let git_for_popover = git_commands.clone();
|
let git_for_popover = git_commands.clone();
|
||||||
|
|
||||||
h_flex()
|
h_flex()
|
||||||
.p_2()
|
.p_6()
|
||||||
.w_full()
|
.w_full()
|
||||||
.gap_6()
|
.gap_6()
|
||||||
.items_start()
|
.items_start()
|
||||||
@@ -257,7 +257,7 @@ impl RepoDetailView {
|
|||||||
this.child(button)
|
this.child(button)
|
||||||
})
|
})
|
||||||
.child(
|
.child(
|
||||||
Popover::new("clone")
|
Popover::new("code-popover")
|
||||||
.open(self.clone_open)
|
.open(self.clone_open)
|
||||||
.on_change(move |open, _, cx| {
|
.on_change(move |open, _, cx| {
|
||||||
if let Err(error) = weak_clone.update(cx, |this, cx| {
|
if let Err(error) = weak_clone.update(cx, |this, cx| {
|
||||||
@@ -268,8 +268,8 @@ impl RepoDetailView {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.trigger(move |_, _| {
|
.trigger(move |_, _| {
|
||||||
Button::new("clone")
|
Button::new("code")
|
||||||
.label("Clone")
|
.label("Code")
|
||||||
.icon(Icon::named(CustomIconName::GitClone))
|
.icon(Icon::named(CustomIconName::GitClone))
|
||||||
.tooltip(Tooltip::text("Clone repository"))
|
.tooltip(Tooltip::text("Clone repository"))
|
||||||
.loading(cloning)
|
.loading(cloning)
|
||||||
@@ -346,7 +346,14 @@ impl RepoDetailView {
|
|||||||
.into_any_element()
|
.into_any_element()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_local_header(&self, cx: &mut Context<Self>) -> AnyElement {
|
fn render_init_banner(&self, cx: &mut Context<Self>) -> AnyElement {
|
||||||
|
let binding = self
|
||||||
|
.store
|
||||||
|
.read(cx)
|
||||||
|
.nip34
|
||||||
|
.as_ref()
|
||||||
|
.filter(|binding| binding.kind == Nip34Kind::Initialized);
|
||||||
|
|
||||||
let path = self
|
let path = self
|
||||||
.store
|
.store
|
||||||
.read(cx)
|
.read(cx)
|
||||||
@@ -355,60 +362,33 @@ impl RepoDetailView {
|
|||||||
.map(|path| path.display().to_string())
|
.map(|path| path.display().to_string())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let name = repo_display_name(self.store.read(cx));
|
v_flex()
|
||||||
let avatar = Avatar::new(path.clone());
|
.flex_none()
|
||||||
|
.p_6()
|
||||||
let bound = self.store.read(cx).nip34.clone();
|
.h_24()
|
||||||
let action = match bound
|
.w_full()
|
||||||
.as_ref()
|
.items_center()
|
||||||
.filter(|binding| binding.kind == Nip34Kind::Initialized)
|
.justify_center()
|
||||||
{
|
.gap_2()
|
||||||
Some(binding) => bound_repo_label(binding, &self.directory, cx),
|
.map(|this| match binding {
|
||||||
None => Button::new("init")
|
Some(binding) => this.child(bound_repo_label(binding, &self.directory, cx)),
|
||||||
|
None => this.child(
|
||||||
|
Button::new("init")
|
||||||
.icon(Icon::named(CustomIconName::Init))
|
.icon(Icon::named(CustomIconName::Init))
|
||||||
|
.large()
|
||||||
.label("Initialize on Nostr")
|
.label("Initialize on Nostr")
|
||||||
.tooltip(Tooltip::text("Publish this repository to Nostr"))
|
.tooltip(Tooltip::text("Publish this repository to Nostr"))
|
||||||
.on_click(cx.listener(|this, _, window, cx| {
|
.on_click(cx.listener(|this, _, window, cx| {
|
||||||
this.open_init_dialog(window, cx);
|
this.open_init_dialog(window, cx);
|
||||||
}))
|
})),
|
||||||
.into_any_element(),
|
),
|
||||||
};
|
})
|
||||||
|
|
||||||
v_flex()
|
|
||||||
.flex_none()
|
|
||||||
.px_4()
|
|
||||||
.pb_4()
|
|
||||||
.w_full()
|
|
||||||
.gap_6()
|
|
||||||
.border_b_1()
|
|
||||||
.border_color(cx.theme().colors.border)
|
|
||||||
.child(
|
|
||||||
h_flex()
|
|
||||||
.w_full()
|
|
||||||
.gap_4()
|
|
||||||
.items_start()
|
|
||||||
.justify_between()
|
|
||||||
.child(
|
|
||||||
v_flex()
|
|
||||||
.flex_1()
|
|
||||||
.min_w_0()
|
|
||||||
.gap_1()
|
|
||||||
.child(
|
|
||||||
h_flex()
|
|
||||||
.gap_2()
|
|
||||||
.typeset(TextRole::Headline, cx)
|
|
||||||
.child(avatar)
|
|
||||||
.child(name),
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.min_w_0()
|
.min_w_0()
|
||||||
.typeset(TextRole::Body, cx)
|
.typeset(TextRole::Caption, cx)
|
||||||
.text_color(cx.theme().colors.muted_foreground)
|
.text_color(cx.theme().colors.muted_foreground)
|
||||||
.child(path),
|
.child(path),
|
||||||
),
|
|
||||||
)
|
|
||||||
.child(action),
|
|
||||||
)
|
)
|
||||||
.into_any_element()
|
.into_any_element()
|
||||||
}
|
}
|
||||||
@@ -507,7 +487,7 @@ impl RepoDetailView {
|
|||||||
|
|
||||||
pub(super) fn render_metadata(&self, cx: &mut Context<Self>) -> AnyElement {
|
pub(super) fn render_metadata(&self, cx: &mut Context<Self>) -> AnyElement {
|
||||||
h_flex()
|
h_flex()
|
||||||
.px_2()
|
.px_6()
|
||||||
.h_12()
|
.h_12()
|
||||||
.w_full()
|
.w_full()
|
||||||
.gap_4()
|
.gap_4()
|
||||||
|
|||||||
@@ -4,24 +4,21 @@ use anyhow::Error;
|
|||||||
use assets::CustomIconName;
|
use assets::CustomIconName;
|
||||||
use gpui::prelude::FluentBuilder as _;
|
use gpui::prelude::FluentBuilder as _;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AnyElement, App, ClipboardItem, Context, Entity, InteractiveElement as _, IntoElement,
|
AnyElement, App, Context, Entity, InteractiveElement as _, IntoElement, ParentElement as _,
|
||||||
ParentElement as _, SharedString, StatefulInteractiveElement as _, Styled as _, Window, div,
|
SharedString, StatefulInteractiveElement as _, Styled as _, Window, div, px,
|
||||||
px,
|
|
||||||
};
|
};
|
||||||
use gpui_native_kit::avatar::Avatar;
|
use gpui_native_kit::avatar::Avatar;
|
||||||
use gpui_native_kit::clipboard::ClipboardButton;
|
use gpui_native_kit::clipboard::ClipboardButton;
|
||||||
use gpui_native_kit::combobox::ComboboxState;
|
use gpui_native_kit::combobox::ComboboxState;
|
||||||
use gpui_native_kit::common::{Sizable as _, h_flex, v_flex};
|
use gpui_native_kit::common::{Sizable as _, h_flex, v_flex};
|
||||||
use gpui_native_kit::icons::Icon;
|
use gpui_native_kit::icons::Icon;
|
||||||
use gpui_native_kit::menu::MenuItem;
|
|
||||||
use gpui_native_kit::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
use gpui_native_kit::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||||
use metadata::ProfileDirectory;
|
use metadata::ProfileDirectory;
|
||||||
use nostr::nips::nip19::Nip19Coordinate;
|
|
||||||
use nostr::prelude::{RelayUrl, ToBech32};
|
use nostr::prelude::{RelayUrl, ToBech32};
|
||||||
use signed_core::Announcement;
|
use signed_core::Announcement;
|
||||||
use signed_git::{DiffHunk, DiffLine, DiffLineKind, FileCommit, FileDiff, Repo};
|
use signed_git::{DiffHunk, DiffLine, DiffLineKind, FileCommit, FileDiff, Repo};
|
||||||
use signed_state::{Nip34Binding, RepoListStore, RepoStore};
|
use signed_state::{Nip34Binding, RepoListStore, RepoStore};
|
||||||
use utils::{middle_truncate, relative_time_secs};
|
use utils::relative_time_secs;
|
||||||
|
|
||||||
use super::RepoDetailView;
|
use super::RepoDetailView;
|
||||||
use crate::shared::tree::{TreeItemSeed, build_tree_items};
|
use crate::shared::tree::{TreeItemSeed, build_tree_items};
|
||||||
@@ -56,67 +53,6 @@ pub(super) struct RepoData {
|
|||||||
pub(super) head_commit: Option<FileCommit>,
|
pub(super) head_commit: Option<FileCommit>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub(super) struct ShareTargets {
|
|
||||||
/// NIP-19 `naddr1...` of the announcement, with its announced relays.
|
|
||||||
pub(super) naddr: String,
|
|
||||||
/// Hex ID of the announcement event itself.
|
|
||||||
event_id: String,
|
|
||||||
/// NIP-34 coordinate `30617:<pubkey>:<repo-id>`.
|
|
||||||
coordinate: String,
|
|
||||||
gitworkshop: String,
|
|
||||||
ditto: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ShareTargets {
|
|
||||||
pub(super) fn from_announcement(announcement: &Announcement) -> Self {
|
|
||||||
let addr = announcement.addr();
|
|
||||||
let coordinate = addr.to_string();
|
|
||||||
let naddr = Nip19Coordinate::new(addr.into(), announcement.relays.iter().cloned())
|
|
||||||
.to_bech32()
|
|
||||||
.unwrap_or_else(|_| coordinate.clone());
|
|
||||||
|
|
||||||
Self {
|
|
||||||
naddr: naddr.clone(),
|
|
||||||
event_id: announcement
|
|
||||||
.event_id
|
|
||||||
.to_bech32()
|
|
||||||
.unwrap_or_else(|_| announcement.event_id.to_string()),
|
|
||||||
coordinate,
|
|
||||||
gitworkshop: format!("https://gitworkshop.dev/{naddr}"),
|
|
||||||
ditto: format!("https://ditto.pub/{naddr}"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) fn menu(&self) -> Vec<MenuItem> {
|
|
||||||
let items = [
|
|
||||||
("GitWorkshop", truncate_naddr_link(&self.gitworkshop, 4)),
|
|
||||||
("Ditto", truncate_naddr_link(&self.ditto, 4)),
|
|
||||||
("Event ID", middle_truncate(&self.event_id, 10, 10)),
|
|
||||||
("Coordinate", middle_truncate(&self.coordinate, 10, 10)),
|
|
||||||
];
|
|
||||||
|
|
||||||
let values = [
|
|
||||||
self.gitworkshop.clone(),
|
|
||||||
self.ditto.clone(),
|
|
||||||
self.event_id.clone(),
|
|
||||||
self.coordinate.clone(),
|
|
||||||
];
|
|
||||||
|
|
||||||
items
|
|
||||||
.into_iter()
|
|
||||||
.zip(values)
|
|
||||||
.map(|((label, detail), value)| {
|
|
||||||
MenuItem::new(SharedString::from(format!("{label} {detail}"))).handler(
|
|
||||||
move |_, cx| {
|
|
||||||
cx.write_to_clipboard(ClipboardItem::new_string(value.clone()));
|
|
||||||
},
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) fn clone_group(
|
pub(super) fn clone_group(
|
||||||
label: &str,
|
label: &str,
|
||||||
id: &'static str,
|
id: &'static str,
|
||||||
@@ -194,16 +130,6 @@ pub(super) fn fork_row(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn truncate_naddr_link(url: &str, tail: usize) -> String {
|
|
||||||
let Some(end) = url.find("naddr1").map(|i| i + "naddr1".len()) else {
|
|
||||||
return url.to_string();
|
|
||||||
};
|
|
||||||
if url.len() - end <= tail + 3 {
|
|
||||||
return url.to_string();
|
|
||||||
}
|
|
||||||
format!("{}...{}", &url[..end], &url[url.len() - tail..])
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) fn load_repo_data(repo: &Repo) -> Result<RepoData, Error> {
|
pub(super) fn load_repo_data(repo: &Repo) -> Result<RepoData, Error> {
|
||||||
let snapshot = repo.snapshot()?;
|
let snapshot = repo.snapshot()?;
|
||||||
let worktree = repo.workdir().map(Path::to_path_buf);
|
let worktree = repo.workdir().map(Path::to_path_buf);
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ pub struct RepoDetailView {
|
|||||||
pub(super) directory: Entity<ProfileDirectory>,
|
pub(super) directory: Entity<ProfileDirectory>,
|
||||||
/// Sync status feeding the sync-to-Nostr banner.
|
/// Sync status feeding the sync-to-Nostr banner.
|
||||||
sync_directory: Entity<SyncStatusDirectory>,
|
sync_directory: Entity<SyncStatusDirectory>,
|
||||||
pub(super) share_open: bool,
|
|
||||||
pub(super) repo_menu_open: bool,
|
pub(super) repo_menu_open: bool,
|
||||||
pub(super) clone_open: bool,
|
pub(super) clone_open: bool,
|
||||||
_subscriptions: Vec<Subscription>,
|
_subscriptions: Vec<Subscription>,
|
||||||
@@ -183,7 +182,6 @@ impl RepoDetailView {
|
|||||||
tasks: Vec::new(),
|
tasks: Vec::new(),
|
||||||
directory: ProfileDirectory::new(cx),
|
directory: ProfileDirectory::new(cx),
|
||||||
sync_directory: SyncStatusDirectory::new(cx),
|
sync_directory: SyncStatusDirectory::new(cx),
|
||||||
share_open: false,
|
|
||||||
repo_menu_open: false,
|
repo_menu_open: false,
|
||||||
clone_open: false,
|
clone_open: false,
|
||||||
_subscriptions: subscriptions,
|
_subscriptions: subscriptions,
|
||||||
@@ -884,24 +882,22 @@ impl RepoDetailView {
|
|||||||
}));
|
}));
|
||||||
})
|
})
|
||||||
.entries(move |_, cx| {
|
.entries(move |_, cx| {
|
||||||
let color = cx.theme().colors.muted_foreground;
|
|
||||||
|
|
||||||
let mut entries = vec![
|
let mut entries = vec![
|
||||||
SidebarEntry::row("repo-nav-commits", "Commits")
|
SidebarEntry::row("repo-nav-commits", "Commits")
|
||||||
.prefix(Icon::named(CustomIconName::GitCommit).color(color))
|
.prefix(Icon::named(CustomIconName::GitCommit))
|
||||||
.when_some(commit_count, |entry, count| entry.detail(count.to_string())),
|
.when_some(commit_count, |entry, count| entry.suffix(count.to_string())),
|
||||||
];
|
];
|
||||||
|
|
||||||
if include_issues {
|
if include_issues {
|
||||||
entries.push(
|
entries.push(
|
||||||
SidebarEntry::row("repo-nav-issues", "Issues")
|
SidebarEntry::row("repo-nav-issues", "Issues")
|
||||||
.prefix(Icon::named(CustomIconName::GitIssueDone).color(color))
|
.prefix(Icon::named(CustomIconName::GitIssueDone))
|
||||||
.when_some(issue_count, |entry, count| entry.detail(count.to_string())),
|
.when_some(issue_count, |entry, count| entry.suffix(count.to_string())),
|
||||||
);
|
);
|
||||||
entries.push(
|
entries.push(
|
||||||
SidebarEntry::row("repo-nav-pulls", "Pull requests")
|
SidebarEntry::row("repo-nav-pulls", "Pull requests")
|
||||||
.prefix(Icon::named(CustomIconName::GitPullRequest).color(color))
|
.prefix(Icon::named(CustomIconName::GitPullRequest))
|
||||||
.when_some(pull_count, |entry, count| entry.detail(count.to_string())),
|
.when_some(pull_count, |entry, count| entry.suffix(count.to_string())),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user