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(demo guide): support keyboard change event (#1662)
boojack412441da849d
diff --git a/frontend/src/bbkit/BBComboBox.vue b/frontend/src/bbkit/BBComboBox.vueindex fdeff700b4..4d3b48ab0b 100644--- a/frontend/src/bbkit/BBComboBox.vue+++ b/frontend/src/bbkit/BBComboBox.vue@@ -45,6 +45,7 @@v-if="state.open"ref="popup"class="z-50 rounded-md bg-white shadow-lg"+ v-bind="dataLabelAttrs":style="{ width: `${width}px` }"><ul@@ -89,6 +90,7 @@import { reactive, watch, ref, withDefaults } from "vue";import { VBinder, VTarget, VFollower } from "vueuc";import { onClickOutside, useElementBounding } from "@vueuse/core";+import useDataLabelAttrs from "@/composables/useDataLabelAttrs";import { isAncestorOf, scrollIntoViewIfNeeded } from "./BBUtil";export type ItemType = number | string | object | any;@@ -136,6 +138,8 @@ const state = reactive<LocalState>({activeItem: props.value,});+const dataLabelAttrs = useDataLabelAttrs("", "-item");+const button = ref<HTMLButtonElement | null>(null);const popup = ref<HTMLElement | null>(null);const itemRefs = ref<HTMLElement[]>([]);diff --git a/frontend/src/components/Issue/IssueSidebar.vue b/frontend/src/components/Issue/IssueSidebar.vueindex dc6aa15caa..f034742d97 100644--- a/frontend/src/components/Issue/IssueSidebar.vue+++ b/frontend/src/components/Issue/IssueSidebar.vue@@ -24,13 +24,14 @@}}<span v-if="create" class="text-red-600">*</span></h2><!-- Only DBA can be assigned to the issue -->- <div class="col-span-2">+ <div class="col-span-2" data-label="bb-assignee-select-container"><!-- eslint-disable vue/attribute-hyphenation --><MemberSelectclass="w-full":disabled="!allowEditAssignee":selectedId="create ? (issue as IssueCreate).assigneeId : (issue as Issue).assignee?.id":allowed-role-list="['OWNER', 'DBA']"+ data-label="bb-assignee-select"@select-principal-id="(principalId: number) => {updateAssigneeId(principalId)diff --git a/frontend/src/components/Issue/IssueStatusTransitionButtonGroup.vue b/frontend/src/components/Issue/IssueStatusTransitionButtonGroup.vueindex 2b17087800..0705eecfb2 100644--- a/frontend/src/components/Issue/IssueStatusTransitionButtonGroup.vue+++ b/frontend/src/components/Issue/IssueStatusTransitionButtonGroup.vue@@ -4,6 +4,7 @@type="button"class="btn-primary px-4 py-2":disabled="!allowCreate"+ data-label="bb-issue-create-button"@click.prevent="doCreate">{{ $t("common.create") }}diff --git a/frontend/src/components/Issue/IssueTaskStatementPanel.vue b/frontend/src/components/Issue/IssueTaskStatementPanel.vueindex 96d83b0327..3768696ad4 100644--- a/frontend/src/components/Issue/IssueTaskStatementPanel.vue+++ b/frontend/src/components/Issue/IssueTaskStatementPanel.vue@@ -83,6 +83,7 @@<MonacoEditorref="editorRef"class="w-full h-auto max-h-[360px]"+ data-label="bb-issue-sql-editor":value="state.editStatement":readonly="!state.editing"@change="onStatementChange"diff --git a/frontend/src/components/MemberSelect.vue b/frontend/src/components/MemberSelect.vueindex 74f3066b27..706e30204c 100644--- a/frontend/src/components/MemberSelect.vue+++ b/frontend/src/components/MemberSelect.vue@@ -5,6 +5,7 @@:filter="filter":placeholder="placeholder":disabled="disabled"+ v-bind="$attrs"@update:value="(principal) => {state.selectedId = principal.id;diff --git a/frontend/src/composables/useDataLabelAttrs.ts b/frontend/src/composables/useDataLabelAttrs.tsnew file mode 100644index 0000000000..f9d5837dbc--- /dev/null+++ b/frontend/src/composables/useDataLabelAttrs.ts@@ -0,0 +1,18 @@+import { reactive, useAttrs } from "vue";++const dataLabelRegex = RegExp("data-.+");++const useDataLabelAttrs = (prefix = "", endfix = "") => {+ const attrs = useAttrs();+ const dataLabelAttrs = reactive<any>({});++ for (const key in attrs) {+ if (dataLabelRegex.test(key)) {+ dataLabelAttrs[key] = prefix + attrs[key] + endfix;+ }+ }++ return dataLabelAttrs;+};++export default useDataLabelAttrs;diff --git a/frontend/src/plugins/guide/data.ts b/frontend/src/plugins/guide/data.tsindex 637a024221..6fe71994cc 100644--- a/frontend/src/plugins/guide/data.ts+++ b/frontend/src/plugins/guide/data.ts@@ -1,14 +1,14 @@import { merge } from "lodash-es";+const fetchJSONData = async (path: string) => {+ const res = await fetch("/static/guide" + path);+ const data = await res.json();+ return data;+};+export const fetchGuideDataWithName = async (guideName: string) => {const recorderData = await fetchJSONData(`/recorder/${guideName}.json`);const guideData = await fetchJSONData(`/${guideName}.json`);return merge(recorderData, guideData);};--const fetchJSONData = async (path: string) => {- const res = await fetch("/static/guide" + path);- const data = await res.json();- return data;-};diff --git a/frontend/src/plugins/guide/dialog.ts b/frontend/src/plugins/guide/dialog.tsindex edf2b5a796..dc9620ea48 100644--- a/frontend/src/plugins/guide/dialog.ts+++ b/frontend/src/plugins/guide/dialog.ts@@ -25,7 +25,7 @@ export const showGuideDialog = async (guideStep: any) => {const targetElement = await waitForTargetElement(guideStep.selectors);if (targetElement) {renderHighlightWrapper(targetElement);- renderGuideDialog(targetElement, guideStep.title, guideStep.description);+ renderGuideDialog(targetElement, guideStep);}};@@ -40,11 +40,8 @@ const renderHighlightWrapper = (targetElement: HTMLElement) => {highlightWrapper.style.height = `${bounding.height}px`;};-const renderGuideDialog = (- targetElement: HTMLElement,- title: string,- description: string-) => {+const renderGuideDialog = (targetElement: HTMLElement, guideStep: any) => {+ const { description, title, type } = guideStep;const guideDialogDiv = document.createElement("div");guideDialogDiv.className = "bb-guide-dialog";const bounding = getElementBounding(targetElement);@@ -61,34 +58,47 @@ const renderGuideDialog = (const buttonsContainer = document.createElement("div");buttonsContainer.className = "bb-guide-btns-container";- const prevButton = document.createElement("button");- prevButton.className = "button";- prevButton.innerText = "Back";+const nextButton = document.createElement("button");nextButton.className = "button";nextButton.innerText = "Next";- buttonsContainer.appendChild(prevButton);buttonsContainer.appendChild(nextButton);guideDialogDiv.appendChild(buttonsContainer);- prevButton.onclick = () => {- // ...how to do prev?- };-- nextButton.onclick = () => {- targetElement.click();- };-- // TOOD(steven): support more action type: input value change...- targetElement.addEventListener("click", () => {- const { guide } = storage.get(["guide"]);- storage.set({- guide: merge(guide, {- stepIndex: (guide?.stepIndex ?? 0) + 1,- }),+ if (type === "click") {+ targetElement.addEventListener("click", () => {+ const { guide } = storage.get(["guide"]);+ storage.set({+ guide: merge(guide, {+ stepIndex: (guide?.stepIndex ?? 0) + 1,+ }),+ });+ storage.emitStorageChangedEvent();});- storage.emitStorageChangedEvent();- });++ nextButton.onclick = () => {+ targetElement.click();+ };+ } else if (type === "change") {+ nextButton.onclick = () => {+ const value =+ targetElement.textContent ||+ targetElement.nodeValue ||+ (targetElement as HTMLInputElement).value ||+ "";+ if (RegExp(guideStep.value).test(value)) {+ const { guide } = storage.get(["guide"]);+ storage.set({+ guide: merge(guide, {+ stepIndex: (guide?.stepIndex ?? 0) + 1,+ }),+ });+ storage.emitStorageChangedEvent();+ } else {+ // ...show invalid value message+ }+ };+ }document.body.appendChild(guideDialogDiv);};diff --git a/frontend/src/plugins/guide/utils.ts b/frontend/src/plugins/guide/utils.tsindex e9733d4605..ce65533f08 100644--- a/frontend/src/plugins/guide/utils.ts+++ b/frontend/src/plugins/guide/utils.ts@@ -53,8 +53,6 @@ export const getElementBounding = ((relativeEl.tagName !== "BODY" && relativeElPosition === "relative") ||relativeElPosition === "sticky") {- // when the container of our target element is _not_ body and has either "relative" or "sticky" position, we should not- // consider the scroll position but we need to include the relative x/y of the container elementreturn assign(bounding, {top: elementRect.top - relativeElRect.top,left: elementRect.left - relativeElRect.left,diff --git a/frontend/static/guide/schema-migration.json b/frontend/static/guide/schema-migration.jsonindex e0d46430d3..aaa7f1433a 100644--- a/frontend/static/guide/schema-migration.json+++ b/frontend/static/guide/schema-migration.json@@ -28,18 +28,35 @@},{"title": "Input the `DROP COLUMN` SQL string in the editor",- "description": ""+ "description": "",+ "url": "http://localhost:3000/issue/new",+ "value": ".+",+ "selectors": [+ [+ "[data-label='bb-issue-sql-editor'] >.monaco-editor .editor-scrollable"+ ]+ ]},{- "title": "Let's choose a member as the Assignee"+ "title": "Let's choose a member as the Assignee",+ "url": "http://localhost:3000/issue/new",+ "selectors": [["[data-label='bb-assignee-select-container']"]]},{"title": "That's him, Demo Owner!",- "description": ""+ "description": "",+ "url": "http://localhost:3000/issue/new",+ "selectors": [+ [+ "[data-label='bb-assignee-select-container'] [data-label='bb-assignee-select-item'] ul li"+ ]+ ]},{"title": "Click Create button",- "description": ""+ "description": "",+ "url": "http://localhost:3000/issue/new",+ "selectors": [["[data-label='bb-issue-create-button']"]]}]}