From 91ec75d2d0e388a8818d0d4d2d7c2990cccf7f62 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Fri, 18 Sep 2020 19:11:56 -0400 Subject: [PATCH] 16811: Filter "Public favorites" from "Shared with me" & add test Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- cypress/integration/favorites.js | 6 ++++++ .../shared-with-me-middleware-service.ts | 4 +++- src/store/side-panel-tree/side-panel-tree-actions.ts | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cypress/integration/favorites.js b/cypress/integration/favorites.js index 8ef4899f..b38399be 100644 --- a/cypress/integration/favorites.js +++ b/cypress/integration/favorites.js @@ -28,6 +28,12 @@ describe('Collection panel tests', function() { cy.clearLocalStorage() }) + it('checks that Public favorites does not appear under shared with me', function() { + cy.loginAs(adminUser); + cy.contains('Shared with me').click(); + cy.get('main').contains('Public favorites').should('not.exist'); + }) + it('creates and removes a public favorite', function() { cy.loginAs(adminUser); cy.createGroup(adminUser.token, { diff --git a/src/store/shared-with-me-panel/shared-with-me-middleware-service.ts b/src/store/shared-with-me-panel/shared-with-me-middleware-service.ts index a09a3085..e5dd6d9f 100644 --- a/src/store/shared-with-me-panel/shared-with-me-middleware-service.ts +++ b/src/store/shared-with-me-panel/shared-with-me-middleware-service.ts @@ -10,7 +10,7 @@ import { getDataExplorer, DataExplorer } from '~/store/data-explorer/data-explor import { updateFavorites } from '~/store/favorites/favorites-actions'; import { updateResources } from '~/store/resources/resources-actions'; import { loadMissingProcessesInformation, getFilters } from '~/store/project-panel/project-panel-middleware-service'; -import {snackbarActions, SnackbarKind} from '~/store/snackbar/snackbar-actions'; +import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions'; import { sharedWithMePanelActions } from './shared-with-me-panel-actions'; import { ListResults } from '~/services/common-service/common-service'; import { GroupContentsResource, GroupContentsResourcePrefix } from '~/services/groups-service/groups-service'; @@ -20,6 +20,7 @@ import { ProjectResource } from '~/models/project'; import { ProjectPanelColumnNames } from '~/views/project-panel/project-panel'; import { getSortColumn } from "~/store/data-explorer/data-explorer-reducer"; import { updatePublicFavorites } from '~/store/public-favorites/public-favorites-actions'; +import { FilterBuilder } from '~/services/api/filter-builder'; export class SharedWithMeMiddlewareService extends DataExplorerMiddlewareService { constructor(private services: ServiceRepository, id: string) { @@ -34,6 +35,7 @@ export class SharedWithMeMiddlewareService extends DataExplorerMiddlewareService .contents('', { ...getParams(dataExplorer), excludeHomeProject: true, + filters: new FilterBuilder().addDistinct('uuid', `${state.auth.config.uuidPrefix}-j7d0g-publicfavorites`).getFilters() }); api.dispatch(updateFavorites(response.items.map(item => item.uuid))); api.dispatch(updatePublicFavorites(response.items.map(item => item.uuid))); diff --git a/src/store/side-panel-tree/side-panel-tree-actions.ts b/src/store/side-panel-tree/side-panel-tree-actions.ts index a09ab6ba..ff506103 100644 --- a/src/store/side-panel-tree/side-panel-tree-actions.ts +++ b/src/store/side-panel-tree/side-panel-tree-actions.ts @@ -106,13 +106,14 @@ const loadProject = (projectUuid: string) => dispatch(resourcesActions.SET_RESOURCES(items)); }; -const loadSharedRoot = async (dispatch: Dispatch, _: () => RootState, services: ServiceRepository) => { +const loadSharedRoot = async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: SidePanelTreeCategory.SHARED_WITH_ME, pickerId: SIDE_PANEL_TREE })); const params = { filters: `[${new FilterBuilder() .addIsA('uuid', ResourceKind.PROJECT) .addEqual('group_class', GroupClass.PROJECT) + .addDistinct('uuid', getState().auth.config.uuidPrefix + '-j7d0g-publicfavorites') .getFilters()}]`, order: new OrderBuilder() .addAsc('name', GroupContentsResourcePrefix.PROJECT) -- 2.30.2