Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: re-implement notification store module with pinia (#1036)
Liu Ji9209cc0776e7
diff --git a/frontend/src/App.vue b/frontend/src/App.vueindex 235b862714..acee890ee4 100644--- a/frontend/src/App.vue+++ b/frontend/src/App.vue@@ -28,7 +28,6 @@ import { useStore } from "vuex";import { useRouter } from "vue-router";import { isDev } from "./utils";-import { Notification } from "./types";import { BBNotificationItem } from "./bbkit/types";import KBarWrapper from "./components/KBar/KBarWrapper.vue";import BBModalStack from "./bbkit/BBModalStack.vue";@@ -36,6 +35,7 @@ import BBModalStack from "./bbkit/BBModalStack.vue";import { NConfigProvider, NDialogProvider } from "naive-ui";import { themeOverrides, dateLang, generalLang } from "../naive-ui.config";import { t } from "./plugins/i18n";+import { useNotificationStore } from "./store";// Show at most 3 notifications to prevent excessive notification when shit hits the fan.const MAX_NOTIFICATION_DISPLAY_COUNT = 3;@@ -51,6 +51,7 @@ interface LocalState {}const store = useStore();+const notificationStore = useNotificationStore();const router = useRouter();const state = reactive<LocalState>({@@ -79,36 +80,33 @@ const removeNotification = (item: BBNotificationItem | undefined) => {};const watchNotification = () => {- store- .dispatch("notification/tryPopNotification", {- module: "bytebase",- })- .then((notification: Notification | undefined) => {- if (notification) {- if (state.notificationList.length >= MAX_NOTIFICATION_DISPLAY_COUNT) {- state.notificationList.pop();- }+ const notification = notificationStore.tryPopNotification({+ module: "bytebase",+ });+ if (notification) {+ if (state.notificationList.length >= MAX_NOTIFICATION_DISPLAY_COUNT) {+ state.notificationList.pop();+ }- const item: BBNotificationItem = {- style: notification.style,- title: notification.title,- description: notification.description || "",- link: notification.link || "",- linkTitle: notification.linkTitle || "",- };- state.notificationList.unshift(item);- if (!notification.manualHide) {- setTimeout(- () => {- removeNotification(item);- },- notification.style == "CRITICAL"- ? CRITICAL_NOTIFICATION_DURATION- : NOTIFICATION_DURATION- );- }- }- });+ const item: BBNotificationItem = {+ style: notification.style,+ title: notification.title,+ description: notification.description || "",+ link: notification.link || "",+ linkTitle: notification.linkTitle || "",+ };+ state.notificationList.unshift(item);+ if (!notification.manualHide) {+ setTimeout(+ () => {+ removeNotification(item);+ },+ notification.style == "CRITICAL"+ ? CRITICAL_NOTIFICATION_DURATION+ : NOTIFICATION_DURATION+ );+ }+ }};watchEffect(watchNotification);@@ -117,7 +115,7 @@ onErrorCaptured((e: any /* , _, info */) => {// If e has response, then we assume it's an http error and has already been// handled by the axios global handler.if (!e.response) {- store.dispatch("notification/pushNotification", {+ notificationStore.pushNotification({module: "bytebase",style: "CRITICAL",title: `Internal error occurred`,@@ -132,7 +130,7 @@ onErrorCaptured((e: any /* , _, info */) => {// Add it here so the notification is displayed on the main window. The OAuth callback window is short lived// and would close before the notification has a chance to be displayed.window.addEventListener("bb.oauth.unknown", (event) => {- store.dispatch("notification/pushNotification", {+ notificationStore.pushNotification({module: "bytebase",style: "CRITICAL",title: t("oauth.unknown-event"),diff --git a/frontend/src/components/CreateDataSourceExample.vue b/frontend/src/components/CreateDataSourceExample.vueindex 09d558e710..1086775684 100644--- a/frontend/src/components/CreateDataSourceExample.vue+++ b/frontend/src/components/CreateDataSourceExample.vue@@ -117,10 +117,10 @@<script lang="ts" setup>import { reactive, PropType } from "vue";-import { useStore } from "vuex";import { toClipboard } from "@soerenmartius/vue3-clipboard";import { useI18n } from "vue-i18n";import { DataSourceType, EngineType } from "../types";+import { pushNotification } from "@/store";interface LocalState {showCreateUserExample: boolean;@@ -145,7 +145,6 @@ const props = defineProps({},});-const store = useStore();const { t } = useI18n();const state = reactive<LocalState>({@@ -190,7 +189,7 @@ const toggleCreateUserExample = () => {const copyGrantStatement = () => {toClipboard(grantStatement(props.engineType, props.dataSourceType)).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "INFO",title: t("instance.copy-grant-statement"),diff --git a/frontend/src/components/CreateInstanceForm.vue b/frontend/src/components/CreateInstanceForm.vueindex 489d6e659c..1b0f3a5d98 100644--- a/frontend/src/components/CreateInstanceForm.vue+++ b/frontend/src/components/CreateInstanceForm.vue@@ -243,6 +243,7 @@ import {} from "../types";import isEmpty from "lodash-es/isEmpty";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";interface LocalState {instance: InstanceCreate;@@ -417,7 +418,7 @@ const doCreate = () => {router.push(`/instance/${instanceSlug(createdInstance)}`);- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t(@@ -440,13 +441,13 @@ const testConnection = () => {};store.dispatch("sql/ping", connectionInfo).then((resultSet: SqlResultSet) => {if (isEmpty(resultSet.error)) {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("instance.successfully-connected-instance"),});} else {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: t("instance.failed-to-connect-instance"),diff --git a/frontend/src/components/DataSourceConnectionPanel.vue b/frontend/src/components/DataSourceConnectionPanel.vueindex 8a85d2d65a..2e7ae9cc69 100644--- a/frontend/src/components/DataSourceConnectionPanel.vue+++ b/frontend/src/components/DataSourceConnectionPanel.vue@@ -108,11 +108,12 @@</template><script lang="ts">-import { computed, reactive, PropType } from "vue";+import { computed, reactive, PropType, defineComponent } from "vue";import { useStore } from "vuex";import { toClipboard } from "@soerenmartius/vue3-clipboard";import { DataSource } from "../types";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";type Connection = {name: string;@@ -123,7 +124,7 @@ interface LocalState {showPassword: boolean;}-export default {+export default defineComponent({name: "DataSourceConnectionPanel",components: {},props: {@@ -211,7 +212,7 @@ export default {const copyText = (connection: Connection) => {toClipboard(connection.value).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "INFO",title: t("datasource.connection-name-string-copied-to-clipboard", [@@ -227,5 +228,5 @@ export default {copyText,};},-};+});</script>diff --git a/frontend/src/components/DataSourceMemberForm.vue b/frontend/src/components/DataSourceMemberForm.vueindex c03ab0c876..81b5525dcf 100644--- a/frontend/src/components/DataSourceMemberForm.vue+++ b/frontend/src/components/DataSourceMemberForm.vue@@ -165,7 +165,7 @@</template><script lang="ts">-import { computed, reactive, PropType } from "vue";+import { computed, reactive, PropType, defineComponent } from "vue";import { useStore } from "vuex";import EnvironmentSelect from "../components/EnvironmentSelect.vue";import DatabaseSelect from "../components/DatabaseSelect.vue";@@ -186,6 +186,7 @@ import {} from "../types";import { issueSlug } from "../utils";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";interface LocalState {environmentId?: EnvironmentId;@@ -197,7 +198,7 @@ interface LocalState {issueId?: IssueId;}-export default {+export default defineComponent({name: "DataSourceMemberCreateForm",components: {EnvironmentSelect,@@ -358,7 +359,7 @@ export default {return item.principal.id == state.granteeId;});- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t(@@ -394,7 +395,7 @@ export default {doGrant,};},-};+});</script><style scoped>diff --git a/frontend/src/components/DataSourceMemberTable.vue b/frontend/src/components/DataSourceMemberTable.vueindex e3a263f084..e4145220be 100644--- a/frontend/src/components/DataSourceMemberTable.vue+++ b/frontend/src/components/DataSourceMemberTable.vue@@ -106,19 +106,20 @@</template><script lang="ts">-import { computed, reactive, PropType } from "vue";+import { computed, reactive, PropType, defineComponent } from "vue";import { useStore } from "vuex";import DataSourceMemberForm from "../components/DataSourceMemberForm.vue";import PrincipalAvatar from "../components/PrincipalAvatar.vue";import { DataSource, DataSourceMember } from "../types";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";interface LocalState {searchText: string;showCreateModal: boolean;}-export default {+export default defineComponent({name: "DataSourceMemberTable",components: { DataSourceMemberForm, PrincipalAvatar },props: {@@ -164,7 +165,7 @@ export default {memberId: member.principal.id,}).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "INFO",title: t(@@ -187,5 +188,5 @@ export default {changeSearchText,};},-};+});</script>diff --git a/frontend/src/components/DataSourceTable.vue b/frontend/src/components/DataSourceTable.vueindex ec226e0e46..b92f85b814 100644--- a/frontend/src/components/DataSourceTable.vue+++ b/frontend/src/components/DataSourceTable.vue@@ -91,7 +91,7 @@</template><script lang="ts">-import { computed, reactive, PropType } from "vue";+import { computed, reactive, PropType, defineComponent } from "vue";import { useStore } from "vuex";import { useRouter } from "vue-router";import DataSourceCreateForm from "../components/DataSourceCreateForm.vue";@@ -100,6 +100,7 @@ import { BBTableColumn } from "../bbkit/types";import { databaseSlug, dataSourceSlug } from "../utils";import { Instance, Database, DataSource, DataSourceCreate } from "../types";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";interface LocalState {searchText: string;@@ -107,7 +108,7 @@ interface LocalState {showCreateModal: boolean;}-export default {+export default defineComponent({name: "DataSourceTable",components: { DataSourceCreateForm },props: {@@ -209,7 +210,7 @@ export default {store.dispatch("dataSource/createDataSource", newDataSource).then((dataSource) => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t(@@ -247,5 +248,5 @@ export default {changeSearchText,};},-};+});</script>diff --git a/frontend/src/components/DatabaseBackupPanel.vue b/frontend/src/components/DatabaseBackupPanel.vueindex e82f108352..280c48ea4d 100644--- a/frontend/src/components/DatabaseBackupPanel.vue+++ b/frontend/src/components/DatabaseBackupPanel.vue@@ -133,7 +133,14 @@</template><script lang="ts">-import { computed, watchEffect, reactive, onUnmounted, PropType } from "vue";+import {+ computed,+ watchEffect,+ reactive,+ onUnmounted,+ PropType,+ defineComponent,+} from "vue";import { useStore } from "vuex";import {Backup,@@ -151,6 +158,7 @@ import BackupTable from "../components/BackupTable.vue";import DatabaseBackupCreateForm from "../components/DatabaseBackupCreateForm.vue";import { cloneDeep, isEqual } from "lodash-es";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";interface LocalState {showCreateBackupModal: boolean;@@ -162,7 +170,7 @@ interface LocalState {pollBackupsTimer?: ReturnType<typeof setTimeout>;}-export default {+export default defineComponent({name: "DatabaseBackupPanel",components: {BackupTable,@@ -381,7 +389,7 @@ export default {.then((backupSetting: BackupSetting) => {assignBackupSetting(backupSetting);const action = on ? t("database.enabled") : t("database.disabled");- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t(@@ -406,7 +414,7 @@ export default {}).then((backupSetting: BackupSetting) => {assignBackupSetting(backupSetting);- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t(@@ -457,5 +465,5 @@ export default {updateBackupHookUrl,};},-};+});</script>diff --git a/frontend/src/components/InstanceForm.vue b/frontend/src/components/InstanceForm.vueindex 4d7a52ef99..7b457680b0 100644--- a/frontend/src/components/InstanceForm.vue+++ b/frontend/src/components/InstanceForm.vue@@ -293,6 +293,7 @@ import {} from "../types";import isEmpty from "lodash-es/isEmpty";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";interface EditDataSource extends DataSource {updatedPassword: string;@@ -454,7 +455,7 @@ const handleCreateDataSource = (type: DataSourceType) => {state.instance.engine === "SNOWFLAKE" ||state.instance.engine === "POSTGRES") {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "WARN",title: t("instance.no-read-only-data-source-support", {@@ -589,8 +590,7 @@ const doUpdate = () => {} as EditDataSource;});-- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("instance.successfully-updated-instance-instance-name", [@@ -627,13 +627,13 @@ const testConnection = () => {};store.dispatch("sql/ping", connectionInfo).then((resultSet: SqlResultSet) => {if (isEmpty(resultSet.error)) {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("instance.successfully-connected-instance"),});} else {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: t("instance.failed-to-connect-instance"),diff --git a/frontend/src/components/Issue/IssueOutputPanel.vue b/frontend/src/components/Issue/IssueOutputPanel.vueindex b5d35fc110..b31cbb1dd7 100644--- a/frontend/src/components/Issue/IssueOutputPanel.vue+++ b/frontend/src/components/Issue/IssueOutputPanel.vue@@ -98,6 +98,7 @@ import DatabaseSelect from "../DatabaseSelect.vue";import { activeEnvironment } from "../../utils";import { OutputField, IssueContext } from "../../plugins";import { DatabaseId, EnvironmentId, Issue, UNKNOWN_ID } from "../../types";+import { pushNotification } from "@/store";// eslint-disable-next-line @typescript-eslint/no-empty-interfaceinterface LocalState {}@@ -161,7 +162,7 @@ export default defineComponent({const copyText = (field: OutputField) => {toClipboard(props.issue.payload[field.id]).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "INFO",title: `${field.name} copied to clipboard.`,diff --git a/frontend/src/components/MonacoEditor/MonacoEditor.vue b/frontend/src/components/MonacoEditor/MonacoEditor.vueindex 2b934fa826..a02b750dc5 100644--- a/frontend/src/components/MonacoEditor/MonacoEditor.vue+++ b/frontend/src/components/MonacoEditor/MonacoEditor.vue@@ -13,7 +13,6 @@ import {watch,computed,} from "vue";-import { useStore } from "vuex";import { useI18n } from "vue-i18n";import { editor as Editor } from "monaco-editor";@@ -24,7 +23,7 @@ import {useNamespacedState,} from "vuex-composition-helpers";-import { useTabStore } from "@/store";+import { pushNotification, useTabStore } from "@/store";import {SqlEditorActions,SqlEditorState,@@ -63,7 +62,6 @@ const sqlCode = toRef(props, "value");const language = toRef(props, "language");const tabStore = useTabStore();-const store = useStore();const { t } = useI18n();const { shouldSetContent, shouldFormatContent } =useNamespacedState<SqlEditorState>("sqlEditor", [@@ -161,7 +159,7 @@ const init = async () => {contextMenuOrder: 1,run: () => {if (readonly.value) {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "INFO",title: t("sql-editor.notify.sheet-is-read-only"),diff --git a/frontend/src/components/ProfileDropdown.vue b/frontend/src/components/ProfileDropdown.vueindex 65e6254f35..a4a8379eca 100644--- a/frontend/src/components/ProfileDropdown.vue+++ b/frontend/src/components/ProfileDropdown.vue@@ -128,7 +128,12 @@ import PrincipalAvatar from "./PrincipalAvatar.vue";import { ServerInfo } from "../types";import { isDBAOrOwner } from "../utils";import { useLanguage } from "../composables/useLanguage";-import { useActuatorStore, useDebugStore, useUIStateStore } from "@/store";+import {+ pushNotification,+ useActuatorStore,+ useDebugStore,+ useUIStateStore,+} from "@/store";import { storeToRefs } from "pinia";export default defineComponent({@@ -222,7 +227,7 @@ export default defineComponent({const ping = () => {actuatorStore.fetchInfo().then((info: ServerInfo) => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: info,diff --git a/frontend/src/components/ProjectCreate.vue b/frontend/src/components/ProjectCreate.vueindex 5e4f06a06a..b1017fd860 100644--- a/frontend/src/components/ProjectCreate.vue+++ b/frontend/src/components/ProjectCreate.vue@@ -132,7 +132,7 @@ import { Project, ProjectCreate } from "../types";import { projectSlug, randomString } from "../utils";import { useI18n } from "vue-i18n";import { useEventListener } from "@vueuse/core";-import { useUIStateStore, hasFeature } from "@/store";+import { hasFeature, pushNotification, useUIStateStore } from "@/store";interface LocalState {project: ProjectCreate;@@ -211,7 +211,7 @@ export default defineComponent({newState: true,});- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("project.create-modal.success-prompt", {diff --git a/frontend/src/components/ProjectDeploymentConfigPanel.vue b/frontend/src/components/ProjectDeploymentConfigPanel.vueindex d8a5dde758..6822e777d9 100644--- a/frontend/src/components/ProjectDeploymentConfigPanel.vue+++ b/frontend/src/components/ProjectDeploymentConfigPanel.vue@@ -143,7 +143,7 @@ import { cloneDeep, isEqual } from "lodash-es";import { useI18n } from "vue-i18n";import { NPopover, useDialog } from "naive-ui";import { generateDefaultSchedule, validateDeploymentConfig } from "../utils";-import { useDeploymentStore, useLabelStore } from "@/store";+import { pushNotification, useDeploymentStore, useLabelStore } from "@/store";import { storeToRefs } from "pinia";type LocalState = {@@ -305,7 +305,7 @@ export default defineComponent({projectId: props.project.id,deploymentConfigPatch,});- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("deployment-config.update-success"),diff --git a/frontend/src/components/ProjectGeneralSettingPanel.vue b/frontend/src/components/ProjectGeneralSettingPanel.vueindex 102c6bf5a7..2063247065 100644--- a/frontend/src/components/ProjectGeneralSettingPanel.vue+++ b/frontend/src/components/ProjectGeneralSettingPanel.vue@@ -53,18 +53,19 @@</template><script lang="ts">-import { computed, PropType, reactive } from "vue";+import { computed, defineComponent, PropType, reactive } from "vue";import { useStore } from "vuex";import isEmpty from "lodash-es/isEmpty";import { DEFAULT_PROJECT_ID, Project, ProjectPatch } from "../types";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";interface LocalState {name: string;key: string;}-export default {+export default defineComponent({name: "ProjectGeneralSettingPanel",props: {project: {@@ -113,7 +114,7 @@ export default {projectPatch,}).then((updatedProject: Project) => {- store.dispatch("notification/", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("project.settings.success-updated-prompt", {@@ -131,5 +132,5 @@ export default {save,};},-};+});</script>diff --git a/frontend/src/components/ProjectMemberPanel.vue b/frontend/src/components/ProjectMemberPanel.vueindex b9fe848749..68e5257821 100644--- a/frontend/src/components/ProjectMemberPanel.vue+++ b/frontend/src/components/ProjectMemberPanel.vue@@ -42,32 +42,7 @@":positive-text="$t('common.confirm')":negative-text="$t('common.cancel')"- @positive-click="- () => {- state.showModal = false;- // the current role provider is BYTEBASE, meaning switching role provider to VCS- if (project.roleProvider === 'BYTEBASE') {- patchProjectRoleProvider('GITLAB_SELF_HOST')- .then(() => {- syncMemberFromVCS();- })- .catch(() => {}); // mute error at browser- } else if (project.roleProvider === 'GITLAB_SELF_HOST') {- // the current role provider is GITLAB_SELF_HOST, meaning switching role provider to BYTEBASE- patchProjectRoleProvider('BYTEBASE').then(() => {- $store- .dispatch('notification/pushNotification', {- module: 'bytebase',- style: 'SUCCESS',- title: $t(- 'project.settings.switch-role-provider-to-bytebase-success-prompt'- ),- })- .catch(() => {}); // mute error at browser- });- }- }- "+ @positive-click="onConfirmToggleRoleProvider"@negative-click="() => {state.showModal = false;@@ -198,7 +173,7 @@ import {} from "../types";import { isOwner, isProjectOwner } from "../utils";import { useI18n } from "vue-i18n";-import { featureToRef } from "@/store";+import { featureToRef, pushNotification } from "@/store";interface LocalState {principalId: PrincipalId;@@ -314,7 +289,7 @@ export default defineComponent({projectMember,}).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("project.settings.success-member-added-prompt", {@@ -350,7 +325,7 @@ export default defineComponent({projectId: props.project.id,}).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("project.settings.success-member-sync-prompt"),@@ -389,6 +364,37 @@ export default defineComponent({}};+ const onConfirmToggleRoleProvider = () => {+ () => {+ state.showModal = false;+ // the current role provider is BYTEBASE, meaning switching role provider to VCS+ if (props.project.roleProvider === "BYTEBASE") {+ patchProjectRoleProvider("GITLAB_SELF_HOST")+ .then(() => {+ syncMemberFromVCS();+ })+ .catch(() => {+ // nothing todo+ }); // mute error at browser+ } else if (props.project.roleProvider === "GITLAB_SELF_HOST") {+ // the current role provider is GITLAB_SELF_HOST, meaning switching role provider to BYTEBASE+ patchProjectRoleProvider("BYTEBASE")+ .then(() => {+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t(+ "project.settings.switch-role-provider-to-bytebase-success-prompt"+ ),+ });+ })+ .catch(() => {+ // nothing todo+ }); // mute error at browser;+ }+ };+ };+return {state,hasRBACFeature,@@ -404,6 +410,7 @@ export default defineComponent({has3rdPartyAuthFeature,onRefreshSync,onToggleRoleProvider,+ onConfirmToggleRoleProvider,};},});diff --git a/frontend/src/components/ProjectMemberTable.vue b/frontend/src/components/ProjectMemberTable.vueindex c013c93a03..49abb62807 100644--- a/frontend/src/components/ProjectMemberTable.vue+++ b/frontend/src/components/ProjectMemberTable.vue@@ -134,7 +134,7 @@ import {import { BBTableColumn, BBTableSectionDataSource } from "../bbkit/types";import { isOwner, isProjectOwner } from "../utils";import { useI18n } from "vue-i18n";-import { featureToRef } from "@/store";+import { featureToRef, pushNotification } from "@/store";// eslint-disable-next-line @typescript-eslint/no-empty-interfaceinterface LocalState {}@@ -296,7 +296,7 @@ export default defineComponent({const deleteRole = (member: ProjectMember) => {store.dispatch("project/deleteMember", member).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "INFO",title: t("project.settings.success-member-deleted-prompt", {diff --git a/frontend/src/components/ProjectVersionControlPanel.vue b/frontend/src/components/ProjectVersionControlPanel.vueindex 62dda234c3..82fc066847 100644--- a/frontend/src/components/ProjectVersionControlPanel.vue+++ b/frontend/src/components/ProjectVersionControlPanel.vue@@ -86,13 +86,14 @@</template><script lang="ts">-import { reactive, watchEffect, watch } from "vue";+import { reactive, watchEffect, watch, defineComponent } from "vue";import { computed, PropType } from "vue";import RepositorySetupWizard from "./RepositorySetupWizard.vue";import RepositoryPanel from "./RepositoryPanel.vue";import { Project, ProjectWorkflowType, Repository, UNKNOWN_ID } from "../types";import { useStore } from "vuex";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";interface LocalState {workflowType: ProjectWorkflowType;@@ -100,7 +101,7 @@ interface LocalState {showWizardForChange: boolean;}-export default {+export default defineComponent({name: "ProjectVersionControlPanel",components: {RepositorySetupWizard,@@ -161,7 +162,7 @@ export default {};const finishWizard = () => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: state.showWizardForCreate@@ -185,5 +186,5 @@ export default {finishWizard,};},-};+});</script>diff --git a/frontend/src/components/ProjectWebhookForm.vue b/frontend/src/components/ProjectWebhookForm.vueindex f1d3c59b96..826b748df7 100644--- a/frontend/src/components/ProjectWebhookForm.vue+++ b/frontend/src/components/ProjectWebhookForm.vue@@ -244,7 +244,7 @@</template><script lang="ts">-import { reactive, computed, PropType, watch } from "vue";+import { reactive, computed, PropType, watch, defineComponent } from "vue";import {ActivityType,Project,@@ -259,12 +259,13 @@ import { useRouter } from "vue-router";import { projectWebhookSlug, projectSlug } from "../utils";import { useStore } from "vuex";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";interface LocalState {webhook: ProjectWebhook | ProjectWebhookCreate;}-export default {+export default defineComponent({name: "ProjectWebhookForm",props: {allowEdit: {@@ -395,7 +396,7 @@ export default {projectWebhookCreate: state.webhook,}).then((webhook: ProjectWebhook) => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("project.webhook.success-created-prompt", {@@ -429,7 +430,7 @@ export default {projectWebhookPatch,}).then((webhook: ProjectWebhook) => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("project.webhook.success-updated-prompt", {@@ -447,7 +448,7 @@ export default {projectWebhookId: (state.webhook as ProjectWebhook).id,}).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("project.webhook.success-deleted-prompt", {@@ -474,5 +475,5 @@ export default {deleteWebhook,};},-};+});</script>diff --git a/frontend/src/components/Quickstart.vue b/frontend/src/components/Quickstart.vueindex 6ea60fd472..ba073e532f 100644--- a/frontend/src/components/Quickstart.vue+++ b/frontend/src/components/Quickstart.vue@@ -63,7 +63,7 @@ import { useStore } from "vuex";import { useI18n } from "vue-i18n";import { isDBA, isOwner } from "../utils";import { useKBarHandler, useKBarEventOnce } from "@bytebase/vue-kbar";-import { useUIStateStore, hasFeature } from "@/store";+import { hasFeature, pushNotification, useUIStateStore } from "@/store";type IntroItem = {name: string | Ref<string>;@@ -182,11 +182,11 @@ export default defineComponent({newState: true,}).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "INFO",- title: computed(() => t("quick-start.notice.title")),- description: computed(() => t("quick-start.notice.desc")),+ title: t("quick-start.notice.title"),+ description: t("quick-start.notice.desc"),manualHide: true,});});diff --git a/frontend/src/components/RepositoryPanel.vue b/frontend/src/components/RepositoryPanel.vueindex c3a1d880bb..c5def1d7d2 100644--- a/frontend/src/components/RepositoryPanel.vue+++ b/frontend/src/components/RepositoryPanel.vue@@ -93,6 +93,7 @@ import {} from "../types";import { useStore } from "vuex";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";interface LocalState {repositoryConfig: RepositoryConfig;@@ -167,7 +168,7 @@ export default defineComponent({store.dispatch("repository/deleteRepositoryByProjectId", props.project.id).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("repository.restore-ui-workflow-success"),@@ -207,7 +208,7 @@ export default defineComponent({repositoryPatch,}).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("repository.update-version-control-config-success"),diff --git a/frontend/src/components/RepositoryVCSProviderPanel.vue b/frontend/src/components/RepositoryVCSProviderPanel.vueindex e4b7dfa1b6..611c2b46f8 100644--- a/frontend/src/components/RepositoryVCSProviderPanel.vue+++ b/frontend/src/components/RepositoryVCSProviderPanel.vue@@ -43,6 +43,7 @@ import { reactive, computed, watchEffect, onUnmounted, onMounted } from "vue";import isEmpty from "lodash-es/isEmpty";import { OAuthWindowEventPayload, openWindowForOAuth, VCS } from "../types";import { isOwner } from "../utils";+import { pushNotification } from "@/store";interface LocalState {selectedVCS?: VCS;@@ -82,7 +83,7 @@ const eventListener = (event: Event) => {emit("set-code", payload.code);emit("next");} else {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: payload.error,diff --git a/frontend/src/components/SingleFileSelector.vue b/frontend/src/components/SingleFileSelector.vueindex 69fc3bedb5..782db3aaf4 100644--- a/frontend/src/components/SingleFileSelector.vue+++ b/frontend/src/components/SingleFileSelector.vue@@ -20,30 +20,28 @@</div></template>-<script lang="ts" setup>import { ref, reactive, PropType } from "vue";-import { useStore } from "vuex";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";interface LocalState {dropAreaActive: boolean;}const props = defineProps({- maxFileSizeInMiB: {- required: true,- type: Number,- },- supportFileExtensions: {- required: true,- type: Object as PropType<string[]>,- },+ maxFileSizeInMiB: {+ required: true,+ type: Number,+ },+ supportFileExtensions: {+ required: true,+ type: Object as PropType<string[]>,+ },});const emit = defineEmits(["on-select"]);-const store = useStore();const { t } = useI18n();const state = reactive<LocalState>({@@ -54,7 +52,7 @@ const uploader = ref<HTMLInputElement | null>(null);const onUploaderClick = () => {uploader.value?.click();-}+};const onFileChange = () => {const files: File[] = (uploader.value as any).files;@@ -84,7 +82,7 @@ const selectFile = (files: File[]) => {const validFile = (file: File): boolean => {const extension = file.name.toLowerCase().split(".").slice(-1)[0];if (!props.supportFileExtensions.includes(`.${extension}`)) {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: t("common.file-selector.type-limit", {@@ -95,12 +93,12 @@ const validFile = (file: File): boolean => {}if (file.size > props.maxFileSizeInMiB * 1024 * 1024) {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: t("common.file-selector.size-limit", {size: props.maxFileSizeInMiB,- })+ }),});return false;}diff --git a/frontend/src/components/TransferDatabaseForm.vue b/frontend/src/components/TransferDatabaseForm.vueindex 2559a22cef..df8304cd8e 100644--- a/frontend/src/components/TransferDatabaseForm.vue+++ b/frontend/src/components/TransferDatabaseForm.vue@@ -111,6 +111,7 @@ import {DatabaseLabel,} from "../types";import { sortDatabaseList } from "../utils";+import { pushNotification } from "@/store";type TransferSource = "DEFAULT" | "OTHER";@@ -188,7 +189,7 @@ export default defineComponent({labels,}).then((updatedDatabase) => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: `Successfully transferred '${updatedDatabase.name}' to project '${updatedDatabase.project.name}'.`,diff --git a/frontend/src/components/VCSProviderOAuthPanel.vue b/frontend/src/components/VCSProviderOAuthPanel.vueindex b9066ca796..5c7ebe57e7 100644--- a/frontend/src/components/VCSProviderOAuthPanel.vue+++ b/frontend/src/components/VCSProviderOAuthPanel.vue@@ -152,7 +152,7 @@ import {VCSConfig,redirectUrl,} from "../types";-import { useStore } from "vuex";+import { pushNotification } from "@/store";interface LocalState {applicationIdValidationTimer?: ReturnType<typeof setTimeout>;@@ -170,7 +170,6 @@ export default defineComponent({},},setup(props) {- const store = useStore();const state = reactive<LocalState>({showApplicationIdError:!isEmpty(props.config.applicationId) &&@@ -198,7 +197,7 @@ export default defineComponent({const copyRedirectURI = () => {toClipboard(redirectUrl()).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "INFO",title: `Redirect URI copied to clipboard. Paste to the corresponding field on the OAuth application form.`,diff --git a/frontend/src/components/VCSSetupWizard.vue b/frontend/src/components/VCSSetupWizard.vueindex 4563861291..59bb68129c 100644--- a/frontend/src/components/VCSSetupWizard.vue+++ b/frontend/src/components/VCSSetupWizard.vue@@ -29,9 +29,9 @@import {reactive,computed,- defineComponent,onUnmounted,onMounted,+ defineComponent,} from "vue";import { useRouter } from "vue-router";import { useStore } from "vuex";@@ -53,6 +53,7 @@ import {} from "../types";import { isUrl } from "../utils";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";const BASIC_INFO_STEP = 0;const OAUTH_INFO_STEP = 1;@@ -173,7 +174,7 @@ export default defineComponent({if (token) {state.currentStep = newStep;allowChangeCallback();- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t(@@ -190,7 +191,7 @@ export default defineComponent({"version-control.setting.add-git-provider.check-oauth-info-match");}- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: "Failed to setup OAuth",@@ -214,7 +215,7 @@ export default defineComponent({router.push({name: "setting.workspace.version-control",});- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("version-control.setting.add-git-provider.add-success", {diff --git a/frontend/src/composables/useExecuteSQL.ts b/frontend/src/composables/useExecuteSQL.tsindex 1db612521b..adaf6b098a 100644--- a/frontend/src/composables/useExecuteSQL.ts+++ b/frontend/src/composables/useExecuteSQL.ts@@ -11,7 +11,7 @@ import {isDDLStatement,isDMLStatement,} from "../components/MonacoEditor/sqlParser";-import { useTabStore } from "@/store";+import { pushNotification, useTabStore } from "@/store";type ExecuteConfig = {databaseType: string;@@ -30,7 +30,7 @@ const useExecuteSQL = () => {});const notify = (type: string, title: string, description?: string) => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: type,title,diff --git a/frontend/src/layouts/DashboardLayout.vue b/frontend/src/layouts/DashboardLayout.vueindex 858f09fae9..6a1b82b9f5 100644--- a/frontend/src/layouts/DashboardLayout.vue+++ b/frontend/src/layouts/DashboardLayout.vue@@ -54,7 +54,12 @@ import BannerDebug from "../views/BannerDebug.vue";import { ServerInfo } from "../types";import { isDBAOrOwner } from "../utils";import { computed, defineComponent } from "vue";-import { useActuatorStore, useDebugStore, useSubscriptionStore } from "@/store";+import {+ pushNotification,+ useActuatorStore,+ useDebugStore,+ useSubscriptionStore,+} from "@/store";import { storeToRefs } from "pinia";export default defineComponent({@@ -74,7 +79,7 @@ export default defineComponent({const ping = () => {actuatorStore.fetchInfo().then((info: ServerInfo) => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: info,diff --git a/frontend/src/layouts/SqlEditorLayout.vue b/frontend/src/layouts/SqlEditorLayout.vueindex 8071ec9ebd..7107b2fbfd 100644--- a/frontend/src/layouts/SqlEditorLayout.vue+++ b/frontend/src/layouts/SqlEditorLayout.vue@@ -35,23 +35,24 @@</template><script lang="ts" setup>-import { useStore } from "vuex";-import ProvideSqlEditorContext from "@/components/ProvideSqlEditorContext.vue";import EditorHeader from "@/views/SqlEditor/EditorHeader.vue";import BannerDemo from "@/views/BannerDemo.vue";import BannerTrial from "@/views/BannerTrial.vue";import { ServerInfo } from "../types";-import { useActuatorStore, useSubscriptionStore } from "@/store";+import {+ pushNotification,+ useActuatorStore,+ useSubscriptionStore,+} from "@/store";import { storeToRefs } from "pinia";-const store = useStore();const actuatorStore = useActuatorStore();const subscriptionStore = useSubscriptionStore();const ping = () => {actuatorStore.fetchInfo().then((info: ServerInfo) => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: info,diff --git a/frontend/src/main.ts b/frontend/src/main.tsindex 0a9ac77dd1..1c859c38d7 100644--- a/frontend/src/main.ts+++ b/frontend/src/main.ts@@ -15,7 +15,13 @@ import dataSourceType from "./directives/data-source-type";// @ts-ignoreimport highlight from "./directives/highlight";import { router } from "./router";-import { store, pinia, useActuatorStore, useSubscriptionStore } from "./store";+import {+ store,+ pinia,+ pushNotification,+ useActuatorStore,+ useSubscriptionStore,+} from "./store";import {databaseSlug,dataSourceSlug,@@ -81,7 +87,7 @@ axios.interceptors.response.use(}if (error.response.data.message) {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: error.response.data.message,@@ -92,7 +98,7 @@ axios.interceptors.response.use(});}} else if (error.code == "ECONNABORTED") {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: "Connecting server timeout. Make sure the server is running.",diff --git a/frontend/src/store/modules/notification.ts b/frontend/src/store/modules/notification.tsdeleted file mode 100644index 356d55abba..0000000000--- a/frontend/src/store/modules/notification.ts+++ /dev/null@@ -1,75 +0,0 @@-import { v1 as uuidv1 } from "uuid";-import {- Notification,- NotificationCreate,- NotificationFilter,- NotificationState,-} from "../../types";--const state: () => NotificationState = () => ({- notificationByModule: new Map(),-});--function findNotification(- state: NotificationState,- filter: NotificationFilter-): Notification | undefined {- const list = state.notificationByModule.get(filter.module);- if (list && list.length > 0) {- if (filter.id) {- return list.find((item) => item.id == filter.id);- }- return list[0];- }- return undefined;-}--const getters = {};--const actions = {- pushNotification({ commit }: any, NotificationCreate: NotificationCreate) {- const notification: Notification = {- id: uuidv1(),- createdTs: Date.now() / 1000,- ...NotificationCreate,- };- commit("appendNotification", notification);- },-- tryPopNotification({ state, commit }: any, filter: NotificationFilter) {- const notification = findNotification(state, filter);- if (notification) {- commit("removeNotification", notification);- }- return notification;- },-};--const mutations = {- appendNotification(state: NotificationState, notification: Notification) {- const list = state.notificationByModule.get(notification.module);- if (list) {- list.push(notification);- } else {- state.notificationByModule.set(notification.module, [notification]);- }- },-- removeNotification(state: NotificationState, notification: Notification) {- const list = state.notificationByModule.get(notification.module);- if (list) {- const i = list.indexOf(notification);- if (i > -1) {- list.splice(i, 1);- }- }- },-};--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.tsindex 6d5cdfe142..d83e3faa2d 100644--- a/frontend/src/store/pinia-modules/index.ts+++ b/frontend/src/store/pinia-modules/index.ts@@ -4,6 +4,7 @@ export * from "./command";export * from "./debug";export * from "./deployment";export * from "./label";+export * from "./notification";export * from "./oauth";export * from "./router";export * from "./setting";diff --git a/frontend/src/store/pinia-modules/notification.ts b/frontend/src/store/pinia-modules/notification.tsnew file mode 100644index 0000000000..6a03a34055--- /dev/null+++ b/frontend/src/store/pinia-modules/notification.ts@@ -0,0 +1,67 @@+import { defineStore } from "pinia";+import { v1 as uuidv1 } from "uuid";+import {+ Notification,+ NotificationCreate,+ NotificationFilter,+ NotificationState,+} from "@/types";++export const useNotificationStore = defineStore("notification", {+ state: (): NotificationState => ({+ notificationByModule: new Map(),+ }),+ actions: {+ appendNotification(notification: Notification) {+ const list = this.notificationByModule.get(notification.module);+ if (list) {+ list.push(notification);+ } else {+ this.notificationByModule.set(notification.module, [notification]);+ }+ },+ removeNotification(notification: Notification) {+ const list = this.notificationByModule.get(notification.module);+ if (list) {+ const i = list.indexOf(notification);+ if (i > -1) {+ list.splice(i, 1);+ }+ }+ },+ pushNotification(notificationCreate: NotificationCreate) {+ const notification: Notification = {+ id: uuidv1(),+ createdTs: Date.now() / 1000,+ ...notificationCreate,+ };+ this.appendNotification(notification);+ },+ tryPopNotification(filter: NotificationFilter) {+ const notification = findNotification(this.$state, filter);+ if (notification) {+ this.removeNotification(notification);+ }+ return notification;+ },+ },+});++function findNotification(+ state: NotificationState,+ filter: NotificationFilter+): Notification | undefined {+ const list = state.notificationByModule.get(filter.module);+ if (list && list.length > 0) {+ if (filter.id) {+ return list.find((item) => item.id == filter.id);+ }+ return list[0];+ }+ return undefined;+}++export const pushNotification = (notificationCreate: NotificationCreate) => {+ const store = useNotificationStore();+ store.pushNotification(notificationCreate);+};diff --git a/frontend/src/views/DataSourceDetail.vue b/frontend/src/views/DataSourceDetail.vueindex cc8d15c74b..3a648307d6 100644--- a/frontend/src/views/DataSourceDetail.vue+++ b/frontend/src/views/DataSourceDetail.vue@@ -153,7 +153,7 @@</template><script lang="ts">-import { computed, nextTick, reactive, ref } from "vue";+import { computed, defineComponent, nextTick, reactive, ref } from "vue";import { useStore } from "vuex";import { useRouter } from "vue-router";import cloneDeep from "lodash-es/cloneDeep";@@ -163,6 +163,7 @@ import DataSourceMemberTable from "../components/DataSourceMemberTable.vue";import { idFromSlug, isDBAOrOwner } from "../utils";import { DataSource, DataSourcePatch, Principal } from "../types";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";interface LocalState {editing: boolean;@@ -170,7 +171,7 @@ interface LocalState {editingDataSource?: DataSource;}-export default {+export default defineComponent({name: "DataSourceDetail",components: { DataSourceConnectionPanel, DataSourceMemberTable },props: {@@ -259,7 +260,7 @@ export default {dataSourceId,}).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("datasource.successfully-deleted-data-source-name", [@@ -283,5 +284,5 @@ export default {doDelete,};},-};+});</script>diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vueindex f5f811f558..25d508a8d4 100644--- a/frontend/src/views/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail.vue@@ -305,6 +305,7 @@ import {} from "../types";import { BBTabFilterItem } from "../bbkit/types";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";const OVERVIEW_TAB = 0;const MIGRATION_HISTORY_TAB = 1;@@ -541,7 +542,7 @@ export default defineComponent({labels,}).then((updatedDatabase) => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t(diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vueindex 5b849b1d12..11e132a0cb 100644--- a/frontend/src/views/InstanceDetail.vue+++ b/frontend/src/views/InstanceDetail.vue@@ -156,7 +156,7 @@ import {} from "../types";import { BBTabFilterItem } from "../bbkit/types";import { useI18n } from "vue-i18n";-import { featureToRef, useSubscriptionStore } from "@/store";+import { featureToRef, pushNotification, useSubscriptionStore } from "@/store";const DATABASE_TAB = 0;const USER_TAB = 1;@@ -318,7 +318,7 @@ const doArchive = () => {},}).then((updatedInstance) => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t(@@ -344,7 +344,7 @@ const doRestore = () => {},}).then((updatedInstance) => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t(@@ -362,7 +362,7 @@ const doCreateMigrationSchema = () => {.then((resultSet: SqlResultSet) => {state.creatingMigrationSchema = false;if (resultSet.error) {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: t(@@ -373,7 +373,7 @@ const doCreateMigrationSchema = () => {});} else {checkMigrationSetup();- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t(@@ -393,7 +393,7 @@ const syncSchema = () => {.then((resultSet: SqlResultSet) => {state.syncingSchema = false;if (resultSet.error) {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: t(@@ -403,7 +403,7 @@ const syncSchema = () => {description: resultSet.error,});} else {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t(diff --git a/frontend/src/views/IssueDetail.vue b/frontend/src/views/IssueDetail.vueindex 844d12f64f..07290ab442 100644--- a/frontend/src/views/IssueDetail.vue+++ b/frontend/src/views/IssueDetail.vue@@ -54,7 +54,7 @@ import {TemplateType,} from "../plugins";import { NSpin } from "naive-ui";-import { useActuatorStore, hasFeature } from "@/store";+import { hasFeature, pushNotification, useActuatorStore } from "@/store";interface LocalState {// Needs to maintain this state and set it to false manually after creating the issue.@@ -100,7 +100,7 @@ export default defineComponent({if (template) {newIssueTemplate.value = template;} else {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "WARN",title: `Unknown template '${issueType}'.`,diff --git a/frontend/src/views/MigrationHistoryDetail.vue b/frontend/src/views/MigrationHistoryDetail.vueindex 7732da7b6a..2b2f173f59 100644--- a/frontend/src/views/MigrationHistoryDetail.vue+++ b/frontend/src/views/MigrationHistoryDetail.vue@@ -221,6 +221,7 @@ import {VCSPushEvent,} from "../types";import { BBSelect } from "../bbkit";+import { pushNotification } from "@/store";type LeftSchemaSelected =| "previousHistorySchema" // schema after last migration@@ -328,7 +329,7 @@ export default defineComponent({const copyStatement = () => {toClipboard(migrationHistory.value.statement).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "INFO",title: `Statement copied to clipboard.`,@@ -338,7 +339,7 @@ export default defineComponent({const copySchema = () => {toClipboard(migrationHistory.value.schema).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "INFO",title: `Schema copied to clipboard.`,diff --git a/frontend/src/views/ProjectWebhookDetail.vue b/frontend/src/views/ProjectWebhookDetail.vueindex ff8822b872..8025057b63 100644--- a/frontend/src/views/ProjectWebhookDetail.vue+++ b/frontend/src/views/ProjectWebhookDetail.vue@@ -49,14 +49,15 @@</template><script lang="ts">-import { computed } from "vue";+import { computed, defineComponent } from "vue";import ProjectWebhookForm from "../components/ProjectWebhookForm.vue";import { idFromSlug } from "../utils";import { useStore } from "vuex";import { ProjectWebhookTestResult } from "../types";import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";-export default {+export default defineComponent({name: "ProjectWebhookDetail",components: { ProjectWebhookForm },props: {@@ -98,7 +99,7 @@ export default {}).then((testResult: ProjectWebhookTestResult) => {if (testResult.error) {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: t("project.webhook.fail-tested-title"),@@ -106,7 +107,7 @@ export default {manualHide: true,});} else {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("project.webhook.success-tested-prompt"),@@ -121,5 +122,5 @@ export default {testWebhook,};},-};+});</script>diff --git a/frontend/src/views/SettingWorkspaceGeneral.vue b/frontend/src/views/SettingWorkspaceGeneral.vueindex 1773eb479f..deb395c1c7 100644--- a/frontend/src/views/SettingWorkspaceGeneral.vue+++ b/frontend/src/views/SettingWorkspaceGeneral.vue@@ -98,7 +98,7 @@ import { useStore } from "vuex";import { isOwner } from "../utils";import { brandingLogoSettingName } from "../types/setting";import { useI18n } from "vue-i18n";-import { featureToRef, useSettingStore } from "@/store";+import { featureToRef, pushNotification, useSettingStore } from "@/store";interface LocalState {displayName?: string;@@ -181,7 +181,7 @@ const uploadLogo = async () => {state.logoFile = null;state.logoUrl = setting.value;- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("settings.general.workspace.logo-upload-succeed"),diff --git a/frontend/src/views/SettingWorkspaceSubscription.vue b/frontend/src/views/SettingWorkspaceSubscription.vueindex c87e294d97..8be729104a 100644--- a/frontend/src/views/SettingWorkspaceSubscription.vue+++ b/frontend/src/views/SettingWorkspaceSubscription.vue@@ -72,12 +72,11 @@<script lang="ts">import { computed, defineComponent, reactive } from "vue";-import { useStore } from "vuex";import { useI18n } from "vue-i18n";import dayjs from "dayjs";import PricingTable from "../components/PricingTable.vue";import { PlanType } from "../types";-import { useSubscriptionStore } from "@/store";+import { pushNotification, useSubscriptionStore } from "@/store";import { storeToRefs } from "pinia";interface LocalState {@@ -91,7 +90,6 @@ export default defineComponent({PricingTable,},setup() {- const store = useStore();const subscriptionStore = useSubscriptionStore();const { t } = useI18n();@@ -110,14 +108,14 @@ export default defineComponent({try {await subscriptionStore.patchSubscription(state.license);- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("subscription.update.success.title"),description: t("subscription.update.success.description"),});} catch {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: t("subscription.update.failure.title"),diff --git a/frontend/src/views/SettingWorkspaceVCSDetail.vue b/frontend/src/views/SettingWorkspaceVCSDetail.vueindex b25dc804b6..2b00ad354f 100644--- a/frontend/src/views/SettingWorkspaceVCSDetail.vue+++ b/frontend/src/views/SettingWorkspaceVCSDetail.vue@@ -157,7 +157,7 @@ import {OAuthWindowEventPayload,OAuthToken,} from "../types";-import { useOAuthStore } from "@/store";+import { pushNotification, useOAuthStore } from "@/store";interface LocalState {name: string;@@ -272,7 +272,7 @@ export default defineComponent({vcsPatch,}).then((vcs: VCS) => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: `Successfully updated '${vcs.name}'`,@@ -287,7 +287,7 @@ export default defineComponent({description ="Please make sure Secret matches the one from your GitLab instance Application.";}- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: `Failed to update '${vcs.value.name}'`,@@ -306,7 +306,7 @@ export default defineComponent({vcsPatch,}).then((updatedVCS: VCS) => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: `Successfully updated '${updatedVCS.name}'`,@@ -324,7 +324,7 @@ export default defineComponent({const deleteVCS = () => {const name = vcs.value.name;store.dispatch("vcs/deleteVCSById", vcs.value.id).then(() => {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: `Successfully deleted '${name}'`,diff --git a/frontend/src/views/SqlEditor/AsidePanel/QueryHistoryContainer.vue b/frontend/src/views/SqlEditor/AsidePanel/QueryHistoryContainer.vueindex 7d6e27b307..d11095a7e2 100644--- a/frontend/src/views/SqlEditor/AsidePanel/QueryHistoryContainer.vue+++ b/frontend/src/views/SqlEditor/AsidePanel/QueryHistoryContainer.vue@@ -64,14 +64,13 @@ import { escape } from "lodash-es";import { computed, reactive } from "vue";import { useI18n } from "vue-i18n";import { useClipboard } from "@vueuse/core";-import { useStore } from "vuex";import {useNamespacedActions,useNamespacedState,} from "vuex-composition-helpers";import { useDialog } from "naive-ui";-import { useTabStore } from "@/store";+import { pushNotification, useTabStore } from "@/store";import { QueryHistory, SqlEditorActions, SqlEditorState } from "@/types";import { getHighlightHTMLByKeyWords } from "@/utils";@@ -81,7 +80,6 @@ interface State {}const { t } = useI18n();-const store = useStore();const dialog = useDialog();const tabStore = useTabStore();@@ -186,7 +184,7 @@ const handleActionBtnClick = (key: string, history: QueryHistory) => {});} else if (key === "copy") {copyTextToClipboard(history.statement);- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("sql-editor.notify.copy-code-succeed"),diff --git a/frontend/src/views/SqlEditor/EditorPanel/ExecuteHint.vue b/frontend/src/views/SqlEditor/EditorPanel/ExecuteHint.vueindex 1d1b66b01f..7116e99219 100644--- a/frontend/src/views/SqlEditor/EditorPanel/ExecuteHint.vue+++ b/frontend/src/views/SqlEditor/EditorPanel/ExecuteHint.vue@@ -51,13 +51,12 @@import { computed } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";-import { useStore } from "vuex";import {useNamespacedGetters,useNamespacedState,} from "vuex-composition-helpers";-import { useTabStore } from "@/store";+import { pushNotification, useTabStore } from "@/store";import { UNKNOWN_ID } from "@/types";import type { SqlEditorState, SqlEditorGetters } from "@/types";@@ -72,7 +71,6 @@ const emit = defineEmits<{}>();const router = useRouter();-const store = useStore();const { t } = useI18n();const tabStore = useTabStore();@@ -111,7 +109,7 @@ const handleColse = () => {const gotoAlterSchema = () => {if (ctx.databaseId === UNKNOWN_ID) {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: t("sql-editor.goto-alter-schema-hint"),diff --git a/frontend/src/views/SqlEditor/EditorPanel/SharePopover.vue b/frontend/src/views/SqlEditor/EditorPanel/SharePopover.vueindex c9a4b1e571..5f7a7bc8a7 100644--- a/frontend/src/views/SqlEditor/EditorPanel/SharePopover.vue+++ b/frontend/src/views/SqlEditor/EditorPanel/SharePopover.vue@@ -78,7 +78,6 @@<script lang="ts" setup>import { ref, computed, onMounted } from "vue";import { useClipboard } from "@vueuse/core";-import { useStore } from "vuex";import { useI18n } from "vue-i18n";import {useNamespacedGetters,@@ -87,7 +86,7 @@ import {} from "vuex-composition-helpers";import slug from "slug";-import { useTabStore } from "@/store";+import { pushNotification, useTabStore } from "@/store";import {SqlEditorState,SheetGetters,@@ -99,7 +98,6 @@ const emit = defineEmits<{(e: "close"): void;}>();-const store = useStore();const { t } = useI18n();const tabStore = useTabStore();@@ -188,7 +186,7 @@ const { copy, copied } = useClipboard({const handleCopy = async () => {await copy();- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "SUCCESS",title: t("sql-editor.notify.copy-share-link"),diff --git a/frontend/src/views/SqlEditor/TabListContainer.vue b/frontend/src/views/SqlEditor/TabListContainer.vueindex a1f7720b06..2acf5019cd 100644--- a/frontend/src/views/SqlEditor/TabListContainer.vue+++ b/frontend/src/views/SqlEditor/TabListContainer.vue@@ -119,14 +119,13 @@import { ref, reactive, nextTick, computed, onMounted, onUnmounted } from "vue";import { debounce } from "lodash-es";import { useI18n } from "vue-i18n";-import { useStore } from "vuex";import {useNamespacedGetters,useNamespacedActions,} from "vuex-composition-helpers";import { useDialog } from "naive-ui";-import { useTabStore } from "@/store";+import { pushNotification, useTabStore } from "@/store";import { TabInfo, SheetGetters, SheetActions } from "@/types";import { useSQLEditorConnection } from "@/composables/useSQLEditorConnection";@@ -143,7 +142,6 @@ const { patchSheetById } = useNamespacedActions<SheetActions>("sheet", ["patchSheetById",]);-const store = useStore();const { t } = useI18n();const { setConnectionContextFromCurrentTab } = useSQLEditorConnection();const dialog = useDialog();@@ -216,7 +214,7 @@ const handleTryChangeLabel = () => {};});} else {- store.dispatch("notification/pushNotification", {+ pushNotification({module: "bytebase",style: "CRITICAL",title: t("sql-editor.please-input-the-tab-label"),