Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor: re-implement uistate store module with pinia (#995)

Liu Ji725ea272ac63
diff --git a/frontend/src/bbkit/BBOutline.vue b/frontend/src/bbkit/BBOutline.vue
index ec8409ee72..b76ca2e06e 100644
--- a/frontend/src/bbkit/BBOutline.vue
+++ b/frontend/src/bbkit/BBOutline.vue
@@ -62,8 +62,8 @@
<script lang="ts" setup>
import { computed, reactive, withDefaults } from "vue";
-import { useStore } from "vuex";
import { BBOutlineItem } from "./types";
+import { useUIStateStore } from "@/store";
interface LocalState {
hoverIndex: number;
@@ -94,7 +94,7 @@ defineEmits<{
(event: "delete-index", index: number): void;
}>();
-const store = useStore();
+const uiStateStore = useUIStateStore();
const state = reactive<LocalState>({
hoverIndex: -1,
@@ -104,7 +104,7 @@ const state = reactive<LocalState>({
const collapseState = computed(() => {
if (props.id) {
- return store.getters["uistate/collapseStateByKey"](props.id);
+ return uiStateStore.getCollapseStateByKey(props.id);
}
return state.collapseState;
});
@@ -113,7 +113,7 @@ const toggleCollapse = () => {
if (props.allowCollapse) {
if (props.id) {
const newState = !collapseState.value;
- store.dispatch("uistate/savecollapseStateByKey", {
+ uiStateStore.saveCollapseStateByKey({
key: props.id,
collapse: newState,
});
diff --git a/frontend/src/components/Breadcrumb.vue b/frontend/src/components/Breadcrumb.vue
index 78a8011673..e8082ea1fd 100644
--- a/frontend/src/components/Breadcrumb.vue
+++ b/frontend/src/components/Breadcrumb.vue
@@ -48,7 +48,7 @@
</template>
<script lang="ts">
-import { computed, ComputedRef } from "vue";
+import { computed, ComputedRef, defineComponent } from "vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
@@ -60,13 +60,14 @@ import {
BookmarkCreate,
} from "../types";
import { idFromSlug } from "../utils";
+import { useUIStateStore } from "@/store";
interface BreadcrumbItem {
name: string;
path?: string;
}
-export default {
+export default defineComponent({
name: "Breadcrumb",
components: {},
setup() {
@@ -181,7 +182,7 @@ export default {
link: currentRoute.value.path,
};
store.dispatch("bookmark/createBookmark", newBookmark).then(() => {
- store.dispatch("uistate/saveIntroStateByKey", {
+ useUIStateStore().saveIntroStateByKey({
key: "bookmark.create",
newState: true,
});
@@ -197,5 +198,5 @@ export default {
toggleBookmark,
};
},
-};
+});
</script>
diff --git a/frontend/src/components/IntroBanner.vue b/frontend/src/components/IntroBanner.vue
index 0d036ffceb..e85d3e5b0f 100644
--- a/frontend/src/components/IntroBanner.vue
+++ b/frontend/src/components/IntroBanner.vue
@@ -37,15 +37,15 @@
</template>
<script lang="ts">
-import { useStore } from "vuex";
+import { useUIStateStore } from "@/store";
+import { defineComponent } from "vue";
-export default {
+export default defineComponent({
name: "IntroBanner",
components: {},
setup() {
- const store = useStore();
const dismiss = () => {
- store.dispatch("uistate/saveIntroStateByKey", {
+ useUIStateStore().saveIntroStateByKey({
key: "general.overview",
newState: true,
});
@@ -54,5 +54,5 @@ export default {
dismiss,
};
},
-};
+});
</script>
diff --git a/frontend/src/components/Issue/IssueActivityPanel.vue b/frontend/src/components/Issue/IssueActivityPanel.vue
index 98436dc575..94c7cb6787 100644
--- a/frontend/src/components/Issue/IssueActivityPanel.vue
+++ b/frontend/src/components/Issue/IssueActivityPanel.vue
@@ -354,6 +354,7 @@ import {
import { IssueTemplate, IssueBuiltinFieldId } from "../../plugins";
import { useI18n } from "vue-i18n";
import dayjs from "dayjs";
+import { useUIStateStore } from "@/store";
interface LocalState {
showDeleteCommentModal: boolean;
@@ -489,7 +490,7 @@ export default defineComponent({
comment: newComment.value,
};
store.dispatch("activity/createActivity", createActivity).then(() => {
- store.dispatch("uistate/saveIntroStateByKey", {
+ useUIStateStore().saveIntroStateByKey({
key: "comment.create",
newState: true,
});
diff --git a/frontend/src/components/MemberAddOrInvite.vue b/frontend/src/components/MemberAddOrInvite.vue
index 498b74501c..0a5c451ef4 100644
--- a/frontend/src/components/MemberAddOrInvite.vue
+++ b/frontend/src/components/MemberAddOrInvite.vue
@@ -105,7 +105,7 @@
</template>
<script lang="ts">
-import { computed, reactive } from "vue";
+import { computed, defineComponent, reactive } from "vue";
import { useStore } from "vuex";
import RoleSelect from "./RoleSelect.vue";
import {
@@ -116,6 +116,7 @@ import {
UNKNOWN_ID,
} from "../types";
import { isOwner, isValidEmail } from "../utils";
+import { useUIStateStore } from "@/store";
type User = {
email: string;
@@ -127,7 +128,7 @@ interface LocalState {
errorList: string[];
}
-export default {
+export default defineComponent({
name: "MemberAddOrInvite",
components: { RoleSelect },
props: {},
@@ -233,7 +234,7 @@ export default {
store.dispatch("member/createdMember", newMember);
});
- store.dispatch("uistate/saveIntroStateByKey", {
+ useUIStateStore().saveIntroStateByKey({
key: "member.addOrInvite",
newState: true,
});
@@ -257,5 +258,5 @@ export default {
addOrInvite,
};
},
-};
+});
</script>
diff --git a/frontend/src/components/ProfileDropdown.vue b/frontend/src/components/ProfileDropdown.vue
index c2215fb1f8..15ac6ef9bc 100644
--- a/frontend/src/components/ProfileDropdown.vue
+++ b/frontend/src/components/ProfileDropdown.vue
@@ -127,7 +127,7 @@ import { useRouter } from "vue-router";
import PrincipalAvatar from "./PrincipalAvatar.vue";
import { ServerInfo } from "../types";
import { useLanguage } from "../composables/useLanguage";
-import { useActuatorStore, useDebugStore } from "@/store";
+import { useActuatorStore, useDebugStore, useUIStateStore } from "@/store";
import { storeToRefs } from "pinia";
export default defineComponent({
@@ -138,6 +138,7 @@ export default defineComponent({
const store = useStore();
const actuatorStore = useActuatorStore();
const debugStore = useDebugStore();
+ const uiStateStore = useUIStateStore();
const router = useRouter();
const { setLocale, locale } = useLanguage();
const languageMenu = ref();
@@ -153,63 +154,27 @@ export default defineComponent({
};
const resetQuickstart = () => {
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "general.overview",
- newState: false,
- });
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "bookmark.create",
- newState: false,
- });
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "comment.create",
- newState: false,
- });
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "project.visit",
- newState: false,
- });
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "environment.visit",
- newState: false,
- });
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "instance.visit",
- newState: false,
- });
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "database.visit",
- newState: false,
- });
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "member.addOrInvite",
- newState: false,
- });
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "hidden",
- newState: false,
- });
-
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "guide.project",
- newState: false,
- });
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "guide.environment",
- newState: false,
- });
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "guide.instance",
- newState: false,
- });
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "guide.database",
- newState: false,
- });
-
- store.dispatch("uistate/saveIntroStateByKey", {
- key: "kbar.open",
- newState: false,
+ const keys = [
+ "general.overview",
+ "bookmark.create",
+ "comment.create",
+ "project.visit",
+ "environment.visit",
+ "instance.visit",
+ "database.visit",
+ "member.addOrInvite",
+ "hidden",
+ "guide.project",
+ "guide.environment",
+ "guide.instance",
+ "guide.database",
+ "kbar.open",
+ ];
+ keys.forEach((key) => {
+ uiStateStore.saveIntroStateByKey({
+ key,
+ newState: false,
+ });
});
};
diff --git a/frontend/src/components/ProjectCreate.vue b/frontend/src/components/ProjectCreate.vue
index 56f5607af2..ade8018033 100644
--- a/frontend/src/components/ProjectCreate.vue
+++ b/frontend/src/components/ProjectCreate.vue
@@ -132,6 +132,7 @@ import { Project, ProjectCreate } from "../types";
import { projectSlug, randomString } from "../utils";
import { useI18n } from "vue-i18n";
import { useEventListener } from "@vueuse/core";
+import { useUIStateStore } from "@/store";
interface LocalState {
project: ProjectCreate;
@@ -205,7 +206,7 @@ export default defineComponent({
store
.dispatch("project/createProject", state.project)
.then((createdProject: Project) => {
- store.dispatch("uistate/saveIntroStateByKey", {
+ useUIStateStore().saveIntroStateByKey({
key: "project.visit",
newState: true,
});
diff --git a/frontend/src/components/ProvideDashboardContext.vue b/frontend/src/components/ProvideDashboardContext.vue
index 48f4a899fd..9afa75ddb5 100644
--- a/frontend/src/components/ProvideDashboardContext.vue
+++ b/frontend/src/components/ProvideDashboardContext.vue
@@ -3,10 +3,12 @@
</template>
<script lang="ts">
+import { useUIStateStore } from "@/store";
+import { defineComponent } from "vue";
import { useStore } from "vuex";
import { DEFAULT_PROJECT_ID } from "../types";
-export default {
+export default defineComponent({
name: "ProvideDashboardContext",
async setup() {
const store = useStore();
@@ -23,8 +25,8 @@ export default {
store.dispatch("environment/fetchEnvironmentList"),
// The default project hosts databases not explicitly assigned to other users project.
store.dispatch("project/fetchProjectById", DEFAULT_PROJECT_ID),
- store.dispatch("uistate/restoreState"),
+ useUIStateStore().restoreState(),
]);
},
-};
+});
</script>
diff --git a/frontend/src/components/Quickstart.vue b/frontend/src/components/Quickstart.vue
index d15332f35b..9a7fb48641 100644
--- a/frontend/src/components/Quickstart.vue
+++ b/frontend/src/components/Quickstart.vue
@@ -58,18 +58,19 @@
</template>
<script lang="ts">
-import { computed, reactive, ComputedRef, defineComponent } from "vue";
+import { computed, reactive, defineComponent, Ref } from "vue";
import { useStore } from "vuex";
import { useI18n } from "vue-i18n";
import { isDBA, isOwner } from "../utils";
import { useKBarHandler, useKBarEventOnce } from "@bytebase/vue-kbar";
+import { useUIStateStore } from "@/store";
type IntroItem = {
- name: string;
+ name: string | Ref<string>;
link: string;
allowDBA: boolean;
allowDeveloper: boolean;
- done: ComputedRef<boolean>;
+ done: Ref<boolean>;
click?: () => void;
};
@@ -77,47 +78,44 @@ export default defineComponent({
name: "QuickStart",
setup() {
const store = useStore();
+ const uiStateStore = useUIStateStore();
const { t } = useI18n();
const kbarHandler = useKBarHandler();
const currentUser = computed(() => store.getters["auth/currentUser"]());
- const introList: IntroItem[] = reactive([
+ const introList = reactive<IntroItem[]>([
{
name: computed(() => t("quick-start.bookmark-an-issue")),
link: "/issue/hello-world-101",
allowDBA: true,
allowDeveloper: true,
- done: computed(() => {
- return store.getters["uistate/introStateByKey"]("bookmark.create");
- }),
+ done: computed(() =>
+ uiStateStore.getIntroStateByKey("bookmark.create")
+ ),
},
{
name: computed(() => t("quick-start.add-a-comment")),
link: "/issue/hello-world-101#activity101",
allowDBA: true,
allowDeveloper: true,
- done: computed(() => {
- return store.getters["uistate/introStateByKey"]("comment.create");
- }),
+ done: computed(() => uiStateStore.getIntroStateByKey("comment.create")),
},
{
name: computed(() => t("quick-start.visit-project")),
link: "/project",
allowDBA: true,
allowDeveloper: true,
- done: computed(() => {
- return store.getters["uistate/introStateByKey"]("project.visit");
- }),
+ done: computed(() => uiStateStore.getIntroStateByKey("project.visit")),
},
{
name: computed(() => t("quick-start.visit-environment")),
link: "/environment",
allowDBA: true,
allowDeveloper: false,
- done: computed(() => {
- return store.getters["uistate/introStateByKey"]("environment.visit");
- }),
+ done: computed(() =>
+ uiStateStore.getIntroStateByKey("environment.visit")
+ ),
},
{
name: computed(() => t("quick-start.visit-instance")),
@@ -126,18 +124,14 @@ export default defineComponent({
allowDeveloper: !store.getters["subscription/feature"](
"bb.feature.dba-workflow"
),
- done: computed(() => {
- return store.getters["uistate/introStateByKey"]("instance.visit");
- }),
+ done: computed(() => uiStateStore.getIntroStateByKey("instance.visit")),
},
{
name: computed(() => t("quick-start.visit-database")),
link: "/db",
allowDBA: true,
allowDeveloper: true,
- done: computed(() =>
- store.getters["uistate/introStateByKey"]("database.visit")
- ),
+ done: computed(() => uiStateStore.getIntroStateByKey("database.visit")),
},
{
name: computed(() => t("quick-start.add-a-member")),
@@ -145,7 +139,7 @@ export default defineComponent({
allowDBA: false,
allowDeveloper: false,
done: computed(() =>
- store.getters["uistate/introStateByKey"]("member.addOrInvite")
+ uiStateStore.getIntroStateByKey("member.addOrInvite")
),
},
{
@@ -160,9 +154,7 @@ export default defineComponent({
click: () => {
kbarHandler.value.show();
},
- done: computed(() =>
- store.getters["uistate/introStateByKey"]("kbar.open")
- ),
+ done: computed(() => uiStateStore.getIntroStateByKey("kbar.open")),
},
]);
@@ -186,8 +178,8 @@ export default defineComponent({
};
const hideQuickstart = () => {
- store
- .dispatch("uistate/saveIntroStateByKey", {
+ uiStateStore
+ .saveIntroStateByKey({
key: "hidden",
newState: true,
})
@@ -204,7 +196,7 @@ export default defineComponent({
useKBarEventOnce("open", () => {
// once kbar is open, mark the quickstart as done
- store.dispatch("uistate/saveIntroStateByKey", {
+ uiStateStore.saveIntroStateByKey({
key: "kbar.open",
newState: true,
});
diff --git a/frontend/src/layouts/BodyLayout.vue b/frontend/src/layouts/BodyLayout.vue
index 1f1d0b3950..c4e65ae1be 100644
--- a/frontend/src/layouts/BodyLayout.vue
+++ b/frontend/src/layouts/BodyLayout.vue
@@ -148,7 +148,7 @@ import QuickActionPanel from "../components/QuickActionPanel.vue";
import { QuickActionType } from "../types";
import { isDBA, isDeveloper, isOwner } from "../utils";
import { PlanType } from "../types";
-import { useActuatorStore } from "@/store";
+import { useActuatorStore, useUIStateStore } from "@/store";
interface LocalState {
showMobileOverlay: boolean;
@@ -165,6 +165,7 @@ export default defineComponent({
setup() {
const store = useStore();
const actuatorStore = useActuatorStore();
+ const uiStateStore = useUIStateStore();
const router = useRouter();
const state = reactive<LocalState>({
@@ -221,15 +222,14 @@ export default defineComponent({
return !(name === "workspace.home" || name === "workspace.profile");
});
- const showIntro = computed(() => {
- return !store.getters["uistate/introStateByKey"]("general.overview");
- });
+ const showIntro = computed(
+ () => !uiStateStore.getIntroStateByKey("general.overview")
+ );
const showQuickstart = computed(() => {
// Do not show quickstart in demo mode since we don't expect user to alter the data
return (
- !actuatorStore.isDemo &&
- !store.getters["uistate/introStateByKey"]("hidden")
+ !actuatorStore.isDemo && !uiStateStore.getIntroStateByKey("hidden")
);
});
diff --git a/frontend/src/store/modules/uistate.ts b/frontend/src/store/modules/uistate.ts
deleted file mode 100644
index 1fd2d8ba47..0000000000
--- a/frontend/src/store/modules/uistate.ts
+++ /dev/null
@@ -1,152 +0,0 @@
-import isUndefined from "lodash-es/isUndefined";
-
-const COLLAPSE_MODULE = "ui.list.collapse";
-const INTRO_MODULE = "ui.intro";
-
-export interface UIState {
- collapseStateByKey: Map<string, boolean>;
- introStateByKey: Map<string, boolean>;
-}
-
-const state: () => UIState = () => ({
- collapseStateByKey: new Map(),
- introStateByKey: new Map(),
-});
-
-const stateByKey = function (
- stateMap: Map<string, boolean>,
- module: string,
- key: string
-): boolean {
- const memState = stateMap.get(key);
- if (!isUndefined(memState)) {
- return memState;
- }
- const localStorageState = localStorage.getItem(module);
- if (localStorageState) {
- return JSON.parse(localStorageState)[key] || false;
- }
- return false;
-};
-
-const saveStateByKey = function (
- module: string,
- key: string,
- state: boolean
-): boolean {
- const item = localStorage.getItem(module);
- const fullState = item ? JSON.parse(item) : {};
- fullState[key] = state;
- localStorage.setItem(module, JSON.stringify(fullState));
- return fullState[key];
-};
-
-const getters = {
- collapseStateByKey:
- (state: UIState) =>
- (key: string): boolean => {
- return stateByKey(state.collapseStateByKey, COLLAPSE_MODULE, key);
- },
-
- introStateByKey:
- (state: UIState) =>
- (key: string): boolean => {
- return stateByKey(state.introStateByKey, INTRO_MODULE, key);
- },
-};
-
-const actions = {
- async restoreState({ commit }: any) {
- const storedCollapseState = localStorage.getItem(COLLAPSE_MODULE);
- const collapseState = storedCollapseState
- ? JSON.parse(storedCollapseState)
- : {};
- commit("setCollapseState", collapseState);
-
- const storedIntroState = localStorage.getItem(INTRO_MODULE);
- const introState = storedIntroState ? JSON.parse(storedIntroState) : {};
- commit("setIntroState", introState);
- },
-
- async savecollapseStateByKey(
- { commit }: any,
- {
- key,
- collapse,
- }: {
- key: string;
- collapse: boolean;
- }
- ) {
- const state = saveStateByKey(COLLAPSE_MODULE, key, collapse);
- commit("setcollapseStateByKey", { key, collapse: state });
- return state;
- },
-
- async saveIntroStateByKey(
- { commit }: any,
- {
- key,
- newState,
- }: {
- key: string;
- newState: boolean;
- }
- ) {
- const state = saveStateByKey(INTRO_MODULE, key, newState);
- commit("setIntroStateByKey", { key, newState });
- return state;
- },
-};
-
-const mutations = {
- setCollapseState(state: UIState, fullState: any) {
- const newMap = new Map();
- for (const key in fullState) {
- newMap.set(key, fullState[key]);
- }
- state.collapseStateByKey = newMap;
- },
-
- setcollapseStateByKey(
- state: UIState,
- {
- key,
- collapse,
- }: {
- key: string;
- collapse: boolean;
- }
- ) {
- state.collapseStateByKey.set(key, collapse);
- },
-
- setIntroState(state: UIState, fullState: any) {
- const newMap = new Map();
- for (const key in fullState) {
- newMap.set(key, fullState[key]);
- }
- state.introStateByKey = newMap;
- },
-
- setIntroStateByKey(
- state: UIState,
- {
- key,
- newState,
- }: {
- key: string;
- newState: boolean;
- }
- ) {
- state.introStateByKey.set(key, newState);
- },
-};
-
-export default {
- namespaced: true,
- state,
- getters,
- actions,
- mutations,
-};
diff --git a/frontend/src/store/pinia-modules/index.ts b/frontend/src/store/pinia-modules/index.ts
index 2f17c4301f..100f3671be 100644
--- a/frontend/src/store/pinia-modules/index.ts
+++ b/frontend/src/store/pinia-modules/index.ts
@@ -3,3 +3,4 @@ export * from "./command";
export * from "./debug";
export * from "./label";
export * from "./tab";
+export * from "./uistate";
diff --git a/frontend/src/store/pinia-modules/uistate.ts b/frontend/src/store/pinia-modules/uistate.ts
new file mode 100644
index 0000000000..1344a0a937
--- /dev/null
+++ b/frontend/src/store/pinia-modules/uistate.ts
@@ -0,0 +1,112 @@
+import { isUndefined } from "lodash-es";
+import { defineStore } from "pinia";
+
+const COLLAPSE_MODULE = "ui.list.collapse";
+const INTRO_MODULE = "ui.intro";
+
+export interface UIState {
+ collapseStateByKey: Map<string, boolean>;
+ introStateByKey: Map<string, boolean>;
+}
+
+export const useUIStateStore = defineStore("uistate", {
+ state: (): UIState => ({
+ collapseStateByKey: new Map(),
+ introStateByKey: new Map(),
+ }),
+ actions: {
+ getCollapseStateByKey(key: string): boolean {
+ return stateByKey(this.collapseStateByKey, COLLAPSE_MODULE, key);
+ },
+ getIntroStateByKey(key: string): boolean {
+ return stateByKey(this.introStateByKey, INTRO_MODULE, key);
+ },
+ setCollapseState(fullState: any) {
+ const newMap = new Map();
+ for (const key in fullState) {
+ newMap.set(key, fullState[key]);
+ }
+ this.collapseStateByKey = newMap;
+ },
+ setCollapseStateByKey({
+ key,
+ collapse,
+ }: {
+ key: string;
+ collapse: boolean;
+ }) {
+ this.collapseStateByKey.set(key, collapse);
+ },
+ setIntroState(fullState: any) {
+ const newMap = new Map();
+ for (const key in fullState) {
+ newMap.set(key, fullState[key]);
+ }
+ this.introStateByKey = newMap;
+ },
+ setIntroStateByKey({ key, newState }: { key: string; newState: boolean }) {
+ this.introStateByKey.set(key, newState);
+ },
+ async restoreState() {
+ const storedCollapseState = localStorage.getItem(COLLAPSE_MODULE);
+ const collapseState = storedCollapseState
+ ? JSON.parse(storedCollapseState)
+ : {};
+ this.setCollapseState(collapseState);
+
+ const storedIntroState = localStorage.getItem(INTRO_MODULE);
+ const introState = storedIntroState ? JSON.parse(storedIntroState) : {};
+ this.setIntroState(introState);
+ },
+ async saveCollapseStateByKey({
+ key,
+ collapse,
+ }: {
+ key: string;
+ collapse: boolean;
+ }) {
+ const state = saveStateByKey(COLLAPSE_MODULE, key, collapse);
+ this.setCollapseStateByKey({ key, collapse: state });
+ return state;
+ },
+ async saveIntroStateByKey({
+ key,
+ newState,
+ }: {
+ key: string;
+ newState: boolean;
+ }) {
+ const state = saveStateByKey(INTRO_MODULE, key, newState);
+ this.setIntroStateByKey({ key, newState });
+ return state;
+ },
+ },
+});
+
+const stateByKey = function (
+ stateMap: Map<string, boolean>,
+ module: string,
+ key: string
+): boolean {
+ const memState = stateMap.get(key);
+ if (!isUndefined(memState)) {
+ return memState;
+ }
+ const localStorageState = localStorage.getItem(module);
+ if (localStorageState) {
+ return JSON.parse(localStorageState)[key] || false;
+ }
+ return false;
+};
+
+const saveStateByKey = function (
+ module: string,
+ key: string,
+ state: boolean
+): boolean {
+ const item = localStorage.getItem(module);
+ const fullState = item ? JSON.parse(item) : {};
+ fullState[key] = state;
+ localStorage.setItem(module, JSON.stringify(fullState));
+ return fullState[key];
+};
diff --git a/frontend/src/views/DatabaseDashboard.vue b/frontend/src/views/DatabaseDashboard.vue
index 5e0751e597..6380db314e 100644
--- a/frontend/src/views/DatabaseDashboard.vue
+++ b/frontend/src/views/DatabaseDashboard.vue
@@ -33,7 +33,14 @@
</template>
<script lang="ts">
-import { computed, watchEffect, onMounted, reactive, ref } from "vue";
+import {
+ computed,
+ watchEffect,
+ onMounted,
+ reactive,
+ ref,
+ defineComponent,
+} from "vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
import EnvironmentTabFilter from "../components/EnvironmentTabFilter.vue";
@@ -41,6 +48,7 @@ import DatabaseTable from "../components/DatabaseTable.vue";
import { Environment, Database, UNKNOWN_ID } from "../types";
import { sortDatabaseList } from "../utils";
import { cloneDeep } from "lodash-es";
+import { useUIStateStore } from "@/store";
interface LocalState {
searchText: string;
@@ -49,7 +57,7 @@ interface LocalState {
showGuide: boolean;
}
-export default {
+export default defineComponent({
name: "InstanceDashboard",
components: {
EnvironmentTabFilter,
@@ -59,6 +67,7 @@ export default {
const searchField = ref();
const store = useStore();
+ const uiStateStore = useUIStateStore();
const router = useRouter();
const state = reactive<LocalState>({
@@ -82,10 +91,10 @@ export default {
// Focus on the internal search field when mounted
searchField.value.$el.querySelector("#search").focus();
- if (!store.getters["uistate/introStateByKey"]("guide.database")) {
+ if (!uiStateStore.getIntroStateByKey("guide.database")) {
setTimeout(() => {
state.showGuide = true;
- store.dispatch("uistate/saveIntroStateByKey", {
+ uiStateStore.saveIntroStateByKey({
key: "database.visit",
newState: true,
});
@@ -108,7 +117,7 @@ export default {
watchEffect(prepareDatabaseList);
const doDismissGuide = () => {
- store.dispatch("uistate/saveIntroStateByKey", {
+ uiStateStore.saveIntroStateByKey({
key: "guide.database",
newState: true,
});
@@ -157,5 +166,5 @@ export default {
changeSearchText,
};
},
-};
+});
</script>
diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vue
index 8f62624311..130f9e661e 100644
--- a/frontend/src/views/EnvironmentDashboard.vue
+++ b/frontend/src/views/EnvironmentDashboard.vue
@@ -91,7 +91,7 @@ import {
DefaultSchedulePolicy,
} from "../types";
import { BBTabItem } from "../bbkit/types";
-import { useRegisterCommand } from "@/store";
+import { useRegisterCommand, useUIStateStore } from "@/store";
const DEFAULT_NEW_ENVIRONMENT: EnvironmentCreate = {
name: "New Env",
@@ -131,6 +131,7 @@ export default defineComponent({
props: {},
setup() {
const store = useStore();
+ const uiStateStore = useUIStateStore();
const router = useRouter();
const state = reactive<LocalState>({
@@ -162,10 +163,10 @@ export default defineComponent({
onMounted(() => {
selectEnvironmentOnHash();
- if (!store.getters["uistate/introStateByKey"]("guide.environment")) {
+ if (!uiStateStore.getIntroStateByKey("guide.environment")) {
setTimeout(() => {
state.showGuide = true;
- store.dispatch("uistate/saveIntroStateByKey", {
+ uiStateStore.saveIntroStateByKey({
key: "environment.visit",
newState: true,
});
@@ -263,7 +264,7 @@ export default defineComponent({
};
const doDismissGuide = () => {
- store.dispatch("uistate/saveIntroStateByKey", {
+ uiStateStore.saveIntroStateByKey({
key: "guide.environment",
newState: true,
});
diff --git a/frontend/src/views/InstanceDashboard.vue b/frontend/src/views/InstanceDashboard.vue
index 8140cbee3d..d207d8e170 100644
--- a/frontend/src/views/InstanceDashboard.vue
+++ b/frontend/src/views/InstanceDashboard.vue
@@ -39,7 +39,14 @@
</template>
<script lang="ts">
-import { computed, watchEffect, onMounted, reactive, ref } from "vue";
+import {
+ computed,
+ watchEffect,
+ onMounted,
+ reactive,
+ ref,
+ defineComponent,
+} from "vue";
import { useRouter } from "vue-router";
import EnvironmentTabFilter from "../components/EnvironmentTabFilter.vue";
import InstanceTable from "../components/InstanceTable.vue";
@@ -48,6 +55,7 @@ import { Environment, Subscription, Instance } from "../types";
import { cloneDeep } from "lodash-es";
import { sortInstanceList } from "../utils";
import { useI18n } from "vue-i18n";
+import { useUIStateStore } from "@/store";
interface LocalState {
searchText: string;
@@ -55,7 +63,7 @@ interface LocalState {
showGuide: boolean;
}
-export default {
+export default defineComponent({
name: "InstanceDashboard",
components: {
EnvironmentTabFilter,
@@ -65,6 +73,7 @@ export default {
const searchField = ref();
const store = useStore();
+ const uiStateStore = useUIStateStore();
const router = useRouter();
const { t } = useI18n();
@@ -86,10 +95,10 @@ export default {
// Focus on the internal search field when mounted
searchField.value.$el.querySelector("#search").focus();
- if (!store.getters["uistate/introStateByKey"]("guide.instance")) {
+ if (!uiStateStore.getIntroStateByKey("guide.instance")) {
setTimeout(() => {
state.showGuide = true;
- store.dispatch("uistate/saveIntroStateByKey", {
+ uiStateStore.saveIntroStateByKey({
key: "instance.visit",
newState: true,
});
@@ -120,7 +129,7 @@ export default {
};
const doDismissGuide = () => {
- store.dispatch("uistate/saveIntroStateByKey", {
+ uiStateStore.saveIntroStateByKey({
key: "guide.instance",
newState: true,
});
@@ -196,5 +205,5 @@ export default {
instanceCountAttention,
};
},
-};
+});
</script>
diff --git a/frontend/src/views/ProjectDashboard.vue b/frontend/src/views/ProjectDashboard.vue
index d1b79c0c62..e59d7ccf2b 100644
--- a/frontend/src/views/ProjectDashboard.vue
+++ b/frontend/src/views/ProjectDashboard.vue
@@ -28,6 +28,7 @@
</template>
<script lang="ts">
+import { useUIStateStore } from "@/store";
import {
watchEffect,
computed,
@@ -55,6 +56,7 @@ export default defineComponent({
const searchField = ref();
const store = useStore();
+ const uiStateStore = useUIStateStore();
const state = reactive<LocalState>({
projectList: [],
@@ -68,10 +70,10 @@ export default defineComponent({
// Focus on the internal search field when mounted
searchField.value.$el.querySelector("#search").focus();
- if (!store.getters["uistate/introStateByKey"]("guide.project")) {
+ if (!uiStateStore.getIntroStateByKey("guide.project")) {
setTimeout(() => {
state.showGuide = true;
- store.dispatch("uistate/saveIntroStateByKey", {
+ uiStateStore.saveIntroStateByKey({
key: "project.visit",
newState: true,
});
@@ -99,7 +101,7 @@ export default defineComponent({
};
const doDismissGuide = () => {
- store.dispatch("uistate/saveIntroStateByKey", {
+ uiStateStore.saveIntroStateByKey({
key: "guide.project",
newState: true,
});