Skip to content

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

Send notification on CUD operation on InstanceDetail

Tianzhou Chene217a37d4d2b
diff --git a/frontend/src/main.js b/frontend/src/main.js
index dfd14e1d98..7f0e14bcde 100644
--- a/frontend/src/main.js
+++ b/frontend/src/main.js
@@ -10,6 +10,7 @@ import {
BBAvatar,
BBContextMenu,
BBModal,
+ BBNotification,
BBStepBar,
BBTab,
BBTabPanel,
@@ -36,6 +37,7 @@ app
.component("BBAvatar", BBAvatar)
.component("BBContextMenu", BBContextMenu)
.component("BBModal", BBModal)
+ .component("BBNotification", BBNotification)
.component("BBStepBar", BBStepBar)
.component("BBTab", BBTab)
.component("BBTabPanel", BBTabPanel)
diff --git a/frontend/src/store/modules/notification.ts b/frontend/src/store/modules/notification.ts
index 2cb8b04be8..27191e7c99 100644
--- a/frontend/src/store/modules/notification.ts
+++ b/frontend/src/store/modules/notification.ts
@@ -15,12 +15,8 @@ function findNotification(
filter: NotificationFilter
): Notification | null {
const list = state.notificationByModule.get(filter.module);
- if (list) {
- for (const notification of list) {
- if (notification.action == filter.action) {
- return notification;
- }
- }
+ if (list && list.length > 0) {
+ return list[0];
}
return null;
}
diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.ts
index 791f223906..79cae64b66 100644
--- a/frontend/src/types/bytebase.ts
+++ b/frontend/src/types/bytebase.ts
@@ -1,4 +1,5 @@
import { ResourceObject } from "./jsonapi";
+import { BBNotificationStyle } from "../bbkit/types";
// These ID format may change in the future, so we encapsulate with a type.
// Also good for readability.
@@ -131,8 +132,9 @@ export type Notification = {
id: string;
createdTs: number;
module: string;
- action: string;
- userInfo?: any;
+ style: BBNotificationStyle;
+ title: string;
+ description?: string;
};
// "id" and "createdTs" is auto generated upon the notification store
@@ -141,7 +143,6 @@ export type NewNotification = Omit<Notification, "id" | "createdTs">;
export type NotificationFilter = {
module: string;
- action: string;
};
// Store
diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vue
index 184ddc088f..b90f5abd18 100644
--- a/frontend/src/views/InstanceDetail.vue
+++ b/frontend/src/views/InstanceDetail.vue
@@ -482,6 +482,11 @@ export default {
newDataSource: newAdminDataSource,
})
.then((dataSource) => {
+ store.dispatch("notification/pushNotification", {
+ module: "bytebase",
+ style: "SUCCESS",
+ title: `Successfully created instance '${instance.attributes.name}'.`,
+ });
router.push({
name: "workspace.instance",
});
@@ -517,6 +522,11 @@ export default {
})
.then((dataSource) => {
assignAdminDataSource(dataSource);
+ store.dispatch("notification/pushNotification", {
+ module: "bytebase",
+ style: "SUCCESS",
+ title: `Successfully updated instance '${updatedInstance.attributes.name}'.`,
+ });
router.push({
name: "workspace.instance",
});
@@ -544,6 +554,13 @@ export default {
instanceId: state.originalInstance!.id,
})
.then(() => {
+ store.dispatch("notification/pushNotification", {
+ module: "bytebase",
+ style: "SUCCESS",
+ title: `Successfully deleted instance '${
+ state.originalInstance!.attributes.name
+ }'.`,
+ });
router.push({
name: "workspace.instance",
});