Commit 39d9880a authored by Ahmed Awan's avatar Ahmed Awan
Browse files

fetch "collection" view for HDCAs in `GenericItem` and `useInvocationGraph`



For the generic content items (used outside of the history panel), there is no need to fetch the entire "element" view when displaying the content item unexpanded. Therefore, I have made the default view "collection", until you click to expand an HDCA which is when the `DatasetCollectionProvider` is remounted to fetch the "element" (detailed) view for the HDCA.

Co-authored-by: default avatarMarius van den Beek <m.vandenbeek@gmail.com>
parent d3dd1332
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
<template>
    <component :is="providerComponent" :id="itemId" v-slot="{ result: item, loading }" auto-refresh>
    <component
        :is="providerComponent"
        :id="itemId"
        :key="view"
        v-slot="{ result: item, loading }"
        :view="view"
        auto-refresh>
        <LoadingSpan v-if="loading" message="Loading dataset" />
        <div v-else>
            <ContentItem
@@ -11,7 +17,7 @@
                :expand-dataset="expandDataset"
                :is-dataset="item.history_content_type == 'dataset' || item.element_type == 'hda'"
                @update:expand-dataset="expandDataset = $event"
                @view-collection="viewCollection = !viewCollection"
                @view-collection="onViewCollection"
                @delete="onDelete"
                @toggleHighlights="onHighlight(item)"
                @undelete="onUndelete(item)"
@@ -60,6 +66,7 @@ export default {
        return {
            viewCollection: false,
            expandDataset: false,
            view: this.itemSrc === "hdca" ? "collection" : "element",
        };
    },
    computed: {
@@ -124,6 +131,12 @@ export default {
                this.onError(error, "Failed to highlight related items");
            }
        },
        onViewCollection(collection) {
            if (this.view === "collection" && collection.model_class === "HistoryDatasetCollectionAssociation") {
                this.view = "element";
            }
            this.viewCollection = !this.viewCollection;
        },
    },
};
</script>
+7 −2
Original line number Diff line number Diff line
import { SingleQueryProvider } from "components/providers/SingleQueryProvider";

import { fetchCollectionDetails } from "@/api/datasetCollections";
import { fetchCollectionDetails, fetchCollectionSummary } from "@/api/datasetCollections";

// There isn't really a good way to know when to stop polling for HDCA updates,
// but we know the populated_state should at least be ok.
export default SingleQueryProvider(
    (params) => fetchCollectionDetails({ hdca_id: params.id }),
    (params) => {
        if (params.view && params.view === "collection") {
            return fetchCollectionSummary({ hdca_id: params.id });
        }
        return fetchCollectionDetails({ hdca_id: params.id });
    },
    (result) => result.populated_state === "ok"
);
+2 −2
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ import { storeToRefs } from "pinia";
import { computed, type Ref, ref, set } from "vue";

import { GalaxyApi } from "@/api";
import { fetchCollectionDetails } from "@/api/datasetCollections";
import { fetchCollectionSummary } from "@/api/datasetCollections";
import { fetchDatasetDetails } from "@/api/datasets";
import type { InvocationStep, StepJobSummary, WorkflowInvocationElementView } from "@/api/invocations";
import type { StoredWorkflowDetailed } from "@/api/workflows";
@@ -334,7 +334,7 @@ export function useInvocationGraph(
                set(graphStep, "state", getContentItemState(hda));
                set(graphStep, "nodeText", `${hda.hid}: <b>${hda.name}</b>`);
            } else {
                const hdca = await fetchCollectionDetails({ hdca_id: inputItem.id });
                const hdca = await fetchCollectionSummary({ hdca_id: inputItem.id });
                // TODO: Same type mismatch as above
                set(graphStep, "state", getContentItemState(hdca));
                set(graphStep, "nodeText", `${hdca.hid}: <b>${hdca.name}</b>`);