[ARVADOS-WORKBENCH2] created: 1.4.1-221-gabe97871
Git user
git at public.arvados.org
Tue Jan 21 15:29:59 UTC 2020
at abe9787195984a919095b4a4c2b82c7a0baf0801 (commit)
commit abe9787195984a919095b4a4c2b82c7a0baf0801
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Tue Dec 24 15:31:07 2019 -0300
15047: Fixes build by nesting pipe() calls instead of passing more tha 7 args.
Also: adds tests.
It seems that lodash's pipe() (an alias of flow()) function changes its
return type to 'any' when being passed more than 7 arguments, sometimes
breaking the build (in this case, resource-type-filters.test.ts)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/src/store/resource-type-filters/resource-type-filters.test.ts b/src/store/resource-type-filters/resource-type-filters.test.ts
index 02f017ed..2f4d3cad 100644
--- a/src/store/resource-type-filters/resource-type-filters.test.ts
+++ b/src/store/resource-type-filters/resource-type-filters.test.ts
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import { getInitialResourceTypeFilters, serializeResourceTypeFilters, ObjectTypeFilter, CollectionTypeFilter } from './resource-type-filters';
+import { getInitialResourceTypeFilters, serializeResourceTypeFilters, ObjectTypeFilter, CollectionTypeFilter, ProcessTypeFilter } from './resource-type-filters';
import { ResourceKind } from '~/models/resource';
import { deselectNode } from '~/models/tree';
import { pipe } from 'lodash/fp';
@@ -47,4 +47,30 @@ describe("serializeResourceTypeFilters", () => {
expect(serializedFilters)
.toEqual(`["uuid","is_a",["${ResourceKind.COLLECTION}"]],["collections.properties.type","not in",["output"]]`);
});
+
+ it("should serialize only main processes", () => {
+ const filters = pipe(
+ () => getInitialResourceTypeFilters(),
+ deselectNode(ObjectTypeFilter.PROJECT),
+ deselectNode(ProcessTypeFilter.CHILD_PROCESS),
+ deselectNode(ObjectTypeFilter.COLLECTION)
+ )();
+
+ const serializedFilters = serializeResourceTypeFilters(filters);
+ expect(serializedFilters)
+ .toEqual(`["uuid","is_a",["${ResourceKind.PROCESS}"]],["container_requests.requesting_container_uuid","=",null]`);
+ });
+
+ it("should serialize only child processes", () => {
+ const filters = pipe(
+ () => getInitialResourceTypeFilters(),
+ deselectNode(ObjectTypeFilter.PROJECT),
+ deselectNode(ProcessTypeFilter.MAIN_PROCESS),
+ deselectNode(ObjectTypeFilter.COLLECTION)
+ )();
+
+ const serializedFilters = serializeResourceTypeFilters(filters);
+ expect(serializedFilters)
+ .toEqual(`["uuid","is_a",["${ResourceKind.PROCESS}"]],["container_requests.requesting_container_uuid","!=",null]`);
+ });
});
diff --git a/src/store/resource-type-filters/resource-type-filters.ts b/src/store/resource-type-filters/resource-type-filters.ts
index d1996a00..4ee9c5f3 100644
--- a/src/store/resource-type-filters/resource-type-filters.ts
+++ b/src/store/resource-type-filters/resource-type-filters.ts
@@ -57,27 +57,35 @@ export const getSimpleObjectTypeFilters = pipe(
initFilter(ObjectTypeFilter.COLLECTION),
);
+// Using pipe() with more tha 7 arguments makes the return type be 'any',
+// causing compile issues.
export const getInitialResourceTypeFilters = pipe(
(): DataTableFilters => createTree<DataTableFilterItem>(),
initFilter(ObjectTypeFilter.PROJECT),
- initFilter(ObjectTypeFilter.PROCESS),
- initFilter(ProcessTypeFilter.MAIN_PROCESS, ObjectTypeFilter.PROCESS),
- initFilter(ProcessTypeFilter.CHILD_PROCESS, ObjectTypeFilter.PROCESS),
- initFilter(ObjectTypeFilter.COLLECTION),
- initFilter(CollectionTypeFilter.GENERAL_COLLECTION, ObjectTypeFilter.COLLECTION),
- initFilter(CollectionTypeFilter.OUTPUT_COLLECTION, ObjectTypeFilter.COLLECTION),
- initFilter(CollectionTypeFilter.LOG_COLLECTION, ObjectTypeFilter.COLLECTION),
+ pipe(
+ initFilter(ObjectTypeFilter.PROCESS),
+ initFilter(ProcessTypeFilter.MAIN_PROCESS, ObjectTypeFilter.PROCESS),
+ initFilter(ProcessTypeFilter.CHILD_PROCESS, ObjectTypeFilter.PROCESS)
+ ),
+ pipe(
+ initFilter(ObjectTypeFilter.COLLECTION),
+ initFilter(CollectionTypeFilter.GENERAL_COLLECTION, ObjectTypeFilter.COLLECTION),
+ initFilter(CollectionTypeFilter.OUTPUT_COLLECTION, ObjectTypeFilter.COLLECTION),
+ initFilter(CollectionTypeFilter.LOG_COLLECTION, ObjectTypeFilter.COLLECTION),
+ ),
);
export const getInitialProcessStatusFilters = pipe(
(): DataTableFilters => createTree<DataTableFilterItem>(),
- initFilter(ProcessStatusFilter.ALL, '', true),
- initFilter(ProcessStatusFilter.RUNNING, '', false),
- initFilter(ProcessStatusFilter.FAILED, '', false),
- initFilter(ProcessStatusFilter.COMPLETED, '', false),
- initFilter(ProcessStatusFilter.CANCELLED, '', false),
- initFilter(ProcessStatusFilter.QUEUED, '', false),
- initFilter(ProcessStatusFilter.LOCKED, '', false),
+ pipe(
+ initFilter(ProcessStatusFilter.ALL, '', true),
+ initFilter(ProcessStatusFilter.RUNNING, '', false),
+ initFilter(ProcessStatusFilter.FAILED, '', false),
+ initFilter(ProcessStatusFilter.COMPLETED, '', false),
+ initFilter(ProcessStatusFilter.CANCELLED, '', false),
+ initFilter(ProcessStatusFilter.QUEUED, '', false),
+ initFilter(ProcessStatusFilter.LOCKED, '', false),
+ ),
);
export const getTrashPanelTypeFilters = pipe(
commit d10d59c54a88506d2aae77dbcdc05828fa671821
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Sat Dec 21 19:47:26 2019 -0300
15047: Adds 'process type' filtering to project panel.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/src/store/resource-type-filters/resource-type-filters.ts b/src/store/resource-type-filters/resource-type-filters.ts
index 8e856c94..d1996a00 100644
--- a/src/store/resource-type-filters/resource-type-filters.ts
+++ b/src/store/resource-type-filters/resource-type-filters.ts
@@ -33,6 +33,11 @@ export enum CollectionTypeFilter {
LOG_COLLECTION = 'Log',
}
+export enum ProcessTypeFilter {
+ MAIN_PROCESS = 'Main',
+ CHILD_PROCESS = 'Child',
+}
+
const initFilter = (name: string, parent = '', isSelected?: boolean) =>
setNode<DataTableFilterItem>({
id: name,
@@ -56,6 +61,8 @@ export const getInitialResourceTypeFilters = pipe(
(): DataTableFilters => createTree<DataTableFilterItem>(),
initFilter(ObjectTypeFilter.PROJECT),
initFilter(ObjectTypeFilter.PROCESS),
+ initFilter(ProcessTypeFilter.MAIN_PROCESS, ObjectTypeFilter.PROCESS),
+ initFilter(ProcessTypeFilter.CHILD_PROCESS, ObjectTypeFilter.PROCESS),
initFilter(ObjectTypeFilter.COLLECTION),
initFilter(CollectionTypeFilter.GENERAL_COLLECTION, ObjectTypeFilter.COLLECTION),
initFilter(CollectionTypeFilter.OUTPUT_COLLECTION, ObjectTypeFilter.COLLECTION),
@@ -103,11 +110,15 @@ const objectTypeToResourceKind = (type: ObjectTypeFilter) => {
const serializeObjectTypeFilters = ({ fb, selectedFilters }: ReturnType<typeof createFiltersBuilder>) => {
const collectionFilters = getMatchingFilters(values(CollectionTypeFilter), selectedFilters);
+ const processFilters = getMatchingFilters(values(ProcessTypeFilter), selectedFilters);
const typeFilters = pipe(
() => new Set(getMatchingFilters(values(ObjectTypeFilter), selectedFilters)),
set => collectionFilters.length > 0
? set.add(ObjectTypeFilter.COLLECTION)
: set,
+ set => processFilters.length > 0
+ ? set.add(ObjectTypeFilter.PROCESS)
+ : set,
set => Array.from(set)
)();
@@ -156,10 +167,36 @@ const buildCollectionTypeFilters = ({ fb, filters }: { fb: FilterBuilder, filter
}
};
+const serializeProcessTypeFilters = ({ fb, selectedFilters }: ReturnType<typeof createFiltersBuilder>) => pipe(
+ () => getMatchingFilters(values(ProcessTypeFilter), selectedFilters),
+ filters => filters,
+ mappedFilters => ({
+ fb: buildProcessTypeFilters({ fb, filters: mappedFilters }),
+ selectedFilters
+ })
+)();
+
+const PROCESS_TYPES = values(ProcessTypeFilter);
+const PROCESS_PREFIX = GroupContentsResourcePrefix.PROCESS;
+
+const buildProcessTypeFilters = ({ fb, filters }: { fb: FilterBuilder, filters: string[] }) => {
+ switch (true) {
+ case filters.length === 0 || filters.length === PROCESS_TYPES.length:
+ return fb;
+ case includes(ProcessTypeFilter.MAIN_PROCESS, filters):
+ return fb.addEqual('requesting_container_uuid', null, PROCESS_PREFIX);
+ case includes(ProcessTypeFilter.CHILD_PROCESS, filters):
+ return fb.addDistinct('requesting_container_uuid', null, PROCESS_PREFIX);
+ default:
+ return fb;
+ }
+};
+
export const serializeResourceTypeFilters = pipe(
createFiltersBuilder,
serializeObjectTypeFilters,
serializeCollectionTypeFilters,
+ serializeProcessTypeFilters,
({ fb }) => fb.getFilters(),
);
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list