From e82305de5636f6066d39e7b51eee7672996742a6 Mon Sep 17 00:00:00 2001 From: Chen-I Lim <46905241+chenilim@users.noreply.github.com> Date: Thu, 24 Mar 2022 10:04:14 -0700 Subject: [PATCH 1/6] Fix #2589. Maintain cardProperty order on patch (#2625) Thanks. Merging as the CI failure is not related to this change. --- server/model/board.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/server/model/board.go b/server/model/board.go index 9b519807a..109bcef65 100644 --- a/server/model/board.go +++ b/server/model/board.go @@ -223,7 +223,8 @@ func (p *BoardPatch) Patch(board *Board) *Board { } if len(p.UpdatedCardProperties) != 0 || len(p.DeletedCardProperties) != 0 { - // first we accumulate all properties indexed by ID + // first we accumulate all properties indexed by, and maintain their order + keyOrder := []string{} cardPropertyMap := map[string]map[string]interface{}{} for _, prop := range board.CardProperties { id, ok := prop["id"].(string) @@ -233,6 +234,7 @@ func (p *BoardPatch) Patch(board *Board) *Board { } cardPropertyMap[id] = prop + keyOrder = append(keyOrder, id) } // if there are properties marked for removal, we delete them @@ -249,13 +251,20 @@ func (p *BoardPatch) Patch(board *Board) *Board { continue } + _, exists := cardPropertyMap[id] + if !exists { + keyOrder = append(keyOrder, id) + } cardPropertyMap[id] = newprop } // and finally we flatten and save the updated properties newCardProperties := []map[string]interface{}{} - for _, p := range cardPropertyMap { - newCardProperties = append(newCardProperties, p) + for _, key := range keyOrder { + p, exists := cardPropertyMap[key] + if exists { + newCardProperties = append(newCardProperties, p) + } } board.CardProperties = newCardProperties From 1a5299044fff2b97f4c83af9f9940c5d9558d1b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Thu, 24 Mar 2022 18:12:31 +0100 Subject: [PATCH 2/6] Fixing ShareBoard users ordering (#2602) --- webapp/src/components/shareBoard/shareBoard.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/webapp/src/components/shareBoard/shareBoard.tsx b/webapp/src/components/shareBoard/shareBoard.tsx index 21860df1d..b4d13bb0c 100644 --- a/webapp/src/components/shareBoard/shareBoard.tsx +++ b/webapp/src/components/shareBoard/shareBoard.tsx @@ -272,17 +272,15 @@ export default function ShareBoardDialog(props: Props): JSX.Element {
- {Object.values(members).map((member) => { - const user = boardUsers.find((u) => u.id === member.userId) - if (!user) { + {boardUsers.map((user) => { + if (!members[user.id]) { return null } - return ( Date: Thu, 24 Mar 2022 13:23:00 -0400 Subject: [PATCH 3/6] fix web app syntax error (#2590) From 70ab1afecd5a858392093722893fbacb3aa5868d Mon Sep 17 00:00:00 2001 From: Scott Bishel Date: Thu, 24 Mar 2022 11:24:18 -0600 Subject: [PATCH 4/6] fix cypress tests (#2628) Co-authored-by: Mattermod --- .../services/permissions/localpermissions/localpermissions.go | 4 +--- webapp/cypress/support/api_commands.ts | 4 ++-- webapp/cypress/support/ui_commands.ts | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/server/services/permissions/localpermissions/localpermissions.go b/server/services/permissions/localpermissions/localpermissions.go index 54fa9366b..1456708b7 100644 --- a/server/services/permissions/localpermissions/localpermissions.go +++ b/server/services/permissions/localpermissions/localpermissions.go @@ -27,9 +27,7 @@ func New(store permissions.Store, logger *mlog.Logger) *Service { } func (s *Service) HasPermissionToTeam(userID, teamID string, permission *mmModel.Permission) bool { - if userID == "" || teamID == "" || permission == nil { - return false - } + // Locally there is no team, so return true return true } diff --git a/webapp/cypress/support/api_commands.ts b/webapp/cypress/support/api_commands.ts index 542ded136..2c008058d 100644 --- a/webapp/cypress/support/api_commands.ts +++ b/webapp/cypress/support/api_commands.ts @@ -117,8 +117,8 @@ Cypress.Commands.add('apiChangePassword', (userId: string, oldPassword: string, Cypress.Commands.add('uiCreateNewBoard', (title?: string) => { cy.log('**Create new empty board**') - cy.findByText('+ Add board').click() - cy.get('.empty-board').first().click({force: true}) + cy.uiCreateEmptyBoard() + cy.findByPlaceholderText('Untitled board').should('exist') cy.wait(10) if (title) { diff --git a/webapp/cypress/support/ui_commands.ts b/webapp/cypress/support/ui_commands.ts index 674cab720..829022b65 100644 --- a/webapp/cypress/support/ui_commands.ts +++ b/webapp/cypress/support/ui_commands.ts @@ -16,7 +16,6 @@ Cypress.Commands.add('uiCreateBoard', (item: string) => { Cypress.Commands.add('uiCreateEmptyBoard', () => { cy.log('Create new empty board') - cy.contains('+ Add board').should('be.visible').click() - + cy.contains('+ Add board').should('be.visible').click().wait(500) return cy.contains('Create empty board').click({force: true}).wait(1000) }) From 71cb654d712ea84c8f974f60f6cc2bb10c606fa1 Mon Sep 17 00:00:00 2001 From: Doug Lauder Date: Thu, 24 Mar 2022 17:45:10 -0400 Subject: [PATCH 5/6] Revert in-memory unit tests for sqlite (#2630) * revert in-memory unit tests for sqlite * fix unit test * fix comments * fix unit tests --- .../permissions/localpermissions/localpermissions.go | 4 +++- server/services/store/sqlstore/util.go | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server/services/permissions/localpermissions/localpermissions.go b/server/services/permissions/localpermissions/localpermissions.go index 1456708b7..54fa9366b 100644 --- a/server/services/permissions/localpermissions/localpermissions.go +++ b/server/services/permissions/localpermissions/localpermissions.go @@ -27,7 +27,9 @@ func New(store permissions.Store, logger *mlog.Logger) *Service { } func (s *Service) HasPermissionToTeam(userID, teamID string, permission *mmModel.Permission) bool { - // Locally there is no team, so return true + if userID == "" || teamID == "" || permission == nil { + return false + } return true } diff --git a/server/services/store/sqlstore/util.go b/server/services/store/sqlstore/util.go index 79cef4e05..b095c3c72 100644 --- a/server/services/store/sqlstore/util.go +++ b/server/services/store/sqlstore/util.go @@ -3,6 +3,7 @@ package sqlstore import ( "database/sql" "fmt" + "io/ioutil" "os" "strings" @@ -33,7 +34,12 @@ func PrepareNewTestDatabase() (dbType string, connectionString string, err error var rootUser string if dbType == model.SqliteDBType { - connectionString = "file::memory:?cache=shared&_busy_timeout=5000" + file, err := ioutil.TempFile("", "fbtest_*.db") + if err != nil { + return "", "", err + } + connectionString = file.Name() + "?_busy_timeout=5000" + _ = file.Close() } else if port := strings.TrimSpace(os.Getenv("FB_STORE_TEST_DOCKER_PORT")); port != "" { // docker unit tests take priority over any DSN env vars var template string From 4645ecbd11b6040ba796342d47fb9a9d297c4387 Mon Sep 17 00:00:00 2001 From: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com> Date: Fri, 25 Mar 2022 12:10:42 +0530 Subject: [PATCH 6/6] Updated SQL migration to insert board memberships for templates (#2627) Co-authored-by: Mattermod --- .../sqlstore/migrations/000017_add_teams_and_boards.up.sql | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/server/services/store/sqlstore/migrations/000017_add_teams_and_boards.up.sql b/server/services/store/sqlstore/migrations/000017_add_teams_and_boards.up.sql index 2ed63ba57..4847cf4d4 100644 --- a/server/services/store/sqlstore/migrations/000017_add_teams_and_boards.up.sql +++ b/server/services/store/sqlstore/migrations/000017_add_teams_and_boards.up.sql @@ -366,13 +366,11 @@ CREATE INDEX idx_boardmembers_user_id ON {{.prefix}}board_members(user_id); INSERT INTO {{.prefix}}board_members ( SELECT B.Id, CM.UserId, CM.Roles, (CM.UserId=B.created_by) OR CM.SchemeAdmin, CM.SchemeUser, FALSE, CM.SchemeGuest FROM {{.prefix}}boards AS B - INNER JOIN ChannelMembers as CM ON CM.ChannelId=B.channel_id - WHERE NOT B.is_template + INNER JOIN ChannelMembers as CM ON CM.ChannelId=B.channel_id; ); {{else}} {{- /* if we're in personal server or desktop, create memberships for everyone */ -}} INSERT INTO {{.prefix}}board_members SELECT B.id, U.id, '', B.created_by=U.id, TRUE, FALSE, FALSE - FROM {{.prefix}}boards AS B, {{.prefix}}users AS U - WHERE NOT B.is_template; + FROM {{.prefix}}boards AS B, {{.prefix}}users AS U; {{end}}