Uncomment enough to register the panel
This commit is contained in:
parent
793fa6e3a4
commit
7f70712dac
3 changed files with 3056 additions and 3032 deletions
|
@ -118,19 +118,16 @@
|
||||||
// to: ChannelId,
|
// to: ChannelId,
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// actions!(
|
actions!(
|
||||||
// collab_panel,
|
ToggleFocus,
|
||||||
// [
|
Remove,
|
||||||
// ToggleFocus,
|
Secondary,
|
||||||
// Remove,
|
CollapseSelectedChannel,
|
||||||
// Secondary,
|
ExpandSelectedChannel,
|
||||||
// CollapseSelectedChannel,
|
StartMoveChannel,
|
||||||
// ExpandSelectedChannel,
|
MoveSelected,
|
||||||
// StartMoveChannel,
|
InsertSpace,
|
||||||
// MoveSelected,
|
);
|
||||||
// InsertSpace,
|
|
||||||
// ]
|
|
||||||
// );
|
|
||||||
|
|
||||||
// impl_actions!(
|
// impl_actions!(
|
||||||
// collab_panel,
|
// collab_panel,
|
||||||
|
@ -158,8 +155,22 @@
|
||||||
|
|
||||||
// const COLLABORATION_PANEL_KEY: &'static str = "CollaborationPanel";
|
// const COLLABORATION_PANEL_KEY: &'static str = "CollaborationPanel";
|
||||||
|
|
||||||
// pub fn init(cx: &mut AppContext) {
|
use std::sync::Arc;
|
||||||
// settings::register::<panel_settings::CollaborationPanelSettings>(cx);
|
|
||||||
|
use gpui::{
|
||||||
|
actions, div, AppContext, AsyncWindowContext, Div, EventEmitter, FocusHandle, ParentComponent,
|
||||||
|
Render, Task, View, ViewContext, VisualContext, WeakView,
|
||||||
|
};
|
||||||
|
use project::Fs;
|
||||||
|
use settings::Settings;
|
||||||
|
use workspace::{
|
||||||
|
dock::{DockPosition, Panel, PanelEvent},
|
||||||
|
Workspace,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::CollaborationPanelSettings;
|
||||||
|
|
||||||
|
pub fn init(cx: &mut AppContext) {
|
||||||
// contact_finder::init(cx);
|
// contact_finder::init(cx);
|
||||||
// channel_modal::init(cx);
|
// channel_modal::init(cx);
|
||||||
// channel_view::init(cx);
|
// channel_view::init(cx);
|
||||||
|
@ -243,7 +254,7 @@
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
// );
|
// );
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[derive(Debug)]
|
// #[derive(Debug)]
|
||||||
// pub enum ChannelEditingState {
|
// pub enum ChannelEditingState {
|
||||||
|
@ -266,10 +277,10 @@
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub struct CollabPanel {
|
pub struct CollabPanel {
|
||||||
// width: Option<f32>,
|
width: Option<f32>,
|
||||||
// fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
// has_focus: bool,
|
focus_handle: FocusHandle,
|
||||||
// channel_clipboard: Option<ChannelMoveClipboard>,
|
// channel_clipboard: Option<ChannelMoveClipboard>,
|
||||||
// pending_serialization: Task<Option<()>>,
|
// pending_serialization: Task<Option<()>>,
|
||||||
// context_menu: ViewHandle<ContextMenu>,
|
// context_menu: ViewHandle<ContextMenu>,
|
||||||
|
@ -288,9 +299,9 @@
|
||||||
// collapsed_sections: Vec<Section>,
|
// collapsed_sections: Vec<Section>,
|
||||||
// collapsed_channels: Vec<ChannelId>,
|
// collapsed_channels: Vec<ChannelId>,
|
||||||
// drag_target_channel: ChannelDragTarget,
|
// drag_target_channel: ChannelDragTarget,
|
||||||
// workspace: WeakViewHandle<Workspace>,
|
_workspace: WeakView<Workspace>,
|
||||||
// context_menu_on_selected: bool,
|
// context_menu_on_selected: bool,
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[derive(PartialEq, Eq)]
|
// #[derive(PartialEq, Eq)]
|
||||||
// enum ChannelDragTarget {
|
// enum ChannelDragTarget {
|
||||||
|
@ -369,9 +380,9 @@
|
||||||
// type Event = Event;
|
// type Event = Event;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// impl CollabPanel {
|
impl CollabPanel {
|
||||||
// pub fn new(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) -> ViewHandle<Self> {
|
pub fn new(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) -> View<Self> {
|
||||||
// cx.add_view::<Self, _>(|cx| {
|
cx.build_view(|cx| {
|
||||||
// let view_id = cx.view_id();
|
// let view_id = cx.view_id();
|
||||||
|
|
||||||
// let filter_editor = cx.add_view(|cx| {
|
// let filter_editor = cx.add_view(|cx| {
|
||||||
|
@ -562,11 +573,11 @@
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// let mut this = Self {
|
let this = Self {
|
||||||
// width: None,
|
width: None,
|
||||||
// has_focus: false,
|
focus_handle: cx.focus_handle(),
|
||||||
// channel_clipboard: None,
|
// channel_clipboard: None,
|
||||||
// fs: workspace.app_state().fs.clone(),
|
fs: workspace.app_state().fs.clone(),
|
||||||
// pending_serialization: Task::ready(None),
|
// pending_serialization: Task::ready(None),
|
||||||
// context_menu: cx.add_view(|cx| ContextMenu::new(view_id, cx)),
|
// context_menu: cx.add_view(|cx| ContextMenu::new(view_id, cx)),
|
||||||
// channel_name_editor,
|
// channel_name_editor,
|
||||||
|
@ -581,12 +592,12 @@
|
||||||
// match_candidates: Vec::default(),
|
// match_candidates: Vec::default(),
|
||||||
// collapsed_sections: vec![Section::Offline],
|
// collapsed_sections: vec![Section::Offline],
|
||||||
// collapsed_channels: Vec::default(),
|
// collapsed_channels: Vec::default(),
|
||||||
// workspace: workspace.weak_handle(),
|
_workspace: workspace.weak_handle(),
|
||||||
// client: workspace.app_state().client.clone(),
|
// client: workspace.app_state().client.clone(),
|
||||||
// context_menu_on_selected: true,
|
// context_menu_on_selected: true,
|
||||||
// drag_target_channel: ChannelDragTarget::None,
|
// drag_target_channel: ChannelDragTarget::None,
|
||||||
// list_state,
|
// list_state,
|
||||||
// };
|
};
|
||||||
|
|
||||||
// this.update_entries(false, cx);
|
// this.update_entries(false, cx);
|
||||||
|
|
||||||
|
@ -638,15 +649,16 @@
|
||||||
// },
|
// },
|
||||||
// ));
|
// ));
|
||||||
|
|
||||||
// this
|
this
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn load(
|
pub fn load(
|
||||||
// workspace: WeakViewHandle<Workspace>,
|
workspace: WeakView<Workspace>,
|
||||||
// cx: AsyncAppContext,
|
cx: AsyncWindowContext,
|
||||||
// ) -> Task<Result<ViewHandle<Self>>> {
|
) -> Task<anyhow::Result<View<Self>>> {
|
||||||
// cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
|
// todo!()
|
||||||
// let serialized_panel = if let Some(panel) = cx
|
// let serialized_panel = if let Some(panel) = cx
|
||||||
// .background()
|
// .background()
|
||||||
// .spawn(async move { KEY_VALUE_STORE.read_kvp(COLLABORATION_PANEL_KEY) })
|
// .spawn(async move { KEY_VALUE_STORE.read_kvp(COLLABORATION_PANEL_KEY) })
|
||||||
|
@ -665,8 +677,8 @@
|
||||||
// None
|
// None
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// workspace.update(&mut cx, |workspace, cx| {
|
workspace.update(&mut cx, |workspace, cx| {
|
||||||
// let panel = CollabPanel::new(workspace, cx);
|
let panel = CollabPanel::new(workspace, cx);
|
||||||
// if let Some(serialized_panel) = serialized_panel {
|
// if let Some(serialized_panel) = serialized_panel {
|
||||||
// panel.update(cx, |panel, cx| {
|
// panel.update(cx, |panel, cx| {
|
||||||
// panel.width = serialized_panel.width;
|
// panel.width = serialized_panel.width;
|
||||||
|
@ -676,10 +688,10 @@
|
||||||
// cx.notify();
|
// cx.notify();
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
// panel
|
panel
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn serialize(&mut self, cx: &mut ViewContext<Self>) {
|
// fn serialize(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
// let width = self.width;
|
// let width = self.width;
|
||||||
|
@ -3233,7 +3245,7 @@
|
||||||
// let item = ClipboardItem::new(channel.link());
|
// let item = ClipboardItem::new(channel.link());
|
||||||
// cx.write_to_clipboard(item)
|
// cx.write_to_clipboard(item)
|
||||||
// }
|
// }
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn render_tree_branch(
|
// fn render_tree_branch(
|
||||||
// branch_style: theme::TreeBranch,
|
// branch_style: theme::TreeBranch,
|
||||||
|
@ -3280,6 +3292,14 @@
|
||||||
// .with_width(size.x())
|
// .with_width(size.x())
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
impl Render for CollabPanel {
|
||||||
|
type Element = Div<Self>;
|
||||||
|
|
||||||
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
div().child("COLLAB PANEL")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// impl View for CollabPanel {
|
// impl View for CollabPanel {
|
||||||
// fn ui_name() -> &'static str {
|
// fn ui_name() -> &'static str {
|
||||||
// "CollabPanel"
|
// "CollabPanel"
|
||||||
|
@ -3379,59 +3399,62 @@
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// impl Panel for CollabPanel {
|
impl EventEmitter<PanelEvent> for CollabPanel {}
|
||||||
// fn position(&self, cx: &gpui::WindowContext) -> DockPosition {
|
|
||||||
// settings::get::<CollaborationPanelSettings>(cx).dock
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn position_is_valid(&self, position: DockPosition) -> bool {
|
impl Panel for CollabPanel {
|
||||||
// matches!(position, DockPosition::Left | DockPosition::Right)
|
fn position(&self, cx: &gpui::WindowContext) -> DockPosition {
|
||||||
// }
|
CollaborationPanelSettings::get_global(cx).dock
|
||||||
|
}
|
||||||
|
|
||||||
// fn set_position(&mut self, position: DockPosition, cx: &mut ViewContext<Self>) {
|
fn position_is_valid(&self, position: DockPosition) -> bool {
|
||||||
// settings::update_settings_file::<CollaborationPanelSettings>(
|
matches!(position, DockPosition::Left | DockPosition::Right)
|
||||||
// self.fs.clone(),
|
}
|
||||||
// cx,
|
|
||||||
// move |settings| settings.dock = Some(position),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn size(&self, cx: &gpui::WindowContext) -> f32 {
|
fn set_position(&mut self, position: DockPosition, cx: &mut ViewContext<Self>) {
|
||||||
// self.width
|
settings::update_settings_file::<CollaborationPanelSettings>(
|
||||||
// .unwrap_or_else(|| settings::get::<CollaborationPanelSettings>(cx).default_width)
|
self.fs.clone(),
|
||||||
// }
|
cx,
|
||||||
|
move |settings| settings.dock = Some(position),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// fn set_size(&mut self, size: Option<f32>, cx: &mut ViewContext<Self>) {
|
fn size(&self, cx: &gpui::WindowContext) -> f32 {
|
||||||
// self.width = size;
|
self.width
|
||||||
|
.unwrap_or_else(|| CollaborationPanelSettings::get_global(cx).default_width)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_size(&mut self, size: Option<f32>, cx: &mut ViewContext<Self>) {
|
||||||
|
self.width = size;
|
||||||
|
// todo!()
|
||||||
// self.serialize(cx);
|
// self.serialize(cx);
|
||||||
// cx.notify();
|
cx.notify();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn icon_path(&self, cx: &gpui::WindowContext) -> Option<&'static str> {
|
fn icon_path(&self, cx: &gpui::WindowContext) -> Option<&'static str> {
|
||||||
// settings::get::<CollaborationPanelSettings>(cx)
|
CollaborationPanelSettings::get_global(cx)
|
||||||
// .button
|
.button
|
||||||
// .then(|| "icons/user_group_16.svg")
|
.then(|| "icons/user_group_16.svg")
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn icon_tooltip(&self) -> (String, Option<Box<dyn gpui::Action>>) {
|
fn icon_tooltip(&self) -> (String, Option<Box<dyn gpui::Action>>) {
|
||||||
// (
|
(
|
||||||
// "Collaboration Panel".to_string(),
|
"Collaboration Panel".to_string(),
|
||||||
// Some(Box::new(ToggleFocus)),
|
Some(Box::new(ToggleFocus)),
|
||||||
// )
|
)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn should_change_position_on_event(event: &Self::Event) -> bool {
|
fn has_focus(&self, cx: &gpui::WindowContext) -> bool {
|
||||||
// matches!(event, Event::DockPositionChanged)
|
self.focus_handle.contains_focused(cx)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn has_focus(&self, _cx: &gpui::WindowContext) -> bool {
|
fn persistent_name(&self) -> &'static str {
|
||||||
// self.has_focus
|
"Collab Panel"
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn is_focus_event(event: &Self::Event) -> bool {
|
fn focus_handle(&self, cx: &ui::prelude::WindowContext) -> gpui::FocusHandle {
|
||||||
// matches!(event, Event::Focus)
|
self.focus_handle.clone()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// impl PartialEq for ListEntry {
|
// impl PartialEq for ListEntry {
|
||||||
// fn eq(&self, other: &Self) -> bool {
|
// fn eq(&self, other: &Self) -> bool {
|
||||||
|
|
|
@ -9,6 +9,7 @@ mod panel_settings;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub use collab_panel::CollabPanel;
|
||||||
pub use collab_titlebar_item::CollabTitlebarItem;
|
pub use collab_titlebar_item::CollabTitlebarItem;
|
||||||
use gpui::AppContext;
|
use gpui::AppContext;
|
||||||
pub use panel_settings::{
|
pub use panel_settings::{
|
||||||
|
@ -29,7 +30,7 @@ pub fn init(_app_state: &Arc<AppState>, cx: &mut AppContext) {
|
||||||
|
|
||||||
// vcs_menu::init(cx);
|
// vcs_menu::init(cx);
|
||||||
collab_titlebar_item::init(cx);
|
collab_titlebar_item::init(cx);
|
||||||
// collab_panel::init(cx);
|
collab_panel::init(cx);
|
||||||
// chat_panel::init(cx);
|
// chat_panel::init(cx);
|
||||||
// notifications::init(&app_state, cx);
|
// notifications::init(&app_state, cx);
|
||||||
|
|
||||||
|
|
|
@ -383,8 +383,8 @@ pub fn initialize_workspace(
|
||||||
let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());
|
let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());
|
||||||
// let terminal_panel = TerminalPanel::load(workspace_handle.clone(), cx.clone());
|
// let terminal_panel = TerminalPanel::load(workspace_handle.clone(), cx.clone());
|
||||||
// let assistant_panel = AssistantPanel::load(workspace_handle.clone(), cx.clone());
|
// let assistant_panel = AssistantPanel::load(workspace_handle.clone(), cx.clone());
|
||||||
// let channels_panel =
|
let channels_panel =
|
||||||
// collab_ui::collab_panel::CollabPanel::load(workspace_handle.clone(), cx.clone());
|
collab_ui::collab_panel::CollabPanel::load(workspace_handle.clone(), cx.clone());
|
||||||
// let chat_panel =
|
// let chat_panel =
|
||||||
// collab_ui::chat_panel::ChatPanel::load(workspace_handle.clone(), cx.clone());
|
// collab_ui::chat_panel::ChatPanel::load(workspace_handle.clone(), cx.clone());
|
||||||
// let notification_panel = collab_ui::notification_panel::NotificationPanel::load(
|
// let notification_panel = collab_ui::notification_panel::NotificationPanel::load(
|
||||||
|
@ -395,16 +395,16 @@ pub fn initialize_workspace(
|
||||||
project_panel,
|
project_panel,
|
||||||
// terminal_panel,
|
// terminal_panel,
|
||||||
// assistant_panel,
|
// assistant_panel,
|
||||||
// channels_panel,
|
channels_panel,
|
||||||
// chat_panel,
|
// chat_panel,
|
||||||
// notification_panel,
|
// notification_panel,
|
||||||
) = futures::try_join!(
|
) = futures::try_join!(
|
||||||
project_panel,
|
project_panel,
|
||||||
// terminal_panel,
|
// terminal_panel,
|
||||||
// assistant_panel,
|
// assistant_panel,
|
||||||
// channels_panel,
|
channels_panel,
|
||||||
// chat_panel,
|
// chat_panel,
|
||||||
// notification_panel,
|
// notification_panel,/
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
workspace_handle.update(&mut cx, |workspace, cx| {
|
workspace_handle.update(&mut cx, |workspace, cx| {
|
||||||
|
@ -412,7 +412,7 @@ pub fn initialize_workspace(
|
||||||
workspace.add_panel(project_panel, cx);
|
workspace.add_panel(project_panel, cx);
|
||||||
// workspace.add_panel(terminal_panel, cx);
|
// workspace.add_panel(terminal_panel, cx);
|
||||||
// workspace.add_panel(assistant_panel, cx);
|
// workspace.add_panel(assistant_panel, cx);
|
||||||
// workspace.add_panel(channels_panel, cx);
|
workspace.add_panel(channels_panel, cx);
|
||||||
// workspace.add_panel(chat_panel, cx);
|
// workspace.add_panel(chat_panel, cx);
|
||||||
// workspace.add_panel(notification_panel, cx);
|
// workspace.add_panel(notification_panel, cx);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue