1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-02-13 19:42:12 +02:00

GH-2796 - Check my membership for sidebar items (#2820)

* check my membership for sidebard items

* update variable name

* Updated server tests

* fix lint errors

* revert board test changes

* fix unit tests

Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
Scott Bishel 2022-04-18 09:59:26 -06:00 committed by GitHub
parent 0489de8bd3
commit cbad8fe9d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -42,6 +42,9 @@ describe('components/sidebarSidebar', () => {
boards: {
[board.id]: board,
},
myBoardMemberships: {
[board.id]: board,
},
},
views: {
views: [],
@ -92,6 +95,9 @@ describe('components/sidebarSidebar', () => {
boards: {
[board.id]: board,
},
myBoardMemberships: {
[board.id]: board,
}
},
views: {
views: [],

View File

@ -8,7 +8,7 @@ import IconButton from '../../widgets/buttons/iconButton'
import HamburgerIcon from '../../widgets/icons/hamburger'
import HideSidebarIcon from '../../widgets/icons/hideSidebar'
import ShowSidebarIcon from '../../widgets/icons/showSidebar'
import {getSortedBoards} from '../../store/boards'
import {getMySortedBoards} from '../../store/boards'
import {useAppDispatch, useAppSelector} from '../../store/hooks'
import {Utils} from '../../utils'
@ -53,7 +53,7 @@ const Sidebar = (props: Props) => {
const [isHidden, setHidden] = useState(false)
const [userHidden, setUserHidden] = useState(false)
const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions())
const boards = useAppSelector(getSortedBoards)
const boards = useAppSelector(getMySortedBoards)
const dispatch = useAppDispatch()
const partialCategories = useAppSelector<Array<CategoryBoards>>(getSidebarCategories)
const sidebarCategories = addMissingItems(partialCategories, boards)

View File

@ -195,10 +195,12 @@ export const {reducer} = boardsSlice
export const getBoards = (state: RootState): {[key: string]: Board} => state.boards.boards
export const getSortedBoards = createSelector(
export const getMySortedBoards = createSelector(
getBoards,
(boards) => {
return Object.values(boards).sort((a, b) => a.title.localeCompare(b.title))
(state: RootState): {[key: string]: BoardMember} => state.boards.myBoardMemberships,
(boards, myBoardMemberships: {[key: string]: BoardMember}) => {
return Object.values(boards).filter((b) => myBoardMemberships[b.id])
.sort((a, b) => a.title.localeCompare(b.title))
},
)