Skip to content

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

Support notificaiton layering

天舟f24db90e6390
diff --git a/frontend/src/bbkit/BBNotification.vue b/frontend/src/bbkit/BBNotification.vue
index 182f50846d..8b8bafd192 100644
--- a/frontend/src/bbkit/BBNotification.vue
+++ b/frontend/src/bbkit/BBNotification.vue
@@ -1,9 +1,14 @@
<template>
<div
- class="fixed inset-0 flex px-4 py-6 pointer-events-none sm:p-6"
+ class="fixed inset-0 px-4 py-6 pointer-events-none sm:p-6"
:class="placementClass"
>
- <!--
+ <template
+ v-for="(notification, index) of notificationList.slice().reverse()"
+ :key="index"
+ >
+ <!-- TODO: Needs to figure out how to do transition -->
+ <!--
Notification panel, show/hide based on alert state.
Entering: "transform ease-out duration-300 transition"
@@ -13,189 +18,181 @@
From: "opacity-100"
To: "opacity-0"
-->
- <transition
- enter-active-class="transform ease-out duration-300 transition"
- enter-from-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"
- enter-to-class="translate-y-0 opacity-100 sm:translate-x-0"
- leave-active-class="transition ease-in duration-100"
- leave-from-class="opacity-100"
- leave-to-class="opacity-0"
- >
- <div
- v-if="showing"
- class="max-w-sm w-full bg-white shadow-lg rounded-lg pointer-events-auto ring-1 ring-black ring-opacity-5 overflow-hidden"
+ <transition
+ enter-active-class="transform ease-out duration-300 transition"
+ enter-from-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"
+ enter-to-class="translate-y-0 opacity-100 sm:translate-x-0"
+ leave-active-class="transition ease-in duration-100"
+ leave-from-class="opacity-100"
+ leave-to-class="opacity-0"
>
- <div class="p-4">
- <div class="flex items-start">
- <div class="flex-shrink-0">
- <template v-if="style == 'SUCCESS'">
- <svg
- class="h-6 w-6 text-success"
- xmlns="http://www.w3.org/2000/svg"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- aria-hidden="true"
- >
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
- />
- </svg>
- </template>
- <template v-else-if="style == 'WARN'">
- <svg
- class="w-6 h-6 text-yellow-600"
- fill="none"
- stroke="currentColor"
- viewBox="0 0 24 24"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
- ></path>
- </svg>
- </template>
- <template v-else-if="style == 'CRITICAL'">
- <svg
- class="w-6 h-6 text-red-600"
- fill="none"
- stroke="currentColor"
- viewBox="0 0 24 24"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
- ></path>
- </svg>
- </template>
- <template v-else>
- <svg
- class="w-6 h-6 text-blue-600"
- fill="none"
- stroke="currentColor"
- viewBox="0 0 24 24"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
- ></path>
- </svg>
- </template>
- </div>
- <div class="ml-3 w-0 flex-1 pt-0.5">
- <p class="text-sm font-medium text-gray-900">{{ title }}</p>
- <p class="mt-1 text-sm text-gray-500 whitespace-pre-wrap">
- {{ description }}
- </p>
- <div v-if="link" class="mt-2">
- <button
- class="bg-white rounded-md text-sm font-medium text-accent hover:text-accent-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent"
- @click.prevent="viewLink"
- >
- {{ linkTitle }}
- </button>
+ <div
+ class="max-w-sm w-full bg-white shadow-lg rounded-lg pointer-events-auto ring-1 ring-black ring-opacity-5 overflow-hidden"
+ >
+ <div class="p-4">
+ <div class="flex items-start">
+ <div class="flex-shrink-0">
+ <template v-if="notification.style == 'SUCCESS'">
+ <svg
+ class="h-6 w-6 text-success"
+ xmlns="http://www.w3.org/2000/svg"
+ fill="none"
+ viewBox="0 0 24 24"
+ stroke="currentColor"
+ aria-hidden="true"
+ >
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
+ />
+ </svg>
+ </template>
+ <template v-else-if="notification.style == 'WARN'">
+ <svg
+ class="w-6 h-6 text-yellow-600"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
+ ></path>
+ </svg>
+ </template>
+ <template v-else-if="notification.style == 'CRITICAL'">
+ <svg
+ class="w-6 h-6 text-red-600"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
+ ></path>
+ </svg>
+ </template>
+ <template v-else>
+ <svg
+ class="w-6 h-6 text-blue-600"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
+ ></path>
+ </svg>
+ </template>
+ </div>
+ <div class="ml-3 w-0 flex-1 pt-0.5">
+ <p class="text-sm font-medium text-gray-900">
+ {{ notification.title }}
+ </p>
+ <p class="mt-1 text-sm text-gray-500 whitespace-pre-wrap">
+ {{ notification.description }}
+ </p>
+ <div v-if="notification.link" class="mt-2">
+ <button
+ class="bg-white rounded-md text-sm font-medium text-accent hover:text-accent-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent"
+ @click.prevent="viewLink(notification.link)"
+ >
+ {{ notification.linkTitle }}
+ </button>
+ <button
+ class="ml-6 bg-white rounded-md text-sm font-medium text-gray-700 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent"
+ @click.prevent="$emit('close')"
+ >
+ Dismiss
+ </button>
+ </div>
+ </div>
+ <div class="ml-4 flex-shrink-0 flex">
<button
- class="ml-6 bg-white rounded-md text-sm font-medium text-gray-700 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent"
+ class="bg-white rounded-md inline-flex text-gray-400 hover:text-gray-500 focus:outline-none"
@click.prevent="$emit('close')"
>
- Dismiss
+ <span class="sr-only">Close</span>
+ <!-- Heroicon name: solid/x -->
+ <svg
+ class="h-5 w-5"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 20 20"
+ fill="currentColor"
+ aria-hidden="true"
+ >
+ <path
+ fill-rule="evenodd"
+ d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
+ clip-rule="evenodd"
+ />
+ </svg>
</button>
</div>
</div>
- <div class="ml-4 flex-shrink-0 flex">
- <button
- class="bg-white rounded-md inline-flex text-gray-400 hover:text-gray-500 focus:outline-none"
- @click.prevent="$emit('close')"
- >
- <span class="sr-only">Close</span>
- <!-- Heroicon name: solid/x -->
- <svg
- class="h-5 w-5"
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 20 20"
- fill="currentColor"
- aria-hidden="true"
- >
- <path
- fill-rule="evenodd"
- d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
- clip-rule="evenodd"
- />
- </svg>
- </button>
- </div>
</div>
</div>
- </div>
- </transition>
+ </transition>
+ </template>
</div>
</template>
<script lang="ts">
import { PropType } from "vue";
import { useRouter } from "vue-router";
-import { BBNotificationStyle, BBNotificationPlacement } from "./types";
+import { BBNotificationPlacement, BBNotificationItem } from "./types";
// For <sm breakpoint, we always position it at the center.
const placementClassMap: Map<BBNotificationPlacement, string> = new Map([
- ["TOP_LEFT", "items-start justify-center sm:justify-start"],
- ["TOP_RIGHT", "items-start justify-center sm:justify-end"],
- ["BOTTOM_LEFT", "items-end justify-center sm:justify-start"],
- ["BOTTOM_RIGHT", "items-end justify-center sm:justify-end"],
+ [
+ "TOP_LEFT",
+ "flex flex-col-reverse items-start justify-center sm:justify-end",
+ ],
+ [
+ "TOP_RIGHT",
+ "flex flex-col-reverse items-end justify-center sm:justify-end",
+ ],
+ [
+ "BOTTOM_LEFT",
+ "flex flex-col space-y-2 items-start justify-center sm:justify-end",
+ ],
+ [
+ "BOTTOM_RIGHT",
+ "flex flex-col space-y-2 items-end justify-center sm:justify-end",
+ ],
]);
export default {
name: "BBNotification",
emits: ["close"],
props: {
- showing: {
- type: Boolean,
- default: false,
- },
- style: {
- type: String as PropType<BBNotificationStyle>,
- default: "INFO",
+ notificationList: {
+ required: true,
+ type: Object as PropType<BBNotificationItem[]>,
},
placement: {
type: String as PropType<BBNotificationPlacement>,
default: "TOP_RIGHT",
},
- title: {
- type: String,
- default: "",
- },
- description: {
- type: String,
- default: "",
- },
- link: {
- type: String,
- default: "",
- },
- linkTitle: {
- type: String,
- default: "View",
- },
- // Any payload pass through to "close" events
- payload: {},
},
setup(props, { emit }) {
const router = useRouter();
- const viewLink = () => {
- router.push(props.link);
+ const viewLink = (link: string) => {
+ router.push(link);
emit("close");
};
diff --git a/frontend/src/bbkit/types.ts b/frontend/src/bbkit/types.ts
index f47a68465b..af54894cda 100644
--- a/frontend/src/bbkit/types.ts
+++ b/frontend/src/bbkit/types.ts
@@ -46,5 +46,12 @@ export type BBNotificationPlacement =
| "TOP_RIGHT"
| "BOTTOM_LEFT"
| "BOTTOM_RIGHT";
+export type BBNotificationItem = {
+ style: BBNotificationStyle;
+ title: string;
+ description: string;
+ link: string;
+ linkTitle: string;
+};
export type BBAlertStyle = "INFO" | "SUCCESS" | "WARN" | "CRITICAL";
diff --git a/frontend/src/components/InstanceForm.vue b/frontend/src/components/InstanceForm.vue
index 5c98ea82c2..89a2876f19 100644
--- a/frontend/src/components/InstanceForm.vue
+++ b/frontend/src/components/InstanceForm.vue
@@ -129,16 +129,16 @@ input[type="number"] {
/>
</div>
</div>
- <!-- Read/Write Datasource Info -->
+ <!-- Read/Write Connection Info -->
<div v-if="create" class="pt-4">
<div class="flex justify-between">
<div>
<h3 class="text-lg leading-6 font-medium text-gray-900">
- Read/Write Data Source Info
+ Read/Write connection info
</h3>
<p class="mt-1 text-sm text-gray-500 max-w-xl">
- This is the data source used by bytebase to perform DDL and DML
- operations. Note, bytebase does NOT need admin/SUPER privilege.
+ This is the connection used by Bytebase to perform DDL and DML
+ operations. Note, Bytebase does NOT need admin/SUPER privilege.
TODO: Add grant statement.
</p>
</div>
diff --git a/frontend/src/layouts/DashboardLayout.vue b/frontend/src/layouts/DashboardLayout.vue
index 2f8b650361..a16e820e8e 100644
--- a/frontend/src/layouts/DashboardLayout.vue
+++ b/frontend/src/layouts/DashboardLayout.vue
@@ -8,17 +8,13 @@
</nav>
<router-view name="body" />
</div>
- <BBNotification
- :placement="'BOTTOM_RIGHT'"
- :showing="state.notification != null"
- :style="state.notification?.style || 'INFO'"
- :title="state.notification?.title || ''"
- :description="state.notification?.description || ''"
- :payload="state.notification?.id"
- :link="state.notification?.link"
- :linkTitle="state.notification?.linkTitle"
- @close="removeNotification"
- />
+ <template v-if="state.notificationList.length > 0">
+ <BBNotification
+ :placement="'BOTTOM_RIGHT'"
+ :notificationList="state.notificationList"
+ @close="removeNotification"
+ />
+ </template>
</template>
<script lang="ts">
@@ -28,11 +24,12 @@ import ProvideContext from "../components/ProvideContext.vue";
import DashboardHeader from "../views/DashboardHeader.vue";
import BannerDemo from "../views/BannerDemo.vue";
import { Notification } from "../types";
+import { BBNotificationItem } from "../bbkit/types";
const NOTIFICAITON_DURATION = 8000;
interface LocalState {
- notification?: Notification | undefined;
+ notificationList: BBNotificationItem[];
}
export default {
@@ -42,37 +39,35 @@ export default {
const store = useStore();
const state = reactive<LocalState>({
- notification: undefined,
+ notificationList: [],
});
const removeNotification = (id: string) => {
- store
- .dispatch("notification/removeNotification", {
- module: "bytebase",
- id,
- })
- .then(() => {
- state.notification = undefined;
- });
+ state.notificationList.shift();
};
const watchNotification = () => {
store
- .dispatch("notification/peekNotification", {
+ .dispatch("notification/tryPopNotification", {
module: "bytebase",
})
- .then((notification: Notification) => {
- state.notification = notification;
- // We don't want user to miss "CRITICAL" notification and
- // thus don't automatically dismiss it.
- if (
- notification &&
- notification.style != "CRITICAL" &&
- !notification.manualHide
- ) {
- setTimeout(() => {
- removeNotification(notification.id);
- }, NOTIFICAITON_DURATION);
+ .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;
+ // We don't want user to miss "CRITICAL" notification and
+ // thus don't automatically dismiss it.
+ if (notification.style != "CRITICAL" && !notification.manualHide) {
+ setTimeout(() => {
+ removeNotification(notification.id);
+ }, NOTIFICAITON_DURATION);
+ }
}
});
};
diff --git a/frontend/src/store/modules/notification.ts b/frontend/src/store/modules/notification.ts
index bc5ac59f3c..27af62eefa 100644
--- a/frontend/src/store/modules/notification.ts
+++ b/frontend/src/store/modules/notification.ts
@@ -36,13 +36,11 @@ const actions = {
commit("appendNotification", notification);
},
- peekNotification({ state }: any, filter: NotificationFilter) {
- return findNotification(state, filter);
- },
-
- removeNotification({ state, commit }: any, filter: NotificationFilter) {
+ tryPopNotification({ state, commit }: any, filter: NotificationFilter) {
const notification = findNotification(state, filter);
- commit("removeNotification", notification);
+ if (notification) {
+ commit("removeNotification", notification);
+ }
return notification;
},
};