wip
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
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
This commit is contained in:
@@ -104,14 +104,16 @@ impl Render for AppRoot {
|
||||
let titlebar_view = self.titlebar.read(cx);
|
||||
let workspace = self.workspace.read(cx);
|
||||
let main = workspace.active_main();
|
||||
let has_main = main.is_some();
|
||||
|
||||
let repo_tabs =
|
||||
titlebar_view.render_repo_tabs(workspace.open_mains(), workspace.active_main_id());
|
||||
let tab_bar = h_flex()
|
||||
.gap_2()
|
||||
.child(titlebar_view.repository_switcher())
|
||||
.when_some(repo_tabs, |bar, tabs| bar.child(tabs));
|
||||
let prefix = h_flex()
|
||||
.gap_1()
|
||||
.child(titlebar_view.render_new_repository())
|
||||
.child(titlebar_view.repository_switcher());
|
||||
|
||||
let tab_bar = h_flex().gap_1().when_some(
|
||||
titlebar_view.render_repo_tabs(workspace.open_mains(), workspace.active_main_id()),
|
||||
|bar, tabs| bar.child(tabs),
|
||||
);
|
||||
|
||||
div()
|
||||
.relative()
|
||||
@@ -133,7 +135,7 @@ impl Render for AppRoot {
|
||||
Shell::new("signed-shell")
|
||||
.titlebar(
|
||||
Titlebar::new("signed-titlebar")
|
||||
.child(titlebar_view.render_actions())
|
||||
.prefix(prefix)
|
||||
.tab_bar(tab_bar)
|
||||
.when_some(titlebar_view.render_user_menu(cx), |titlebar, menu| {
|
||||
titlebar.suffix(menu)
|
||||
@@ -141,13 +143,15 @@ impl Render for AppRoot {
|
||||
)
|
||||
.panel(
|
||||
PanelRow::new("signed-panel")
|
||||
.when_some(main, |row, main| {
|
||||
row.main(main).when(workspace.has_details(), |row| {
|
||||
.when_some(main.as_ref(), |row, main| {
|
||||
row.main(main.clone()).when(workspace.has_details(), |row| {
|
||||
row.split(self.workspace.clone())
|
||||
})
|
||||
})
|
||||
.when(!has_main && signed_in, |row| row.main(self.empty.clone()))
|
||||
.when(!has_main && !signed_in, |row| {
|
||||
.when(!main.is_some() && signed_in, |row| {
|
||||
row.main(self.empty.clone())
|
||||
})
|
||||
.when(!main.is_some() && !signed_in, |row| {
|
||||
row.main(self.sign_in.clone())
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -137,7 +137,7 @@ impl IssuesView {
|
||||
SegmentedOption::new(IssueFilter::All, format!("All ({})", counts.total))
|
||||
.icon(Icon::named(IconRole::GitIssueDone).color(muted)),
|
||||
SegmentedOption::new(IssueFilter::Open, format!("Open ({})", counts.open))
|
||||
.icon(Icon::named(IconRole::GitIssueOpen).color(muted)),
|
||||
.icon(Icon::named(IconRole::GitIssueOngoing).color(muted)),
|
||||
SegmentedOption::new(
|
||||
IssueFilter::Closed,
|
||||
format!("Closed ({})", counts.closed),
|
||||
|
||||
@@ -355,8 +355,7 @@ impl NewPullRequestView {
|
||||
.selected(self.active_tab)
|
||||
.tabs(move |_, _| {
|
||||
vec![
|
||||
Tab::new("files", format!("Files ({files})"))
|
||||
.lead(Icon::named(IconRole::GitFile)),
|
||||
Tab::new("files", format!("Files ({files})")).lead(Icon::named(IconRole::File)),
|
||||
Tab::new("commits", format!("Commits ({commits})"))
|
||||
.lead(Icon::named(IconRole::GitCommit)),
|
||||
]
|
||||
|
||||
@@ -9,7 +9,7 @@ use ui::tooltip::Tooltip;
|
||||
/// The status pill shown on issue and pull-request rows.
|
||||
pub fn status_badge(status: RepoStatus) -> Badge {
|
||||
let (label, variant, icon) = match status {
|
||||
RepoStatus::Open => ("Open", BadgeVariant::Neutral, IconRole::GitIssueOpen),
|
||||
RepoStatus::Open => ("Open", BadgeVariant::Neutral, IconRole::GitIssueOngoing),
|
||||
RepoStatus::Closed => ("Closed", BadgeVariant::Danger, IconRole::GitIssueClosed),
|
||||
RepoStatus::Draft => ("Draft", BadgeVariant::Warning, IconRole::GitIssueOngoing),
|
||||
RepoStatus::Applied => ("Applied", BadgeVariant::Success, IconRole::GitIssueDone),
|
||||
|
||||
@@ -4,8 +4,7 @@ use std::sync::Arc;
|
||||
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext as _, Context, Entity, IntoElement, KeyBinding,
|
||||
KeyBindingContextPredicate, ParentElement as _, SharedString, Styled as _, Subscription,
|
||||
WeakEntity, Window, px,
|
||||
KeyBindingContextPredicate, ParentElement as _, SharedString, Subscription, WeakEntity, Window,
|
||||
};
|
||||
use metadata::{Profile, ProfileDirectory};
|
||||
use nostr::prelude::PublicKey;
|
||||
@@ -16,11 +15,9 @@ use signed_state::{Backend, BackendEvent, LocalReposStore, RepoListStore, Resolv
|
||||
use ui::avatar::Avatar;
|
||||
use ui::button::{Button, ButtonVariant};
|
||||
use ui::command_palette::{Command, CommandPalette, CommandPaletteState};
|
||||
use ui::common::h_flex;
|
||||
use ui::icons::{Icon, IconRole};
|
||||
use ui::menu::{Menu, MenuItem};
|
||||
use ui::tabs::{Tab, Tabs, TabsVariant};
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use ui::tooltip::Tooltip;
|
||||
|
||||
use crate::repo::{RepoDetailView, actions, dialogs};
|
||||
@@ -364,6 +361,7 @@ impl TitlebarView {
|
||||
.unwrap_or(usize::MAX);
|
||||
|
||||
let workspace = self.workspace.clone();
|
||||
let close_workspace = self.workspace.clone();
|
||||
let open_for_change = open.to_vec();
|
||||
|
||||
Some(
|
||||
@@ -380,7 +378,7 @@ impl TitlebarView {
|
||||
.map(|entry| entry.label.clone())
|
||||
.unwrap_or_else(|| id.clone());
|
||||
|
||||
let mut tab = Tab::new(id.clone(), label);
|
||||
let mut tab = Tab::new(id.clone(), label).closeable(true);
|
||||
if let Some(entry) = entry {
|
||||
tab = tab.lead(entry.avatar(&lookup_directory, cx));
|
||||
}
|
||||
@@ -395,6 +393,11 @@ impl TitlebarView {
|
||||
log_dropped(workspace.update(cx, |workspace, cx| {
|
||||
workspace.activate_main(&id, cx);
|
||||
}));
|
||||
})
|
||||
.on_close(move |index, _, cx| {
|
||||
log_dropped(close_workspace.update(cx, |workspace, cx| {
|
||||
workspace.close_main_at(index, cx);
|
||||
}));
|
||||
}),
|
||||
)
|
||||
}
|
||||
@@ -502,40 +505,48 @@ impl TitlebarView {
|
||||
Some(self.render_user(&profile, cx).into_any_element())
|
||||
}
|
||||
|
||||
fn render_user(&self, profile: &Profile, cx: &App) -> impl IntoElement {
|
||||
pub fn render_new_repository(&self) -> AnyElement {
|
||||
let workspace = self.workspace.clone();
|
||||
|
||||
Button::new("add-repo")
|
||||
.icon(IconRole::Plus)
|
||||
.variant(ButtonVariant::Ghost)
|
||||
.fully_rounded(true)
|
||||
.tooltip(Tooltip::text("Create repository"))
|
||||
.on_click(move |_, window, cx| {
|
||||
dialogs::create::open(workspace.clone(), window, cx);
|
||||
})
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
fn render_user(&self, profile: &Profile, _cx: &App) -> impl IntoElement {
|
||||
let name = profile.name();
|
||||
let picture = profile.picture();
|
||||
let public_key = profile.public_key();
|
||||
let weak = self.weak.clone();
|
||||
let muted = cx.theme().colors.muted_foreground;
|
||||
|
||||
Menu::new("user-menu")
|
||||
.open(self.user_menu_open)
|
||||
.on_change({
|
||||
let weak = weak.clone();
|
||||
move |open, _, cx| {
|
||||
log_dropped(weak.update(cx, |this, cx| {
|
||||
this.user_menu_open = open;
|
||||
cx.notify();
|
||||
}));
|
||||
}
|
||||
.on_change(move |open, _, cx| {
|
||||
log_dropped(weak.update(cx, |this, cx| {
|
||||
this.user_menu_open = open;
|
||||
cx.notify();
|
||||
}));
|
||||
})
|
||||
.trigger({
|
||||
let name = name.clone();
|
||||
let picture = picture.clone();
|
||||
move |_, _| {
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.items_center()
|
||||
Button::new("user-menu-trigger")
|
||||
.variant(ButtonVariant::Ghost)
|
||||
.fully_rounded(true)
|
||||
.padded(false)
|
||||
.accessibility_label(name.clone())
|
||||
.child(
|
||||
Avatar::new(public_key)
|
||||
.name(name.clone())
|
||||
.picture(picture.clone()),
|
||||
)
|
||||
.child(
|
||||
Icon::named(IconRole::ChevronDown)
|
||||
.size(px(12.))
|
||||
.color(muted),
|
||||
.picture(picture.clone())
|
||||
.fully_rounded(true),
|
||||
)
|
||||
.into_any_element()
|
||||
}
|
||||
@@ -550,35 +561,6 @@ impl TitlebarView {
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
pub fn render_actions(&self) -> AnyElement {
|
||||
let workspace = self.workspace.clone();
|
||||
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.child(
|
||||
Button::new("open-command-palette")
|
||||
.icon(IconRole::Search)
|
||||
.variant(ButtonVariant::Ghost)
|
||||
.tooltip(Tooltip::text("Command palette"))
|
||||
.on_click({
|
||||
let palette = self.palette.clone();
|
||||
move |_, window, cx| {
|
||||
palette.update(cx, |palette, cx| palette.toggle(window, cx));
|
||||
}
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
Button::new("add-repo")
|
||||
.icon(IconRole::Plus)
|
||||
.variant(ButtonVariant::Ghost)
|
||||
.tooltip(Tooltip::text("Create repository"))
|
||||
.on_click(move |_, window, cx| {
|
||||
dialogs::create::open(workspace.clone(), window, cx);
|
||||
}),
|
||||
)
|
||||
.into_any_element()
|
||||
}
|
||||
}
|
||||
|
||||
fn announcement_key(announcement: &Announcement) -> SharedString {
|
||||
|
||||
@@ -128,8 +128,9 @@ impl Render for RepositorySwitcher {
|
||||
})
|
||||
.trigger(move |_window: &mut Window, _cx: &mut App| {
|
||||
Button::new("repo-switcher")
|
||||
.icon(Icon::named(IconRole::Folder))
|
||||
.icon(Icon::named(IconRole::Stack))
|
||||
.variant(ButtonVariant::Ghost)
|
||||
.fully_rounded(true)
|
||||
.tooltip(Tooltip::text("Repositories"))
|
||||
.accessibility_label("Repositories")
|
||||
.into_any_element()
|
||||
@@ -150,7 +151,7 @@ impl Render for RepositorySwitcher {
|
||||
.cloned()
|
||||
.collect();
|
||||
|
||||
let row_height = theme.sizes.medium.menu_item_height + theme.spacing.unit * 0.5;
|
||||
let row_height = theme.sizes.medium.menu_item_height + px(2.);
|
||||
let list_height = (row_height * visible.len() as f32).min(px(280.));
|
||||
let list_entries = visible.clone();
|
||||
let list_directory = directory.clone();
|
||||
@@ -160,8 +161,8 @@ impl Render for RepositorySwitcher {
|
||||
|
||||
v_flex()
|
||||
.w(px(380.))
|
||||
.p(theme.spacing.unit * 2.0)
|
||||
.gap(theme.spacing.unit * 2.0)
|
||||
.p_2()
|
||||
.gap_2()
|
||||
.child(
|
||||
Input::new("repo-switcher-search", content_search.clone())
|
||||
.placeholder("Filter repositories...")
|
||||
@@ -204,8 +205,8 @@ impl Render for RepositorySwitcher {
|
||||
.role(Role::MenuItem)
|
||||
.w_full()
|
||||
.h(row_height)
|
||||
.px(theme.spacing.unit * 3.0)
|
||||
.gap(theme.spacing.unit * 2.0)
|
||||
.px_3()
|
||||
.gap_2()
|
||||
.rounded(theme.radius.control)
|
||||
.text_size(theme.sizes.medium.text_size)
|
||||
.hover(|row| row.bg(theme.colors.muted))
|
||||
|
||||
@@ -115,6 +115,30 @@ impl Workspace {
|
||||
self.close_detail_at(index, cx);
|
||||
}
|
||||
|
||||
pub fn close_main_at(&mut self, index: usize, cx: &mut Context<Self>) {
|
||||
if index >= self.main_order.len() {
|
||||
return;
|
||||
}
|
||||
|
||||
let id = self.main_order.remove(index);
|
||||
self.main_views.remove(&id);
|
||||
|
||||
if self.main.as_ref() == Some(&id) {
|
||||
self.main = self
|
||||
.main_order
|
||||
.get(index)
|
||||
.or_else(|| {
|
||||
index
|
||||
.checked_sub(1)
|
||||
.and_then(|prev| self.main_order.get(prev))
|
||||
})
|
||||
.cloned();
|
||||
self.clear_details();
|
||||
}
|
||||
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn clear(&mut self, cx: &mut Context<Self>) {
|
||||
self.main = None;
|
||||
self.main_order.clear();
|
||||
|
||||
Reference in New Issue
Block a user