1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-24 13:43:12 +02:00

Added logic for system board category to show last (#4163)

* Added logic for system board category to show last

* NIT
This commit is contained in:
Rajat Dabade 2022-11-08 21:29:09 +05:30 committed by GitHub
parent f5e8f4f82d
commit bddeeedd75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,8 +38,14 @@ export const DefaultCategory: CategoryBoards = {
export const fetchSidebarCategories = createAsyncThunk(
'sidebarCategories/fetch',
async (teamID: string) => {
const categories = await client.getSidebarCategories(teamID)
return categories.sort((a, b) => a.name.localeCompare(b.name))
// TODO All this logic should remove once LHS DND PR gets merged
const allCategories = await client.getSidebarCategories(teamID)
const boardSystemCategoies = allCategories.filter((category) => category.name === 'Boards' && category.type === 'system')
const categoriesWithoutSystemBoard = allCategories.filter((category) => category.name !== 'Boards' && category.type !== 'system')
const categories = categoriesWithoutSystemBoard
categories.sort((a, b) => a.name.localeCompare(b.name))
categories.push(boardSystemCategoies[0])
return categories
},
)
@ -74,8 +80,14 @@ const sidebarSlice = createSlice({
}
})
// sort categories alphabetically
state.categoryAttributes.sort((a, b) => a.name.localeCompare(b.name))
// sort categories alphabetically only keeping board system category at the end
// TODO All this logic should remove once LHS DND PR gets merged
const boardsSystemCategories = state.categoryAttributes.filter((category) => category.name === 'Boards' && category.type === 'system')
const categoriesWithoutSystemBoard = state.categoryAttributes.filter((category) => category.name !== 'Baords' && category.type !== 'system')
const categories = categoriesWithoutSystemBoard
categories.sort((a, b) => a.name.localeCompare(b.name))
categories.push(boardsSystemCategories[0])
state.categoryAttributes = categories
},
updateBoardCategories: (state, action: PayloadAction<BoardCategoryWebsocketData[]>) => {
action.payload.forEach((boardCategory) => {