From af7b6f4621c5cdc63b7e41c923e498fa316aefb1 Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Mon, 23 Oct 2023 17:59:44 -0500 Subject: [PATCH] Convert `historyItemsStore` to ts+composition Also, set `loading` bool to true for async History operations in panel --- .../History/CurrentHistory/HistoryPanel.vue | 59 +++++----- .../History/adapters/HistoryPanelProxy.js | 2 +- client/src/components/Tool/ToolForm.vue | 6 +- .../components/Workflow/Run/WorkflowRun.vue | 6 +- .../Workflow/Run/WorkflowRunDefaultStep.vue | 6 +- .../store/historyStore/model/watchHistory.js | 12 ++- .../historyStore/model/watchHistory.test.js | 2 +- .../src/stores/history/historyItemsStore.js | 102 ------------------ client/src/stores/historyItemsStore.ts | 97 +++++++++++++++++ client/src/utils/promise-queue.js | 3 + 10 files changed, 145 insertions(+), 150 deletions(-) delete mode 100644 client/src/stores/history/historyItemsStore.js create mode 100644 client/src/stores/historyItemsStore.ts diff --git a/client/src/components/History/CurrentHistory/HistoryPanel.vue b/client/src/components/History/CurrentHistory/HistoryPanel.vue index 5250251220bf..be929a5f2775 100644 --- a/client/src/components/History/CurrentHistory/HistoryPanel.vue +++ b/client/src/components/History/CurrentHistory/HistoryPanel.vue @@ -18,7 +18,7 @@ :scope-key="queryKey" :get-item-key="(item) => item.type_id" :filter-text="filterText" - :total-items-in-query="totalItemsInQuery" + :total-items-in-query="totalMatchesCount" @query-selection-break="querySelectionBreak = true">
@@ -63,7 +63,7 @@ :content-selection="selectedItems" :selection-size="selectionSize" :is-query-selection="isQuerySelection" - :total-items-in-query="totalItemsInQuery" + :total-items-in-query="totalMatchesCount" :operation-running.sync="operationRunning" @update:show-selection="setShowSelection" @operation-error="onOperationError" @@ -156,7 +156,7 @@ import LoadingSpan from "components/LoadingSpan"; import { Toast } from "composables/toast"; import { mapActions, mapState, storeToRefs } from "pinia"; import { rewatchHistory } from "store/historyStore/model/watchHistory"; -import { useHistoryItemsStore } from "stores/history/historyItemsStore"; +import { useHistoryItemsStore } from "stores/historyItemsStore"; import { useHistoryStore } from "stores/historyStore"; import { getOperatorForAlias } from "utils/filtering"; import Vue from "vue"; @@ -199,6 +199,11 @@ export default { showControls: { type: Boolean, default: true }, filterable: { type: Boolean, default: false }, }, + setup() { + const { currentFilterText, currentHistoryId } = storeToRefs(useHistoryStore()); + const { lastCheckedTime, totalMatchesCount, isWatching } = storeToRefs(useHistoryItemsStore()); + return { currentFilterText, currentHistoryId, lastCheckedTime, totalMatchesCount, isWatching }; + }, data() { return { filterText: "", @@ -244,21 +249,6 @@ export default { itemsLoaded() { return this.getHistoryItems(this.historyId, this.filterText); }, - /** @returns {Date} */ - lastChecked() { - const { getLastCheckedTime } = storeToRefs(useHistoryItemsStore()); - return getLastCheckedTime.value; - }, - /** @returns {Number} */ - totalItemsInQuery() { - const { getTotalMatchesCount } = storeToRefs(useHistoryItemsStore()); - return getTotalMatchesCount.value; - }, - /** @returns {Boolean} */ - isWatching() { - const { getWatchingVisibility } = storeToRefs(useHistoryItemsStore()); - return getWatchingVisibility.value; - }, /** @returns {Object} */ formattedSearchError() { if (this.searchError) { @@ -278,9 +268,8 @@ export default { }, /** @returns {String} */ storeFilterText() { - const { currentFilterText, currentHistoryId } = storeToRefs(useHistoryStore()); - if (this.historyId === currentHistoryId.value) { - return currentFilterText.value || ""; + if (this.historyId === this.currentHistoryId) { + return this.currentFilterText || ""; } else { return ""; } @@ -313,8 +302,8 @@ export default { offset() { this.loadHistoryItems(); }, - historyUpdateTime() { - this.loadHistoryItems(); + async historyUpdateTime() { + await this.loadHistoryItems(); }, }, async mounted() { @@ -363,9 +352,11 @@ export default { this.loading = false; } }, - onDelete(item, recursive = false) { + async onDelete(item, recursive = false) { + this.loading = true; this.setInvisible(item); - deleteContent(item, { recursive: recursive }); + await deleteContent(item, { recursive: recursive }); + this.loading = false; }, onHideSelection(selectedItems) { selectedItems.forEach((item) => { @@ -375,13 +366,17 @@ export default { onScroll(offset) { this.offset = offset; }, - onUndelete(item) { + async onUndelete(item) { this.setInvisible(item); - updateContentFields(item, { deleted: false }); + this.loading = true; + await updateContentFields(item, { deleted: false }); + this.loading = false; }, - onUnhide(item) { + async onUnhide(item) { this.setInvisible(item); - updateContentFields(item, { visible: true }); + this.loading = true; + await updateContentFields(item, { visible: true }); + this.loading = false; }, reloadContents() { rewatchHistory(); @@ -405,7 +400,7 @@ export default { this.showDropZone = false; } }, - onDrop(evt) { + async onDrop(evt) { this.showDropZone = false; let data; try { @@ -416,7 +411,7 @@ export default { if (data) { const dataSource = data.history_content_type === "dataset" ? "hda" : "hdca"; if (data.history_id != this.historyId) { - copyDataset(data.id, this.historyId, data.history_content_type, dataSource) + await copyDataset(data.id, this.historyId, data.history_content_type, dataSource) .then(() => { if (data.history_content_type === "dataset") { Toast.info("Dataset copied to history"); diff --git a/client/src/components/History/adapters/HistoryPanelProxy.js b/client/src/components/History/adapters/HistoryPanelProxy.js index b5b3483d2f6c..1ad3b8f6f966 100644 --- a/client/src/components/History/adapters/HistoryPanelProxy.js +++ b/client/src/components/History/adapters/HistoryPanelProxy.js @@ -5,7 +5,7 @@ import Backbone from "backbone"; import { createDatasetCollection } from "components/History/model/queries"; import { watchHistory } from "store/historyStore/model/watchHistory"; -import { useHistoryItemsStore } from "stores/history/historyItemsStore"; +import { useHistoryItemsStore } from "stores/historyItemsStore"; import { useHistoryStore } from "stores/historyStore"; import { buildCollectionModal } from "./buildCollectionModal"; diff --git a/client/src/components/Tool/ToolForm.vue b/client/src/components/Tool/ToolForm.vue index bcca2a7c2302..f7b5f7b8182b 100644 --- a/client/src/components/Tool/ToolForm.vue +++ b/client/src/components/Tool/ToolForm.vue @@ -107,7 +107,7 @@ import FormElement from "components/Form/FormElement"; import LoadingSpan from "components/LoadingSpan"; import ToolEntryPoints from "components/ToolEntryPoints/ToolEntryPoints"; import { mapActions, mapState } from "pinia"; -import { useHistoryItemsStore } from "stores/history/historyItemsStore"; +import { useHistoryItemsStore } from "stores/historyItemsStore"; import { useJobStore } from "stores/jobStore"; import { refreshContentsWrapper } from "utils/data"; @@ -187,7 +187,7 @@ export default { computed: { ...mapState(useUserStore, ["currentUser"]), ...mapState(useHistoryStore, ["currentHistoryId"]), - ...mapState(useHistoryItemsStore, ["getLastUpdateTime"]), + ...mapState(useHistoryItemsStore, ["lastUpdateTime"]), toolName() { return this.formConfig.name; }, @@ -225,7 +225,7 @@ export default { currentHistoryId() { this.onHistoryChange(); }, - getLastUpdateTime() { + lastUpdateTime() { this.onHistoryChange(); }, }, diff --git a/client/src/components/Workflow/Run/WorkflowRun.vue b/client/src/components/Workflow/Run/WorkflowRun.vue index fb24d55f5ad8..8ab28c028b09 100644 --- a/client/src/components/Workflow/Run/WorkflowRun.vue +++ b/client/src/components/Workflow/Run/WorkflowRun.vue @@ -47,7 +47,7 @@