From b1d6f816e639d1068f1cfd67a57699e24987f4f1 Mon Sep 17 00:00:00 2001 From: Alireza Heidari Date: Tue, 22 Nov 2022 17:59:35 +0100 Subject: [PATCH 1/4] init history store with pinia --- client/src/stores/historyStore.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 client/src/stores/historyStore.js diff --git a/client/src/stores/historyStore.js b/client/src/stores/historyStore.js new file mode 100644 index 00000000000..4668a9bcdec --- /dev/null +++ b/client/src/stores/historyStore.js @@ -0,0 +1,26 @@ +import { ref } from "vue"; +import { defineStore } from "pinia"; + +export const useHistoryStore = defineStore( + "historyStore", + () => { + const pinnedHistories = ref([]); + + const pinHistory = (historyId) => { + pinnedHistories.value.push({ id: historyId }); + }; + + const unpinHistory = (historyId) => { + pinnedHistories.value = pinnedHistories.value.filter((h) => h.id !== historyId); + }; + + return { + pinnedHistories, + pinHistory, + unpinHistory, + }; + }, + { + persist: ["pinnedHistories"], + } +); From e06d33e8b7c7c761c0d3db5961fd4ce429a408b2 Mon Sep 17 00:00:00 2001 From: Alireza Heidari Date: Tue, 22 Nov 2022 18:01:36 +0100 Subject: [PATCH 2/4] use `pinia-plugin-persistedstate` to persist pinia state --- client/package.json | 1 + client/src/entry/analysis/index.js | 2 ++ client/yarn.lock | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/client/package.json b/client/package.json index a4a02d84195..b647fe3d6d3 100644 --- a/client/package.json +++ b/client/package.json @@ -67,6 +67,7 @@ "markdown-it-regexp": "^0.4.0", "object-hash": "^3.0.0", "pinia": "^2.0.23", + "pinia-plugin-persistedstate": "^2.4.0", "popper.js": "^1.16.1", "pretty-bytes": "^6.0.0", "pyre-to-regexp": "^0.0.5", diff --git a/client/src/entry/analysis/index.js b/client/src/entry/analysis/index.js index 175a61e15a8..e33eada15d3 100644 --- a/client/src/entry/analysis/index.js +++ b/client/src/entry/analysis/index.js @@ -5,9 +5,11 @@ import App from "./App.vue"; import store from "store"; import { getRouter } from "./router"; import { createPinia, PiniaVuePlugin } from "pinia"; +import piniaPluginPersistedstate from "pinia-plugin-persistedstate"; Vue.use(PiniaVuePlugin); const pinia = createPinia(); +pinia.use(piniaPluginPersistedstate); addInitialization((Galaxy) => { console.log("App setup"); diff --git a/client/yarn.lock b/client/yarn.lock index 254ae707135..004bac3ae7f 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -8078,6 +8078,11 @@ pikaday@1.5.1: optionalDependencies: moment "2.x" +pinia-plugin-persistedstate@^2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-2.4.0.tgz#fda569b3c397517a0cf8aba83a628283767da620" + integrity sha512-bQcpv47jk3ISl+InuJWsFaS/K7pRZ97kfoD2WCf/suhnlLy48k3BnFM2tI6YZ1xMsDaPv4yOsaPuPAUuSmEO2Q== + pinia@^2.0.23: version "2.0.23" resolved "https://registry.yarnpkg.com/pinia/-/pinia-2.0.23.tgz#570f5f82160b656b412602789683faa95502d227" From a7c6661ae2d61e3fd8437ceda91d1e68181bf27a Mon Sep 17 00:00:00 2001 From: Alireza Heidari Date: Tue, 22 Nov 2022 18:03:11 +0100 Subject: [PATCH 3/4] use pinia history store in multiple view and delete old related store methods --- .../History/Multiple/MultipleViewList.vue | 9 +++++---- client/src/store/historyStore/historyStore.js | 16 ---------------- client/src/store/index.js | 3 +-- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/client/src/components/History/Multiple/MultipleViewList.vue b/client/src/components/History/Multiple/MultipleViewList.vue index fb138be6ac3..0876a977761 100644 --- a/client/src/components/History/Multiple/MultipleViewList.vue +++ b/client/src/components/History/Multiple/MultipleViewList.vue @@ -31,9 +31,10 @@