From 2751b4d80c0f6a0b69aba307c233a08e4a05577c Mon Sep 17 00:00:00 2001 From: Rajat-Dabade Date: Wed, 17 Aug 2022 11:54:23 +0530 Subject: [PATCH] Fixed the new button error in kanban --- webapp/src/components/kanban/kanban.tsx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/webapp/src/components/kanban/kanban.tsx b/webapp/src/components/kanban/kanban.tsx index 81bde2d15..79232325c 100644 --- a/webapp/src/components/kanban/kanban.tsx +++ b/webapp/src/components/kanban/kanban.tsx @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. /* eslint-disable max-lines */ -import React, {useCallback, useState, useMemo} from 'react' +import React, { useCallback, useState, useMemo, useEffect } from 'react' import {FormattedMessage, injectIntl, IntlShape} from 'react-intl' import withScrolling, {createHorizontalStrength, createVerticalStrength} from 'react-dnd-scrolling' @@ -21,6 +21,7 @@ import {Constants, Permission} from '../../constants' import {dragAndDropRearrange} from '../cardDetail/cardDetailContentsUtility' +import {getCurrentBoardTemplates} from '../../store/cards' import BoardPermissionGate from '../permissions/boardPermissionGate' import HiddenCardCount from '../../components/hiddenCardCount/hiddenCardCount' @@ -55,7 +56,20 @@ const vStrength = createVerticalStrength(Utils.isMobile() ? 60 : 250) const Kanban = (props: Props) => { const currentView = useAppSelector(getCurrentView) + const cardTemplates: Card[] = useAppSelector(getCurrentBoardTemplates) const {board, activeView, cards, groupByProperty, visibleGroups, hiddenGroups, hiddenCardsCount} = props + const [defaultTemplateID, setDefaultTemplateID] = useState('') + + useEffect(() => { + if(currentView.fields.defaultTemplateId) { + cardTemplates.forEach((cardTemplate) => { + if(cardTemplate.id === currentView.fields.defaultTemplateId) { + setDefaultTemplateID(currentView.fields.defaultTemplateId) + } + }) + } + }, [currentView]) + if (!groupByProperty) { Utils.assertFailure('Board views must have groupByProperty set') @@ -297,8 +311,8 @@ const Kanban = (props: Props) => {