aboutsummaryrefslogtreecommitdiff
path: root/src/api/schema
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/schema')
-rw-r--r--src/api/schema/panes.rs10
-rw-r--r--src/api/schema/tabs.rs6
-rw-r--r--src/api/schema/tests.rs52
-rw-r--r--src/api/schema/workspaces.rs6
4 files changed, 74 insertions, 0 deletions
diff --git a/src/api/schema/panes.rs b/src/api/schema/panes.rs
index 9bd8103d..55241131 100644
--- a/src/api/schema/panes.rs
+++ b/src/api/schema/panes.rs
@@ -127,6 +127,16 @@ pub struct LayoutApplyParams {
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+pub struct LayoutSetSplitRatioParams {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub tab_id: Option<String>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub pane_id: Option<String>,
+ pub path: Vec<bool>,
+ pub ratio: f32,
+}
+
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct LayoutDescription {
pub workspace_id: String,
pub tab_id: String,
diff --git a/src/api/schema/tabs.rs b/src/api/schema/tabs.rs
index 4be94c3b..41af5c6b 100644
--- a/src/api/schema/tabs.rs
+++ b/src/api/schema/tabs.rs
@@ -31,6 +31,12 @@ pub struct TabRenameParams {
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct TabMoveParams {
+ pub tab_id: String,
+ pub insert_index: usize,
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct TabInfo {
pub tab_id: String,
pub workspace_id: String,
diff --git a/src/api/schema/tests.rs b/src/api/schema/tests.rs
index c8c8adbb..d9ebe30b 100644
--- a/src/api/schema/tests.rs
+++ b/src/api/schema/tests.rs
@@ -703,6 +703,58 @@ fn layout_export_apply_round_trip() {
}
#[test]
+fn authority_mutation_requests_round_trip() {
+ let workspace_move = Request {
+ id: "move_ws".into(),
+ method: Method::WorkspaceMove(WorkspaceMoveParams {
+ workspace_id: "w1".into(),
+ insert_index: 2,
+ }),
+ };
+ let json = serde_json::to_value(&workspace_move).unwrap();
+ assert_eq!(json["method"], "workspace.move");
+ let restored: Request = serde_json::from_value(json).unwrap();
+ assert_eq!(restored, workspace_move);
+
+ let tab_move = Request {
+ id: "move_tab".into(),
+ method: Method::TabMove(TabMoveParams {
+ tab_id: "w1:1".into(),
+ insert_index: 1,
+ }),
+ };
+ let json = serde_json::to_value(&tab_move).unwrap();
+ assert_eq!(json["method"], "tab.move");
+ let restored: Request = serde_json::from_value(json).unwrap();
+ assert_eq!(restored, tab_move);
+
+ let pane_focus = Request {
+ id: "focus_pane".into(),
+ method: Method::PaneFocus(PaneTarget {
+ pane_id: "w1:1".into(),
+ }),
+ };
+ let json = serde_json::to_value(&pane_focus).unwrap();
+ assert_eq!(json["method"], "pane.focus");
+ let restored: Request = serde_json::from_value(json).unwrap();
+ assert_eq!(restored, pane_focus);
+
+ let split_ratio = Request {
+ id: "set_ratio".into(),
+ method: Method::LayoutSetSplitRatio(LayoutSetSplitRatioParams {
+ tab_id: Some("w1:1".into()),
+ pane_id: None,
+ path: vec![false, true],
+ ratio: 0.6,
+ }),
+ };
+ let json = serde_json::to_value(&split_ratio).unwrap();
+ assert_eq!(json["method"], "layout.set_split_ratio");
+ let restored: Request = serde_json::from_value(json).unwrap();
+ assert_eq!(restored, split_ratio);
+}
+
+#[test]
fn create_response_round_trips_with_root_pane() {
let response = SuccessResponse {
id: "req_2".into(),
diff --git a/src/api/schema/workspaces.rs b/src/api/schema/workspaces.rs
index d15cf09b..be5ef0b4 100644
--- a/src/api/schema/workspaces.rs
+++ b/src/api/schema/workspaces.rs
@@ -23,6 +23,12 @@ pub struct WorkspaceRenameParams {
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct WorkspaceMoveParams {
+ pub workspace_id: String,
+ pub insert_index: usize,
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct WorkspaceInfo {
pub workspace_id: String,
pub number: usize,