Skip to content

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

Show at most 5 notifications to prevent excessive notification when shit hits the fan

天舟8e1fadf246db
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index 4af70e56d0..f2552d1b0b 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -62,8 +62,11 @@ export default {
}
}, CHECK_LOGGEDIN_STATE_DURATION);
- const removeNotification = (id: string) => {
- state.notificationList.shift();
+ const removeNotification = (item: BBNotificationItem) => {
+ const index = state.notificationList.indexOf(item);
+ if (index >= 0) {
+ state.notificationList.splice(index, 1);
+ }
};
const watchNotification = () => {
@@ -73,23 +76,26 @@ export default {
})
.then((notification: Notification | undefined) => {
if (notification) {
- state.notificationList.push({
- style: notification.style,
- title: notification.title,
- description: notification.description || "",
- link: notification.link || "",
- linkTitle: notification.linkTitle || "",
- });
- // state.notification = notification;
- if (!notification.manualHide) {
- setTimeout(
- () => {
- removeNotification(notification.id);
- },
- notification.style == "CRITICAL"
- ? CRITICAL_NOTIFICAITON_DURATION
- : NOTIFICAITON_DURATION
- );
+ // Show at most 5 notifications to prevent excessive notification when shit hits the fan.
+ if (state.notificationList.length < 5) {
+ const item: BBNotificationItem = {
+ style: notification.style,
+ title: notification.title,
+ description: notification.description || "",
+ link: notification.link || "",
+ linkTitle: notification.linkTitle || "",
+ };
+ state.notificationList.push(item);
+ if (!notification.manualHide) {
+ setTimeout(
+ () => {
+ removeNotification(item);
+ },
+ notification.style == "CRITICAL"
+ ? CRITICAL_NOTIFICAITON_DURATION
+ : NOTIFICAITON_DURATION
+ );
+ }
}
}
});
diff --git a/frontend/src/bbkit/BBNotification.vue b/frontend/src/bbkit/BBNotification.vue
index a3010407f2..3aa5f5b61b 100644
--- a/frontend/src/bbkit/BBNotification.vue
+++ b/frontend/src/bbkit/BBNotification.vue
@@ -124,7 +124,9 @@
text-accent
hover:text-accent-hover
focus:outline-none
- focus:ring-2 focus:ring-offset-2 focus:ring-accent
+ focus:ring-2
+ focus:ring-offset-2
+ focus:ring-accent
"
@click.prevent="viewLink(notification.link)"
>
@@ -140,9 +142,11 @@
text-gray-700
hover:text-gray-500
focus:outline-none
- focus:ring-2 focus:ring-offset-2 focus:ring-accent
+ focus:ring-2
+ focus:ring-offset-2
+ focus:ring-accent
"
- @click.prevent="$emit('close')"
+ @click.prevent="$emit('close', notification)"
>
Dismiss
</button>
@@ -158,7 +162,7 @@
hover:text-gray-500
focus:outline-none
"
- @click.prevent="$emit('close')"
+ @click.prevent="$emit('close', notification)"
>
<span class="sr-only">Close</span>
<!-- Heroicon name: solid/x -->