Fixes for admins when LastBoardID doesn't exist (#22993)

* fixes for admins when LastBoardID doesn't exist

* lint fixes

* Update webapp/boards/src/components/sidebar/sidebarCategory.tsx

Co-authored-by: Caleb Roseland <caleb@calebroseland.com>

* after deletion, if no boards, send to team (template selector)

---------

Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Scott Bishel 2023-04-24 14:46:16 -06:00 committed by GitHub
parent 94cb2867a7
commit a52a6d9abd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import CompassIcon from 'src/widgets/icons/compassIcon'
import OptionsIcon from 'src/widgets/icons/options'
import Menu from 'src/widgets/menu'
import MenuWrapper from 'src/widgets/menuWrapper'
import {UserSettings} from 'src/userSettings'
import './sidebarCategory.scss'
import {Category, CategoryBoardMetadata, CategoryBoards} from 'src/store/sidebar'
@ -202,12 +203,24 @@ const SidebarCategory = (props: Props) => {
setTimeout(() => {
showBoard(props.boards[nextBoardId as number].id)
}, 120)
} else {
setTimeout(() => {
const newPath = generatePath('/team/:teamId', {teamId: teamID,})
history.push(newPath)
}, 120)
}
},
async () => {
showBoard(deleteBoard.id)
},
)
if (
UserSettings.lastBoardId &&
UserSettings.lastBoardId[deleteBoard.teamId] == deleteBoard.id
) {
UserSettings.setLastBoardID(deleteBoard.teamId, null)
UserSettings.setLastViewId(deleteBoard.id, null)
}
}, [showBoard, deleteBoard, props.boards])
const updateCategory = useCallback(async (value: boolean) => {

View File

@ -186,7 +186,9 @@ const BoardPage = (props: Props): JSX.Element => {
const joinBoard = async (myUser: IUser, boardTeamId: string, boardId: string, allowAdmin: boolean) => {
const member = await octoClient.joinBoard(boardId, allowAdmin)
if (!member) {
if (myUser.permissions?.find((s) => s === 'manage_system' || s === 'manage_team')) {
// if allowAdmin is true, then we failed to join the board
// as an admin, normally, this is deleted/missing board
if (!allowAdmin && myUser.permissions?.find((s) => s === 'manage_system' || s === 'manage_team')) {
setShowJoinBoardDialog(true)
return
}