Skip to content

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

Add notification to the DashbaordLayout, the notification bar will stay for 4s

Tianzhou Chen08bc4b2a4b7c
diff --git a/frontend/src/layouts/DashboardLayout.vue b/frontend/src/layouts/DashboardLayout.vue
index a38e7db243..8d53d00019 100644
--- a/frontend/src/layouts/DashboardLayout.vue
+++ b/frontend/src/layouts/DashboardLayout.vue
@@ -6,17 +6,64 @@
<DashboardHeader />
</div>
</nav>
-
<router-view name="body" />
</div>
+ <BBNotification
+ :showing="state.notification != null"
+ :style="state.notification?.style || 'INFO'"
+ :title="state.notification?.title || ''"
+ :description="state.notification?.description || ''"
+ />
</template>
<script lang="ts">
+import { reactive, watchEffect } from "vue";
+import { useStore } from "vuex";
+import { Notification } from "../types";
import DashboardHeader from "../views/DashboardHeader.vue";
+const NOTIFICAITON_DURATION = 4000;
+
+interface LocalState {
+ notification?: Notification | null;
+}
+
export default {
name: "DashboardLayout",
components: { DashboardHeader },
- setup(props, ctx) {},
+ setup(props, ctx) {
+ const store = useStore();
+
+ const state = reactive<LocalState>({
+ notification: null,
+ });
+
+ const watchNotification = () => {
+ store
+ .dispatch("notification/peekNotification", {
+ module: "bytebase",
+ })
+ .then((notification) => {
+ if (notification) {
+ state.notification = notification;
+ setTimeout(() => {
+ store
+ .dispatch("notification/popNotification", {
+ module: "bytebase",
+ })
+ .then(() => {
+ state.notification = null;
+ });
+ }, NOTIFICAITON_DURATION);
+ }
+ });
+ };
+
+ watchEffect(watchNotification);
+
+ return {
+ state,
+ };
+ },
};
</script>