Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: update demo style (#1906)
boojacke9ae261aaf5a
diff --git a/frontend/public/demo/schema-migration-history/hint.json b/frontend/public/demo/schema-migration-history/hint.jsonindex 19be643f05..d0e2c381b7 100644--- a/frontend/public/demo/schema-migration-history/hint.json+++ b/frontend/public/demo/schema-migration-history/hint.json@@ -12,7 +12,10 @@{"selector": "[data-label='bb-dashboard-header']","type": "shield",- "url": ".*"+ "url": ".*",+ "additionStyle": {+ "zIndex": "10"+ }},{"selector": "[data-label='bb-breadcrumb']",@@ -64,7 +67,7 @@},{"selector": "[data-label='bb-database-detail-tab'] button:nth-child(2)",- "url": ".+?/db/.+?(?<!#migration-history)$",+ "url": ".+?/db/.+?#overview$","type": "tooltip","dialog": {"title": "",@@ -100,9 +103,10 @@}},{- "selector": "[data-label='bb-migration-history-table'] tr:nth-child(2) > td:nth-child(1)",+ "selector": "[data-label='bb-migration-history-table'] tr:nth-child(2) > td:nth-child(2)","url": ".+?/db/.+?#migration-history$","type": "tooltip",+ "position": "left","dialog": {"title": "","description": {@@ -111,10 +115,6 @@},"alwaysShow": true,"position": "right"- },- "additionStyle": {- "marginLeft": "-16px",- "marginTop": "8px"}},{@@ -129,9 +129,6 @@"zh-CN": "让我们专注在数据库变更管理场景"},"position": "left"- },- "additionStyle": {- "marginTop": "8px"}},{@@ -148,20 +145,34 @@"position": "right"}},+ {+ "selector": "div.w-full.mx-auto nav[data-label='bb-breadcrumb'] > div:nth-child(3)",+ "url": ".+?/db/.+?/history/.+",+ "type": "tooltip",+ "dialog": {+ "title": "",+ "description": {+ "en-US": "Click here to go back",+ "zh-CN": "点击这里来返回"+ },+ "position": "right"+ }+ },{"selector": "[data-label='bb-migration-history-diff-switch']","url": ".+?/db/.+?/history/.+",+ "type": "tooltip","dialog": {"title": "","description": {"en-US": "You can also view the full Schema snapshot after the change","zh-CN": "也可以查看变更后的完整 Schema 快照"},- "position": "right",- "showOnce": "true"+ "position": "right"},"additionStyle": {- "boxShadow": "rgb(78 70 211) 0px 0px 1px 2px"+ "marginLeft": "-72px",+ "marginTop": "-4px"}},{@@ -181,8 +192,10 @@}},{- "selector": "[data-label='bb-migration-history-code-diff-block']",+ "selector": "[data-label='bb-migration-history-code-diff-block'] div.d2h-file-side-diff:nth-child(2)","url": ".+?/db/.+?/history/.+",+ "type": "tooltip",+ "position": "left","dialog": {"title": "","description": {@@ -190,12 +203,14 @@"zh-CN": "这是两个数据库 Schema 版本之间的差异"},"alwaysShow": true,- "position": "topright"+ "position": "right"}},{"selector": "[data-label='bb-migration-history-code-block']","url": ".+?/db/.+?/history/.+",+ "type": "tooltip",+ "position": "left","dialog": {"title": "","description": {@@ -203,7 +218,7 @@"zh-CN": "这是现在数据库的完整 Schema"},"alwaysShow": true,- "position": "topright"+ "position": "right"}},{diff --git a/frontend/src/plugins/demo/data.ts b/frontend/src/plugins/demo/data.tsindex 67bb765bca..bc44fe3c5c 100644--- a/frontend/src/plugins/demo/data.ts+++ b/frontend/src/plugins/demo/data.ts@@ -2,6 +2,8 @@ import { merge } from "lodash-es";import { validateStepData } from "./guide";import { GuideData, HintData } from "./types";+const hintCache = new Map<string, HintData[]>();+const fetchJSONData = async (path: string) => {const res = await fetch("/demo" + path);const data = await res.json();@@ -17,8 +19,14 @@ export const fetchGuideDataWithName = async (guideName: string) => {};export const fetchHintDataWithName = async (hintName: string) => {+ if (hintCache.has(hintName)) {+ return hintCache.get(hintName) as HintData[];+ }+const hintData = (await fetchJSONData(`/${hintName}/hint.json`)) as HintData[];+ hintCache.set(hintName, hintData);+return hintData;};diff --git a/frontend/src/plugins/demo/hint.ts b/frontend/src/plugins/demo/hint.tsindex 23a92f82ae..bc6c498525 100644--- a/frontend/src/plugins/demo/hint.ts+++ b/frontend/src/plugins/demo/hint.ts@@ -1,3 +1,4 @@+import { removeElementBySelector } from "@/utils";import { indexOf, isUndefined } from "lodash-es";import { getStringFromI18NText } from "./i18n";import { Position, HintData } from "./types";@@ -53,6 +54,7 @@ const renderHint = (if (hintData.type === "shield") {hintWrapper.classList.add("shield");}+ removeElementBySelector(`.bb-hint-wrapper.bb-hint-${hintIndex}`);document.body.appendChild(hintWrapper);if (hintData.cover) {@@ -148,6 +150,7 @@ const renderHintDialog = (hintDialogDiv.appendChild(descriptionElement);}+ removeElementBySelector(`.bb-hint-dialog.bb-hint-${hintIndex}`);document.body.appendChild(hintDialogDiv);adjustHintDialogPosition(targetElement, hintDialogDiv, position);@@ -230,13 +233,17 @@ const renderTooltip = () => {const tooltipWrapper = document.createElement("div");tooltipWrapper.className = `bb-hint-tooltip-wrapper bb-hint-${hintIndex}`;+ const pingElement = document.createElement("span");+ pingElement.className = "bb-hint-tooltip-ping";+ tooltipWrapper.appendChild(pingElement);+tooltipWrapper.style.zIndex = `${getElementMaxZIndex(targetElement)}`;- tooltipWrapper.textContent = "!";if (hintData.additionStyle) {for (const key in hintData.additionStyle) {tooltipWrapper.style[key] = `${hintData.additionStyle[key]}`;}}+ removeElementBySelector(`.bb-hint-tooltip-wrapper.bb-hint-${hintIndex}`);document.body.appendChild(tooltipWrapper);tooltipWrapper.addEventListener("mouseenter", () => {@@ -257,17 +264,6 @@ const renderTooltip = (removeHint(hintIndex);});- targetElement.addEventListener(- "click",- () => {- closedHintIndexSet.add(hintIndex);- removeHint(hintIndex);- },- {- once: true,- }- );-requestAnimationFrame(() =>updateTooltipPosition(targetElement, hintData, hintIndex));@@ -282,7 +278,7 @@ const updateTooltipPosition = (`.bb-hint-tooltip-wrapper.bb-hint-${hintIndex}`) as HTMLElement;- if (!targetElement || !hintWrapper) {+ if (!hintWrapper) {removeHint(hintIndex);return;}@@ -313,6 +309,7 @@ const renderCover = (targetElement: HTMLElement, hintIndex: number) => {coverElement.className = `bb-hint-cover-wrapper bb-hint-${hintIndex}`;const maxZIndex = getElementMaxZIndex(targetElement);coverElement.style.zIndex = `${Math.max(maxZIndex - 1, 0)}`;+ removeElementBySelector(`.bb-hint-cover-wrapper.bb-hint-${hintIndex}`);document.body.appendChild(coverElement);targetElement.classList.add("bb-hint-target-element");};diff --git a/frontend/src/plugins/demo/listener.ts b/frontend/src/plugins/demo/listener.tsindex 67ee4ea322..1e2d3c63dd 100644--- a/frontend/src/plugins/demo/listener.ts+++ b/frontend/src/plugins/demo/listener.ts@@ -84,28 +84,24 @@ const initLocationListenerForGuide = () => {// initMutationListenerForHint using mutation observer to detect DOM changes.const initMutationListenerForHint = () => {- let flag: any = -1;const observer = new MutationObserver(async (mutations: MutationRecord[]) => {- for (const mutation of mutations) {- const changedNodes = [...mutation.addedNodes, ...mutation.removedNodes];- for (const changedNode of changedNodes) {- if (- changedNode instanceof HTMLElement &&- !changedNode.matches(".bb-hint-wrapper") &&- !changedNode.matches(".bb-hint-cover-wrapper") &&- !changedNode.matches(".bb-hint-dialog") &&- !changedNode.matches(".bb-hint-tooltip-wrapper")- ) {- if (flag) {- clearTimeout(flag);- }- flag = setTimeout(() => {+ setTimeout(() => {+ for (const mutation of mutations) {+ const changedNodes = [...mutation.addedNodes, ...mutation.removedNodes];+ for (const changedNode of changedNodes) {+ if (+ changedNode instanceof HTMLElement &&+ !changedNode.matches(".bb-hint-wrapper") &&+ !changedNode.matches(".bb-hint-cover-wrapper") &&+ !changedNode.matches(".bb-hint-dialog") &&+ !changedNode.matches(".bb-hint-tooltip-wrapper")+ ) {tryToShowHints();- }, 100);- return;+ return;+ }}}- }+ });});observer.observe(document.body, {diff --git a/frontend/src/plugins/demo/style.css b/frontend/src/plugins/demo/style.cssindex 9739bcd8be..47986049f6 100644--- a/frontend/src/plugins/demo/style.css+++ b/frontend/src/plugins/demo/style.css@@ -74,7 +74,7 @@.bb-hint-dialog.left::before {content: "";position: absolute;- top: 12px;+ top: 10px;right: -6px;border-top: 6px solid transparent;border-bottom: 6px solid transparent;@@ -87,7 +87,7 @@.bb-hint-dialog.right::before {content: "";position: absolute;- top: 20px;+ top: 18px;left: -6px;border-top: 6px solid transparent;border-bottom: 6px solid transparent;@@ -135,29 +135,11 @@}.bb-hint-tooltip-wrapper {- @apply fixed w-4 h-4 text-xs text-center leading-4 shadow-none rounded-full m-0 bg-white cursor-default;- animation: 2s linear 0s infinite breathing;- box-shadow: rgb(78 70 211) 0px 0px 1px 2px;- color: rgb(78 70 211);-}--@keyframes breathing {- 0% {- box-shadow: rgb(78 70 211) 0px 0px 1px 2px;- }- 30% {- box-shadow: rgb(78 70 211) 0px 0px 1px 2px,- rgb(78 70 211 / 40%) 0px 0px 0px 4px;- }- 60% {- box-shadow: rgb(78 70 211) 0px 0px 1px 2px,- rgb(78 70 211 / 40%) 0px 0px 0px 12px;- }- 70% {- box-shadow: rgb(78 70 211) 0px 0px 1px 2px,- rgb(78 70 211 / 40%) 0px 0px 0px 8px;- }- 100% {- box-shadow: rgb(78 70 211) 0px 0px 1px 2px;- }+ @apply fixed w-3 h-3 text-xs text-center leading-4 shadow-none rounded-full m-0 bg-white cursor-default;+ background-color: #4f46e5;+}++.bb-hint-tooltip-wrapper > .bb-hint-tooltip-ping {+ @apply absolute top-0 left-0 w-full h-full animate-ping rounded-full;+ background-color: #4f46e5;}diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.tsindex 13306cc68a..b4d48eddc6 100644--- a/frontend/src/utils/util.ts+++ b/frontend/src/utils/util.ts@@ -182,3 +182,7 @@ export function emitStorageChangedEvent() {iframeEl.contentWindow?.localStorage.setItem("t", Date.now().toString());iframeEl.remove();}++export function removeElementBySelector(selector: string) {+ document.body.querySelectorAll(selector).forEach((e) => e.remove());+}