2020-10-12 11:02:07 -07:00
|
|
|
import React from "react"
|
|
|
|
import { BoardTree } from "../boardTree"
|
|
|
|
import { Mutator } from "../mutator"
|
2020-10-14 15:25:39 +02:00
|
|
|
import { IBlock } from "../octoTypes"
|
2020-10-12 11:02:07 -07:00
|
|
|
import { Utils } from "../utils"
|
|
|
|
import { WorkspaceTree } from "../workspaceTree"
|
|
|
|
import { BoardComponent } from "./boardComponent"
|
|
|
|
import { Sidebar } from "./sidebar"
|
|
|
|
import { TableComponent } from "./tableComponent"
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
mutator: Mutator,
|
|
|
|
workspaceTree: WorkspaceTree
|
|
|
|
boardTree?: BoardTree
|
2020-10-14 11:19:14 -07:00
|
|
|
showBoard: (id: string) => void
|
|
|
|
showView: (id: string) => void
|
|
|
|
showCard: (card: IBlock) => void
|
|
|
|
showFilter: (el: HTMLElement) => void
|
|
|
|
setSearchText: (text: string) => void
|
2020-10-12 11:02:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
class WorkspaceComponent extends React.Component<Props> {
|
|
|
|
render() {
|
2020-10-14 11:19:14 -07:00
|
|
|
const { mutator, boardTree, workspaceTree, showBoard } = this.props
|
2020-10-12 12:01:00 -07:00
|
|
|
|
2020-10-14 11:19:14 -07:00
|
|
|
Utils.assert(workspaceTree)
|
2020-10-12 11:02:07 -07:00
|
|
|
const element =
|
|
|
|
<div className="octo-workspace">
|
2020-10-14 15:25:39 +02:00
|
|
|
<Sidebar mutator={mutator} showBoard={showBoard} workspaceTree={workspaceTree} boardTree={boardTree}></Sidebar>
|
2020-10-12 11:02:07 -07:00
|
|
|
{this.mainComponent()}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
return element
|
|
|
|
}
|
|
|
|
|
|
|
|
private mainComponent() {
|
2020-10-14 15:25:39 +02:00
|
|
|
const { mutator, boardTree, showCard, showFilter, setSearchText, showView } = this.props
|
2020-10-13 14:36:29 -07:00
|
|
|
const { activeView } = boardTree || {}
|
2020-10-12 11:02:07 -07:00
|
|
|
|
2020-10-13 14:36:29 -07:00
|
|
|
if (!activeView) {
|
|
|
|
return <div></div>
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (activeView?.viewType) {
|
2020-10-12 11:02:07 -07:00
|
|
|
case "board": {
|
2020-10-14 11:19:14 -07:00
|
|
|
return <BoardComponent mutator={mutator} boardTree={boardTree} showCard={showCard} showFilter={showFilter} setSearchText={setSearchText} showView={showView} />
|
2020-10-12 11:02:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
case "table": {
|
2020-10-14 11:19:14 -07:00
|
|
|
return <TableComponent mutator={mutator} boardTree={boardTree} showCard={showCard} showFilter={showFilter} setSearchText={setSearchText} showView={showView} />
|
2020-10-12 11:02:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
|
|
|
Utils.assertFailure(`render() Unhandled viewType: ${activeView.viewType}`)
|
|
|
|
return <div></div>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export { WorkspaceComponent }
|