From 8ac37839a602e5dfdb80a2a0d804c2ad9497bde8 Mon Sep 17 00:00:00 2001 From: Chen-I Lim Date: Mon, 12 Oct 2020 19:28:15 -0700 Subject: [PATCH] Sidebar: Switch to board when adding --- src/client/components/sidebar.tsx | 13 +++++++++++-- src/client/components/workspaceComponent.tsx | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/client/components/sidebar.tsx b/src/client/components/sidebar.tsx index 2a2cb95d0..9c810a4cd 100644 --- a/src/client/components/sidebar.tsx +++ b/src/client/components/sidebar.tsx @@ -1,5 +1,6 @@ import React from "react" import { Board } from "../board" +import { BoardTree } from "../boardTree" import { Mutator } from "../mutator" import { IPageController } from "../octoTypes" import { WorkspaceTree } from "../workspaceTree" @@ -7,7 +8,8 @@ import { WorkspaceTree } from "../workspaceTree" type Props = { mutator: Mutator pageController: IPageController - workspaceTree: WorkspaceTree + workspaceTree: WorkspaceTree, + boardTree?: BoardTree } class Sidebar extends React.Component { @@ -42,9 +44,16 @@ class Sidebar extends React.Component { } async addBoardClicked() { - const { mutator } = this.props + const { mutator, boardTree, pageController } = this.props + const oldBoardId = boardTree?.board?.id const board = new Board() + await mutator.insertBlock( + board, + "add board", + async () => { pageController.showBoard(board.id) }, + async () => { if (oldBoardId) { pageController.showBoard(oldBoardId) } }) + await mutator.insertBlock(board) } } diff --git a/src/client/components/workspaceComponent.tsx b/src/client/components/workspaceComponent.tsx index 940fa1a46..c5417e2a6 100644 --- a/src/client/components/workspaceComponent.tsx +++ b/src/client/components/workspaceComponent.tsx @@ -17,11 +17,11 @@ type Props = { class WorkspaceComponent extends React.Component { render() { - const { mutator, workspaceTree, pageController } = this.props + const { mutator, boardTree, workspaceTree, pageController } = this.props const element =
- + {this.mainComponent()}