From 7d5b6c670570191d91e1004fdda9e47fc5ef39fb Mon Sep 17 00:00:00 2001 From: Kyle Kelley Date: Tue, 15 Oct 2024 17:02:18 -0700 Subject: [PATCH] starter modal --- crates/repl/src/jupyter_servers.rs | 65 +++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/crates/repl/src/jupyter_servers.rs b/crates/repl/src/jupyter_servers.rs index b41a2ac7e6..d8b5aff74d 100644 --- a/crates/repl/src/jupyter_servers.rs +++ b/crates/repl/src/jupyter_servers.rs @@ -1,5 +1,66 @@ use gpui::{ - Action, AnyElement, AppContext, DismissEvent, EventEmitter, FocusHandle, FocusableView, - Subscription, Task, View, ViewContext, WeakView, + div, prelude::*, AppContext, DismissEvent, EventEmitter, FocusHandle, FocusableView, + Refineable, Render, ScrollHandle, ViewContext, WeakView, }; +use ui::{ActiveTheme, IntoElement}; +use workspace::{ModalView, Workspace}; + gpui::actions!(repl, [ConnectJupyterServer]); + +struct JupyterServers { + focus_handle: FocusHandle, + scroll_handle: ScrollHandle, + workspace: WeakView, +} + +impl JupyterServers { + pub fn register(workspace: &mut Workspace, _: &mut ViewContext) { + // + workspace.register_action(|workspace, _: &ConnectJupyterServer, cx| { + let handle = cx.view().downgrade(); + workspace.toggle_modal(cx, |cx| Self::new(cx, handle)); + }); + } + + pub fn new(cx: &mut ViewContext, workspace: WeakView) -> Self { + let focus_handle = cx.focus_handle(); + // let dev_server_store = dev_server_projects::Store::global(cx); + + // let subscription = cx.observe(&dev_server_store, |_, _, cx| { + // cx.notify(); + // }); + + let mut base_style = cx.text_style(); + base_style.refine(&gpui::TextStyleRefinement { + color: Some(cx.theme().colors().editor_foreground), + ..Default::default() + }); + + Self { + // mode: Mode::Default, + focus_handle, + scroll_handle: ScrollHandle::new(), + // dev_server_store, + workspace, + // _dev_server_subscription: subscription, + // selectable_items: Default::default(), + } + } +} + +impl ModalView for JupyterServers {} + +impl EventEmitter for JupyterServers {} + +impl FocusableView for JupyterServers { + fn focus_handle(&self, _cx: &AppContext) -> FocusHandle { + self.focus_handle.clone() + } +} + +impl Render for JupyterServers { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { + div().child("test") + // + } +}