diff --git a/client/src/components/Grid/configs/historiesPublished.ts b/client/src/components/Grid/configs/historiesPublished.ts new file mode 100644 index 000000000000..6b9926179a04 --- /dev/null +++ b/client/src/components/Grid/configs/historiesPublished.ts @@ -0,0 +1,112 @@ +import { faEye } from "@fortawesome/free-solid-svg-icons"; +import { useEventBus } from "@vueuse/core"; + +import { historiesFetcher } from "@/api/histories"; +import Filtering, { contains, expandNameTag, type ValidFilter } from "@/utils/filtering"; +import _l from "@/utils/localization"; + +import type { FieldArray, GridConfig } from "./types"; + +const { emit } = useEventBus("grid-router-push"); + +/** + * Local types + */ +type HistoryEntry = Record; +type SortKeyLiteral = "name" | "update_time" | undefined; + +/** + * Request and return data from server + */ +async function getData(offset: number, limit: number, search: string, sort_by: string, sort_desc: boolean) { + const { data, headers } = await historiesFetcher({ + limit, + offset, + search, + sort_by: sort_by as SortKeyLiteral, + sort_desc, + show_own: false, + show_published: true, + show_shared: false, + }); + const totalMatches = parseInt(headers.get("total_matches") ?? "0"); + return [data, totalMatches]; +} + +/** + * Declare columns to be displayed + */ +const fields: FieldArray = [ + { + key: "name", + title: "Name", + type: "operations", + operations: [ + { + title: "View", + icon: faEye, + condition: (data: HistoryEntry) => !data.deleted, + handler: (data: HistoryEntry) => { + emit(`/histories/view?id=${data.id}`); + }, + }, + ], + }, + { + key: "annotation", + title: "Annotation", + type: "text", + }, + { + key: "id", + title: "Size", + type: "datasets", + }, + { + key: "tags", + title: "Tags", + type: "tags", + disabled: true, + }, + { + key: "update_time", + title: "Updated", + type: "date", + }, + { + key: "username", + title: "Username", + type: "text", + }, +]; + +/** + * Declare filter options + */ +const validFilters: Record> = { + name: { placeholder: "name", type: String, handler: contains("name"), menuItem: true }, + user: { placeholder: "user", type: String, handler: contains("username"), menuItem: true }, + tag: { + placeholder: "tag(s)", + type: "MultiTags", + handler: contains("tag", "tag", expandNameTag), + menuItem: true, + }, +}; + +/** + * Grid configuration + */ +const gridConfig: GridConfig = { + id: "histories-published-grid", + fields: fields, + filtering: new Filtering(validFilters, undefined, false, false), + getData: getData, + plural: "Histories", + sortBy: "name", + sortDesc: true, + sortKeys: ["name", "update_time", "username"], + title: "Published Histories", +}; + +export default gridConfig; diff --git a/client/src/components/History/HistoryPublishedList.vue b/client/src/components/History/HistoryPublishedList.vue deleted file mode 100644 index 723cbc4e2e83..000000000000 --- a/client/src/components/History/HistoryPublishedList.vue +++ /dev/null @@ -1,278 +0,0 @@ - - - - - diff --git a/client/src/entry/analysis/router.js b/client/src/entry/analysis/router.js index ce3a76b4386c..e8312f3814c0 100644 --- a/client/src/entry/analysis/router.js +++ b/client/src/entry/analysis/router.js @@ -8,13 +8,13 @@ import DatasetDetails from "components/DatasetInformation/DatasetDetails"; import DatasetError from "components/DatasetInformation/DatasetError"; import FormGeneric from "components/Form/FormGeneric"; import historiesGridConfig from "components/Grid/configs/histories"; +import historiesPublishedGridConfig from "components/Grid/configs/historiesPublished"; import historiesSharedGridConfig from "components/Grid/configs/historiesShared"; import visualizationsGridConfig from "components/Grid/configs/visualizations"; import visualizationsPublishedGridConfig from "components/Grid/configs/visualizationsPublished"; import GridList from "components/Grid/GridList"; import HistoryExportTasks from "components/History/Export/HistoryExport"; import HistoryPublished from "components/History/HistoryPublished"; -import HistoryPublishedList from "components/History/HistoryPublishedList"; import HistoryView from "components/History/HistoryView"; import HistoryMultipleView from "components/History/Multiple/MultipleView"; import { HistoryExport } from "components/HistoryExport/index"; @@ -282,11 +282,9 @@ export function getRouter(Galaxy) { }, { path: "histories/list_published", - component: HistoryPublishedList, - props: (route) => { - return { - ...route.query, - }; + component: GridList, + props: { + gridConfig: historiesPublishedGridConfig, }, }, {