improve button dropdown menus
Some checks failed
Rust / build (ubuntu-latest, stable) (push) Failing after 3m28s
Rust / build (ubuntu-latest, stable) (pull_request) Failing after 1m36s
Rust / build (macos-latest, stable) (push) Has been cancelled
Rust / build (windows-latest, stable) (push) Has been cancelled
Rust / build (macos-latest, stable) (pull_request) Has been cancelled
Rust / build (windows-latest, stable) (pull_request) Has been cancelled

This commit is contained in:
2026-02-28 12:59:53 +07:00
parent 5310ae6369
commit d6a2e748d0

View File

@@ -503,54 +503,35 @@ impl Workspace {
.small() .small()
.ghost() .ghost()
.when(inbox_state.subscribing(), |this| this.indicator()) .when(inbox_state.subscribing(), |this| this.indicator())
.dropdown_menu(move |this, _window, _cx| { .dropdown_menu(move |this, _window, cx| {
this.min_w(px(260.))
.label("Messaging Relays")
.menu_element_with_disabled(
Box::new(Command::ShowRelayList),
true,
move |_window, cx| {
let persons = PersonRegistry::global(cx); let persons = PersonRegistry::global(cx);
let profile = persons.read(cx).get(&pkey, cx); let profile = persons.read(cx).get(&pkey, cx);
let urls = profile.messaging_relays(); let urls: Vec<SharedString> = profile
.messaging_relays()
.iter()
.map(|url| SharedString::from(url.to_string()))
.collect();
v_flex() // Header
.gap_1() let menu = this.min_w(px(260.)).label("Messaging Relays");
.w_full()
.items_start()
.justify_start()
.children({
let mut items = vec![];
for url in urls.iter() { // Content
items.push( let menu = urls.into_iter().fold(menu, |this, url| {
this.item(PopupMenuItem::element(move |_window, _cx| {
h_flex() h_flex()
.h_6() .px_1()
.w_full() .w_full()
.gap_2() .gap_2()
.px_2() .text_sm()
.text_xs()
.bg(cx
.theme()
.elevated_surface_background)
.rounded(cx.theme().radius)
.child( .child(
div() div().size_1p5().rounded_full().bg(gpui::green()),
.size_1()
.rounded_full()
.bg(gpui::green()),
) )
.child(SharedString::from( .child(url.clone())
url.to_string(), }))
)), });
);
}
items // Footer
}) menu.separator()
},
)
.separator()
.menu_with_icon( .menu_with_icon(
"Reload", "Reload",
IconName::Refresh, IconName::Refresh,
@@ -591,51 +572,30 @@ impl Workspace {
.small() .small()
.ghost() .ghost()
.when(relay_list.configured(), |this| this.indicator()) .when(relay_list.configured(), |this| this.indicator())
.dropdown_menu(move |this, _window, _cx| { .dropdown_menu(move |this, _window, cx| {
this.min_w(px(260.))
.label("Relays")
.menu_element_with_disabled(
Box::new(Command::ShowRelayList),
true,
move |_window, cx| {
let nostr = NostrRegistry::global(cx); let nostr = NostrRegistry::global(cx);
let urls = nostr.read(cx).read_only_relays(&pkey, cx); let urls = nostr.read(cx).read_only_relays(&pkey, cx);
v_flex() // Header
.gap_1() let menu = this.min_w(px(260.)).label("Relays");
.w_full()
.items_start()
.justify_start()
.children({
let mut items = vec![];
for url in urls.into_iter() { // Content
items.push( let menu = urls.into_iter().fold(menu, |this, url| {
this.item(PopupMenuItem::element(move |_window, _cx| {
h_flex() h_flex()
.h_6() .px_1()
.w_full() .w_full()
.gap_2() .gap_2()
.px_2() .text_sm()
.text_xs()
.bg(cx
.theme()
.elevated_surface_background)
.rounded(cx.theme().radius)
.child( .child(
div() div().size_1p5().rounded_full().bg(gpui::green()),
.size_1()
.rounded_full()
.bg(gpui::green()),
) )
.child(url), .child(url.clone())
); }))
} });
items // Footer
}) menu.separator()
},
)
.separator()
.menu_with_icon( .menu_with_icon(
"Reload", "Reload",
IconName::Refresh, IconName::Refresh,