Sidebar: Switch to board when adding
This commit is contained in:
parent
057007d21c
commit
8ac37839a6
2 changed files with 13 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { Board } from "../board"
|
import { Board } from "../board"
|
||||||
|
import { BoardTree } from "../boardTree"
|
||||||
import { Mutator } from "../mutator"
|
import { Mutator } from "../mutator"
|
||||||
import { IPageController } from "../octoTypes"
|
import { IPageController } from "../octoTypes"
|
||||||
import { WorkspaceTree } from "../workspaceTree"
|
import { WorkspaceTree } from "../workspaceTree"
|
||||||
|
@ -7,7 +8,8 @@ import { WorkspaceTree } from "../workspaceTree"
|
||||||
type Props = {
|
type Props = {
|
||||||
mutator: Mutator
|
mutator: Mutator
|
||||||
pageController: IPageController
|
pageController: IPageController
|
||||||
workspaceTree: WorkspaceTree
|
workspaceTree: WorkspaceTree,
|
||||||
|
boardTree?: BoardTree
|
||||||
}
|
}
|
||||||
|
|
||||||
class Sidebar extends React.Component<Props> {
|
class Sidebar extends React.Component<Props> {
|
||||||
|
@ -42,9 +44,16 @@ class Sidebar extends React.Component<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async addBoardClicked() {
|
async addBoardClicked() {
|
||||||
const { mutator } = this.props
|
const { mutator, boardTree, pageController } = this.props
|
||||||
|
|
||||||
|
const oldBoardId = boardTree?.board?.id
|
||||||
const board = new Board()
|
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)
|
await mutator.insertBlock(board)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,11 @@ type Props = {
|
||||||
|
|
||||||
class WorkspaceComponent extends React.Component<Props> {
|
class WorkspaceComponent extends React.Component<Props> {
|
||||||
render() {
|
render() {
|
||||||
const { mutator, workspaceTree, pageController } = this.props
|
const { mutator, boardTree, workspaceTree, pageController } = this.props
|
||||||
|
|
||||||
const element =
|
const element =
|
||||||
<div className="octo-workspace">
|
<div className="octo-workspace">
|
||||||
<Sidebar mutator={mutator} pageController={pageController} workspaceTree={workspaceTree}></Sidebar>
|
<Sidebar mutator={mutator} pageController={pageController} workspaceTree={workspaceTree} boardTree={boardTree}></Sidebar>
|
||||||
{this.mainComponent()}
|
{this.mainComponent()}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue