refactor: merge workspace state into app root
This commit is contained in:
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
use gpui::{App, Entity, SharedString, WeakEntity, Window};
|
||||
use ui::layout::panel::{Panel, PanelView};
|
||||
|
||||
use crate::workspace::Workspace;
|
||||
use crate::app::AppRoot;
|
||||
|
||||
/// Which slot of the workspace a panel opens into.
|
||||
#[derive(Clone, Copy)]
|
||||
@@ -14,7 +14,7 @@ enum PanelSlot {
|
||||
|
||||
impl PanelSlot {
|
||||
/// Whether the slot already holds a panel under `id`.
|
||||
fn has(self, workspace: &WeakEntity<Workspace>, id: &SharedString, cx: &App) -> bool {
|
||||
fn has(self, workspace: &WeakEntity<AppRoot>, id: &SharedString, cx: &App) -> bool {
|
||||
match self {
|
||||
PanelSlot::Main => workspace
|
||||
.read_with(cx, |workspace, _| workspace.has_main(id))
|
||||
@@ -26,7 +26,7 @@ impl PanelSlot {
|
||||
}
|
||||
|
||||
/// Activates the slot's cached panel under `id`.
|
||||
fn activate(self, workspace: &WeakEntity<Workspace>, id: &SharedString, cx: &mut App) {
|
||||
fn activate(self, workspace: &WeakEntity<AppRoot>, id: &SharedString, cx: &mut App) {
|
||||
let result = match self {
|
||||
PanelSlot::Main => {
|
||||
workspace.update(cx, |workspace, cx| workspace.activate_main(id, cx))
|
||||
@@ -43,7 +43,7 @@ impl PanelSlot {
|
||||
/// Shows the panel in the slot.
|
||||
fn show(
|
||||
self,
|
||||
workspace: &WeakEntity<Workspace>,
|
||||
workspace: &WeakEntity<AppRoot>,
|
||||
id: SharedString,
|
||||
view: Arc<dyn PanelView>,
|
||||
cx: &mut App,
|
||||
@@ -65,7 +65,7 @@ impl PanelSlot {
|
||||
/// Opens a panel in `slot`, reusing it when it is already cached.
|
||||
fn open_slot<P, F>(
|
||||
slot: PanelSlot,
|
||||
workspace: &WeakEntity<Workspace>,
|
||||
workspace: &WeakEntity<AppRoot>,
|
||||
id: impl Into<SharedString>,
|
||||
build: F,
|
||||
window: &mut Window,
|
||||
@@ -87,7 +87,7 @@ fn open_slot<P, F>(
|
||||
|
||||
/// Opens a repository in the main panel, reusing it when it is already cached.
|
||||
pub fn open_primary<P, F>(
|
||||
workspace: &WeakEntity<Workspace>,
|
||||
workspace: &WeakEntity<AppRoot>,
|
||||
id: impl Into<SharedString>,
|
||||
build: F,
|
||||
window: &mut Window,
|
||||
@@ -101,7 +101,7 @@ pub fn open_primary<P, F>(
|
||||
|
||||
/// Opens a detail panel beside the main panel, reusing it when it is already cached.
|
||||
pub fn open_detail<P, F>(
|
||||
workspace: &WeakEntity<Workspace>,
|
||||
workspace: &WeakEntity<AppRoot>,
|
||||
id: impl Into<SharedString>,
|
||||
build: F,
|
||||
window: &mut Window,
|
||||
|
||||
Reference in New Issue
Block a user