diff --git a/src/client/boardPage.tsx b/src/client/boardPage.tsx index c157a4497..bfab5475f 100644 --- a/src/client/boardPage.tsx +++ b/src/client/boardPage.tsx @@ -227,6 +227,16 @@ class BoardPage implements IPageController { this.render() } + showBoard(boardId: string) { + if (this.boardTree.board.id === boardId) { return } + + const newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + `?id=${encodeURIComponent(boardId)}` + window.history.pushState({ path: newUrl }, "", newUrl) + + this.boardTree = new BoardTree(this.octo, boardId) + this.sync() + } + showView(viewId: string) { this.viewId = viewId this.boardTree.setActiveView(this.viewId) diff --git a/src/client/components/sidebar.tsx b/src/client/components/sidebar.tsx index 870cc6ee6..2a2cb95d0 100644 --- a/src/client/components/sidebar.tsx +++ b/src/client/components/sidebar.tsx @@ -1,10 +1,12 @@ import React from "react" import { Board } from "../board" import { Mutator } from "../mutator" +import { IPageController } from "../octoTypes" import { WorkspaceTree } from "../workspaceTree" type Props = { mutator: Mutator + pageController: IPageController workspaceTree: WorkspaceTree } @@ -35,7 +37,8 @@ class Sidebar extends React.Component { } private boardClicked(board: Board) { - // TODO + const { pageController } = this.props + pageController.showBoard(board.id) } async addBoardClicked() { diff --git a/src/client/components/workspaceComponent.tsx b/src/client/components/workspaceComponent.tsx index fff247acd..940fa1a46 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 } = this.props + const { mutator, workspaceTree, pageController } = this.props const element =
- + {this.mainComponent()}
diff --git a/src/client/octoTypes.ts b/src/client/octoTypes.ts index 026046329..498478c14 100644 --- a/src/client/octoTypes.ts +++ b/src/client/octoTypes.ts @@ -24,6 +24,7 @@ interface IBlock { // These are methods exposed by the top-level page to components interface IPageController { showCard(card: IBlock): Promise + showBoard(boardId: string): void showView(viewId: string): void showFilter(anchorElement?: HTMLElement): void setSearchText(text?: string): void