From 74ae35413ea809012a1eaf54251b71ed4b3bf6eb Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 17 Jun 2024 17:23:52 +0200 Subject: [PATCH] Fix collection map over status for dragged collections Fixes https://github.com/galaxyproject/galaxy/issues/12614, which is the source of many templating errors such as https://sentry.galaxyproject.org/share/issue/008a129bf7e44b3086491789f4bfb07e/: ``` NotFound: cannot find 'forward' File "galaxy/util/template.py", line 87, in fill_template return unicodify(t, log_exception=False) File "galaxy/util/__init__.py", line 1183, in unicodify value = str(value) File "Cheetah/Template.py", line 1053, in __unicode__ return getattr(self, mainMethName)() File "cheetah_DynamicallyCompiledCheetahTemplate_1718305116_116218_60583.py", line 206, in respond ``` If we don't set `batch` and `map_over_type` (this is correctly done by the backend when building the parameter options from the history) we pass in the whole collection, which likely won't have a `forward` element. --- .../Form/Elements/FormData/FormData.vue | 18 +++++++++++++++++- .../components/Form/Elements/FormData/types.ts | 1 + client/src/components/Form/FormElement.vue | 3 ++- lib/galaxy/tools/parameters/basic.py | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/client/src/components/Form/Elements/FormData/FormData.vue b/client/src/components/Form/Elements/FormData/FormData.vue index 123d24bb43b5..ee65daad081d 100644 --- a/client/src/components/Form/Elements/FormData/FormData.vue +++ b/client/src/components/Form/Elements/FormData/FormData.vue @@ -35,6 +35,7 @@ const props = withDefaults( }; extensions?: Array; type?: string; + collectionTypes?: Array; flavor?: string; tag?: string; }>(), @@ -45,6 +46,7 @@ const props = withDefaults( value: undefined, extensions: () => [], type: "data", + collectionTypes: undefined, flavor: undefined, tag: undefined, } @@ -311,14 +313,28 @@ function handleIncoming(incoming: Record, partial = true) { const newName = v.name ? v.name : newId; const newSrc = v.src || (v.history_content_type === "dataset_collection" ? SOURCE.COLLECTION : SOURCE.DATASET); - const newValue = { + const newValue: DataOption = { id: newId, src: newSrc, + batch: false, + map_over_type: undefined, hid: newHid, name: newName, keep: true, tags: [], }; + if (v.collection_type && props.collectionTypes?.length > 0) { + if (!props.collectionTypes.includes(v.collection_type)) { + const mapOverType = props.collectionTypes.find((collectionType) => + v.collection_type.endsWith(collectionType) + ); + if (!mapOverType) { + return false; + } + newValue["batch"] = true; + newValue["map_over_type"] = mapOverType; + } + } // Verify that new value has corresponding option const keepKey = `${newId}_${newSrc}`; const existingOptions = props.options && props.options[newSrc]; diff --git a/client/src/components/Form/Elements/FormData/types.ts b/client/src/components/Form/Elements/FormData/types.ts index 52c8a418897e..acdf8299eca6 100644 --- a/client/src/components/Form/Elements/FormData/types.ts +++ b/client/src/components/Form/Elements/FormData/types.ts @@ -3,6 +3,7 @@ export type DataOption = { hid: number; is_dataset?: boolean; keep: boolean; + batch: boolean; map_over_type?: string; name: string; src: string; diff --git a/client/src/components/Form/FormElement.vue b/client/src/components/Form/FormElement.vue index 34baae64c846..10bf6cc0ccc9 100644 --- a/client/src/components/Form/FormElement.vue +++ b/client/src/components/Form/FormElement.vue @@ -288,7 +288,8 @@ const isOptional = computed(() => !isRequired.value && attrs.value["optional"] ! :optional="attrs.optional" :options="attrs.options" :tag="attrs.tag" - :type="props.type" /> + :type="props.type" + :collection-types="attrs.collection_types" />