From 93e83324467c3c494319f2ca533c3934aabfaf2b Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:46:29 +0200 Subject: [PATCH] Move fetchDatasetDetails to api/datasets --- client/src/api/datasets.ts | 10 ++++++++++ .../components/Dataset/DatasetLink/DatasetLink.vue | 2 +- client/src/components/providers/DatasetProvider.js | 2 +- client/src/stores/datasetStore.ts | 3 +-- client/src/stores/services/dataset.service.ts | 11 ----------- 5 files changed, 13 insertions(+), 15 deletions(-) delete mode 100644 client/src/stores/services/dataset.service.ts diff --git a/client/src/api/datasets.ts b/client/src/api/datasets.ts index ab286ab0b54..09948b45ce2 100644 --- a/client/src/api/datasets.ts +++ b/client/src/api/datasets.ts @@ -1,5 +1,6 @@ import type { FetchArgType } from "openapi-typescript-fetch"; +import { DatasetDetails } from "@/api"; import { fetcher } from "@/api/schema"; import { withPrefix } from "@/utils/redirect"; @@ -35,6 +36,15 @@ export async function getDatasets(options: GetDatasetsOptions = {}) { return data; } +const getDataset = fetcher.path("/api/datasets/{dataset_id}").method("get").create(); + +export async function fetchDatasetDetails(params: { id: string }): Promise { + const { data } = await getDataset({ dataset_id: params.id, view: "detailed" }); + // We know that the server will return a DatasetDetails object because of the view parameter + // but the type system doesn't, so we have to cast it. + return data as unknown as DatasetDetails; +} + const updateHistoryDataset = fetcher.path("/api/histories/{history_id}/contents/{type}s/{id}").method("put").create(); export async function undeleteHistoryDataset(historyId: string, datasetId: string) { diff --git a/client/src/components/Dataset/DatasetLink/DatasetLink.vue b/client/src/components/Dataset/DatasetLink/DatasetLink.vue index 273d7631829..f4b9c2ed860 100644 --- a/client/src/components/Dataset/DatasetLink/DatasetLink.vue +++ b/client/src/components/Dataset/DatasetLink/DatasetLink.vue @@ -7,7 +7,7 @@