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()}