mirror of
https://github.com/mattermost/focalboard.git
synced 2025-02-01 19:14:35 +02:00
Handle deleting last board correctly
This commit is contained in:
parent
0d5f45b9b4
commit
50efb8f0c3
@ -24,7 +24,7 @@ import MenuWrapper from '../widgets/menuWrapper'
|
||||
import './sidebar.scss'
|
||||
|
||||
type Props = {
|
||||
showBoard: (id: string) => void
|
||||
showBoard: (id?: string) => void
|
||||
showView: (id: string, boardId?: string) => void
|
||||
workspaceTree: WorkspaceTree,
|
||||
activeBoardId?: string
|
||||
@ -125,7 +125,7 @@ class Sidebar extends React.Component<Props, State> {
|
||||
board,
|
||||
'delete block',
|
||||
async () => {
|
||||
nextBoardId && this.props.showBoard(nextBoardId!)
|
||||
this.props.showBoard(nextBoardId)
|
||||
},
|
||||
async () => {
|
||||
this.props.showBoard(board.id)
|
||||
|
@ -15,7 +15,7 @@ import './workspaceComponent.scss'
|
||||
type Props = {
|
||||
workspaceTree: WorkspaceTree
|
||||
boardTree?: BoardTree
|
||||
showBoard: (id: string) => void
|
||||
showBoard: (id?: string) => void
|
||||
showView: (id: string, boardId?: string) => void
|
||||
setSearchText: (text?: string) => void
|
||||
setLanguage: (lang: string) => void
|
||||
|
@ -133,9 +133,18 @@ export default class BoardPage extends React.Component<Props, State> {
|
||||
)
|
||||
}
|
||||
|
||||
private async attachToBoard(boardId: string, viewId?: string) {
|
||||
private async attachToBoard(boardId?: string, viewId?: string) {
|
||||
Utils.log(`attachToBoard: ${boardId}`)
|
||||
this.sync(boardId, viewId)
|
||||
if (boardId) {
|
||||
this.sync(boardId, viewId)
|
||||
} else {
|
||||
// No board
|
||||
this.setState({
|
||||
boardTree: undefined,
|
||||
boardId: '',
|
||||
viewId: '',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private async sync(boardId: string = this.state.boardId, viewId: string | undefined = this.state.viewId) {
|
||||
@ -187,24 +196,29 @@ export default class BoardPage extends React.Component<Props, State> {
|
||||
newState = {...newState, workspaceTree: newWorkspaceTree}
|
||||
}
|
||||
|
||||
const newBoardTree = boardTree ? boardTree.mutableCopy() : new MutableBoardTree(this.state.boardId)
|
||||
if (newBoardTree.incrementalUpdate(blocks)) {
|
||||
newBoardTree.setActiveView(this.state.viewId)
|
||||
newState = {...newState, boardTree: newBoardTree}
|
||||
if (boardTree || this.state.boardId) {
|
||||
const newBoardTree = boardTree ? boardTree.mutableCopy() : new MutableBoardTree(this.state.boardId)
|
||||
if (newBoardTree.incrementalUpdate(blocks)) {
|
||||
newBoardTree.setActiveView(this.state.viewId)
|
||||
newState = {...newState, boardTree: newBoardTree}
|
||||
}
|
||||
}
|
||||
|
||||
this.setState(newState)
|
||||
}
|
||||
|
||||
// IPageController
|
||||
showBoard(boardId: string): void {
|
||||
showBoard(boardId?: string): void {
|
||||
const {boardTree} = this.state
|
||||
|
||||
if (boardTree?.board?.id === boardId) {
|
||||
return
|
||||
}
|
||||
|
||||
const newUrl = window.location.protocol + '//' + window.location.host + window.location.pathname + `?id=${encodeURIComponent(boardId)}`
|
||||
let newUrl = window.location.protocol + '//' + window.location.host + window.location.pathname
|
||||
if (boardId) {
|
||||
newUrl += `?id=${encodeURIComponent(boardId)}`
|
||||
}
|
||||
window.history.pushState({path: newUrl}, '', newUrl)
|
||||
|
||||
this.attachToBoard(boardId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user