update
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:
@@ -21,8 +21,8 @@ use ui::toast::{Toast, Toasts};
|
||||
use crate::app::placeholder::PlaceholderView;
|
||||
use crate::app::sign_in::SignedOutView;
|
||||
use crate::explore::ExploreView;
|
||||
use crate::identity;
|
||||
use crate::shared::dialogs::DialogHost;
|
||||
use crate::identity::passphrase::PassphraseDialog;
|
||||
use crate::shared::log_dropped;
|
||||
use crate::titlebar::{
|
||||
CreateRepository, REPOSITORY_KEY_CONTEXT, SwitchRepository, TitlebarView,
|
||||
bind_repository_shortcuts,
|
||||
@@ -35,7 +35,7 @@ pub struct AppRoot {
|
||||
toasts: Entity<Toasts>,
|
||||
sign_in: Entity<SignedOutView>,
|
||||
empty: Entity<PlaceholderView>,
|
||||
dialogs: Entity<DialogHost>,
|
||||
passphrase: Option<Entity<PassphraseDialog>>,
|
||||
_subscriptions: Vec<Subscription>,
|
||||
}
|
||||
|
||||
@@ -50,9 +50,6 @@ impl AppRoot {
|
||||
let sign_in = cx.new(|_| SignedOutView::new());
|
||||
let empty = cx.new(|_| PlaceholderView::new("Select a repository"));
|
||||
|
||||
let dialogs = cx.new(DialogHost::new);
|
||||
DialogHost::set_global(dialogs.clone(), cx);
|
||||
|
||||
let backend = Backend::global(cx);
|
||||
let settings = SettingsStore::global(cx);
|
||||
let mut subscriptions = Vec::new();
|
||||
@@ -62,7 +59,7 @@ impl AppRoot {
|
||||
window,
|
||||
|this, backend, event, window, cx| match event {
|
||||
BackendEvent::PassphraseRequired => {
|
||||
identity::helpers::open_passphrase(cx);
|
||||
this.open_passphrase(cx);
|
||||
}
|
||||
BackendEvent::Error(message) => {
|
||||
this.toasts.update(cx, |toasts, cx| {
|
||||
@@ -86,9 +83,10 @@ impl AppRoot {
|
||||
apply_appearance(&settings, cx);
|
||||
}));
|
||||
|
||||
let app = cx.entity().downgrade();
|
||||
window.defer(cx, move |_window, cx| {
|
||||
if backend.read(cx).passphrase_required() {
|
||||
identity::helpers::open_passphrase(cx);
|
||||
log_dropped(app.update(cx, |this, cx| this.open_passphrase(cx)));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -98,10 +96,15 @@ impl AppRoot {
|
||||
toasts,
|
||||
sign_in,
|
||||
empty,
|
||||
dialogs,
|
||||
passphrase: None,
|
||||
_subscriptions: subscriptions,
|
||||
}
|
||||
}
|
||||
|
||||
fn open_passphrase(&mut self, cx: &mut Context<Self>) {
|
||||
self.passphrase = Some(PassphraseDialog::new(cx));
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for AppRoot {
|
||||
@@ -167,7 +170,8 @@ impl Render for AppRoot {
|
||||
)
|
||||
.toasts(self.toasts.clone()),
|
||||
)
|
||||
.child(self.dialogs.clone())
|
||||
.child(titlebar_view.palette())
|
||||
.children(titlebar_view.dialogs())
|
||||
.when_some(self.passphrase.clone(), |el, view| el.child(view))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,36 @@
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
App, Context, FontWeight, IntoElement, ParentElement as _, Render, SharedString, Styled as _,
|
||||
Window, div,
|
||||
App, Context, Entity, FontWeight, IntoElement, ParentElement as _, Render, SharedString,
|
||||
Styled as _, Window, div,
|
||||
};
|
||||
use ui::button::{Button, ButtonVariant};
|
||||
use ui::common::v_flex;
|
||||
use ui::layout::panel::Panel;
|
||||
|
||||
use crate::identity;
|
||||
use crate::identity::import::ImportDialog;
|
||||
use crate::identity::onboarding::OnboardingDialog;
|
||||
|
||||
pub struct SignedOutView;
|
||||
pub struct SignedOutView {
|
||||
onboarding: Option<Entity<OnboardingDialog>>,
|
||||
import: Option<Entity<ImportDialog>>,
|
||||
}
|
||||
|
||||
impl SignedOutView {
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
Self {
|
||||
onboarding: None,
|
||||
import: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn open_onboarding(&mut self, cx: &mut Context<Self>) {
|
||||
self.onboarding = Some(OnboardingDialog::new(cx));
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn open_import(&mut self, cx: &mut Context<Self>) {
|
||||
self.import = Some(ImportDialog::new(cx));
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +41,7 @@ impl Panel for SignedOutView {
|
||||
}
|
||||
|
||||
impl Render for SignedOutView {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
v_flex()
|
||||
.size_full()
|
||||
.items_center()
|
||||
@@ -42,18 +60,16 @@ impl Render for SignedOutView {
|
||||
.child(
|
||||
Button::new("onboarding")
|
||||
.label("Join now")
|
||||
.on_click(|_, _, cx| {
|
||||
identity::helpers::open_onboarding(cx);
|
||||
}),
|
||||
.on_click(cx.listener(|this, _, _, cx| this.open_onboarding(cx))),
|
||||
)
|
||||
.child(
|
||||
Button::new("import")
|
||||
.label("Import identity")
|
||||
.variant(ButtonVariant::Secondary)
|
||||
.on_click(|_, _, cx| {
|
||||
identity::helpers::open_import(cx);
|
||||
}),
|
||||
.on_click(cx.listener(|this, _, _, cx| this.open_import(cx))),
|
||||
),
|
||||
)
|
||||
.when_some(self.onboarding.clone(), |el, view| el.child(view))
|
||||
.when_some(self.import.clone(), |el, view| el.child(view))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,32 @@
|
||||
use gpui::{
|
||||
AnyElement, Context, IntoElement, ParentElement as _, Render, Styled as _, Window, div,
|
||||
AnyElement, App, AppContext as _, Context, Entity, IntoElement, ParentElement as _, Render,
|
||||
Styled as _, Window, div,
|
||||
};
|
||||
use signed_state::Backend;
|
||||
use ui::button::{Button, ButtonVariant};
|
||||
use ui::common::v_flex;
|
||||
use ui::dialog::Dialog;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
|
||||
use crate::shared::dialogs::close_global;
|
||||
pub struct ExitDialog {
|
||||
handle: DialogHandle,
|
||||
}
|
||||
|
||||
pub struct ExitDialog;
|
||||
impl ExitDialog {
|
||||
pub fn new(cx: &mut App) -> Entity<Self> {
|
||||
cx.new(|_| Self {
|
||||
handle: DialogHandle::new(true),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for ExitDialog {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let cancel_close = self.handle.clone();
|
||||
let confirm_close = self.handle.clone();
|
||||
|
||||
Dialog::new("exit-dialog")
|
||||
.open(true)
|
||||
.on_change(|open, _, cx| {
|
||||
if !open {
|
||||
close_global(cx);
|
||||
}
|
||||
})
|
||||
.handle(self.handle.clone())
|
||||
.title("Exit Signed?")
|
||||
.content(|_, cx| {
|
||||
v_flex()
|
||||
@@ -33,20 +40,23 @@ impl Render for ExitDialog {
|
||||
)
|
||||
.into_any_element()
|
||||
})
|
||||
.actions(|_, _| {
|
||||
.actions(move |_, _| {
|
||||
let cancel_close = cancel_close.clone();
|
||||
let confirm_close = confirm_close.clone();
|
||||
|
||||
let cancel: AnyElement = Button::new("cancel-exit")
|
||||
.label("Cancel")
|
||||
.variant(ButtonVariant::Secondary)
|
||||
.on_click(|_, _, cx| close_global(cx))
|
||||
.on_click(move |_, _, cx| cancel_close.close(cx))
|
||||
.into_any_element();
|
||||
|
||||
let exit: AnyElement = Button::new("confirm-exit")
|
||||
.label("Exit")
|
||||
.variant(ButtonVariant::Destructive)
|
||||
.on_click(|_, _, cx| {
|
||||
.on_click(move |_, _, cx| {
|
||||
let backend = Backend::global(cx);
|
||||
backend.update(cx, |backend, cx| backend.sign_out(cx));
|
||||
close_global(cx);
|
||||
confirm_close.close(cx);
|
||||
})
|
||||
.into_any_element();
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
use gpui::{App, AppContext as _};
|
||||
|
||||
use super::exit::ExitDialog;
|
||||
use super::import::ImportDialog;
|
||||
use super::onboarding::OnboardingDialog;
|
||||
use super::passphrase::PassphraseDialog;
|
||||
use crate::shared::dialogs::open_global;
|
||||
|
||||
pub fn open_passphrase(cx: &mut App) {
|
||||
open_global(PassphraseDialog::new(cx), cx);
|
||||
}
|
||||
|
||||
pub fn open_onboarding(cx: &mut App) {
|
||||
open_global(OnboardingDialog::new(cx), cx);
|
||||
}
|
||||
|
||||
pub fn open_import(cx: &mut App) {
|
||||
open_global(ImportDialog::new(cx), cx);
|
||||
}
|
||||
|
||||
pub fn open_exit(cx: &mut App) {
|
||||
open_global(cx.new(|_| ExitDialog), cx);
|
||||
}
|
||||
@@ -6,12 +6,11 @@ use gpui::{
|
||||
use signed_state::Backend;
|
||||
use ui::button::Button;
|
||||
use ui::common::v_flex;
|
||||
use ui::dialog::Dialog;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::field::Field;
|
||||
use ui::input::{Input, InputState, InputStateEvent};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
|
||||
use crate::shared::dialogs::close_global;
|
||||
use crate::shared::progress::{DialogProgress, error_row};
|
||||
|
||||
#[derive(Clone, Copy, Default, PartialEq, Eq)]
|
||||
@@ -56,6 +55,7 @@ pub struct ImportState {
|
||||
}
|
||||
|
||||
pub struct ImportDialog {
|
||||
handle: DialogHandle,
|
||||
secret_input: Entity<InputState>,
|
||||
pass_input: Entity<InputState>,
|
||||
repass_input: Entity<InputState>,
|
||||
@@ -65,6 +65,7 @@ pub struct ImportDialog {
|
||||
|
||||
impl ImportDialog {
|
||||
pub fn new(cx: &mut App) -> Entity<Self> {
|
||||
let handle = DialogHandle::new(true);
|
||||
let state = cx.new(|_| ImportState::default());
|
||||
let secret_input = InputState::new(cx);
|
||||
let pass_input = InputState::builder().password().build(cx);
|
||||
@@ -78,15 +79,24 @@ impl ImportDialog {
|
||||
let pass_input = pass_input.clone();
|
||||
let repass_input = repass_input.clone();
|
||||
let state = state.clone();
|
||||
let handle = handle.clone();
|
||||
|
||||
subscriptions.push(cx.subscribe(input, move |_this, _input, event, cx| {
|
||||
if matches!(event, InputStateEvent::Submitted) {
|
||||
submit(&secret_input, &pass_input, &repass_input, &state, cx);
|
||||
submit(
|
||||
&secret_input,
|
||||
&pass_input,
|
||||
&repass_input,
|
||||
&state,
|
||||
&handle,
|
||||
cx,
|
||||
);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
Self {
|
||||
handle,
|
||||
secret_input,
|
||||
pass_input,
|
||||
repass_input,
|
||||
@@ -110,15 +120,11 @@ impl Render for ImportDialog {
|
||||
|
||||
let action_pass = pass_input.clone();
|
||||
let action_repass = repass_input.clone();
|
||||
let action_close = self.handle.clone();
|
||||
|
||||
Dialog::new("import-dialog")
|
||||
.open(true)
|
||||
.handle(self.handle.clone())
|
||||
.min_width(px(520.))
|
||||
.on_change(|open, _, cx| {
|
||||
if !open {
|
||||
close_global(cx);
|
||||
}
|
||||
})
|
||||
.title("Import identity")
|
||||
.content(move |_window, cx| {
|
||||
let state = state.read(cx);
|
||||
@@ -181,13 +187,14 @@ impl Render for ImportDialog {
|
||||
let pass = action_pass.clone();
|
||||
let repass = action_repass.clone();
|
||||
let state = action_state.clone();
|
||||
let handle = action_close.clone();
|
||||
|
||||
let import: AnyElement = Button::new("import-identity")
|
||||
.label(label)
|
||||
.loading(busy)
|
||||
.disabled(busy)
|
||||
.on_click(move |_, _, cx| {
|
||||
submit(&secret, &pass, &repass, &state, cx);
|
||||
submit(&secret, &pass, &repass, &state, &handle, cx);
|
||||
})
|
||||
.into_any_element();
|
||||
|
||||
@@ -201,6 +208,7 @@ fn submit(
|
||||
pass_input: &Entity<InputState>,
|
||||
repass_input: &Entity<InputState>,
|
||||
state: &Entity<ImportState>,
|
||||
handle: &DialogHandle,
|
||||
cx: &mut App,
|
||||
) {
|
||||
if state.read(cx).progress.busy {
|
||||
@@ -208,14 +216,19 @@ fn submit(
|
||||
}
|
||||
|
||||
match state.read(cx).stage {
|
||||
Stage::Credential => start_import(secret_input, state, cx),
|
||||
Stage::Encrypt => import_nsec(pass_input, repass_input, state, cx),
|
||||
Stage::Decrypt => import_ncryptsec(pass_input, state, cx),
|
||||
Stage::Credential => start_import(secret_input, state, handle, cx),
|
||||
Stage::Encrypt => import_nsec(pass_input, repass_input, state, handle, cx),
|
||||
Stage::Decrypt => import_ncryptsec(pass_input, state, handle, cx),
|
||||
}
|
||||
}
|
||||
|
||||
/// Parses the entered credential and either moves to the passphrase step or connects to a bunker.
|
||||
fn start_import(secret_input: &Entity<InputState>, state: &Entity<ImportState>, cx: &mut App) {
|
||||
fn start_import(
|
||||
secret_input: &Entity<InputState>,
|
||||
state: &Entity<ImportState>,
|
||||
handle: &DialogHandle,
|
||||
cx: &mut App,
|
||||
) {
|
||||
let credential = match Credential::parse(secret_input.read(cx).value()) {
|
||||
Some(credential) => credential,
|
||||
None => {
|
||||
@@ -254,7 +267,7 @@ fn start_import(secret_input: &Entity<InputState>, state: &Entity<ImportState>,
|
||||
|
||||
let backend = Backend::global(cx);
|
||||
let task = backend.update(cx, |backend, cx| backend.import_bunker(&uri, cx));
|
||||
finish_import(task, state, cx);
|
||||
finish_import(task, state, handle, cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,6 +277,7 @@ fn import_nsec(
|
||||
pass_input: &Entity<InputState>,
|
||||
repass_input: &Entity<InputState>,
|
||||
state: &Entity<ImportState>,
|
||||
handle: &DialogHandle,
|
||||
cx: &mut App,
|
||||
) {
|
||||
let backend = Backend::global(cx);
|
||||
@@ -293,11 +307,16 @@ fn import_nsec(
|
||||
});
|
||||
|
||||
let task = backend.update(cx, |backend, cx| backend.import_nsec(&nsec, &pass, cx));
|
||||
finish_import(task, state, cx);
|
||||
finish_import(task, state, handle, cx);
|
||||
}
|
||||
|
||||
/// Decrypts the entered `ncryptsec` with the passphrase and signs in with it.
|
||||
fn import_ncryptsec(pass_input: &Entity<InputState>, state: &Entity<ImportState>, cx: &mut App) {
|
||||
fn import_ncryptsec(
|
||||
pass_input: &Entity<InputState>,
|
||||
state: &Entity<ImportState>,
|
||||
handle: &DialogHandle,
|
||||
cx: &mut App,
|
||||
) {
|
||||
let backend = Backend::global(cx);
|
||||
let ncryptsec = state.read(cx).credential.clone();
|
||||
let pass = pass_input.read(cx).value().to_string();
|
||||
@@ -318,19 +337,21 @@ fn import_ncryptsec(pass_input: &Entity<InputState>, state: &Entity<ImportState>
|
||||
let task = backend.update(cx, |backend, cx| {
|
||||
backend.import_ncryptsec(&ncryptsec, &pass, cx)
|
||||
});
|
||||
finish_import(task, state, cx);
|
||||
finish_import(task, state, handle, cx);
|
||||
}
|
||||
|
||||
/// Runs the import task to completion, closing the dialog on success.
|
||||
fn finish_import<T: 'static>(
|
||||
task: Task<Result<T, anyhow::Error>>,
|
||||
state: &Entity<ImportState>,
|
||||
handle: &DialogHandle,
|
||||
cx: &mut App,
|
||||
) {
|
||||
let state = state.clone();
|
||||
let handle = handle.clone();
|
||||
|
||||
cx.spawn(async move |cx| match task.await {
|
||||
Ok(_) => cx.update(close_global),
|
||||
Ok(_) => cx.update(|cx| handle.close(cx)),
|
||||
Err(error) => {
|
||||
state.update(cx, |state, cx| {
|
||||
state.progress.fail(error.to_string());
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
pub mod exit;
|
||||
pub mod helpers;
|
||||
pub mod import;
|
||||
pub mod onboarding;
|
||||
pub mod passphrase;
|
||||
|
||||
@@ -6,15 +6,15 @@ use gpui::{
|
||||
use signed_state::Backend;
|
||||
use ui::button::Button;
|
||||
use ui::common::v_flex;
|
||||
use ui::dialog::Dialog;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::field::Field;
|
||||
use ui::input::{Input, InputState};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
|
||||
use crate::shared::dialogs::close_global;
|
||||
use crate::shared::progress::{DialogProgress, error_row};
|
||||
|
||||
pub struct OnboardingDialog {
|
||||
handle: DialogHandle,
|
||||
name_input: Entity<InputState>,
|
||||
pass_input: Entity<InputState>,
|
||||
repass_input: Entity<InputState>,
|
||||
@@ -29,6 +29,7 @@ impl OnboardingDialog {
|
||||
let repass_input = InputState::builder().password().build(cx);
|
||||
|
||||
cx.new(|_| Self {
|
||||
handle: DialogHandle::new(true),
|
||||
name_input,
|
||||
pass_input,
|
||||
repass_input,
|
||||
@@ -61,9 +62,10 @@ impl OnboardingDialog {
|
||||
let backend = Backend::global(cx);
|
||||
let task = backend.update(cx, |backend, cx| backend.create_identity(&name, &pass, cx));
|
||||
let state = self.state.clone();
|
||||
let handle = self.handle.clone();
|
||||
|
||||
cx.spawn(async move |_this, cx| match task.await {
|
||||
Ok(_) => cx.update(close_global),
|
||||
Ok(_) => cx.update(|cx| handle.close(cx)),
|
||||
Err(error) => {
|
||||
state.update(cx, |state, cx| {
|
||||
state.fail(error.to_string());
|
||||
@@ -85,13 +87,8 @@ impl Render for OnboardingDialog {
|
||||
let this = cx.entity().downgrade();
|
||||
|
||||
Dialog::new("onboarding-dialog")
|
||||
.open(true)
|
||||
.handle(self.handle.clone())
|
||||
.min_width(px(520.))
|
||||
.on_change(|open, _, cx| {
|
||||
if !open {
|
||||
close_global(cx);
|
||||
}
|
||||
})
|
||||
.title("Create identity")
|
||||
.content(move |_window, cx| {
|
||||
let progress = state.read(cx);
|
||||
|
||||
@@ -6,15 +6,15 @@ use gpui::{
|
||||
use signed_state::Backend;
|
||||
use ui::button::Button;
|
||||
use ui::common::v_flex;
|
||||
use ui::dialog::Dialog;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::field::Field;
|
||||
use ui::icons::{Icon, IconRole};
|
||||
use ui::input::{Input, InputState, InputStateEvent};
|
||||
|
||||
use crate::shared::dialogs::close_global;
|
||||
use crate::shared::progress::{DialogProgress, error_row, push_steps_row};
|
||||
|
||||
pub struct PassphraseDialog {
|
||||
handle: DialogHandle,
|
||||
pass_input: Entity<InputState>,
|
||||
state: Entity<DialogProgress>,
|
||||
_enter_subscription: Subscription,
|
||||
@@ -34,6 +34,7 @@ impl PassphraseDialog {
|
||||
});
|
||||
|
||||
Self {
|
||||
handle: DialogHandle::new(true),
|
||||
pass_input,
|
||||
state,
|
||||
_enter_subscription: enter_subscription,
|
||||
@@ -64,11 +65,10 @@ impl PassphraseDialog {
|
||||
let backend = Backend::global(cx);
|
||||
let task = backend.update(cx, |backend, cx| backend.restore_with_passphrase(&pass, cx));
|
||||
let state = self.state.clone();
|
||||
let handle = self.handle.clone();
|
||||
|
||||
cx.spawn(async move |_this, cx| match task.await {
|
||||
Ok(_) => {
|
||||
cx.update(close_global);
|
||||
}
|
||||
Ok(_) => cx.update(|cx| handle.close(cx)),
|
||||
Err(error) => {
|
||||
state.update(cx, |state, cx| {
|
||||
state.fail(error.to_string());
|
||||
@@ -88,8 +88,9 @@ impl Render for PassphraseDialog {
|
||||
let this = cx.entity().downgrade();
|
||||
|
||||
Dialog::new("passphrase-dialog")
|
||||
.open(true)
|
||||
.on_change(|_open, _, _| {})
|
||||
.handle(self.handle.clone())
|
||||
.close_on_escape(false)
|
||||
.close_on_backdrop(false)
|
||||
.min_width(px(420.))
|
||||
.title("Unlock your identity")
|
||||
.content(move |_window, cx| {
|
||||
|
||||
@@ -34,6 +34,7 @@ const ISSUE_ROW_HEIGHT: f32 = 73.;
|
||||
pub struct IssuesView {
|
||||
workspace: WeakEntity<Workspace>,
|
||||
store: Entity<RepoStore>,
|
||||
new_issue: Option<Entity<new_issue::NewIssueDialog>>,
|
||||
filter: IssueFilter,
|
||||
visible_issues: Vec<usize>,
|
||||
counts: StatusCounts,
|
||||
@@ -61,7 +62,8 @@ impl IssuesView {
|
||||
|
||||
Self {
|
||||
workspace,
|
||||
store,
|
||||
store: store.clone(),
|
||||
new_issue: None,
|
||||
filter: IssueFilter::Open,
|
||||
visible_issues: Vec::new(),
|
||||
counts: StatusCounts::default(),
|
||||
@@ -72,6 +74,11 @@ impl IssuesView {
|
||||
}
|
||||
}
|
||||
|
||||
fn open_new_issue(&mut self, cx: &mut Context<Self>) {
|
||||
self.new_issue = Some(new_issue::NewIssueDialog::new(self.store.clone(), cx));
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/// Total number of issues across all statuses, for the sidebar label.
|
||||
pub fn total_count(&self) -> usize {
|
||||
self.counts.total
|
||||
@@ -159,7 +166,7 @@ impl IssuesView {
|
||||
.label("New issue")
|
||||
.icon(Icon::named(IconRole::CirclePlus))
|
||||
.on_click(cx.listener(|this, _, _, cx| {
|
||||
new_issue::open(this.store.clone(), cx);
|
||||
this.open_new_issue(cx);
|
||||
})),
|
||||
)
|
||||
.into_any_element()
|
||||
@@ -184,6 +191,7 @@ impl Render for IssuesView {
|
||||
v_flex()
|
||||
.size_full()
|
||||
.child(self.render_header(cx))
|
||||
.when_some(self.new_issue.clone(), |el, view| el.child(view))
|
||||
.child(
|
||||
v_flex()
|
||||
.relative()
|
||||
|
||||
@@ -5,14 +5,13 @@ use gpui::{
|
||||
use signed_state::RepoStore;
|
||||
use ui::button::Button;
|
||||
use ui::common::v_flex;
|
||||
use ui::dialog::Dialog;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::field::Field;
|
||||
use ui::input::{Input, InputState};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
|
||||
use crate::shared::dialogs::{close_global, open_global};
|
||||
|
||||
pub struct NewIssueDialog {
|
||||
handle: DialogHandle,
|
||||
store: Entity<RepoStore>,
|
||||
subject: Entity<InputState>,
|
||||
content: Entity<InputState>,
|
||||
@@ -24,6 +23,7 @@ impl NewIssueDialog {
|
||||
let content = InputState::builder().multiline().build(cx);
|
||||
|
||||
cx.new(|_| Self {
|
||||
handle: DialogHandle::new(true),
|
||||
store,
|
||||
subject,
|
||||
content,
|
||||
@@ -39,7 +39,7 @@ impl NewIssueDialog {
|
||||
store.open_issue(subject, content, cx);
|
||||
});
|
||||
|
||||
close_global(cx);
|
||||
self.handle.close(cx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,13 +50,8 @@ impl Render for NewIssueDialog {
|
||||
let this = cx.entity().downgrade();
|
||||
|
||||
Dialog::new("new-issue-dialog")
|
||||
.open(true)
|
||||
.handle(self.handle.clone())
|
||||
.min_width(gpui::px(520.))
|
||||
.on_change(|open, _, cx| {
|
||||
if !open {
|
||||
close_global(cx);
|
||||
}
|
||||
})
|
||||
.title("New issue")
|
||||
.content(move |_, cx| {
|
||||
v_flex()
|
||||
@@ -90,8 +85,3 @@ impl Render for NewIssueDialog {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Opens the new-issue form for `store`.
|
||||
pub fn open(store: Entity<RepoStore>, cx: &mut App) {
|
||||
open_global(NewIssueDialog::new(store, cx), cx);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ pub struct PullRequestDetailView {
|
||||
workspace: WeakEntity<Workspace>,
|
||||
store: Entity<RepoStore>,
|
||||
pr_id: EventId,
|
||||
update_dialog: Option<Entity<dialogs::update::UpdatePrDialog>>,
|
||||
comment_input: Entity<InputState>,
|
||||
worktree: Option<PathBuf>,
|
||||
description: SharedString,
|
||||
@@ -90,6 +91,7 @@ impl PullRequestDetailView {
|
||||
workspace,
|
||||
store,
|
||||
pr_id,
|
||||
update_dialog: None,
|
||||
comment_input,
|
||||
worktree: None,
|
||||
description: SharedString::default(),
|
||||
@@ -555,7 +557,13 @@ impl PullRequestDetailView {
|
||||
})
|
||||
.cloned();
|
||||
if let Some(root) = root {
|
||||
dialogs::update::open(this.store.clone(), root, cx);
|
||||
this.update_dialog =
|
||||
Some(dialogs::update::UpdatePrDialog::new(
|
||||
this.store.clone(),
|
||||
root,
|
||||
cx,
|
||||
));
|
||||
cx.notify();
|
||||
}
|
||||
}));
|
||||
},
|
||||
@@ -596,6 +604,7 @@ impl Render for PullRequestDetailView {
|
||||
.size_full()
|
||||
.min_h_0()
|
||||
.child(self.render_header(cx))
|
||||
.when_some(self.update_dialog.clone(), |el, view| el.child(view))
|
||||
.child(self.render_tabs(cx))
|
||||
.map(|this| match self.active_tab {
|
||||
0 => this.child(self.render_discussion(cx)),
|
||||
|
||||
@@ -6,14 +6,13 @@ use nostr::prelude::Event;
|
||||
use signed_state::RepoStore;
|
||||
use ui::button::Button;
|
||||
use ui::common::v_flex;
|
||||
use ui::dialog::Dialog;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::field::Field;
|
||||
use ui::input::{Input, InputState};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
|
||||
use crate::shared::dialogs::{close_global, open_global};
|
||||
|
||||
pub struct UpdatePrDialog {
|
||||
handle: DialogHandle,
|
||||
store: Entity<RepoStore>,
|
||||
root: Event,
|
||||
patch: Entity<InputState>,
|
||||
@@ -22,7 +21,12 @@ pub struct UpdatePrDialog {
|
||||
impl UpdatePrDialog {
|
||||
pub fn new(store: Entity<RepoStore>, root: Event, cx: &mut App) -> Entity<Self> {
|
||||
let patch = InputState::builder().multiline().build(cx);
|
||||
cx.new(|_| Self { store, root, patch })
|
||||
cx.new(|_| Self {
|
||||
handle: DialogHandle::new(true),
|
||||
store,
|
||||
root,
|
||||
patch,
|
||||
})
|
||||
}
|
||||
|
||||
fn submit(&mut self, cx: &mut Context<Self>) {
|
||||
@@ -33,7 +37,7 @@ impl UpdatePrDialog {
|
||||
self.store.update(cx, |store, cx| {
|
||||
store.update_pull_request(&self.root, patch, cx);
|
||||
});
|
||||
close_global(cx);
|
||||
self.handle.close(cx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,13 +47,8 @@ impl Render for UpdatePrDialog {
|
||||
let this = cx.entity().downgrade();
|
||||
|
||||
Dialog::new("update-pr-dialog")
|
||||
.open(true)
|
||||
.handle(self.handle.clone())
|
||||
.min_width(gpui::px(520.))
|
||||
.on_change(|open, _, cx| {
|
||||
if !open {
|
||||
close_global(cx);
|
||||
}
|
||||
})
|
||||
.title("Update pull request")
|
||||
.content(move |_, cx| {
|
||||
v_flex()
|
||||
@@ -79,7 +78,3 @@ impl Render for UpdatePrDialog {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn open(store: Entity<RepoStore>, root: Event, cx: &mut App) {
|
||||
open_global(UpdatePrDialog::new(store, root, cx), cx);
|
||||
}
|
||||
|
||||
@@ -8,13 +8,12 @@ use signed_core::Announcement;
|
||||
use ui::avatar::Avatar;
|
||||
use ui::clipboard::ClipboardButton;
|
||||
use ui::common::{Sizable as _, h_flex, v_flex};
|
||||
use ui::dialog::Dialog;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use utils::middle_truncate;
|
||||
|
||||
use crate::shared::dialogs::{close_global, open_global};
|
||||
|
||||
pub struct AboutDialog {
|
||||
handle: DialogHandle,
|
||||
announcement: Announcement,
|
||||
directory: Entity<ProfileDirectory>,
|
||||
}
|
||||
@@ -26,6 +25,7 @@ impl AboutDialog {
|
||||
cx: &mut App,
|
||||
) -> Entity<Self> {
|
||||
cx.new(|_| Self {
|
||||
handle: DialogHandle::new(true),
|
||||
announcement,
|
||||
directory,
|
||||
})
|
||||
@@ -38,13 +38,8 @@ impl Render for AboutDialog {
|
||||
let directory = self.directory.clone();
|
||||
|
||||
Dialog::new("about-dialog")
|
||||
.open(true)
|
||||
.handle(self.handle.clone())
|
||||
.min_width(px(500.))
|
||||
.on_change(|open, _, cx| {
|
||||
if !open {
|
||||
close_global(cx);
|
||||
}
|
||||
})
|
||||
.title("About")
|
||||
.content(move |_, cx| announcement_rows(&announcement, &directory, cx))
|
||||
.into_any_element()
|
||||
@@ -259,8 +254,3 @@ fn list(id: &'static str, items: impl IntoIterator<Item = String>, cx: &App) ->
|
||||
}))
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
/// Opens the read-only repository metadata dialog.
|
||||
pub fn open(announcement: Announcement, directory: Entity<ProfileDirectory>, cx: &mut App) {
|
||||
open_global(AboutDialog::new(announcement, directory, cx), cx);
|
||||
}
|
||||
|
||||
@@ -3,34 +3,35 @@ use std::path::PathBuf;
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext as _, Context, Entity, IntoElement, ParentElement as _,
|
||||
PathPromptOptions, Render, Styled as _, WeakEntity, Window, div, px,
|
||||
PathPromptOptions, Render, Styled as _, Task, WeakEntity, Window, div, px,
|
||||
};
|
||||
use settings::SettingsStore;
|
||||
use signed_state::{Backend, CheckoutsStore};
|
||||
use ui::button::{Button, ButtonVariant};
|
||||
use ui::common::{h_flex, v_flex};
|
||||
use ui::dialog::Dialog;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::field::Field;
|
||||
use ui::icons::{Icon, IconRole};
|
||||
use ui::input::{Input, InputState};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use ui::tooltip::Tooltip;
|
||||
|
||||
use super::grasp_servers::{GraspServersState, grasp_servers_field, load_user_grasp_servers};
|
||||
use crate::repo::actions::open_repo_panel;
|
||||
use crate::shared::dialogs::{close_global, open_global};
|
||||
use crate::shared::progress::{DialogProgress, error_row, push_steps_row};
|
||||
use crate::workspace::Workspace;
|
||||
|
||||
/// Progress of the create-repository flow, so async results can be rendered.
|
||||
pub struct CreateRepoDialog {
|
||||
workspace: WeakEntity<Workspace>,
|
||||
handle: DialogHandle,
|
||||
name_input: Entity<InputState>,
|
||||
desc_input: Entity<InputState>,
|
||||
folder_input: Entity<InputState>,
|
||||
relay_input: Entity<InputState>,
|
||||
state: Entity<DialogProgress>,
|
||||
grasp_state: Entity<GraspServersState>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
/// Held so the grasp-server load is cancelled when the dialog drops.
|
||||
task: Option<Task<()>>,
|
||||
}
|
||||
|
||||
impl CreateRepoDialog {
|
||||
@@ -40,6 +41,11 @@ impl CreateRepoDialog {
|
||||
cx: &mut App,
|
||||
) -> Entity<Self> {
|
||||
let settings = SettingsStore::global(cx);
|
||||
let grasp_settings = settings.read(cx).settings().grasp_servers.clone();
|
||||
|
||||
let name_input = InputState::new(cx);
|
||||
let desc_input = InputState::builder().multiline().build(cx);
|
||||
|
||||
let default_folder = settings
|
||||
.read(cx)
|
||||
.settings()
|
||||
@@ -47,29 +53,33 @@ impl CreateRepoDialog {
|
||||
.default_folder
|
||||
.clone()
|
||||
.unwrap_or_else(paths::desktop_dir);
|
||||
let grasp_settings = settings.read(cx).settings().grasp_servers.clone();
|
||||
|
||||
let name_input = InputState::new(cx);
|
||||
let desc_input = InputState::builder().multiline().build(cx);
|
||||
let folder_input = InputState::builder()
|
||||
.text(default_folder.to_string_lossy())
|
||||
.read_only()
|
||||
.build(cx);
|
||||
folder_input.update(cx, |state, cx| state.set_read_only(true, cx));
|
||||
|
||||
let relay_input = InputState::new(cx);
|
||||
let state = cx.new(|_| DialogProgress::default());
|
||||
let grasp_state = cx.new(|_| GraspServersState::new_default(&grasp_settings));
|
||||
|
||||
load_user_grasp_servers(grasp_state.clone(), window, cx);
|
||||
cx.new(|cx| {
|
||||
cx.defer_in(window, move |this: &mut Self, window, cx| {
|
||||
let task = load_user_grasp_servers(this.grasp_state.clone(), window, cx);
|
||||
this.task = Some(task);
|
||||
});
|
||||
|
||||
cx.new(|_| Self {
|
||||
name_input,
|
||||
desc_input,
|
||||
folder_input,
|
||||
relay_input,
|
||||
state,
|
||||
grasp_state,
|
||||
workspace,
|
||||
Self {
|
||||
workspace,
|
||||
handle: DialogHandle::new(true),
|
||||
name_input,
|
||||
desc_input,
|
||||
folder_input,
|
||||
relay_input,
|
||||
state,
|
||||
grasp_state,
|
||||
task: None,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -110,6 +120,7 @@ impl CreateRepoDialog {
|
||||
});
|
||||
let state = self.state.clone();
|
||||
let workspace = self.workspace.clone();
|
||||
let close = self.handle.clone();
|
||||
let handle = window.window_handle();
|
||||
|
||||
cx.spawn(async move |_this, cx| match task.await {
|
||||
@@ -127,7 +138,7 @@ impl CreateRepoDialog {
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
close_global(cx);
|
||||
close.close(cx);
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
@@ -161,27 +172,16 @@ impl Render for CreateRepoDialog {
|
||||
let this = cx.entity().downgrade();
|
||||
|
||||
Dialog::new("create-repo-dialog")
|
||||
.open(true)
|
||||
.handle(self.handle.clone())
|
||||
.min_width(px(520.))
|
||||
.on_change(|open, _, cx| {
|
||||
if !open {
|
||||
close_global(cx);
|
||||
}
|
||||
})
|
||||
.title("Create repository")
|
||||
.title("Create Repository")
|
||||
.content(move |_window, cx| {
|
||||
let progress = state.read(cx);
|
||||
|
||||
v_flex()
|
||||
.gap_3()
|
||||
.child(
|
||||
div()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child("Publish a new repository to your grasp servers."),
|
||||
)
|
||||
.child(
|
||||
Field::new("repo-name", "Repository name")
|
||||
Field::new("repo-name", "Repository Name")
|
||||
.description("Max 100 characters")
|
||||
.child(Input::new("repo-name-input", name_input.clone())),
|
||||
)
|
||||
@@ -196,7 +196,7 @@ impl Render for CreateRepoDialog {
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.items_center()
|
||||
.w_full()
|
||||
.child(div().flex_1().child(Input::new(
|
||||
"repo-folder-input",
|
||||
folder_input.clone(),
|
||||
@@ -275,8 +275,3 @@ fn choose_folder(folder_input: &Entity<InputState>, window: &mut Window, cx: &mu
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
|
||||
/// Opens the create-repository form.
|
||||
pub fn open(workspace: WeakEntity<Workspace>, window: &mut Window, cx: &mut App) {
|
||||
open_global(CreateRepoDialog::new(workspace, window, cx), cx);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext as _, Entity, IntoElement, ParentElement as _, SharedString,
|
||||
Styled as _, Window, div,
|
||||
Styled as _, Task, Window, div,
|
||||
};
|
||||
use nostr::prelude::RelayUrl;
|
||||
use settings::{DEFAULT_GRASP_SERVERS, GraspServersSettings};
|
||||
@@ -214,7 +214,7 @@ pub fn load_user_grasp_servers(
|
||||
state: Entity<GraspServersState>,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) {
|
||||
) -> Task<()> {
|
||||
let backend = Backend::global(cx);
|
||||
let (user, client) = {
|
||||
let backend = backend.read(cx);
|
||||
@@ -223,7 +223,7 @@ pub fn load_user_grasp_servers(
|
||||
|
||||
let Some(user) = user else {
|
||||
state.update(cx, |state, _| state.loading_servers = false);
|
||||
return;
|
||||
return Task::ready(());
|
||||
};
|
||||
|
||||
let task =
|
||||
@@ -249,7 +249,6 @@ pub fn load_user_grasp_servers(
|
||||
log::warn!("failed to apply grasp servers: {error}");
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
|
||||
/// Normalize a user-typed grasp server, adding a `wss://` scheme when none is given.
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::path::PathBuf;
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext as _, Context, Entity, IntoElement, ParentElement as _, Render,
|
||||
SharedString, Styled as _, WeakEntity, Window, div, px,
|
||||
SharedString, Styled as _, Task, WeakEntity, Window, div, px,
|
||||
};
|
||||
use settings::SettingsStore;
|
||||
use signed_core::RepoAddr;
|
||||
@@ -11,7 +11,7 @@ use signed_git::Repo;
|
||||
use signed_state::Backend;
|
||||
use ui::button::Button;
|
||||
use ui::common::v_flex;
|
||||
use ui::dialog::Dialog;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::field::Field;
|
||||
use ui::icons::{Icon, IconRole};
|
||||
use ui::input::{Input, InputState};
|
||||
@@ -20,10 +20,10 @@ use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
|
||||
use super::grasp_servers::{GraspServersState, grasp_servers_field, load_user_grasp_servers};
|
||||
use crate::repo::RepoDetailView;
|
||||
use crate::shared::dialogs::{close_global, open_global};
|
||||
use crate::shared::progress::{DialogProgress, error_row, push_steps_row};
|
||||
|
||||
pub struct InitRepoDialog {
|
||||
handle: DialogHandle,
|
||||
local_path: PathBuf,
|
||||
name_input: Entity<InputState>,
|
||||
desc_input: Entity<InputState>,
|
||||
@@ -33,6 +33,8 @@ pub struct InitRepoDialog {
|
||||
branches: Vec<SharedString>,
|
||||
selected_branch: Option<SharedString>,
|
||||
view: WeakEntity<RepoDetailView>,
|
||||
/// Held so the grasp-server load is cancelled when the dialog drops.
|
||||
task: Option<Task<()>>,
|
||||
}
|
||||
|
||||
impl InitRepoDialog {
|
||||
@@ -63,18 +65,25 @@ impl InitRepoDialog {
|
||||
let desc_input = InputState::builder().multiline().build(cx);
|
||||
let relay_input = InputState::new(cx);
|
||||
|
||||
load_user_grasp_servers(grasp_state.clone(), window, cx);
|
||||
let dialog = cx.new(|cx| {
|
||||
cx.defer_in(window, move |this: &mut Self, window, cx| {
|
||||
let task = load_user_grasp_servers(this.grasp_state.clone(), window, cx);
|
||||
this.task = Some(task);
|
||||
});
|
||||
|
||||
let dialog = cx.new(|_| Self {
|
||||
local_path,
|
||||
name_input,
|
||||
desc_input,
|
||||
relay_input,
|
||||
state,
|
||||
grasp_state,
|
||||
branches: Vec::new(),
|
||||
selected_branch: None,
|
||||
view,
|
||||
Self {
|
||||
handle: DialogHandle::new(true),
|
||||
local_path,
|
||||
name_input,
|
||||
desc_input,
|
||||
relay_input,
|
||||
state,
|
||||
grasp_state,
|
||||
branches: Vec::new(),
|
||||
selected_branch: None,
|
||||
view,
|
||||
task: None,
|
||||
}
|
||||
});
|
||||
|
||||
load_branches(dialog.clone(), cx);
|
||||
@@ -122,12 +131,13 @@ impl InitRepoDialog {
|
||||
});
|
||||
let state = self.state.clone();
|
||||
let view = self.view.clone();
|
||||
let close = self.handle.clone();
|
||||
let handle = window.window_handle();
|
||||
|
||||
cx.spawn(async move |_this, cx| match task.await {
|
||||
Ok(announcement) => {
|
||||
cx.update_window(handle, |_, _window, cx| {
|
||||
close_global(cx);
|
||||
close.close(cx);
|
||||
if let Some(view) = view.upgrade() {
|
||||
view.update(cx, |this, cx| this.apply_announcement(announcement, cx));
|
||||
}
|
||||
@@ -166,13 +176,8 @@ impl Render for InitRepoDialog {
|
||||
let selected_branch = self.selected_branch.clone();
|
||||
|
||||
Dialog::new("init-repo-dialog")
|
||||
.open(true)
|
||||
.handle(self.handle.clone())
|
||||
.min_width(px(520.))
|
||||
.on_change(|open, _, cx| {
|
||||
if !open {
|
||||
close_global(cx);
|
||||
}
|
||||
})
|
||||
.title("Initialize repository")
|
||||
.content(move |_, cx| {
|
||||
let progress = state.read(cx);
|
||||
@@ -279,13 +284,3 @@ fn load_branches(dialog: Entity<InitRepoDialog>, cx: &mut App) {
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
|
||||
/// Opens the initialize form for `local_path`.
|
||||
pub fn open(
|
||||
local_path: PathBuf,
|
||||
view: WeakEntity<RepoDetailView>,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) {
|
||||
open_global(InitRepoDialog::new(local_path, view, window, cx), cx);
|
||||
}
|
||||
|
||||
@@ -5,19 +5,22 @@ use gpui::{
|
||||
use signed_state::RepoStore;
|
||||
use ui::button::{Button, ButtonVariant};
|
||||
use ui::common::v_flex;
|
||||
use ui::dialog::Dialog;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
|
||||
use crate::shared::dialogs::{close_global, open_global};
|
||||
|
||||
pub struct ResetRemoteDialog {
|
||||
handle: DialogHandle,
|
||||
store: Entity<RepoStore>,
|
||||
deleted: Vec<String>,
|
||||
}
|
||||
|
||||
impl ResetRemoteDialog {
|
||||
pub fn new(store: Entity<RepoStore>, deleted: Vec<String>, cx: &mut App) -> Entity<Self> {
|
||||
cx.new(|_| Self { store, deleted })
|
||||
cx.new(|_| Self {
|
||||
handle: DialogHandle::new(true),
|
||||
store,
|
||||
deleted,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,15 +28,12 @@ impl Render for ResetRemoteDialog {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let deleted = self.deleted.clone();
|
||||
let store = self.store.clone();
|
||||
let cancel_close = self.handle.clone();
|
||||
let confirm_close = self.handle.clone();
|
||||
|
||||
Dialog::new("reset-remote-dialog")
|
||||
.open(true)
|
||||
.handle(self.handle.clone())
|
||||
.min_width(px(480.))
|
||||
.on_change(|open, _, cx| {
|
||||
if !open {
|
||||
close_global(cx);
|
||||
}
|
||||
})
|
||||
.title("Reset remote to local")
|
||||
.content(move |_, cx| {
|
||||
v_flex()
|
||||
@@ -67,10 +67,13 @@ impl Render for ResetRemoteDialog {
|
||||
})
|
||||
.actions(move |_, _| {
|
||||
let store = store.clone();
|
||||
let cancel_close = cancel_close.clone();
|
||||
let confirm_close = confirm_close.clone();
|
||||
|
||||
let cancel: AnyElement = Button::new("cancel-reset-remote")
|
||||
.label("Cancel")
|
||||
.variant(ButtonVariant::Secondary)
|
||||
.on_click(|_, _, cx| close_global(cx))
|
||||
.on_click(move |_, _, cx| cancel_close.close(cx))
|
||||
.into_any_element();
|
||||
|
||||
let confirm: AnyElement = Button::new("confirm-reset-remote")
|
||||
@@ -84,7 +87,7 @@ impl Render for ResetRemoteDialog {
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
close_global(cx);
|
||||
confirm_close.close(cx);
|
||||
})
|
||||
.into_any_element();
|
||||
|
||||
@@ -92,8 +95,3 @@ impl Render for ResetRemoteDialog {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Opens the reset confirmation listing the refs the reset deletes.
|
||||
pub fn open(store: Entity<RepoStore>, deleted: Vec<String>, cx: &mut App) {
|
||||
open_global(ResetRemoteDialog::new(store, deleted, cx), cx);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,13 @@ impl RepoDetailView {
|
||||
let Some(local_path) = self.store.read(cx).path.clone() else {
|
||||
return;
|
||||
};
|
||||
dialogs::init::open(local_path, cx.entity().downgrade(), window, cx);
|
||||
self.init = Some(dialogs::init::InitRepoDialog::new(
|
||||
local_path,
|
||||
cx.entity().downgrade(),
|
||||
window,
|
||||
cx,
|
||||
));
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub(super) fn render_about(&mut self, cx: &mut Context<Self>) -> AnyElement {
|
||||
@@ -225,11 +231,12 @@ impl RepoDetailView {
|
||||
let announcement = announcement_for_menu.clone();
|
||||
move |_, cx| {
|
||||
if let Err(error) = weak.update(cx, |this, cx| {
|
||||
dialogs::about::open(
|
||||
this.about = Some(dialogs::about::AboutDialog::new(
|
||||
announcement.clone(),
|
||||
this.directory.clone(),
|
||||
cx,
|
||||
);
|
||||
));
|
||||
cx.notify();
|
||||
}) {
|
||||
log::warn!("failed to open about: {error}");
|
||||
}
|
||||
|
||||
@@ -63,6 +63,9 @@ pub enum RefKind {
|
||||
pub struct RepoDetailView {
|
||||
pub(super) workspace: WeakEntity<Workspace>,
|
||||
pub(super) store: Entity<RepoStore>,
|
||||
about: Option<Entity<dialogs::about::AboutDialog>>,
|
||||
init: Option<Entity<dialogs::init::InitRepoDialog>>,
|
||||
reset: Option<Entity<dialogs::reset::ResetRemoteDialog>>,
|
||||
/// A repository opened by address alone starts without an announcement.
|
||||
repo_started: bool,
|
||||
/// The file explorer and preview.
|
||||
@@ -171,6 +174,9 @@ impl RepoDetailView {
|
||||
Self {
|
||||
workspace,
|
||||
store: store.clone(),
|
||||
about: None,
|
||||
init: None,
|
||||
reset: None,
|
||||
repo_started: false,
|
||||
files,
|
||||
history,
|
||||
@@ -808,7 +814,10 @@ impl RepoDetailView {
|
||||
let deleted = probe.await;
|
||||
|
||||
this.update_in(cx, |this, _window, cx| match deleted {
|
||||
Ok(deleted) => dialogs::reset::open(store, deleted, cx),
|
||||
Ok(deleted) => {
|
||||
this.reset = Some(dialogs::reset::ResetRemoteDialog::new(store, deleted, cx));
|
||||
cx.notify();
|
||||
}
|
||||
Err(error) => {
|
||||
this.error = Some(error.to_string().into());
|
||||
cx.notify();
|
||||
@@ -1030,5 +1039,8 @@ impl Render for RepoDetailView {
|
||||
.child(self.render_pane(cx)),
|
||||
),
|
||||
)
|
||||
.when_some(self.about.clone(), |el, view| el.child(view))
|
||||
.when_some(self.init.clone(), |el, view| el.child(view))
|
||||
.when_some(self.reset.clone(), |el, view| el.child(view))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,8 @@ pub fn event_fetching_select(cx: &App) -> Select<EventFetchingStrategy> {
|
||||
}
|
||||
|
||||
pub fn grasp_servers_editor(input: &Entity<InputState>, cx: &App) -> AnyElement {
|
||||
let servers = SettingsStore::global(cx)
|
||||
let store = SettingsStore::global(cx);
|
||||
let servers = store
|
||||
.read(cx)
|
||||
.settings()
|
||||
.grasp_servers
|
||||
@@ -117,17 +118,16 @@ pub fn grasp_servers_editor(input: &Entity<InputState>, cx: &App) -> AnyElement
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.children(servers.iter().enumerate().map(|(ix, server)| {
|
||||
let store = SettingsStore::global(cx);
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.child(
|
||||
div()
|
||||
h_flex()
|
||||
.flex_1()
|
||||
.h_8()
|
||||
.px_2()
|
||||
.bg(cx.theme().colors.muted)
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.typeset(TextRole::Body, cx)
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.rounded(cx.theme().radius.control)
|
||||
.child(display_server(server)),
|
||||
)
|
||||
@@ -167,7 +167,9 @@ pub fn grasp_servers_editor(input: &Entity<InputState>, cx: &App) -> AnyElement
|
||||
.tooltip(Tooltip::text("Add grasp server"))
|
||||
.on_click({
|
||||
let input = input.clone();
|
||||
move |_, window, cx| add_server(&input, window, cx)
|
||||
move |_, window, cx| {
|
||||
add_server(&input, window, cx);
|
||||
}
|
||||
}),
|
||||
),
|
||||
)
|
||||
@@ -182,14 +184,18 @@ fn display_server(server: &str) -> SharedString {
|
||||
}
|
||||
|
||||
fn add_server(input: &Entity<InputState>, window: &mut Window, cx: &mut App) {
|
||||
let settings = SettingsStore::global(cx);
|
||||
let value = input.read(cx).value().trim().to_owned();
|
||||
|
||||
if value.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
let Some((normalized, _)) = normalize_server(&value) else {
|
||||
return;
|
||||
};
|
||||
SettingsStore::global(cx).update(cx, |store, cx| {
|
||||
|
||||
settings.update(cx, |store, cx| {
|
||||
store.edit(
|
||||
|settings| {
|
||||
if !settings.grasp_servers.default_servers.contains(&normalized) {
|
||||
@@ -206,28 +212,22 @@ fn add_server(input: &Entity<InputState>, window: &mut Window, cx: &mut App) {
|
||||
}
|
||||
|
||||
pub fn scan_paths_editor(cx: &App) -> AnyElement {
|
||||
let scan_paths = SettingsStore::global(cx)
|
||||
.read(cx)
|
||||
.settings()
|
||||
.local_repos
|
||||
.scan_paths
|
||||
.clone();
|
||||
let store = SettingsStore::global(cx);
|
||||
let scan_paths = store.read(cx).settings().local_repos.scan_paths.clone();
|
||||
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.children(scan_paths.iter().enumerate().map(|(ix, path)| {
|
||||
let store = store.clone();
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.child(
|
||||
div()
|
||||
h_flex()
|
||||
.flex_1()
|
||||
.h_8()
|
||||
.px_2()
|
||||
.bg(cx.theme().colors.muted)
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.typeset(TextRole::Body, cx)
|
||||
.typeset(TextRole::Caption, cx)
|
||||
.rounded(cx.theme().radius.control)
|
||||
.child(path.display().to_string()),
|
||||
)
|
||||
@@ -237,6 +237,7 @@ pub fn scan_paths_editor(cx: &App) -> AnyElement {
|
||||
.variant(ui::button::ButtonVariant::Ghost)
|
||||
.tooltip(Tooltip::text("Remove"))
|
||||
.on_click(move |_, _, cx| {
|
||||
let store = SettingsStore::global(cx);
|
||||
store.update(cx, |store, cx| {
|
||||
store.edit(
|
||||
|settings| {
|
||||
|
||||
@@ -10,13 +10,12 @@ use helpers::{
|
||||
};
|
||||
use settings::SettingsStore;
|
||||
use ui::common::v_flex;
|
||||
use ui::dialog::Dialog;
|
||||
use ui::dialog::{Dialog, DialogHandle};
|
||||
use ui::input::InputState;
|
||||
use ui::separator::Separator;
|
||||
|
||||
use crate::shared::dialogs::open_global;
|
||||
|
||||
pub struct SettingsDialog {
|
||||
handle: DialogHandle,
|
||||
grasp_input: Entity<InputState>,
|
||||
default_folder: Entity<InputState>,
|
||||
}
|
||||
@@ -39,6 +38,7 @@ impl SettingsDialog {
|
||||
.build(cx);
|
||||
|
||||
cx.new(|_| Self {
|
||||
handle: DialogHandle::new(true),
|
||||
grasp_input,
|
||||
default_folder,
|
||||
})
|
||||
@@ -47,61 +47,58 @@ impl SettingsDialog {
|
||||
|
||||
impl Render for SettingsDialog {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
const APPEARANCE_DESC: &str =
|
||||
"Choose whether the app follows the system theme or uses a light/dark theme.";
|
||||
const FETCH_DESC: &str = "Curated fetches events from relays in the repository's announcement. Uncensored also fetches from every maintainer's relays.";
|
||||
const GRASP_DESC: &str =
|
||||
"Servers used to host your git repositories via the Grasp protocol";
|
||||
const SCAN_DESC: &str = "Directories scanned for local git repositories.";
|
||||
const FOLDER_DESC: &str = "The folder for newly created repositories.";
|
||||
|
||||
let grasp_input = self.grasp_input.clone();
|
||||
let default_folder = self.default_folder.clone();
|
||||
|
||||
Dialog::new("settings-dialog")
|
||||
.open(true)
|
||||
.min_width(px(650.))
|
||||
.handle(self.handle.clone())
|
||||
.height(px(560.))
|
||||
.on_change(|open, _, cx| {
|
||||
if !open {
|
||||
crate::shared::dialogs::close_global(cx);
|
||||
}
|
||||
})
|
||||
.title("Settings")
|
||||
.content(move |_, cx| {
|
||||
v_flex()
|
||||
.gap_4()
|
||||
.child(setting_row(
|
||||
cx,
|
||||
"Appearance",
|
||||
"Choose whether the app follows the system theme or uses a light/dark theme.",
|
||||
appearance_select(cx),
|
||||
))
|
||||
.child(Separator::horizontal())
|
||||
.child(setting_row(
|
||||
cx,
|
||||
"Event Fetching Strategy",
|
||||
"Curated fetches events from relays in the repository's announcement. Uncensored also fetches from every maintainer's relays.",
|
||||
event_fetching_select(cx),
|
||||
))
|
||||
.child(Separator::horizontal())
|
||||
.child(setting_block(
|
||||
cx,
|
||||
"Grasp Servers",
|
||||
"Servers used to host your git repositories via the Grasp protocol",
|
||||
grasp_servers_editor(&grasp_input, cx),
|
||||
))
|
||||
.child(Separator::horizontal())
|
||||
.child(setting_block(
|
||||
cx,
|
||||
"Scan Directories",
|
||||
"Directories scanned for local git repositories.",
|
||||
scan_paths_editor(cx),
|
||||
))
|
||||
.child(setting_block(
|
||||
cx,
|
||||
"Default Folder",
|
||||
"The folder for newly created repositories.",
|
||||
default_folder_selector(&default_folder),
|
||||
))
|
||||
.gap_4()
|
||||
.child(setting_row(
|
||||
cx,
|
||||
"Appearance",
|
||||
APPEARANCE_DESC,
|
||||
appearance_select(cx),
|
||||
))
|
||||
.child(Separator::horizontal())
|
||||
.child(setting_row(
|
||||
cx,
|
||||
"Event Fetching Strategy",
|
||||
FETCH_DESC,
|
||||
event_fetching_select(cx),
|
||||
))
|
||||
.child(Separator::horizontal())
|
||||
.child(setting_block(
|
||||
cx,
|
||||
"Grasp Servers",
|
||||
GRASP_DESC,
|
||||
grasp_servers_editor(&grasp_input, cx),
|
||||
))
|
||||
.child(Separator::horizontal())
|
||||
.child(setting_block(
|
||||
cx,
|
||||
"Scan Directories",
|
||||
SCAN_DESC,
|
||||
scan_paths_editor(cx),
|
||||
))
|
||||
.child(setting_block(
|
||||
cx,
|
||||
"Default Folder",
|
||||
FOLDER_DESC,
|
||||
default_folder_selector(&default_folder),
|
||||
))
|
||||
.into_any_element()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Opens the settings dialog.
|
||||
pub fn open(cx: &mut App) {
|
||||
open_global(SettingsDialog::new(cx), cx);
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
AnyView, App, Context, Entity, Global, IntoElement, ParentElement as _, Render, Styled as _,
|
||||
Window, div,
|
||||
};
|
||||
|
||||
struct GlobalDialogHost(Entity<DialogHost>);
|
||||
|
||||
impl Global for GlobalDialogHost {}
|
||||
|
||||
/// Owns the modal currently mounted at the window root.
|
||||
pub struct DialogHost {
|
||||
open: Option<AnyView>,
|
||||
}
|
||||
|
||||
impl DialogHost {
|
||||
pub fn new(_cx: &mut Context<Self>) -> Self {
|
||||
Self { open: None }
|
||||
}
|
||||
|
||||
pub fn set_global(entity: Entity<Self>, cx: &mut App) {
|
||||
cx.set_global(GlobalDialogHost(entity));
|
||||
}
|
||||
|
||||
pub fn global(cx: &App) -> Entity<Self> {
|
||||
cx.global::<GlobalDialogHost>().0.clone()
|
||||
}
|
||||
|
||||
pub fn open(&mut self, view: AnyView, cx: &mut Context<Self>) {
|
||||
self.open = Some(view);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn close(&mut self, cx: &mut Context<Self>) {
|
||||
self.open = None;
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for DialogHost {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
div()
|
||||
.absolute()
|
||||
.inset_0()
|
||||
.when_some(self.open.clone(), |host, view| host.child(view))
|
||||
}
|
||||
}
|
||||
|
||||
/// Replaces the mounted modal with `view`.
|
||||
pub fn open_global(view: impl Into<AnyView>, cx: &mut App) {
|
||||
let host = DialogHost::global(cx);
|
||||
host.update(cx, |host, cx| host.open(view.into(), cx));
|
||||
}
|
||||
|
||||
/// Unmounts the current modal, if any.
|
||||
pub fn close_global(cx: &mut App) {
|
||||
let host = DialogHost::global(cx);
|
||||
host.update(cx, |host, cx| host.close(cx));
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
pub mod dialogs;
|
||||
pub mod panels;
|
||||
pub mod progress;
|
||||
pub mod tree;
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext as _, Context, Entity, IntoElement, KeyBinding,
|
||||
AnyElement, AnyView, App, AppContext as _, Context, Entity, IntoElement, KeyBinding,
|
||||
KeyBindingContextPredicate, ParentElement as _, SharedString, Subscription, WeakEntity, Window,
|
||||
};
|
||||
use metadata::{Profile, ProfileDirectory};
|
||||
@@ -21,10 +21,11 @@ use ui::tabs::{Tab, Tabs, TabsVariant};
|
||||
use ui::tooltip::Tooltip;
|
||||
|
||||
use crate::explore::ExploreView;
|
||||
use crate::identity::exit::ExitDialog;
|
||||
use crate::repo::{RepoDetailView, actions, dialogs};
|
||||
use crate::settings::SettingsDialog;
|
||||
use crate::shared::{log_dropped, panels};
|
||||
use crate::workspace::Workspace;
|
||||
use crate::{identity, settings};
|
||||
|
||||
mod repository_switcher;
|
||||
|
||||
@@ -110,6 +111,9 @@ pub struct TitlebarView {
|
||||
/// The command palette opened from the titlebar.
|
||||
palette: Entity<CommandPaletteState>,
|
||||
repository_switcher: Entity<RepositorySwitcher>,
|
||||
settings: Option<Entity<SettingsDialog>>,
|
||||
exit: Option<Entity<ExitDialog>>,
|
||||
create: Option<Entity<dialogs::create::CreateRepoDialog>>,
|
||||
user_menu_open: bool,
|
||||
_subscriptions: Vec<Subscription>,
|
||||
}
|
||||
@@ -124,11 +128,11 @@ impl TitlebarView {
|
||||
let repos = RepoListStore::global(cx);
|
||||
let local = LocalReposStore::global(cx);
|
||||
|
||||
let palette = Self::new_palette(workspace.clone(), window, cx);
|
||||
let weak = cx.entity().downgrade();
|
||||
let palette = Self::new_palette(weak.clone(), window, cx);
|
||||
let directory = ProfileDirectory::new(cx);
|
||||
|
||||
let entity = cx.entity();
|
||||
let weak = entity.downgrade();
|
||||
let mut subscriptions = Vec::new();
|
||||
|
||||
let repository_switcher = cx.new(|cx| {
|
||||
@@ -197,13 +201,16 @@ impl TitlebarView {
|
||||
directory,
|
||||
palette,
|
||||
repository_switcher,
|
||||
settings: None,
|
||||
exit: None,
|
||||
create: None,
|
||||
user_menu_open: false,
|
||||
_subscriptions: subscriptions,
|
||||
}
|
||||
}
|
||||
|
||||
fn new_palette(
|
||||
workspace: WeakEntity<Workspace>,
|
||||
weak: WeakEntity<Self>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Entity<CommandPaletteState> {
|
||||
@@ -220,13 +227,19 @@ impl TitlebarView {
|
||||
CommandPaletteState::new(
|
||||
CommandPalette::new("command-palette", Self::palette_commands(), matcher)
|
||||
.on_execute(move |command, window, cx| match command.id.as_ref() {
|
||||
"create-repo" => dialogs::create::open(workspace.clone(), window, cx),
|
||||
"create-repo" => {
|
||||
log_dropped(weak.update(cx, |this, cx| this.open_create(window, cx)));
|
||||
}
|
||||
"rescan-repos" => {
|
||||
let local_repos = LocalReposStore::global(cx);
|
||||
local_repos.update(cx, |store, cx| store.rescan(cx));
|
||||
}
|
||||
"open-settings" => settings::open(cx),
|
||||
"exit" => identity::helpers::open_exit(cx),
|
||||
"open-settings" => {
|
||||
log_dropped(weak.update(cx, |this, cx| this.open_settings(cx)));
|
||||
}
|
||||
"exit" => {
|
||||
log_dropped(weak.update(cx, |this, cx| this.open_exit(cx)));
|
||||
}
|
||||
_ => {}
|
||||
}),
|
||||
window,
|
||||
@@ -403,7 +416,35 @@ impl TitlebarView {
|
||||
pub(crate) fn create_repository(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
self.repository_switcher
|
||||
.update(cx, |switcher, cx| switcher.close(cx));
|
||||
dialogs::create::open(self.workspace.clone(), window, cx);
|
||||
self.open_create(window, cx);
|
||||
}
|
||||
|
||||
fn open_settings(&mut self, cx: &mut Context<Self>) {
|
||||
self.settings = Some(SettingsDialog::new(cx));
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn open_exit(&mut self, cx: &mut Context<Self>) {
|
||||
self.exit = Some(ExitDialog::new(cx));
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn open_create(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
let view = dialogs::create::CreateRepoDialog::new(self.workspace.clone(), window, cx);
|
||||
self.create = Some(view);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/// The dialogs this titlebar opens, rendered at the window root.
|
||||
pub fn dialogs(&self) -> Vec<AnyView> {
|
||||
[
|
||||
self.settings.clone().map(Into::into),
|
||||
self.exit.clone().map(Into::into),
|
||||
self.create.clone().map(Into::into),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn activate(&mut self, index: usize, window: &mut Window, cx: &mut Context<Self>) {
|
||||
@@ -507,7 +548,7 @@ impl TitlebarView {
|
||||
}
|
||||
|
||||
pub fn render_new_repository(&self) -> AnyElement {
|
||||
let workspace = self.workspace.clone();
|
||||
let weak = self.weak.clone();
|
||||
|
||||
Button::new("add-repo")
|
||||
.icon(IconRole::Plus)
|
||||
@@ -515,7 +556,7 @@ impl TitlebarView {
|
||||
.fully_rounded(true)
|
||||
.tooltip(Tooltip::text("Create repository"))
|
||||
.on_click(move |_, window, cx| {
|
||||
dialogs::create::open(workspace.clone(), window, cx);
|
||||
log_dropped(weak.update(cx, |this, cx| this.open_create(window, cx)));
|
||||
})
|
||||
.into_any_element()
|
||||
}
|
||||
@@ -528,11 +569,14 @@ impl TitlebarView {
|
||||
|
||||
Menu::new("user-menu")
|
||||
.open(self.user_menu_open)
|
||||
.on_change(move |open, _, cx| {
|
||||
log_dropped(weak.update(cx, |this, cx| {
|
||||
this.user_menu_open = open;
|
||||
cx.notify();
|
||||
}));
|
||||
.on_change({
|
||||
let weak = weak.clone();
|
||||
move |open, _, cx| {
|
||||
log_dropped(weak.update(cx, |this, cx| {
|
||||
this.user_menu_open = open;
|
||||
cx.notify();
|
||||
}));
|
||||
}
|
||||
})
|
||||
.trigger({
|
||||
let name = name.clone();
|
||||
@@ -552,13 +596,21 @@ impl TitlebarView {
|
||||
.into_any_element()
|
||||
}
|
||||
})
|
||||
.items(|_, _| {
|
||||
.items(move |_, _| {
|
||||
vec![
|
||||
MenuItem::new("Settings").handler(|_, cx| settings::open(cx)),
|
||||
MenuItem::new("Settings").handler({
|
||||
let weak = weak.clone();
|
||||
move |_, cx| {
|
||||
log_dropped(weak.update(cx, |this, cx| this.open_settings(cx)));
|
||||
}
|
||||
}),
|
||||
MenuItem::separator(),
|
||||
MenuItem::new("Exit")
|
||||
.destructive(true)
|
||||
.handler(|_, cx| identity::helpers::open_exit(cx)),
|
||||
MenuItem::new("Exit").destructive(true).handler({
|
||||
let weak = weak.clone();
|
||||
move |_, cx| {
|
||||
log_dropped(weak.update(cx, |this, cx| this.open_exit(cx)));
|
||||
}
|
||||
}),
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user