[arvados] created: 2.7.0-6054-gbba33fe67b
git repository hosting
git at public.arvados.org
Tue Feb 27 20:10:32 UTC 2024
at bba33fe67b5126c092ac09e6fe0ff388aefd5619 (commit)
commit bba33fe67b5126c092ac09e6fe0ff388aefd5619
Author: Stephen Smith <stephen at curii.com>
Date: Tue Feb 27 15:10:14 2024 -0500
21249: Add unit tests to check group details pagination
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen at curii.com>
diff --git a/services/workbench2/src/store/group-details-panel/group-details-panel-members-middleware-service.test.js b/services/workbench2/src/store/group-details-panel/group-details-panel-members-middleware-service.test.js
new file mode 100644
index 0000000000..d386ed3953
--- /dev/null
+++ b/services/workbench2/src/store/group-details-panel/group-details-panel-members-middleware-service.test.js
@@ -0,0 +1,28 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { initialDataExplorer } from '../data-explorer/data-explorer-reducer'
+import { getParams } from './group-details-panel-members-middleware-service'
+
+describe('group-details-panel-members-middleware', () => {
+ describe('getParams', () => {
+ it('should paginate', () => {
+ // given
+ const dataExplorer = initialDataExplorer;
+ let params = getParams(dataExplorer, 'uuid');
+
+ // expect
+ expect(params.offset).toBe(0);
+ expect(params.limit).toBe(50);
+
+ // when
+ dataExplorer.page = 1;
+ params = getParams(dataExplorer, 'uuid');
+
+ // expect
+ expect(params.offset).toBe(50);
+ expect(params.limit).toBe(50);
+ });
+ })
+})
diff --git a/services/workbench2/src/store/group-details-panel/group-details-panel-permissions-middleware-service.test.js b/services/workbench2/src/store/group-details-panel/group-details-panel-permissions-middleware-service.test.js
new file mode 100644
index 0000000000..1e5e3b1467
--- /dev/null
+++ b/services/workbench2/src/store/group-details-panel/group-details-panel-permissions-middleware-service.test.js
@@ -0,0 +1,28 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { initialDataExplorer } from '../data-explorer/data-explorer-reducer'
+import { getParams } from './group-details-panel-permissions-middleware-service'
+
+describe('group-details-panel-permissions-middleware', () => {
+ describe('getParams', () => {
+ it('should paginate', () => {
+ // given
+ const dataExplorer = initialDataExplorer;
+ let params = getParams(dataExplorer, 'uuid');
+
+ // expect
+ expect(params.offset).toBe(0);
+ expect(params.limit).toBe(50);
+
+ // when
+ dataExplorer.page = 1;
+ params = getParams(dataExplorer, 'uuid');
+
+ // expect
+ expect(params.offset).toBe(50);
+ expect(params.limit).toBe(50);
+ });
+ })
+})
commit 113b2b5d0b9628ddc85baab9c1b33cadd7cf8633
Author: Stephen Smith <stephen at curii.com>
Date: Tue Feb 27 14:12:22 2024 -0500
21249: Implement paging for group members panel and group permission list
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen at curii.com>
diff --git a/services/workbench2/src/store/group-details-panel/group-details-panel-members-middleware-service.ts b/services/workbench2/src/store/group-details-panel/group-details-panel-members-middleware-service.ts
index 507b4eb30f..6f95ca4ee2 100644
--- a/services/workbench2/src/store/group-details-panel/group-details-panel-members-middleware-service.ts
+++ b/services/workbench2/src/store/group-details-panel/group-details-panel-members-middleware-service.ts
@@ -3,11 +3,11 @@
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch, MiddlewareAPI } from "redux";
-import { DataExplorerMiddlewareService, listResultsToDataExplorerItemsMeta } from "store/data-explorer/data-explorer-middleware-service";
+import { DataExplorerMiddlewareService, dataExplorerToListParams, listResultsToDataExplorerItemsMeta } from "store/data-explorer/data-explorer-middleware-service";
import { RootState } from "store/store";
import { ServiceRepository } from "services/services";
import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
-import { getDataExplorer } from "store/data-explorer/data-explorer-reducer";
+import { DataExplorer, getDataExplorer } from "store/data-explorer/data-explorer-reducer";
import { FilterBuilder } from 'services/api/filter-builder';
import { updateResources } from 'store/resources/resources-actions';
import { getCurrentGroupDetailsPanelUuid, GroupMembersPanelActions } from 'store/group-details-panel/group-details-panel-actions';
@@ -33,12 +33,7 @@ export class GroupDetailsPanelMembersMiddlewareService extends DataExplorerMiddl
const groupResource = await this.services.groupsService.get(groupUuid);
api.dispatch(updateResources([groupResource]));
- const permissionsIn = await this.services.permissionService.list({
- filters: new FilterBuilder()
- .addEqual('head_uuid', groupUuid)
- .addEqual('link_class', LinkClass.PERMISSION)
- .getFilters()
- });
+ const permissionsIn = await this.services.permissionService.list(getParams(dataExplorer, groupUuid));
api.dispatch(updateResources(permissionsIn.items));
api.dispatch(GroupMembersPanelActions.SET_ITEMS({
@@ -74,6 +69,20 @@ export class GroupDetailsPanelMembersMiddlewareService extends DataExplorerMiddl
}
}
+export const getParams = (dataExplorer: DataExplorer, groupUuid: string) => ({
+ ...dataExplorerToListParams(dataExplorer),
+ filters: getFilters(groupUuid),
+});
+
+export const getFilters = (groupUuid: string) => {
+ const filters = new FilterBuilder()
+ .addEqual('head_uuid', groupUuid)
+ .addEqual('link_class', LinkClass.PERMISSION)
+ .getFilters();
+
+ return filters;
+};
+
const couldNotFetchGroupDetailsContents = () =>
snackbarActions.OPEN_SNACKBAR({
message: 'Could not fetch group members.',
diff --git a/services/workbench2/src/store/group-details-panel/group-details-panel-permissions-middleware-service.ts b/services/workbench2/src/store/group-details-panel/group-details-panel-permissions-middleware-service.ts
index 85beecd726..c6cb05f87b 100644
--- a/services/workbench2/src/store/group-details-panel/group-details-panel-permissions-middleware-service.ts
+++ b/services/workbench2/src/store/group-details-panel/group-details-panel-permissions-middleware-service.ts
@@ -3,11 +3,11 @@
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch, MiddlewareAPI } from "redux";
-import { DataExplorerMiddlewareService, listResultsToDataExplorerItemsMeta } from "store/data-explorer/data-explorer-middleware-service";
+import { DataExplorerMiddlewareService, dataExplorerToListParams, listResultsToDataExplorerItemsMeta } from "store/data-explorer/data-explorer-middleware-service";
import { RootState } from "store/store";
import { ServiceRepository } from "services/services";
import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
-import { getDataExplorer } from "store/data-explorer/data-explorer-reducer";
+import { DataExplorer, getDataExplorer } from "store/data-explorer/data-explorer-reducer";
import { FilterBuilder } from 'services/api/filter-builder';
import { updateResources } from 'store/resources/resources-actions';
import { getCurrentGroupDetailsPanelUuid, GroupPermissionsPanelActions } from 'store/group-details-panel/group-details-panel-actions';
@@ -27,12 +27,7 @@ export class GroupDetailsPanelPermissionsMiddlewareService extends DataExplorerM
// No-op if data explorer is not set since refresh may be triggered from elsewhere
} else {
try {
- const permissionsOut = await this.services.permissionService.list({
- filters: new FilterBuilder()
- .addEqual('tail_uuid', groupUuid)
- .addEqual('link_class', LinkClass.PERMISSION)
- .getFilters()
- });
+ const permissionsOut = await this.services.permissionService.list(getParams(dataExplorer, groupUuid));
api.dispatch(updateResources(permissionsOut.items));
api.dispatch(GroupPermissionsPanelActions.SET_ITEMS({
@@ -76,6 +71,20 @@ export class GroupDetailsPanelPermissionsMiddlewareService extends DataExplorerM
}
}
+export const getParams = (dataExplorer: DataExplorer, groupUuid: string) => ({
+ ...dataExplorerToListParams(dataExplorer),
+ filters: getFilters(groupUuid),
+});
+
+export const getFilters = (groupUuid: string) => {
+ const filters = new FilterBuilder()
+ .addEqual('tail_uuid', groupUuid)
+ .addEqual('link_class', LinkClass.PERMISSION)
+ .getFilters();
+
+ return filters;
+};
+
const couldNotFetchGroupDetailsContents = () =>
snackbarActions.OPEN_SNACKBAR({
message: 'Could not fetch group permissions.',
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list