Sidebar: showBoard

This commit is contained in:
Chen-I Lim 2020-10-12 12:23:28 -07:00
parent 7791b885a6
commit 7668dea023
4 changed files with 17 additions and 3 deletions

View file

@ -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)

View file

@ -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<Props> {
}
private boardClicked(board: Board) {
// TODO
const { pageController } = this.props
pageController.showBoard(board.id)
}
async addBoardClicked() {

View file

@ -17,11 +17,11 @@ type Props = {
class WorkspaceComponent extends React.Component<Props> {
render() {
const { mutator, workspaceTree } = this.props
const { mutator, workspaceTree, pageController } = this.props
const element =
<div className="octo-workspace">
<Sidebar mutator={mutator} workspaceTree={workspaceTree}></Sidebar>
<Sidebar mutator={mutator} pageController={pageController} workspaceTree={workspaceTree}></Sidebar>
{this.mainComponent()}
</div>

View file

@ -24,6 +24,7 @@ interface IBlock {
// These are methods exposed by the top-level page to components
interface IPageController {
showCard(card: IBlock): Promise<void>
showBoard(boardId: string): void
showView(viewId: string): void
showFilter(anchorElement?: HTMLElement): void
setSearchText(text?: string): void