Skip to content

Commit

Permalink
export explicit types for content source and type
Browse files Browse the repository at this point in the history
Co-authored-by: David López <[email protected]>
  • Loading branch information
ahmedhamidawan and davelopez committed Aug 21, 2024
1 parent 219c78a commit 989b769
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion client/src/api/datasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function purgeDataset(datasetId: string) {
}

const datasetCopy = fetcher.path("/api/histories/{history_id}/contents/{type}s").method("post").create();
export type HistoryContentsArgs = FetchArgType<typeof datasetCopy>;
type HistoryContentsArgs = FetchArgType<typeof datasetCopy>;
export async function copyDataset(
datasetId: HistoryContentsArgs["content"],
historyId: HistoryContentsArgs["history_id"],
Expand Down Expand Up @@ -95,3 +95,6 @@ export async function fetchDatasetAttributes(datasetId: string) {

return data;
}

export type HistoryContentType = components["schemas"]["HistoryContentType"];
export type HistoryContentSource = components["schemas"]["HistoryContentSource"];
6 changes: 3 additions & 3 deletions client/src/components/History/CurrentHistory/HistoryPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
isHistoryItem,
userOwnsHistory,
} from "@/api";
import { copyDataset, HistoryContentsArgs } from "@/api/datasets";
import { copyDataset, type HistoryContentSource, type HistoryContentType } from "@/api/datasets";
import ExpandedItems from "@/components/History/Content/ExpandedItems";
import SelectedItems from "@/components/History/Content/SelectedItems";
import { HistoryFilters } from "@/components/History/HistoryFilters";
Expand Down Expand Up @@ -399,8 +399,8 @@ async function onDrop() {
try {
// iterate over the data array and copy each item to the current history
for (const item of data) {
let dataSource: HistoryContentsArgs["source"];
let type: HistoryContentsArgs["type"];
let dataSource: HistoryContentSource;
let type: HistoryContentType;
let id: string;
if (isHistoryItem(item)) {
dataSource = item.history_content_type === "dataset" ? "hda" : "hdca";
Expand Down

0 comments on commit 989b769

Please sign in to comment.