Skip to content

Commit

Permalink
fix: shared views can be favorited (#921)
Browse files Browse the repository at this point in the history
* fix: favorite shared views

Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
  • Loading branch information
elzody authored Mar 18, 2024
1 parent cfc12c6 commit 7f4fa63
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
20 changes: 19 additions & 1 deletion cypress/e2e/tables-favorite.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,23 @@ describe('Favorite tables/views', () => {

cy.get('@testView').parent().parent().should('contain.text', 'Tutorial')
})


it('can (un)favorite views with favorited parent tables', () => {
cy.get('[data-cy="navigationViewItem"]').first().as('testView')
cy.get('[data-cy="navigationTableItem"]').first().as('tutorialTable')

cy.get('@testView').parent().parent().should('contain.text', 'Tutorial')
cy.get('@testView').find('[aria-haspopup="menu"]').click({ force: true })
cy.contains('Add to favorites').click({ force: true })

cy.get('@testView').parent().should('contain.text', 'Favorites')

cy.get('@tutorialTable').should('contain.text', 'Tutorial')
cy.get('@tutorialTable').find('[aria-haspopup="menu"]').first().click({ force: true })
cy.contains('Add to favorites').click({ force: true })

cy.get('@tutorialTable').parent().should('contain.text', 'Tables')
cy.get('@testView').parent().should('not.contain.text', 'Favorites')
})

})
16 changes: 12 additions & 4 deletions src/modules/navigation/sections/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,22 @@ export default {
}).filter(view => view.title.toLowerCase().includes(this.filterString.toLowerCase()))
},
getSharedViews() {
const sharedTableIds = this.getFilteredTables.map(table => table.id)
return this.views.filter(view => {
return view.isShared && view.ownership !== getCurrentUser().uid && !sharedTableIds.includes(view.tableId)
return view.isShared && view.ownership !== getCurrentUser().uid
}).filter(view => view.title.toLowerCase().includes(this.filterString.toLowerCase()))
},
getFavoriteTables() {
return this.getAllNodes.filter(node => !node.tableId && node.favorite)
},
getFavoriteViews() {
return this.getAllNodes.filter(node => node.tableId && node.favorite)
},
getFavoriteNodes() {
return this.getAllNodes.filter(node => node.favorite)
const favoriteViews = this.getFavoriteViews.filter(view => {
return !this.getFavoriteTables.map(t => t.id).includes(view.tableId)
})
return [...this.getFavoriteTables, ...favoriteViews]
},
getArchivedTables() {
return this.getFilteredTables.filter(node => node.archived)
Expand Down

0 comments on commit 7f4fa63

Please sign in to comment.