diff --git a/client/src/api/datasets.ts b/client/src/api/datasets.ts index c0e19339b566..a3ae67690dee 100644 --- a/client/src/api/datasets.ts +++ b/client/src/api/datasets.ts @@ -48,22 +48,26 @@ export async function purgeDataset(datasetId: string) { return data; } -type CopyDatasetParamsType = GalaxyApiPaths["/api/histories/{history_id}/contents/{type}s"]["post"]["parameters"]; -type CopyDatasetBodyType = components["schemas"]["CreateHistoryContentPayload"]; +type CopyContentParamsType = GalaxyApiPaths["/api/histories/{history_id}/contents/{type}s"]["post"]["parameters"]; +type CopyContentBodyType = components["schemas"]["CreateHistoryContentPayload"]; -export async function copyDataset( - datasetId: CopyDatasetBodyType["content"], - historyId: CopyDatasetParamsType["path"]["history_id"], - type: CopyDatasetParamsType["path"]["type"] = "dataset", - source: CopyDatasetBodyType["source"] = "hda" +export async function copyContent( + contentId: CopyContentBodyType["content"], + historyId: CopyContentParamsType["path"]["history_id"], + type: CopyContentParamsType["path"]["type"] = "dataset", + source: CopyContentBodyType["source"] = null ) { + // match source from type unless explicitly provided + if (source === null) { + source = type === "dataset" ? "hda" : "hdca"; + } const { data, error } = await GalaxyApi().POST("/api/histories/{history_id}/contents/{type}s", { params: { path: { history_id: historyId, type }, }, body: { source, - content: datasetId, + content: contentId, // TODO: Investigate. These should be optional, but the API requires explicit null values? type, copy_elements: null, diff --git a/client/src/components/Dataset/DatasetList.vue b/client/src/components/Dataset/DatasetList.vue index 524c33f414ea..8d0e86c29890 100644 --- a/client/src/components/Dataset/DatasetList.vue +++ b/client/src/components/Dataset/DatasetList.vue @@ -3,8 +3,8 @@ import { BAlert, BTable } from "bootstrap-vue"; import { storeToRefs } from "pinia"; import { computed, onMounted, ref } from "vue"; -import { GalaxyApi, type HDASummary } from "@/api"; -import { copyDataset } from "@/api/datasets"; +import { GalaxyApi, type HistoryItemSummary } from "@/api"; +import { copyContent } from "@/api/datasets"; import { updateTags } from "@/api/tags"; import { useHistoryStore } from "@/stores/historyStore"; import { rethrowSimple } from "@/utils/simple-error"; @@ -26,7 +26,7 @@ const message = ref(""); const loading = ref(true); const sortDesc = ref(true); const sortBy = ref("update_time"); -const rows = ref([]); +const rows = ref([]); const messageVariant = ref("danger"); const fields = ref([ { @@ -86,7 +86,7 @@ async function load(concat = false) { rethrowSimple(error); } - const datasets = data as HDASummary[]; + const datasets = data as HistoryItemSummary[]; if (concat) { rows.value = rows.value.concat(datasets); @@ -100,23 +100,20 @@ async function load(concat = false) { } } -async function onCopyDataset(item: HDASummary) { +async function onCopyContent(item: HistoryItemSummary) { const dataset_id = item.id; - try { if (!currentHistoryId.value) { throw new Error("No current history found."); } - - await copyDataset(dataset_id, currentHistoryId.value); - + await copyContent(dataset_id, currentHistoryId.value, item.history_content_type); historyStore.loadCurrentHistory(); } catch (error: any) { onError(error); } } -async function onShowDataset(item: HDASummary) { +async function onShowDataset(item: HistoryItemSummary) { const { history_id } = item; const filters = { deleted: item.deleted, @@ -198,7 +195,7 @@ onMounted(() => { :items="rows" @sort-changed="onSort">