Updated share board modal to support templates

This commit is contained in:
Harshil Sharma 2022-03-25 11:54:27 +05:30
parent 018c829132
commit f26a854d3c
2 changed files with 8 additions and 6 deletions

View file

@ -77,10 +77,11 @@ func (s *SQLStore) getTemplateBoards(db sq.BaseRunner, teamID, userID string) ([
query := s.getQueryBuilder(db).
Select(boardFields("")...).
From(s.tablePrefix+"boards as b").
LeftJoin(s.tablePrefix+"board_members as bm on b.id = bm.board_id and and bm.user_id = ?", userID).
LeftJoin(s.tablePrefix+"board_members as bm on b.id = bm.board_id and bm.user_id = ?", userID).
Where(sq.Eq{"is_template": true}).
Where(sq.Eq{"b.team_id": teamID}).
Where(sq.Or{
// this is to include public templates even if there is not board_member entry
sq.And{
sq.Eq{"bm.board_id": nil},
sq.Eq{"b.type": model.BoardTypeOpen},

View file

@ -9,7 +9,7 @@ import Select from 'react-select/async'
import {CSSObject} from '@emotion/serialize'
import {useAppSelector} from '../../store/hooks'
import {getCurrentBoardId, getCurrentBoardMembers} from '../../store/boards'
import {getCurrentBoard, getCurrentBoardMembers} from '../../store/boards'
import {getMe, getBoardUsersList} from '../../store/users'
import {Utils, IDType} from '../../utils'
@ -95,7 +95,8 @@ export default function ShareBoardDialog(props: Props): JSX.Element {
// members of the current board
const members = useAppSelector<{[key: string]: BoardMember}>(getCurrentBoardMembers)
const boardId = useAppSelector(getCurrentBoardId)
const board = useAppSelector(getCurrentBoard)
const boardId = board.id
const boardUsers = useAppSelector<IUser[]>(getBoardUsersList)
const me = useAppSelector<IUser|null>(getMe)
@ -291,7 +292,7 @@ export default function ShareBoardDialog(props: Props): JSX.Element {
})}
</div>
{props.enableSharedBoards && (
{props.enableSharedBoards && !board.isTemplate && (
<div className='tabs-container'>
<button
onClick={() => setPublish(false)}
@ -315,7 +316,7 @@ export default function ShareBoardDialog(props: Props): JSX.Element {
</BoardPermissionGate>
</div>
)}
{(props.enableSharedBoards && publish) &&
{(props.enableSharedBoards && publish && !board.isTemplate) &&
(<BoardPermissionGate permissions={[Permission.ShareBoard]}>
<div className='tabs-content'>
<div>
@ -393,7 +394,7 @@ export default function ShareBoardDialog(props: Props): JSX.Element {
</BoardPermissionGate>
)}
{!publish && (
{!publish && !board.isTemplate && (
<div className='tabs-content'>
<div>
<div className='d-flex justify-content-between'>