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

don't copy 'comment' blocks (#3267)

* don't copy 'comment' blocks

* update tests

* lint fixes
This commit is contained in:
Scott Bishel 2022-06-22 15:57:27 -06:00 committed by GitHub
parent 39c1d07974
commit 2f0c1235bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 3 deletions

View File

@ -781,6 +781,9 @@ func (s *SQLStore) duplicateBlock(db sq.BaseRunner, boardID string, blockID stri
var rootBlock model.Block
allBlocks := []model.Block{}
for _, block := range blocks {
if block.Type == model.TypeComment {
continue
}
if block.ID == blockID {
if block.Fields == nil {
block.Fields = make(map[string]interface{})

View File

@ -165,7 +165,13 @@ func (s *SQLStore) duplicateBoard(db sq.BaseRunner, boardID string, userID strin
if err != nil {
return nil, nil, err
}
bab.Blocks = blocks
newBlocks := []model.Block{}
for _, b := range blocks {
if b.Type != model.TypeComment {
newBlocks = append(newBlocks, b)
}
}
bab.Blocks = newBlocks
bab, err = model.GenerateBoardsAndBlocksIDs(bab, nil)
if err != nil {

View File

@ -796,7 +796,25 @@ func testGetBlock(t *testing.T, store store.Store) {
}
func testDuplicateBlock(t *testing.T, store store.Store) {
InsertBlocks(t, store, subtreeSampleBlocks, "user-id-1")
blocksToInsert := subtreeSampleBlocks
blocksToInsert = append(blocksToInsert,
model.Block{
ID: "grandchild1a",
BoardID: testBoardID,
ParentID: "child1",
ModifiedBy: testUserID,
Type: model.TypeComment,
},
model.Block{
ID: "grandchild2a",
BoardID: testBoardID,
ParentID: "child2",
ModifiedBy: testUserID,
Type: model.TypeComment,
},
)
InsertBlocks(t, store, blocksToInsert, "user-id-1")
time.Sleep(1 * time.Millisecond)
defer DeleteBlocks(t, store, subtreeSampleBlocks, "test")

View File

@ -583,6 +583,7 @@ func testDuplicateBoard(t *testing.T, store store.Store) {
},
Blocks: []model.Block{
{ID: "block-id-1", BoardID: "board-id-1", Type: model.TypeCard},
{ID: "block-id-1a", BoardID: "board-id-1", Type: model.TypeComment},
{ID: "block-id-2", BoardID: "board-id-2", Type: model.TypeCard},
},
}
@ -591,7 +592,7 @@ func testDuplicateBoard(t *testing.T, store store.Store) {
require.Nil(t, err)
require.NotNil(t, bab)
require.Len(t, bab.Boards, 3)
require.Len(t, bab.Blocks, 2)
require.Len(t, bab.Blocks, 3)
t.Run("duplicate existing board as no template", func(t *testing.T) {
bab, members, err := store.DuplicateBoard("board-id-1", userID, teamID, false)