Skip to content

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

chore: remove demo codes (#8366)

boojack390756fbcec2
diff --git a/frontend/public/demo/schema-migration-history/demo.json b/frontend/public/demo/schema-migration-history/demo.json
deleted file mode 100644
index 1d1b26203b..0000000000
--- a/frontend/public/demo/schema-migration-history/demo.json
+++ /dev/null
@@ -1,110 +0,0 @@
-{
- "process": [
- {
- "url": "/db/employee-103/history/20220708094434-3",
- "title": "schema drift",
- "description": "This is schema drift page"
- },
- {
- "url": "/db/employee-103#change-history",
- "title": "change history",
- "description": "This is change history page"
- },
- {
- "url": "/issue/104?stage=test-employee-1&task=update-employee-schema-105",
- "title": "issue detail",
- "description": "This is another issue detail page"
- }
- ],
- "hint": [
- {
- "selector": "[data-label='bb-database-detail-action-buttons-container']",
- "type": "shield",
- "url": ".*",
- "additionStyle": {
- "backdropFilter": "unset",
- "background": "transparent"
- }
- },
- {
- "selector": "[data-label='bb-dashboard-header']",
- "url": ".*",
- "type": "shield",
- "additionStyle": {
- "backdropFilter": "unset",
- "background": "transparent"
- }
- },
- {
- "selector": "[data-label='bb-dashboard-static-sidebar']",
- "url": ".*",
- "type": "shield",
- "additionStyle": {
- "backdropFilter": "unset",
- "background": "transparent"
- }
- },
- {
- "selector": "[data-label='bb-change-history-establish-baseline-alert'] [data-label='bb-alert-ok-button']",
- "type": "shield",
- "url": "/db/.+?#change-history$",
- "dialog": {
- "title": "",
- "description": {
- "en-US": "Since this is a read-only DEMO, you can contact [email protected] to request a full DEMO.",
- "es-ES": "Como se trata de una DEMO de solo lectura, puede ponerse en contacto con [email protected] para solicitar una DEMO completa.",
- "zh-CN": "但由于这是个只读 DEMO,您可以联系 [email protected] 来申请完整的 DEMO 进行尝试"
- },
- "alwaysShow": true
- },
- "additionStyle": {
- "backdropFilter": "unset"
- }
- },
- {
- "selector": "[data-label='bb-database-detail-tab'] button:nth-child(3)",
- "url": ".*",
- "type": "shield",
- "additionStyle": {
- "backdropFilter": "unset",
- "background": "transparent"
- }
- },
- {
- "selector": "[data-label='bb-change-history-table'] tr:nth-child(2) > td:nth-child(4) > a",
- "url": "/db/.+?#change-history$",
- "type": "tooltip",
- "position": "center",
- "dialog": {
- "title": "",
- "description": {
- "en-US": "Let's take a closer look at the issue it generates.",
- "es-ES": "Echemos un vistazo más de cerca al problema que genera.",
- "zh-CN": "让我们来详细看看它产生的工单"
- },
- "alwaysShow": true,
- "position": "right"
- }
- },
- {
- "selector": "[data-label='bb-change-history-view-drift-button']",
- "url": "/db/.+?/history/.+",
- "type": "tooltip",
- "position": "center",
- "dialog": {
- "title": "",
- "description": {
- "en-US": "This change task also detected schema drift. It means some schema changes are performed via other client outside of Bytebase.",
- "es-ES": "Esta tarea de cambio también detectó la desviación del esquema. Significa que algunos cambios de esquema se realizan a través de otro cliente fuera de Bytebase.",
- "zh-CN": "本次变更还检测到了 Schema 偏差,说明有数据库变更通过其他客户端发起,脱离了 Bytebase 管控"
- },
- "alwaysShow": true,
- "position": "bottom"
- },
- "additionStyle": {
- "marginLeft": "2px",
- "marginTop": "10px"
- }
- }
- ]
-}
diff --git a/frontend/src/components/DatabaseSelect.vue b/frontend/src/components/DatabaseSelect.vue
index 952765ee8c..07334ce222 100644
--- a/frontend/src/components/DatabaseSelect.vue
+++ b/frontend/src/components/DatabaseSelect.vue
@@ -29,7 +29,6 @@ import {
PropType,
defineComponent,
} from "vue";
-import { isNullOrUndefined } from "@/plugins/demo/utils";
import {
useCurrentUserV1,
useDatabaseV1Store,
@@ -37,6 +36,7 @@ import {
useInstanceV1Store,
} from "@/store";
import { Engine, State } from "@/types/proto/v1/common";
+import { isNullOrUndefined } from "@/utils";
import {
UNKNOWN_ID,
ComposedDatabase,
diff --git a/frontend/src/components/DatabaseTable.vue b/frontend/src/components/DatabaseTable.vue
index 68a9eb069b..9c7cb54740 100644
--- a/frontend/src/components/DatabaseTable.vue
+++ b/frontend/src/components/DatabaseTable.vue
@@ -233,8 +233,8 @@ import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { SQLEditorButton } from "@/components/DatabaseDetail";
import DatabaseName from "@/components/DatabaseName.vue";
-import { getScrollParent } from "@/plugins/demo/utils";
import { useCurrentUserV1, useDatabaseV1Store } from "@/store";
+import { getScrollParent } from "@/utils";
import { BBGridColumn } from "../bbkit/types";
import { Database } from "../types";
import {
diff --git a/frontend/src/components/OnboardingGuide.vue b/frontend/src/components/OnboardingGuide.vue
deleted file mode 100644
index ffbcaa7f39..0000000000
--- a/frontend/src/components/OnboardingGuide.vue
+++ /dev/null
@@ -1,97 +0,0 @@
-<template>
- <CreateDatabaseGuide
- v-if="shouldShowCreateDatabaseGuide"
- ></CreateDatabaseGuide>
-</template>
-
-<script lang="ts" setup>
-import { onMounted, ref, watch } from "vue";
-import { useRoute, useRouter } from "vue-router";
-import {
- databaseServiceClient,
- instanceServiceClient,
- projectServiceClient,
-} from "@/grpcweb";
-import { useCurrentUserV1, useOnboardingGuideStore } from "@/store";
-import { UNKNOWN_USER_NAME } from "@/types";
-import { isDev, isOwner } from "@/utils";
-import CreateDatabaseGuide from "./OnboardingGuides/CreateDatabaseGuide.vue";
-
-const currentUserV1 = useCurrentUserV1();
-const guideStore = useOnboardingGuideStore();
-
-const shouldShowCreateDatabaseGuide = ref(false);
-
-const route = useRoute();
-const router = useRouter();
-
-onMounted(async () => {
- await router.isReady();
- if (currentUserV1.value.name !== UNKNOWN_USER_NAME) {
- shouldShowCreateDatabaseGuide.value =
- await checkShouldShowCreateDatabaseGuide();
- if (shouldShowCreateDatabaseGuide.value) {
- guideStore.setGuideName("create-database");
- }
- }
-});
-
-const checkShouldShowCreateDatabaseGuide = async () => {
- // Do not show guide in dev mode and `noguide` flag in query.
- if (isDev() && route.query.noguide) {
- return false;
- }
-
- // Show create database guide when user is owner and no data at all.
- if (isOwner(currentUserV1.value.userRole)) {
- // Fetch data directly instead of useStore to prevent data from being cached in store.
- const { instances } = await instanceServiceClient.listInstances({});
- const { projects } = await projectServiceClient.searchProjects({});
- const { databases } = await databaseServiceClient.searchDatabases({
- parent: "instances/-",
- });
- if (
- instances.length === 0 &&
- // We have a default project so the length should be 1 not 0.
- projects.length === 1 &&
- databases.length === 0
- ) {
- return true;
- }
- }
-
- return false;
-};
-
-watch(
- () => currentUserV1.value.name,
- async (name) => {
- try {
- // Check should show guide only when user is logged in.
- if (name !== UNKNOWN_USER_NAME) {
- shouldShowCreateDatabaseGuide.value =
- await checkShouldShowCreateDatabaseGuide();
- if (shouldShowCreateDatabaseGuide.value) {
- guideStore.setGuideName("create-database");
- }
- }
- } catch (error) {
- // When the data requests failed in onboarding guide checking,
- // we just need to log it instead of notify.
- console.error(error);
- }
- }
-);
-
-watch(
- guideStore,
- async () => {
- if (!guideStore.guideName) {
- shouldShowCreateDatabaseGuide.value = false;
- }
- },
- {
- immediate: true,
- }
-);
-</script>
diff --git a/frontend/src/components/OnboardingGuides/CreateDatabaseGuide.vue b/frontend/src/components/OnboardingGuides/CreateDatabaseGuide.vue
deleted file mode 100644
index d893a40a58..0000000000
--- a/frontend/src/components/OnboardingGuides/CreateDatabaseGuide.vue
+++ /dev/null
@@ -1,193 +0,0 @@
-<template>
- <template v-if="guideIndex >= 0 && guideIndex < guideStepList.length">
- <GuideDialog
- v-for="guide in shownGuideList"
- :key="guide.title"
- :title="guide.title"
- :position="guide.position"
- :loading="guide.showLoading || false"
- :target-element-selector="guide.targetElementSelector"
- ></GuideDialog>
- </template>
- <Transition>
- <CreateDatabaseGuideFinished v-if="guideIndex === guideStepList.length" />
- </Transition>
-</template>
-
-<script lang="ts" setup>
-import { computed, onMounted, ref, watch } from "vue";
-import { useI18n } from "vue-i18n";
-import { useRoute, useRouter } from "vue-router";
-import GuideDialog from "@/plugins/demo/components/GuideDialog.vue";
-import { useIssueStore, useProjectV1List, useInstanceV1List } from "@/store";
-import { lastTask } from "@/utils";
-import CreateDatabaseGuideFinished from "./CreateDatabaseGuideFinished.vue";
-
-const { t } = useI18n();
-const route = useRoute();
-const router = useRouter();
-
-type GuideData = {
- title: string;
- description: string;
- position: string;
- targetElementSelector: string;
- route: string;
- expectedUrl: any;
- showLoading?: boolean;
-};
-
-const guideStepList = computed(() => {
- return [
- // guides for `add instance`
- [
- {
- title: t("onboarding-guide.create-database-guide.let-add-a-instance"),
- description: "",
- position: "bottom-center",
- targetElementSelector: "[data-label='bb-quick-action-add-instance']",
- route: "/",
- expectedUrl: /.*/,
- },
- ],
- // guides for `add project`
- [
- {
- title: t(
- "onboarding-guide.create-database-guide.go-to-project-list-page"
- ),
- description: "",
- position: "bottom-center",
- targetElementSelector: "[data-label='bb-header-project-button']",
- expectedUrl: /^(?!\/project)/,
- },
- {
- title: t("onboarding-guide.create-database-guide.click-new-project"),
- description: "",
- position: "bottom-center",
- targetElementSelector: "[data-label='bb-quick-action-new-project']",
- expectedUrl: /^\/project/,
- },
- ],
- // guides for `add issue`
- [
- {
- title: t("onboarding-guide.create-database-guide.click-new-database"),
- description: "",
- position: "bottom-center",
- targetElementSelector: "[data-label='bb-quick-action-new-db']",
- expectedUrl: /.*/,
- },
- ],
- // guides for `approve issue`
- [
- {
- title: t("onboarding-guide.create-database-guide.click-approve"),
- description: "",
- position: "bottom-right",
- targetElementSelector:
- "[data-label='bb-issue-status-transition-button']",
- expectedUrl: /.*/,
- },
- ],
- // guides for `loading`
- [
- {
- title: t("onboarding-guide.create-database-guide.wait-issue-finished"),
- description: "",
- position: "center",
- targetElementSelector: "#app",
- expectedUrl: /.*/,
- showLoading: true,
- },
- ],
- // guides for `back to home`
- [
- {
- title: t("onboarding-guide.create-database-guide.back-to-home"),
- description: "",
- position: "bottom",
- targetElementSelector:
- "[data-label='bb-dashboard-sidebar-home-button']",
- expectedUrl: /^\/.+/,
- },
- ],
- ] as GuideData[][];
-});
-
-const { instanceList } = useInstanceV1List(false /* !showDeleted */);
-const { projectList } = useProjectV1List(false /* !showDeleted */);
-const issueList = computed(() => useIssueStore().issueList);
-
-const shownGuideList = computed(() => {
- const guideList = guideStepList.value[guideIndex.value];
-
- return guideList.filter((guide) => {
- if (guide.expectedUrl) {
- return route.path.match(guide.expectedUrl);
- }
- return true;
- });
-});
-
-const guideIndex = ref(-1);
-
-onMounted(() => {
- if (route.name !== "workspace.home") {
- router.push({
- name: "workspace.home",
- });
- }
-});
-
-watch(
- [route, instanceList, projectList, issueList],
- async () => {
- let tempGuideIndex = 0;
- if (instanceList.value.length > 0) {
- tempGuideIndex = 1;
- }
- if (projectList.value.length > 1) {
- tempGuideIndex = 2;
- }
- if (issueList.value.length > 0) {
- const issue = issueList.value[0];
- const task = lastTask(issue.pipeline!);
- if (task.status === "PENDING_APPROVAL") {
- tempGuideIndex = 3;
- } else if (task.status === "PENDING" || task.status === "RUNNING") {
- tempGuideIndex = 4;
- } else {
- tempGuideIndex = 5;
- }
-
- if (tempGuideIndex === 5 && route.name === "workspace.home") {
- tempGuideIndex = 6;
- }
- }
-
- guideIndex.value = tempGuideIndex;
- },
- {
- immediate: true,
- }
-);
-
-watch(guideIndex, () => {
- document.body
- .querySelectorAll(".bb-guide-target-element")
- .forEach((el) => el.classList.remove("bb-guide-target-element"));
-});
-</script>
-
-<style scoped>
-.v-enter-active,
-.v-leave-active {
- transition: opacity 0.3s ease-in;
-}
-
-.v-enter-from,
-.v-leave-to {
- opacity: 0;
-}
-</style>
diff --git a/frontend/src/components/OnboardingGuides/CreateDatabaseGuideFinished.vue b/frontend/src/components/OnboardingGuides/CreateDatabaseGuideFinished.vue
deleted file mode 100644
index 9fdd7a75b6..0000000000
--- a/frontend/src/components/OnboardingGuides/CreateDatabaseGuideFinished.vue
+++ /dev/null
@@ -1,135 +0,0 @@
-<template>
- <teleport to="body">
- <div class="dialog-wrapper fixed top-0 left-0 w-full h-full">
- <div
- class="dialog-container relative top-1/2 -translate-y-1/2 -mt-8 mx-auto w-128 bg-white shadow-2xl rounded-lg p-4 flex flex-col justify-start items-start"
- >
- <span
- class="absolute right-3 top-3 p-px rounded cursor-pointer hover:bg-gray-100 hover:shadow"
- @click="handleCloseButtonClick"
- >
- <heroicons-outline:x class="w-6 h-auto" />
- </span>
- <p class="text-9xl w-full text-center mt-6">🎉</p>
- <div
- class="showup w-1/2 mx-auto flex flex-col justify-start items-start mt-6 text-lg leading-9"
- >
- <p>
- {{
- $t(
- "onboarding-guide.create-database-guide.finished-dialog.you-have-done"
- )
- }}
- </p>
- <p>
- ✅
- {{
- $t(
- "onboarding-guide.create-database-guide.finished-dialog.add-an-instance"
- )
- }}
- </p>
- <p>
- ✅
- {{
- $t(
- "onboarding-guide.create-database-guide.finished-dialog.create-a-project"
- )
- }}
- </p>
- <p>
- ✅
- {{
- $t(
- "onboarding-guide.create-database-guide.finished-dialog.create-an-issue"
- )
- }}
- </p>
- <p>
- ✅
- {{
- $t(
- "onboarding-guide.create-database-guide.finished-dialog.create-a-new-database"
- )
- }}
- </p>
- </div>
- <button
- class="showup self-center mt-6 mb-4 shadow text-lg px-6 py-3 rounded-md text-white bg-green-600 hover:bg-green-700"
- @click="handleCloseButtonClick"
- >
- {{
- $t(
- "onboarding-guide.create-database-guide.finished-dialog.keep-going-with-bytebase"
- )
- }}
- </button>
- </div>
- </div>
- </teleport>
-</template>
-
-<script lang="ts" setup>
-import { onMounted } from "vue";
-import { useOnboardingGuideStore } from "@/store";
-
-onMounted(() => {
- const colors = ["#2563eb", "#f43f5e", "#f5a30b", "#f5e10b"];
-
- import("canvas-confetti").then(({ default: confetti }) => {
- const end = Date.now() + 3 * 1000;
-
- const framework = () => {
- confetti({
- particleCount: 4,
- angle: 60,
- spread: 60,
- origin: { x: 0 },
- zIndex: 10000,
- colors,
- });
- confetti({
- particleCount: 4,
- angle: 120,
- spread: 60,
- origin: { x: 1 },
- zIndex: 10000,
- colors,
- });
-
- if (Date.now() < end) {
- requestAnimationFrame(framework);
- }
- };
-
- framework();
- });
-});
-
-const handleCloseButtonClick = () => {
- useOnboardingGuideStore().removeGuide();
-};
-</script>
-
-<style scoped>
-.dialog-wrapper {
- z-index: 1000;
- background-color: rgb(33 33 33 / 50%);
-}
-
-.showup {
- animation: moveup 1s ease;
-}
-
-@keyframes moveup {
- from {
- @apply opacity-0;
- transform: translateY(24px);
- }
-
- to {
- @apply opacity-100;
- transform: translateY(0);
- }
-}
-</style>
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
index 607a6cfb9c..e159935a8e 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
@@ -150,7 +150,6 @@ import {
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { BBGridColumn } from "@/bbkit/types";
-import { getScrollParent } from "@/plugins/demo/utils";
import { useCurrentUserV1 } from "@/store";
import { getProjectNameAndDatabaseGroupName } from "@/store/modules/v1/common";
import { usePolicyV1Store } from "@/store/modules/v1/policy";
@@ -160,6 +159,7 @@ import {
PolicyType,
PolicyResourceType,
} from "@/types/proto/v1/org_policy_service";
+import { getScrollParent } from "@/utils";
import {
databaseV1Slug,
isDatabaseV1Queryable,
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index 7f38668be5..65d29ff076 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -9,8 +9,6 @@ import "./assets/css/inter.css";
import "./assets/css/tailwind.css";
import dataSourceType from "./directives/data-source-type";
import dayjs from "./plugins/dayjs";
-import mountDemoApp from "./plugins/demo";
-import "./plugins/demo/style.css";
import highlight from "./plugins/highlight";
import i18n from "./plugins/i18n";
import NaiveUI from "./plugins/naive-ui";
@@ -193,10 +191,4 @@ Promise.all([
// Install router after the necessary data fetching is complete.
app.use(router).use(highlight).use(i18n).use(NaiveUI);
app.mount("#app");
-
- // Try to mount demo vue app instance
- const serverInfo = useActuatorV1Store().serverInfo;
- if ((serverInfo && serverInfo.demoName) || isDev()) {
- mountDemoApp();
- }
});
diff --git a/frontend/src/plugins/demo/components/DemoWrapper.vue b/frontend/src/plugins/demo/components/DemoWrapper.vue
deleted file mode 100644
index 11e5e04ce8..0000000000
--- a/frontend/src/plugins/demo/components/DemoWrapper.vue
+++ /dev/null
@@ -1,65 +0,0 @@
-<template>
- <template v-if="!state.isDemoCompleted && state.showDemo">
- <ProcessBar @close.once="handleProcessClose" />
- </template>
-</template>
-
-<script lang="ts" setup>
-import { onMounted, reactive, watchEffect } from "vue";
-import { useRoute } from "vue-router";
-import { removeDemo } from "..";
-import { fetchDemoDataWithName } from "../data";
-import useAppStore from "../store";
-import ProcessBar from "./ProcessBar.vue";
-
-interface LocalState {
- isDemoCompleted: boolean;
- showDemo: boolean;
-}
-
-const props = defineProps<{
- demoName: string;
-}>();
-
-const state = reactive<LocalState>({
- isDemoCompleted: false,
- showDemo: false,
-});
-
-const route = useRoute();
-const store = useAppStore();
-
-onMounted(async () => {
- try {
- const demoData = await fetchDemoDataWithName(props.demoName);
- if (demoData) {
- store.setState({
- demoName: props.demoName,
- processDataList: demoData.process,
- hintDataList: demoData.hint,
- });
- state.showDemo = true;
- }
- } catch (error) {
- // do nth
- }
-
- watchEffect(() => {
- if (state.isDemoCompleted) {
- return;
- }
-
- if (String(route.name).startsWith("auth")) {
- state.showDemo = false;
- } else {
- state.showDemo = true;
- }
- });
-});
-
-const handleProcessClose = () => {
- state.showDemo = false;
- state.isDemoCompleted = true;
- removeDemo();
-};
-</script>
diff --git a/frontend/src/plugins/demo/components/GuideDialog.vue b/frontend/src/plugins/demo/components/GuideDialog.vue
deleted file mode 100644
index 300c8b3465..0000000000
--- a/frontend/src/plugins/demo/components/GuideDialog.vue
+++ /dev/null
@@ -1,316 +0,0 @@
-<template>
- <teleport to="body">
- <div v-if="shouldShow" ref="coverWrapperRef" class="cover-wrapper"></div>
- <Transition>
- <div
- v-if="shouldShow"
- ref="dialogWrapperRef"
- class="guide-wrapper"
- :class="position"
- >
- <p class="flex flex-row justify-start items-center">
- <BBSpin v-if="loading" class="mr-1" />
- {{ props.title }}
- </p>
- </div>
- </Transition>
- <Transition>
- <div
- v-if="shouldShow"
- ref="highlightWrapperRef"
- class="highlight-wrapper"
- ></div>
- </Transition>
- </teleport>
-</template>
-
-<script lang="ts" setup>
-import { cloneDeep } from "lodash-es";
-import { nextTick, onMounted, onUnmounted, ref, watch } from "vue";
-import {
- getElementBounding,
- getElementMaxZIndex,
- getScrollParent,
- getStylePropertyValue,
- waitForTargetElement,
-} from "../utils";
-
-const props = defineProps({
- title: {
- type: String,
- default: "",
- },
- description: {
- type: String,
- default: "",
- },
- position: {
- type: String,
- default: "bottom",
- },
- targetElementSelector: {
- type: String,
- default: "",
- },
- loading: {
- type: Boolean,
- default: false,
- },
-});
-
-const shouldShow = ref(false);
-const targetElementRef = ref<HTMLElement>();
-const dialogWrapperRef = ref<HTMLElement>();
-const highlightWrapperRef = ref<HTMLElement>();
-const coverWrapperRef = ref<HTMLElement>();
-
-const initialElements = async () => {
- const clonedProps = cloneDeep(props);
- const targetElement = await waitForTargetElement(
- clonedProps.targetElementSelector
- );
- if (!targetElement) {
- return;
- }
-
- targetElementRef.value = targetElement;
- targetElement.classList.add("bb-guide-target-element");
-
- const parentEl = getScrollParent(targetElementRef.value);
- parentEl.addEventListener("scroll", handleScrollableParentScroll);
-
- shouldShow.value = true;
- await updateDialogPosition();
-};
-
-onMounted(() => {
- nextTick(async () => {
- await initialElements();
- });
-});
-
-onUnmounted(() => {
- targetElementRef.value?.classList.remove("bb-guide-target-element");
- const parentEl = getScrollParent(targetElementRef.value);
- parentEl.removeEventListener("scroll", handleScrollableParentScroll);
-});
-
-watch([props], () => {
- nextTick(async () => {
- await initialElements();
- });
-});
-
-const handleScrollableParentScroll = () => {
- if (!targetElementRef.value) {
- return;
- }
- const parentEl = getScrollParent(targetElementRef.value);
- if (
- targetElementRef.value.offsetTop + 8 <
- parentEl.scrollTop + parentEl.offsetTop
- ) {
- shouldShow.value = false;
- } else {
- shouldShow.value = true;
- }
-};
-
-const updateDialogPosition = async () => {
- if (
- !coverWrapperRef.value ||
- !dialogWrapperRef.value ||
- !highlightWrapperRef.value
- ) {
- requestAnimationFrame(() => updateDialogPosition());
- return;
- }
-
- const targetElement = document.body.querySelector(
- props.targetElementSelector
- ) as HTMLElement;
- if (!targetElement) {
- shouldShow.value = false;
- return;
- }
-
- if (getStylePropertyValue(targetElement, "border-radius") !== "0px") {
- highlightWrapperRef.value.style.borderRadius = getStylePropertyValue(
- targetElement,
- "border-radius"
- );
- }
-
- targetElement.classList.add("bb-guide-target-element");
- const maxZIndex = getElementMaxZIndex(targetElement);
- coverWrapperRef.value.style.zIndex = `${Math.max(maxZIndex - 1, 0)}`;
- highlightWrapperRef.value.style.zIndex = `${maxZIndex}`;
- dialogWrapperRef.value.style.zIndex = `${maxZIndex + 1}`;
-
- const bounding = getElementBounding(targetElement);
- if (bounding.width === 0 || bounding.height === 0) {
- shouldShow.value = false;
- return;
- }
-
- if (props.position !== "center") {
- highlightWrapperRef.value.style.top = `${bounding.top}px`;
- highlightWrapperRef.value.style.left = `${bounding.left}px`;
- highlightWrapperRef.value.style.width = `${bounding.width}px`;
- highlightWrapperRef.value.style.height = `${bounding.height}px`;
- }
-
- const dialogBounding = getElementBounding(dialogWrapperRef.value);
- if (props.position === "bottom") {
- dialogWrapperRef.value.style.top = `${bounding.top + bounding.height}px`;
- dialogWrapperRef.value.style.left = `${bounding.left - 4}px`;
- } else if (props.position === "top") {
- dialogWrapperRef.value.style.top = `${
- bounding.top - dialogBounding.height - 8
- }px`;
- dialogWrapperRef.value.style.left = `${bounding.left - 4}px`;
- } else if (props.position === "left") {
- dialogWrapperRef.value.style.top = `${bounding.top - 8}px`;
- dialogWrapperRef.value.style.left = `${
- bounding.left - dialogBounding.width - 12
- }px`;
- } else if (props.position === "right") {
- dialogWrapperRef.value.style.top = `${bounding.top - 4}px`;
- dialogWrapperRef.value.style.left = `${bounding.left + bounding.width}px`;
- } else if (props.position === "bottom-right") {
- dialogWrapperRef.value.style.top = `${bounding.top + bounding.height}px`;
- dialogWrapperRef.value.style.left = `${
- bounding.left + bounding.width - dialogBounding.width
- }px`;
- } else if (props.position === "bottom-center") {
- dialogWrapperRef.value.style.top = `${bounding.top + bounding.height}px`;
- dialogWrapperRef.value.style.left = `${
- bounding.left + (bounding.width - dialogBounding.width) / 2
- }px`;
- }
- requestAnimationFrame(() => updateDialogPosition());
-};
-</script>
-
-<style>
-.bb-guide-target-element {
- z-index: 1;
-}
-</style>
-
-<style scoped>
-.guide-wrapper {
- @apply fixed -top-full -left-full bg-white w-64 m-1 my-2 p-3 px-4 text-base text-slate-900 rounded-lg text-left;
- z-index: 10000;
- box-shadow: 0 4px 36px rgb(33 33 33 / 40%);
-}
-
-.highlight-wrapper {
- @apply fixed pointer-events-none rounded-lg;
- box-shadow: 0 4px 36px rgb(33 33 33 / 40%),
- rgb(33 33 33 / 50%) 0px 0px 0px 100vw;
- z-index: 9999;
-}
-
-.cover-wrapper {
- @apply fixed inset-0 overflow-hidden;
- pointer-events: auto !important;
-}
-
-.v-enter-active,
-.v-leave-active {
- transition: opacity 0.3s ease-in;
-}
-
-.v-enter-from,
-.v-leave-to {
- opacity: 0;
-}
-
-.guide-wrapper.top {
- margin-top: -4px;
-}
-.guide-wrapper.top::before {
- content: "";
- position: absolute;
- bottom: -8px;
- left: 24px;
- border-left: 8px solid transparent;
- border-right: 8px solid transparent;
- border-top: 8px solid white;
-}
-
-.guide-wrapper.bottom {
- margin-top: 16px;
-}
-.guide-wrapper.bottom::before {
- content: "";
- position: absolute;
- top: -8px;
- left: 24px;
- border-left: 8px solid transparent;
- border-right: 8px solid transparent;
- border-bottom: 8px solid white;
-}
-
-.guide-wrapper.bottom-center {
- @apply w-auto text-base;
- margin-top: 12px;
-}
-
-.guide-wrapper.bottom-center::before {
- content: "";
- position: absolute;
- top: -8px;
- left: 50%;
- margin-left: -12px;
- border-left: 8px solid transparent;
- border-right: 8px solid transparent;
- border-bottom: 8px solid white;
-}
-
-.guide-wrapper.bottom-right {
- margin-top: 12px;
-}
-
-.guide-wrapper.bottom-right::before {
- content: "";
- position: absolute;
- top: -8px;
- right: 24px;
- border-left: 8px solid transparent;
- border-right: 8px solid transparent;
- border-bottom: 8px solid white;
-}
-
-.guide-wrapper.left {
- margin: 0;
- margin-top: -6px;
-}
-.guide-wrapper.left::before {
- content: "";
- position: absolute;
- top: 8px;
- right: -10px;
- border-top: 10px solid transparent;
- border-bottom: 10px solid transparent;
- border-left: 10px solid white;
-}
-
-.guide-wrapper.right {
- margin-top: -10px;
-}
-.guide-wrapper.right::before {
- content: "";
- position: absolute;
- top: 16px;
- left: -10px;
- border-top: 10px solid transparent;
- border-bottom: 10px solid transparent;
- border-right: 10px solid white;
-}
-
-.guide-wrapper.center {
- @apply w-auto top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 -mt-16 whitespace-nowrap;
-}
-</style>
diff --git a/frontend/src/plugins/demo/components/ProcessBar.vue b/frontend/src/plugins/demo/components/ProcessBar.vue
deleted file mode 100644
index d6385e7255..0000000000
--- a/frontend/src/plugins/demo/components/ProcessBar.vue
+++ /dev/null
@@ -1,302 +0,0 @@
-<template>
- <div
- v-show="!showRequestDemoDialog"
- class="process-bar-container"
- :class="isCompleted ? 'completed' : ''"
- >
- <span
- v-if="isCompleted"
- class="absolute right-3 top-3 p-px rounded cursor-pointer hover:bg-gray-100 hover:shadow"
- @click="handleCloseButtonClick"
- >
- <heroicons-outline:x class="w-5 h-auto" />
- </span>
- <div
- v-if="isCompleted"
- class="w-full flex flex-col justify-start items-start my-2"
- >
- <p class="text-gray-800 w-full text-2xl leading-10">
- <span class="text-3xl mr-2">🎉</span> Demo completed
- </p>
- </div>
- <div
- v-else-if="currentProcessData"
- class="w-full flex flex-col justify-start items-start"
- >
- <p class="text-gray-800 w-full leading-7">
- {{ currentProcessData.description }}
- </p>
- </div>
- <div v-else class="w-full flex flex-col justify-start items-start">
- <p class="text-gray-800 w-full leading-7">
- Looks like you've got out of the demo process 🙁
- </p>
- <span
- class="border px-3 py-1 mt-2 rounded-lg text-indigo-600 bg-indigo-50 cursor-pointer hover:opacity-80"
- :class="actionButtonFlag ? 'cursor-not-allowed !opacity-80' : ''"
- @click="handleBackToDemoButtonClick"
- >👉 Get back to Demo</span
- >
- </div>
-
- <div
- class="my-4 bg-gray-200 w-full flex flex-row justify-start items-center rounded-full overflow-hidden"
- >
- <div
- class="h-1 bg-indigo-600 rounded-full transition-all duration-500"
- :style="{
- width: processBarWidth,
- }"
- ></div>
- </div>
- <div
- class="relative w-full grid text-base text-gray-400"
- :class="`grid-cols-${processDataList.length}`"
- >
- <div
- v-for="(processData, index) in processDataList"
- :key="index"
- class="select-none flex flex-col justify-start items-center first:items-start last:items-end"
- :class="`${index <= currentProcessIndex ? 'text-indigo-600' : ''} ${
- index <= currentProcessIndex + 1 && !isCompleted
- ? 'cursor-pointer'
- : ''
- }`"
- @click="handleProcessItemClick(processData)"
- >
- <span
- class="absolute -top-6 block w-3 h-3 rounded-full bg-gray-200"
- :class="`${index <= currentProcessIndex ? 'bg-indigo-600' : ''}`"
- ></span>
- <p>{{ processData.title }}</p>
- </div>
- </div>
-
- <div
- v-if="isCompleted"
- class="w-full mt-6 flex flex-col justify-start items-start"
- >
- <div class="w-full flex flex-row justify-between items-center">
- <button
- class="w-auto flex flex-row justify-center items-center border px-3 leading-10 select-none rounded-md hover:opacity-60"
- :class="actionButtonFlag ? 'cursor-wait !opacity-80' : ''"
- @click="handleRestartButtonClick"
- >
- <heroicons-outline:refresh class="w-5 h-auto mr-2" /> Replay
- </button>
- <button
- class="w-auto flex flex-row justify-center items-center border px-3 leading-10 select-none rounded-md hover:opacity-60"
- @click="handleDeployNowButtonClick"
- >
- <img src="../../../assets/deploy.svg" class="w-5 h-auto mr-2" />
- Deploy now
- </button>
- <button
- class="w-auto flex flex-row justify-center items-center px-3 leading-10 select-none rounded-md font-medium bg-indigo-600 text-white shadow hover:opacity-80"
- @click="showRequestDemoDialog = true"
- >
- <heroicons-outline:chat class="w-5 h-auto mr-2" /> Request full demo
- </button>
- </div>
-
- <hr class="w-full bg-gray-50 mt-6" />
-
- <div class="mt-6 w-full grid grid-cols-3 leading-9">
- <p class="col-span-1">More quick demos:</p>
- <div class="w-full col-span-2 grid grid-cols-2 leading-9">
- <a
- class="text-indigo-600 w-full flex flex-row justify-start items-center hover:underline"
- target="_blank"
- href="#placeholder"
- >VCS Integration<heroicons-outline:arrow-right
- class="w-4 h-auto ml-2"
- /></a>
- <a
- class="text-indigo-600 w-full flex flex-row justify-start items-center hover:underline"
- target="_blank"
- href="#placeholder"
- >SQL Editor<heroicons-outline:arrow-right class="w-4 h-auto ml-2"
- /></a>
- <a
- class="text-indigo-600 w-full flex flex-row justify-start items-center hover:underline"
- target="_blank"
- href="#placeholder"
- >SQL Review<heroicons-outline:arrow-right class="w-4 h-auto ml-2"
- /></a>
- </div>
- </div>
- </div>
- <div
- v-else
- v-show="
- currentProcessIndex >= 0 && currentProcessIndex < processDataList.length
- "
- class="w-full flex flex-row justify-between items-center mt-2"
- >
- <span
- class="border px-3 py-1 mt-2 rounded-lg text-indigo-600 bg-indigo-50 cursor-pointer select-none hover:opacity-80"
- :class="`${
- currentProcessIndex === 0 ? '!opacity-40 !cursor-not-allowed' : ''
- } ${actionButtonFlag ? '!cursor-wait !opacity-80' : ''}`"
- @click="handlePrevButtonClick"
- >👈 Prev</span
- >
- <span
- class="border px-3 py-1 mt-2 rounded-lg text-indigo-600 bg-indigo-50 cursor-pointer select-none hover:opacity-80"
- :class="actionButtonFlag ? '!cursor-wait !opacity-80' : ''"
- @click="handleNextButtonClick"
- >{{
- currentProcessIndex < processDataList.length - 1
- ? "Next 👉"
- : "Complete"
- }}</span
- >
- </div>
- </div>
-
- <RequestDemoDialog
- v-show="showRequestDemoDialog"
- @close="handleRequestDemoDialogClose"
- />
-</template>
-
-<script lang="ts" setup>
-import { first, indexOf } from "lodash-es";
-import { computed, ref, watch } from "vue";
-import { useRoute, useRouter } from "vue-router";
-import useAppStore from "../store";
-import { ProcessData } from "../types";
-import RequestDemoDialog from "./RequestDemoDialog.vue";
-
-const emit = defineEmits(["close"]);
-
-const route = useRoute();
-const router = useRouter();
-
-const store = useAppStore();
-const processDataList = computed(() => store.processDataList);
-
-const isCompleted = ref<boolean>(false);
-const actionButtonFlag = ref(false);
-const currentProcessIndex = ref<number>(-1);
-const showRequestDemoDialog = ref(false);
-
-const currentProcessData = computed(() => {
- return currentProcessIndex.value >= 0
- ? processDataList.value[currentProcessIndex.value]
- : undefined;
-});
-const processBarWidth = computed(() => {
- return (
- Math.max(
- (currentProcessIndex.value / (processDataList.value.length - 1)) * 100,
- 2
- ) + "%"
- );
-});
-
-watch(
- route,
- () => {
- actionButtonFlag.value = false;
- let matchedProcessDataIndex = -1;
- for (let i = 0; i < processDataList.value.length; i++) {
- const processData = processDataList.value[i];
- if (window.location.href.includes(processData.url)) {
- matchedProcessDataIndex = i;
- break;
- }
- }
- currentProcessIndex.value = matchedProcessDataIndex;
- },
- {
- immediate: true,
- }
-);
-
-const handleProcessItemClick = (processData: ProcessData) => {
- if (isCompleted.value) {
- return;
- }
-
- actionButtonFlag.value = true;
- const index = indexOf(processDataList.value, processData);
- if (currentProcessIndex.value + 1 >= index) {
- router.push(processData.url);
- }
-};
-
-const handlePrevButtonClick = () => {
- const process = processDataList.value[currentProcessIndex.value - 1];
- if (process) {
- actionButtonFlag.value = true;
- router.push(process.url);
- }
-};
-
-const handleNextButtonClick = async () => {
- if (currentProcessIndex.value === processDataList.value.length - 1) {
- isCompleted.value = true;
- return;
- }
-
- const process = processDataList.value[currentProcessIndex.value + 1];
- if (process) {
- actionButtonFlag.value = true;
- await router.push(process.url);
- }
-};
-
-const handleCloseButtonClick = () => {
- emit("close");
-};
-
-const handleRestartButtonClick = async () => {
- const process = first(processDataList.value);
- if (process) {
- actionButtonFlag.value = true;
- await router.push(process.url);
- }
-};
-
-const handleDeployNowButtonClick = () => {
- window.open(
- "https://www.bytebase.com/docs/get-started/install/overview",
- "_blank"
- );
-};
-
-const handleBackToDemoButtonClick = async () => {
- const process = first(processDataList.value);
- if (process) {
- actionButtonFlag.value = true;
- await router.push(process.url);
- }
-};
-
-const handleRequestDemoDialogClose = () => {
- showRequestDemoDialog.value = false;
-};
-
-watch(currentProcessIndex, () => {
- if (currentProcessIndex.value === processDataList.value.length - 1) {
- // do nth
- } else {
- isCompleted.value = false;
- }
-});
-</script>
-
-<style scoped>
-.process-bar-container {
- @apply max-w-full fixed bottom-4 left-1/2 -translate-x-1/2 translate-y-0 flex flex-col justify-start items-center bg-white px-8 py-6 rounded-lg;
- min-width: 600px;
- z-index: 10001;
- box-shadow: 0 0 24px 8px rgb(0 0 0 / 20%);
- transition: bottom ease 0.4s;
-}
-
-.completed {
- @apply bottom-1/2 translate-y-1/2;
-}
-</style>
diff --git a/frontend/src/plugins/demo/components/RequestDemoDialog.vue b/frontend/src/plugins/demo/components/RequestDemoDialog.vue
deleted file mode 100644
index 345a364713..0000000000
--- a/frontend/src/plugins/demo/components/RequestDemoDialog.vue
+++ /dev/null
@@ -1,88 +0,0 @@
-<template>
- <div
- class="dialog-wrapper fixed top-0 left-0 w-full h-full flex flex-col justify-center items-center"
- >
- <div
- class="dialog-container bg-white relative rounded-lg px-2 pb-6 w-72 h-auto flex flex-col justify-start items-center"
- >
- <span
- class="absolute right-3 top-3 p-px rounded cursor-pointer hover:bg-gray-100 hover:shadow"
- @click="handleCloseButtonClick"
- >
- <heroicons-outline:x class="w-5 h-auto" />
- </span>
- <img src="../../../assets/book-demo.webp" class="w-full h-auto" alt="" />
- <template v-if="!submitted">
- <input
- ref="emailInputRef"
- v-model="email"
- type="text"
- class="w-60 rounded shadow-inner border-gray-300 text-center"
- placeholder="Enter your email"
- @keydown="handleInputKeydown"
- />
- <button
- class="w-60 px-4 mt-4 flex flex-row justify-center items-center leading-10 rounded shadow bg-indigo-600 text-white hover:opacity-80"
- @click="handleRequestButtonClick"
- >
- <heroicons-outline:chat class="w-5 h-auto mr-2" /> Request full demo
- </button>
- </template>
- <template v-else>
- <p class="text-indigo-600 text-xl my-2 font-medium">
- <span class="text-2xl mr-2">🙌</span>Congratulations
- </p>
- <p class="text-sm text-gray-600 leading-10">
- We will contact you in 1 business day!
- </p>
- </template>
- </div>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { ref } from "vue";
-
-const emit = defineEmits(["close"]);
-
-const emailInputRef = ref<HTMLInputElement>();
-const email = ref("");
-const submitted = ref(false);
-
-const handleInputKeydown = (event: KeyboardEvent) => {
- if (event.code === "Enter") {
- handleRequestButtonClick();
- }
-};
-
-const handleCloseButtonClick = () => {
- emit("close");
-};
-
-const handleRequestButtonClick = async () => {
- if (email.value === "") {
- return;
- }
-
- const analytics = (window as any).analytics;
- analytics.identify(email.value, {
- category: "request-demo",
- integrations: {
- MailChimp: {
- subscriptionStatus: "subscribed",
- },
- },
- });
- submitted.value = true;
-};
-</script>
-
-<style scoped>
-.dialog-wrapper {
- z-index: 100000;
-}
-.dialog-wrapper > .dialog-container {
- z-index: 100000;
- box-shadow: 0 0 24px 8px rgb(0 0 0 / 20%);
-}
-</style>
diff --git a/frontend/src/plugins/demo/data.ts b/frontend/src/plugins/demo/data.ts
deleted file mode 100644
index ba92dbe826..0000000000
--- a/frontend/src/plugins/demo/data.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { merge } from "lodash-es";
-import { validateStepData } from "./guide";
-import { DemoData, GuideData } from "./types";
-
-const demoDataCache = new Map<string, DemoData>();
-
-const fetchJSONData = async (path: string) => {
- const res = await fetch("/demo" + path);
- const data = await res.json();
- return data;
-};
-
-export const fetchGuideDataWithName = async (guideName: string) => {
- const recorderData = await fetchJSONData(`/${guideName}/recorder.json`);
- const guideRawData = await fetchJSONData(`/${guideName}/guide.json`);
- const guideData = merge(recorderData, guideRawData) as GuideData;
- guideData.steps = guideData.steps.filter((s) => validateStepData(s));
- return guideData;
-};
-
-export const fetchDemoDataWithName = async (demoName: string) => {
- if (demoDataCache.has(demoName)) {
- return demoDataCache.get(demoName) as DemoData;
- }
-
- const demoData = (await fetchJSONData(`/${demoName}/demo.json`)) as DemoData;
- demoDataCache.set(demoName, demoData);
-
- return demoData;
-};
diff --git a/frontend/src/plugins/demo/guide.ts b/frontend/src/plugins/demo/guide.ts
deleted file mode 100644
index 7253830bab..0000000000
--- a/frontend/src/plugins/demo/guide.ts
+++ /dev/null
@@ -1,236 +0,0 @@
-import { merge } from "lodash-es";
-import { getStringFromI18NText, nextI18NText } from "./i18n";
-import * as storage from "./storage";
-import { Position, GuideData, StepData } from "./types";
-import {
- checkUrlPathnameMatched,
- getElementBounding,
- getElementMaxZIndex,
- isNullOrUndefined,
- waitForTargetElement,
-} from "./utils";
-
-// validateStepData will check if the step data is valid
-export const validateStepData = (stepData: StepData) => {
- // type is required and must be one of ["click", "change"]
- if (stepData.type !== "click" && stepData.type !== "change") {
- return false;
- }
- // title is required
- if (isNullOrUndefined(stepData.title)) {
- return false;
- }
- // description is required
- if (isNullOrUndefined(stepData.description)) {
- return false;
- }
-
- return true;
-};
-
-export const showGuideDialog = async (
- guideData: GuideData,
- stepIndex: number
-) => {
- removeGuideDialog();
- const guideStep = guideData.steps[stepIndex];
- if (!guideStep) {
- return;
- }
-
- if (guideStep.url && !checkUrlPathnameMatched(guideStep.url)) {
- return;
- }
-
- // NOTE: stay empty value for now.
- const targetElement = await waitForTargetElement("");
- if (targetElement) {
- // After got the targetElement, remove the guide dialog again
- // to ensure that only one guide dialog is shown at a time.
- removeGuideDialog();
- renderHighlight(targetElement, guideStep);
- renderGuideDialog(targetElement, guideData, stepIndex);
- requestAnimationFrame(() => updateDialogPosition(targetElement, guideStep));
- }
-};
-
-const renderHighlight = (targetElement: HTMLElement, guideStep: StepData) => {
- const highlightWrapper = document.createElement("div");
- highlightWrapper.className = "bb-demo-element bb-guide-highlight-wrapper";
- document.body.appendChild(highlightWrapper);
- const bounding = getElementBounding(targetElement);
- highlightWrapper.style.top = `${bounding.top}px`;
- highlightWrapper.style.left = `${bounding.left}px`;
- highlightWrapper.style.width = `${bounding.width}px`;
- highlightWrapper.style.height = `${bounding.height}px`;
-
- if (guideStep.cover) {
- const maxZIndex = getElementMaxZIndex(targetElement);
- highlightWrapper.classList.add("covered");
- const coverElement = document.createElement("div");
- coverElement.className = "bb-demo-element bb-guide-cover-wrapper";
- coverElement.style.zIndex = `${maxZIndex - 1}`;
- document.body.appendChild(coverElement);
- targetElement.classList.add("bb-guide-target-element");
- }
-};
-
-const renderGuideDialog = (
- targetElement: HTMLElement,
- guideData: GuideData,
- stepIndex: number
-) => {
- const guideStep = guideData.steps[stepIndex];
- const { description, title, type } = guideStep;
- const guideDialogDiv = document.createElement("div");
- guideDialogDiv.className = "bb-demo-element bb-guide-dialog";
- adjustGuideDialogPosition(targetElement, guideDialogDiv, guideStep.position);
-
- const closeButton = document.createElement("button");
- closeButton.className = "bb-demo-element bb-guide-close-button";
- closeButton.innerHTML = "&times;";
- closeButton.addEventListener("click", () => removeGuideDialog());
- guideDialogDiv.appendChild(closeButton);
-
- const titleElement = document.createElement("p");
- titleElement.className = "bb-demo-element bb-guide-title-text";
- titleElement.innerText = getStringFromI18NText(title);
- guideDialogDiv.appendChild(titleElement);
- const descriptionElement = document.createElement("p");
- descriptionElement.className = "bb-demo-element bb-guide-description-text";
- descriptionElement.innerText = getStringFromI18NText(description);
- guideDialogDiv.appendChild(descriptionElement);
-
- if (!guideStep.hideNextButton) {
- const buttonsContainer = document.createElement("div");
- buttonsContainer.className = "bb-demo-element bb-guide-btns-container";
- const nextButton = document.createElement("button");
- nextButton.className = "bb-demo-element button";
- if (stepIndex === guideData.steps.length - 1) {
- nextButton.innerText = "Done";
- } else {
- nextButton.innerText = getStringFromI18NText(nextI18NText);
- }
- buttonsContainer.appendChild(nextButton);
- guideDialogDiv.appendChild(buttonsContainer);
-
- if (type === "click") {
- nextButton.onclick = () => {
- targetElement.click();
- };
- } else if (type === "change") {
- nextButton.onclick = () => {
- const value =
- targetElement.textContent ||
- targetElement.nodeValue ||
- (targetElement as HTMLInputElement).value ||
- "";
-
- if (guideStep.value && RegExp(guideStep.value).test(value)) {
- const { guide } = storage.get(["guide"]);
- storage.set({
- guide: merge(guide, {
- stepIndex: stepIndex + 1,
- }),
- });
- storage.emitStorageChangedEvent();
- } else {
- // show invalid value message by alert
- alert(`invalid content value, should be like \`${guideStep.value}\``);
- }
- };
- }
- }
-
- if (type === "click") {
- targetElement.addEventListener("click", () => {
- const { guide } = storage.get(["guide"]);
- storage.set({
- guide: merge(guide, {
- stepIndex: stepIndex + 1,
- }),
- });
- if (stepIndex + 1 >= guideData.steps.length) {
- storage.remove(["guide"]);
- }
- storage.emitStorageChangedEvent();
- });
- }
-
- document.body.appendChild(guideDialogDiv);
-};
-
-const adjustGuideDialogPosition = (
- targetElement: HTMLElement,
- guideDialogDiv: HTMLElement,
- position: Position = "bottom"
-) => {
- const bounding = getElementBounding(targetElement);
- const guideDialogBounding = getElementBounding(guideDialogDiv);
-
- if (position === "bottom") {
- guideDialogDiv.style.top = `${bounding.top + bounding.height}px`;
- guideDialogDiv.style.left = `${bounding.left - 4}px`;
- } else if (position === "top") {
- guideDialogDiv.style.top = `${
- bounding.top - guideDialogBounding.height - 8
- }px`;
- guideDialogDiv.style.left = `${bounding.left - 4}px`;
- } else if (position === "left") {
- guideDialogDiv.style.top = `${bounding.top - 4}px`;
- guideDialogDiv.style.left = `${
- bounding.left - guideDialogBounding.width - 8
- }px`;
- } else if (position === "right") {
- guideDialogDiv.style.top = `${bounding.top - 4}px`;
- guideDialogDiv.style.left = `${bounding.left + bounding.width}px`;
- }
-};
-
-const updateDialogPosition = (
- targetElement: HTMLElement,
- guideStep: StepData
-) => {
- const highlightWrapper = document.body.querySelector(
- ".bb-guide-highlight-wrapper"
- ) as HTMLElement;
- const guideDialogDiv = document.body.querySelector(
- ".bb-guide-dialog"
- ) as HTMLElement;
-
- if (!targetElement || !highlightWrapper || !guideDialogDiv) {
- return;
- }
-
- const bounding = getElementBounding(targetElement);
-
- highlightWrapper.style.top = `${bounding.top}px`;
- highlightWrapper.style.left = `${bounding.left}px`;
- highlightWrapper.style.width = `${bounding.width}px`;
- highlightWrapper.style.height = `${bounding.height}px`;
-
- adjustGuideDialogPosition(targetElement, guideDialogDiv, guideStep.position);
-
- requestAnimationFrame(() => updateDialogPosition(targetElement, guideStep));
-};
-
-export const removeGuideDialog = () => {
- document.body.querySelectorAll(".bb-guide-dialog")?.forEach((element) => {
- element.remove();
- });
- document.body
- .querySelectorAll(".bb-guide-highlight-wrapper")
- ?.forEach((element) => {
- element.remove();
- });
- document.body
- .querySelectorAll(".bb-guide-cover-wrapper")
- ?.forEach((element) => {
- element.remove();
- });
- document.body
- .querySelectorAll(".bb-guide-target-element")
- ?.forEach((element) => {
- element.classList.remove("bb-guide-target-element");
- });
-};
diff --git a/frontend/src/plugins/demo/hint.ts b/frontend/src/plugins/demo/hint.ts
deleted file mode 100644
index 7491398f7d..0000000000
--- a/frontend/src/plugins/demo/hint.ts
+++ /dev/null
@@ -1,372 +0,0 @@
-import { indexOf, isUndefined } from "lodash-es";
-import { removeElementBySelector } from "@/utils";
-import { getStringFromI18NText } from "./i18n";
-import { Position, HintData } from "./types";
-import {
- checkUrlMatched,
- getElementBounding,
- getElementMaxZIndex,
- getStylePropertyValue,
- waitForTargetElement,
-} from "./utils";
-
-const closedHintIndexSet = new Set<number>();
-
-export const showHints = async (hintDataList: HintData[]) => {
- const findTargetPromiseList = hintDataList.map(async (hintData) => {
- const index = indexOf(hintDataList, hintData);
-
- if (closedHintIndexSet.has(index) || !checkUrlMatched(hintData.url)) {
- removeHint(index);
- return;
- }
-
- const targetElement = await waitForTargetElement(hintData.selector);
- if (targetElement) {
- renderHint(targetElement, hintData, index);
- } else {
- removeHint(index);
- }
- });
-
- await Promise.all(findTargetPromiseList);
-};
-
-const renderHint = (
- targetElement: HTMLElement,
- hintData: HintData,
- hintIndex: number
-) => {
- if (hintData.type === "tooltip") {
- renderTooltip(targetElement, hintData, hintIndex);
- return;
- }
-
- const hintWrapper = document.createElement("div");
- hintWrapper.className = `bb-demo-element bb-hint-wrapper bb-hint-${hintIndex}`;
- if (hintData.type === "shield") {
- hintWrapper.classList.add("shield");
- }
- removeElementBySelector(`.bb-hint-wrapper.bb-hint-${hintIndex}`);
- document.body.appendChild(hintWrapper);
-
- if (hintData.cover) {
- hintWrapper.classList.add("covered");
- renderCover(targetElement, hintIndex);
- }
-
- const maxZIndex = getElementMaxZIndex(targetElement);
- hintWrapper.style.zIndex = `${maxZIndex}`;
- if (hintData.additionStyle) {
- for (const key in hintData.additionStyle) {
- hintWrapper.style[key] = hintData.additionStyle[key];
- }
- }
- const borderRadius = getStylePropertyValue(targetElement, "border-radius");
- hintWrapper.style.borderRadius = borderRadius;
-
- const bounding = getElementBounding(targetElement);
- hintWrapper.style.top = `${bounding.top}px`;
- hintWrapper.style.left = `${bounding.left}px`;
- hintWrapper.style.width = `${bounding.width}px`;
- hintWrapper.style.height = `${bounding.height}px`;
- hintWrapper.style.pointerEvents = "none";
-
- if (hintData.dialog) {
- if (hintData.dialog.alwaysShow) {
- renderHintDialog(targetElement, hintData, hintIndex);
- } else {
- hintWrapper.style.pointerEvents = "auto";
- hintWrapper.addEventListener(
- "click",
- (e) => {
- e.stopPropagation();
- hintWrapper.style.pointerEvents = "none";
- renderHintDialog(targetElement, hintData, hintIndex);
- if (hintData.dialog?.showOnce) {
- closedHintIndexSet.add(hintIndex);
- }
- },
- {
- once: true,
- }
- );
- }
- }
-
- updateHintPosition(targetElement, hintData, hintIndex);
-};
-
-const renderCover = (targetElement: HTMLElement, hintIndex: number) => {
- const coverElement = document.createElement("div");
- coverElement.className = `bb-demo-element 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");
-};
-
-const updateHintPosition = (
- targetElement: HTMLElement,
- hintData: HintData,
- hintIndex: number
-) => {
- const hintWrapper = document.body.querySelector(
- `.bb-hint-wrapper.bb-hint-${hintIndex}`
- ) as HTMLElement;
-
- if (!targetElement || !hintWrapper) {
- removeHint(hintIndex);
- return;
- }
-
- const bounding = getElementBounding(targetElement);
-
- if (bounding.width === 0 && bounding.height === 0) {
- removeHint(hintIndex);
- return;
- }
-
- hintWrapper.style.top = `${bounding.top}px`;
- hintWrapper.style.left = `${bounding.left}px`;
- hintWrapper.style.width = `${bounding.width}px`;
- hintWrapper.style.height = `${bounding.height}px`;
-
- requestAnimationFrame(() =>
- updateHintPosition(targetElement, hintData, hintIndex)
- );
-};
-
-const renderHintDialog = (
- targetElement: HTMLElement,
- hintData: HintData,
- hintIndex: number
-) => {
- if (isUndefined(hintData.dialog) || closedHintIndexSet.has(hintIndex)) {
- return;
- }
-
- const {
- dialog: { title, description, position, alwaysShow },
- } = hintData;
- const hintDialogDiv = document.createElement("div");
- hintDialogDiv.className = `bb-demo-element bb-hint-dialog bb-hint-${hintIndex} ${
- position ?? "bottom"
- }`;
-
- if (hintData.type === "tooltip") {
- hintDialogDiv.classList.add("tooltip-dialog");
- }
-
- const maxZIndex = getStylePropertyValue(targetElement, "z-index");
- hintDialogDiv.style.zIndex = `${maxZIndex}`;
-
- if (!alwaysShow) {
- const closeButton = document.createElement("button");
- closeButton.className = "bb-demo-element bb-hint-close-button";
- closeButton.innerHTML = "&times;";
- closeButton.addEventListener("click", () => {
- removeHint(hintIndex);
- closedHintIndexSet.add(hintIndex);
- });
- hintDialogDiv.appendChild(closeButton);
- }
-
- if (getStringFromI18NText(title)) {
- const titleElement = document.createElement("p");
- titleElement.className = "bb-demo-element bb-hint-title-text";
- titleElement.innerText = getStringFromI18NText(title);
- hintDialogDiv.appendChild(titleElement);
- }
- if (getStringFromI18NText(description)) {
- const descriptionElement = document.createElement("p");
- descriptionElement.className = "bb-demo-element bb-hint-description-text";
- descriptionElement.innerText = getStringFromI18NText(description);
- hintDialogDiv.appendChild(descriptionElement);
- }
-
- removeElementBySelector(`.bb-hint-dialog.bb-hint-${hintIndex}`);
- document.body.appendChild(hintDialogDiv);
- adjustHintDialogPosition(targetElement, hintDialogDiv, position);
-
- return hintDialogDiv;
-};
-
-const adjustHintDialogPosition = (
- targetElement: HTMLElement,
- hintDialogDiv: HTMLElement,
- position: Position = "bottom"
-) => {
- const bounding = getElementBounding(targetElement);
- const hintDialogBounding = getElementBounding(hintDialogDiv);
-
- if (bounding.width === 0 && bounding.height === 0) {
- hintDialogDiv.remove();
- return;
- }
-
- if (position === "bottom") {
- hintDialogDiv.style.top = `${bounding.top + bounding.height}px`;
- hintDialogDiv.style.left = `${bounding.left - 4}px`;
- } else if (position === "top") {
- hintDialogDiv.style.top = `${
- bounding.top - hintDialogBounding.height - 8
- }px`;
- hintDialogDiv.style.left = `${bounding.left - 4}px`;
- } else if (position === "left") {
- hintDialogDiv.style.top = `${bounding.top - 4}px`;
- hintDialogDiv.style.left = `${
- bounding.left - hintDialogBounding.width - 8
- }px`;
- } else if (position === "right") {
- hintDialogDiv.style.top = `${bounding.top - 4}px`;
- hintDialogDiv.style.left = `${bounding.left + bounding.width}px`;
- } else if (position === "topright") {
- hintDialogDiv.style.top = `${
- bounding.top - hintDialogBounding.height - 8
- }px`;
- hintDialogDiv.style.left = `${
- bounding.left + bounding.width - hintDialogBounding.width
- }px`;
- }
-
- requestAnimationFrame(() =>
- adjustHintDialogPosition(targetElement, hintDialogDiv, position)
- );
-};
-
-const renderTooltip = (
- targetElement: HTMLElement,
- hintData: HintData,
- hintIndex: number
-) => {
- const tooltipWrapper = document.createElement("div");
- tooltipWrapper.className = `bb-demo-element bb-hint-tooltip-wrapper bb-hint-${hintIndex}`;
- const pingElement = document.createElement("span");
- pingElement.className = "bb-demo-element bb-hint-tooltip-ping";
- tooltipWrapper.appendChild(pingElement);
- const blockElement = document.createElement("span");
- blockElement.className = "bb-demo-element bb-hint-tooltip-block";
- tooltipWrapper.appendChild(blockElement);
-
- tooltipWrapper.style.zIndex = `${getElementMaxZIndex(targetElement)}`;
- 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);
- renderHintDialog(tooltipWrapper, hintData, hintIndex);
-
- tooltipWrapper.addEventListener("click", () => {
- targetElement.click();
- removeHint(hintIndex);
- });
-
- requestAnimationFrame(() =>
- updateTooltipPosition(targetElement, hintData, hintIndex)
- );
-};
-
-const updateTooltipPosition = (
- targetElement: HTMLElement,
- hintData: HintData,
- hintIndex: number
-) => {
- const hintWrapper = document.body.querySelector(
- `.bb-hint-tooltip-wrapper.bb-hint-${hintIndex}`
- ) as HTMLElement;
-
- if (!hintWrapper) {
- removeHint(hintIndex);
- return;
- }
-
- const position = hintData.position;
- const bounding = getElementBounding(targetElement);
-
- if (bounding.width === 0 && bounding.height === 0) {
- removeHint(hintIndex);
- return;
- }
-
- if (!position || position === "right") {
- hintWrapper.style.top = `${bounding.top}px`;
- hintWrapper.style.left = `${bounding.left + bounding.width}px`;
- } else if (position === "left") {
- hintWrapper.style.top = `${bounding.top}px`;
- hintWrapper.style.left = `${bounding.left}px`;
- } else if (position === "leftcenter") {
- hintWrapper.style.top = `${bounding.top + bounding.height / 2 - 12}px`;
- hintWrapper.style.left = `${bounding.left}px`;
- } else if (position === "center") {
- hintWrapper.style.top = `${bounding.top + bounding.height / 2 - 12}px`;
- hintWrapper.style.left = `${bounding.left + bounding.width / 2 - 12}px`;
- }
-
- requestAnimationFrame(() =>
- updateTooltipPosition(targetElement, hintData, hintIndex)
- );
-};
-
-export const removeHint = (hintIndex?: number) => {
- if (isUndefined(hintIndex)) {
- const hintWrappers = document.querySelectorAll(".bb-hint-wrapper");
- if (hintWrappers) {
- hintWrappers.forEach((hintWrapper) => {
- hintWrapper.remove();
- });
- }
-
- const hintDialogs = document.querySelectorAll(".bb-hint-dialog");
- if (hintDialogs) {
- hintDialogs.forEach((hintDialog) => {
- hintDialog.remove();
- });
- }
-
- const hintCovers = document.querySelectorAll(".bb-hint-cover-wrapper");
- if (hintCovers) {
- hintCovers.forEach((item) => {
- item.remove();
- });
- }
-
- const hintTooltips = document.querySelectorAll(".bb-hint-tooltip-wrapper");
- if (hintTooltips) {
- hintTooltips.forEach((item) => {
- item.remove();
- });
- }
- } else {
- const hintWrapper = document.querySelector(
- `.bb-hint-wrapper.bb-hint-${hintIndex}`
- );
- if (hintWrapper) {
- hintWrapper.remove();
- }
-
- const hintDialog = document.querySelector(
- `.bb-hint-dialog.bb-hint-${hintIndex}`
- );
- if (hintDialog) {
- hintDialog.remove();
- }
-
- const hintCover = document.querySelector(
- `.bb-hint-cover-wrapper.bb-hint-${hintIndex}`
- );
- if (hintCover) {
- hintCover.remove();
- }
-
- const hintTooltip = document.querySelector(
- `.bb-hint-tooltip-wrapper.bb-hint-${hintIndex}`
- );
- if (hintTooltip) {
- hintTooltip.remove();
- }
- }
-};
diff --git a/frontend/src/plugins/demo/i18n.ts b/frontend/src/plugins/demo/i18n.ts
deleted file mode 100644
index 5119dad41b..0000000000
--- a/frontend/src/plugins/demo/i18n.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { head } from "lodash-es";
-import * as storage from "./storage";
-import { I18NText } from "./types";
-
-export const nextI18NText = {
- "en-US": "Next",
- "zh-CN": "下一步",
- "es-ES": "Siguiente",
-};
-
-export const getStringFromI18NText = (text: string | I18NText) => {
- if (typeof text === "string") {
- return text;
- }
-
- const values = Object.values(text);
- const firstValue = head(values) || "";
- const { bytebase_options: BBOptions } = storage.get(["bytebase_options"]);
-
- if (BBOptions && BBOptions.appearance) {
- const language = BBOptions.appearance.language;
- return text[language] || firstValue;
- }
-
- return firstValue;
-};
diff --git a/frontend/src/plugins/demo/index.ts b/frontend/src/plugins/demo/index.ts
deleted file mode 100644
index d4ce4481f1..0000000000
--- a/frontend/src/plugins/demo/index.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import { isNull } from "lodash-es";
-import { createApp } from "vue";
-import { actuatorServiceClient } from "@/grpcweb";
-import { router } from "@/router";
-import { isDev } from "@/utils";
-import DemoWrapper from "./components/DemoWrapper.vue";
-import { removeGuideDialog } from "./guide";
-import { removeHint } from "./hint";
-import { initLocationListenerForDemo } from "./listener";
-import * as storage from "./storage";
-import { piniaInstance } from "./store";
-import { waitBodyLoaded } from "./utils";
-
-const initDemo = async (demoName: string) => {
- await waitBodyLoaded();
- // mount the demo vue app
- const demoAppContainer = document.createElement("div");
- document.body.appendChild(demoAppContainer);
- const app = createApp(DemoWrapper, {
- demoName,
- });
- app.use(router).use(piniaInstance).mount(demoAppContainer);
-
- storage.set({
- demo: {
- name: demoName,
- },
- });
- // TODO(steven): refactor the pure js element into vue
- await initLocationListenerForDemo();
-
- // inject segment script
- const scriptElement = document.createElement("script");
- scriptElement.innerHTML = `
- !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};analytics._writeKey="CVXXNXv3EzfQPYqHoYvlDDDOXmKa9XOj";;analytics.SNIPPET_VERSION="4.15.3";
- analytics.load("CVXXNXv3EzfQPYqHoYvlDDDOXmKa9XOj");
- analytics.page();
- }}();`;
- document.body.appendChild(scriptElement);
-};
-
-const mountDemoApp = async () => {
- const serverInfo = await actuatorServiceClient.getActuatorInfo({});
-
- // only show feature demo if it's not the default demo.
- if (serverInfo.demoName && serverInfo.demoName != "default") {
- const demoName = serverInfo.demoName;
- if (demoName) {
- initDemo(demoName);
- }
- }
-
- // only using in dev mode
- if (isDev()) {
- const params = new URLSearchParams(window.location.search);
- const demoName = params.get("demo") ?? "";
- if (demoName) {
- initDemo(demoName);
- }
-
- const clearDemo = params.get("cleardemo");
- if (!isNull(clearDemo)) {
- storage.remove(["demo", "guide"]);
- }
- }
-};
-
-export const removeDemo = () => {
- storage.remove(["demo", "guide"]);
- removeHint();
- removeGuideDialog();
-};
-
-export default mountDemoApp;
diff --git a/frontend/src/plugins/demo/listener.ts b/frontend/src/plugins/demo/listener.ts
deleted file mode 100644
index ec0b598b12..0000000000
--- a/frontend/src/plugins/demo/listener.ts
+++ /dev/null
@@ -1,144 +0,0 @@
-import { isEqual } from "lodash-es";
-import { fetchDemoDataWithName, fetchGuideDataWithName } from "./data";
-import { removeGuideDialog, showGuideDialog } from "./guide";
-import { removeHint, showHints } from "./hint";
-import * as storage from "./storage";
-
-const tryToShowGuides = async () => {
- const { guide } = storage.get(["guide"]);
-
- if (guide) {
- const guideData = await fetchGuideDataWithName(guide.name);
- showGuideDialog(guideData, guide.stepIndex);
- } else {
- removeGuideDialog();
- }
-};
-
-const tryToShowHints = async () => {
- const { demo } = storage.get(["demo"]);
-
- if (demo) {
- const demoData = await fetchDemoDataWithName(demo.name);
- showHints(demoData.hint);
- } else {
- removeHint();
- }
-};
-
-// initLocationListenerForGuide using mutation observer to detect DOM changes for mocking location changed.
-const initLocationListenerForGuide = () => {
- let prevLocationString = "";
-
- const observer = new MutationObserver(async () => {
- const locationString = window.location.toString();
-
- if (!isEqual(prevLocationString, locationString)) {
- prevLocationString = locationString;
- tryToShowGuides();
- }
- });
-
- observer.observe(document.body, {
- childList: true,
- subtree: true,
- });
-};
-
-// initMutationListenerForHint using mutation observer to detect DOM changes.
-const initMutationListenerForHint = () => {
- const observer = new MutationObserver((mutations: MutationRecord[]) => {
- setTimeout(async () => {
- for (const mutation of mutations) {
- const changedNodes = [...mutation.addedNodes, ...mutation.removedNodes];
- for (const changedNode of changedNodes) {
- if (
- changedNode instanceof HTMLElement &&
- !changedNode.matches(".bb-demo-element")
- ) {
- await tryToShowHints();
- return;
- }
- }
- }
- });
- });
-
- observer.observe(document.body, {
- childList: true,
- subtree: true,
- });
-};
-
-const initGuideListeners = () => {
- initLocationListenerForGuide();
- window.addEventListener("storage", async () => {
- tryToShowGuides();
- });
-};
-
-const initHintListeners = () => {
- initMutationListenerForHint();
- window.addEventListener("storage", async () => {
- tryToShowHints();
- });
-};
-
-const initDemoListeners = async () => {
- const { demo } = storage.get(["demo"]);
- if (demo && demo.name) {
- const demoData = await fetchDemoDataWithName(demo.name);
- if (demoData) {
- try {
- const guideData = await fetchGuideDataWithName(demo.name);
- if (guideData) {
- await tryToShowGuides();
- initGuideListeners();
- }
- } catch (error) {
- // do nth
- }
-
- try {
- const demoData = await fetchDemoDataWithName(demo.name);
- if (demoData.hint) {
- await tryToShowHints();
- initHintListeners();
- }
- } catch (error) {
- // do nth
- }
- }
- }
-};
-
-export const initLocationListenerForDemo = async () => {
- const { demo } = storage.get(["demo"]);
-
- if (demo && demo.name) {
- const demoData = await fetchDemoDataWithName(demo.name);
- if (demoData) {
- let prevLocationString = "";
-
- const observer = new MutationObserver(async () => {
- const locationString = window.location.toString();
-
- if (!isEqual(prevLocationString, locationString)) {
- prevLocationString = locationString;
- // Do not show demo element in /auth pages.
- if (window.location.pathname.startsWith("/auth")) {
- return;
- }
-
- initDemoListeners();
- observer.disconnect();
- }
- });
-
- observer.observe(document.body, {
- childList: true,
- subtree: true,
- });
- }
- }
-};
diff --git a/frontend/src/plugins/demo/storage.ts b/frontend/src/plugins/demo/storage.ts
deleted file mode 100644
index 7b9086de54..0000000000
--- a/frontend/src/plugins/demo/storage.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Define storage data type for guide
- */
-interface StorageData {
- demo: {
- name: string;
- };
- guide: {
- name: string;
- stepIndex: number;
- };
- bytebase_options: {
- appearance: {
- language: string;
- };
- };
-}
-
-type StorageKey = keyof StorageData;
-
-export function get(keys: StorageKey[]): Partial<StorageData> {
- const data: Partial<StorageData> = {};
-
- for (const key of keys) {
- try {
- const stringifyValue = localStorage.getItem(key);
-
- if (stringifyValue !== null) {
- const val = JSON.parse(stringifyValue);
- data[key] = val;
- }
- } catch (error: any) {
- console.error("Get storage failed in ", key, error);
- }
- }
-
- return data;
-}
-
-export function set(data: Partial<StorageData>) {
- for (const key in data) {
- try {
- const stringifyValue = JSON.stringify(data[key as StorageKey]);
-
- localStorage.setItem(key, stringifyValue);
- } catch (error: any) {
- console.error("Save storage failed in ", key, error);
- }
- }
-}
-
-export function remove(keys: StorageKey[]) {
- for (const key of keys) {
- try {
- localStorage.removeItem(key);
- } catch (error: any) {
- console.error("Remove storage failed in ", key, error);
- }
- }
-}
-
-export function emitStorageChangedEvent() {
- const iframeEl = document.createElement("iframe");
- iframeEl.style.display = "none";
- document.body.appendChild(iframeEl);
-
- iframeEl.contentWindow?.localStorage.setItem("t", Date.now().toString());
- iframeEl.remove();
-}
diff --git a/frontend/src/plugins/demo/store/index.ts b/frontend/src/plugins/demo/store/index.ts
deleted file mode 100644
index 5cca8a32b9..0000000000
--- a/frontend/src/plugins/demo/store/index.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { createPinia, defineStore } from "pinia";
-import { HintData, ProcessData } from "../types";
-
-export const piniaInstance = createPinia();
-
-interface State {
- demoName: string;
- processDataList: ProcessData[];
- hintDataList: HintData[];
-}
-
-const useAppStore = defineStore("appStore", {
- state: (): State => {
- return {
- demoName: "",
- processDataList: [],
- hintDataList: [],
- };
- },
- actions: {
- setState(state: State) {
- this.demoName = state.demoName;
- this.processDataList = state.processDataList;
- this.hintDataList = state.hintDataList;
- },
- },
-});
-
-export default useAppStore;
diff --git a/frontend/src/plugins/demo/style.css b/frontend/src/plugins/demo/style.css
deleted file mode 100644
index 0e8e105091..0000000000
--- a/frontend/src/plugins/demo/style.css
+++ /dev/null
@@ -1,159 +0,0 @@
-.bb-guide-cover-wrapper,
-.bb-hint-cover-wrapper {
- @apply fixed inset-0 overflow-hidden;
- pointer-events: auto !important;
-}
-
-.bb-guide-target-element,
-.bb-hint-target-element {
- z-index: 1;
-}
-
-.bb-guide-highlight-wrapper {
- @apply absolute rounded pointer-events-none;
- box-shadow: rgb(33 33 33 / 80%) 0px 0px 1px 2px;
- z-index: 9999;
-}
-
-.bb-guide-highlight-wrapper.covered {
- box-shadow: rgb(33 33 33 / 80%) 0px 0px 1px 2px,
- rgb(33 33 33 / 50%) 0px 0px 0px 5000px;
-}
-
-.bb-guide-dialog,
-.bb-hint-dialog {
- @apply fixed bg-white w-auto m-1 my-2 p-3 px-4 text-slate-900 rounded-lg text-left -top-full -left-full;
- z-index: 10000;
- max-width: 300px;
- box-shadow: 0 4px 36px rgb(33 33 33 / 40%);
- font-size: 15px;
-}
-
-.bb-hint-dialog.tooltip-dialog {
- @apply mx-2;
-}
-
-.bb-hint-dialog.topright::before {
- content: "";
- position: absolute;
- bottom: -10px;
- right: 24px;
- border-left: 10px solid transparent;
- border-right: 10px solid transparent;
- border-top: 10px solid white;
-}
-
-.bb-hint-dialog.top {
- margin-top: -4px;
-}
-.bb-hint-dialog.top::before {
- content: "";
- position: absolute;
- bottom: -10px;
- left: 24px;
- border-left: 10px solid transparent;
- border-right: 10px solid transparent;
- border-top: 10px solid white;
-}
-
-.bb-hint-dialog.bottom {
- margin-top: 12px;
- margin-left: -17px;
-}
-.bb-hint-dialog.bottom::before {
- content: "";
- position: absolute;
- top: -10px;
- left: 24px;
- border-left: 10px solid transparent;
- border-right: 10px solid transparent;
- border-bottom: 10px solid white;
-}
-
-.bb-hint-dialog.left {
- margin: 0;
- margin-top: -6px;
-}
-.bb-hint-dialog.left::before {
- content: "";
- position: absolute;
- top: 8px;
- right: -10px;
- border-top: 10px solid transparent;
- border-bottom: 10px solid transparent;
- border-left: 10px solid white;
-}
-
-.bb-hint-dialog.right {
- margin-top: -10px;
-}
-.bb-hint-dialog.right::before {
- content: "";
- position: absolute;
- top: 16px;
- left: -10px;
- border-top: 10px solid transparent;
- border-bottom: 10px solid transparent;
- border-right: 10px solid white;
-}
-
-.bb-guide-close-button,
-.bb-hint-close-button {
- @apply absolute top-1 right-1 flex justify-center items-center w-6 h-6 pb-1 rounded cursor-pointer opacity-80 text-gray-600 hover:bg-gray-200 hover:shadow;
- font-size: 20px;
-}
-
-.bb-guide-title-text,
-.bb-hint-title-text {
- @apply text-lg text-black leading-6 py-1 my-1 pr-3 break-words;
-}
-
-.bb-guide-description-text,
-.bb-hint-description-text {
- @apply text-base py-1 text-gray-700 break-words;
-}
-
-.bb-guide-btns-container {
- @apply mt-1 w-full flex flex-row justify-end items-center;
-}
-
-.bb-guide-btns-container > button {
- @apply px-2 py-1 border text-sm rounded hover:opacity-80 hover:border-gray-400;
-}
-
-.bb-hint-wrapper {
- @apply fixed rounded cursor-pointer overflow-hidden;
- z-index: 9999;
-}
-
-.bb-hint-wrapper.covered {
- box-shadow: 0 3px 30px rgb(33 33 33 / 30%), rgb(0 0 0 / 30%) 0px 0px 0px 100vw;
-}
-
-.bb-hint-wrapper.shield {
- @apply border-none rounded-none overflow-hidden bg-transparent shadow-none cursor-not-allowed;
- pointer-events: auto !important;
- backdrop-filter: blur(4px);
- background: rgba(255, 255, 255, 0.4);
-}
-
-.bb-hint-tooltip-wrapper {
- @apply fixed text-xs w-6 h-6 m-0 shadow-none rounded-full cursor-pointer;
- padding: 7px;
- box-sizing: border-box;
-}
-
-.bb-hint-tooltip-wrapper > .bb-hint-tooltip-block {
- @apply block rounded-full;
- width: 10px;
- height: 10px;
- background-color: #4f46e5;
-}
-
-.bb-hint-tooltip-wrapper > .bb-hint-tooltip-ping {
- @apply absolute w-3 h-3 animate-ping rounded-full;
- top: 6px;
- left: 6px;
- background-color: #4f46e5;
- animation-duration: 2s;
-}
diff --git a/frontend/src/plugins/demo/types.ts b/frontend/src/plugins/demo/types.ts
deleted file mode 100644
index 8e83a8d0bb..0000000000
--- a/frontend/src/plugins/demo/types.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-export interface ProcessData {
- url: string;
- title: string | I18NText;
- description: string | I18NText;
-}
-
-export interface DemoData {
- process: ProcessData[];
- hint: HintData[];
-}
-
-type StepType = "click" | "change";
-
-export type Position =
- | "bottom"
- | "top"
- | "left"
- | "right"
- | "topright"
- | "center"
- | "leftcenter";
-
-export type I18NText = {
- [key: string]: string;
-};
-
-export interface StepData {
- type: StepType;
- title: string | I18NText;
- description: string | I18NText;
- selectors: string[][];
- // url is using for validate url in change step
- url?: string;
- // value is the regex-like string using for check the target content value
- value?: string;
- // position is the position of the guide dialog (default is bottom)
- position?: Position;
- // cover is the flag that cover should be shown
- cover?: boolean;
- // hideNextButton is the flag that next button should be hidden
- hideNextButton?: boolean;
-}
-
-export interface GuideData {
- name: string;
- steps: StepData[];
-}
-
-export type HintType = "tooltip" | "shield";
-
-// Hint is a special guide that has no Next button and is always shown.
-export interface HintData {
- selector: string;
- type: HintType;
- // pathname is the wanted pathname of the url, cound be a regex-like string
- pathname: string;
- // url is using for validate url in change step
- url: string;
- highlight?: boolean;
- // cover is the flag that cover should be shown
- cover?: boolean;
- // position is the position of the hint espectially for tooltip (default is right)
- position?: Position;
- // addStyle for customizing the actual style
- // dialog is a data of dialog info. If it's undefined, then the dialog will not be shown.
- dialog?: {
- title: string | I18NText;
- description: string | I18NText;
- // position is the position of the guide dialog (default is bottom)
- position?: Position;
- alwaysShow?: boolean;
- showOnce?: boolean;
- };
- additionStyle?: CSSStyleDeclaration;
-}
diff --git a/frontend/src/plugins/demo/utils.ts b/frontend/src/plugins/demo/utils.ts
deleted file mode 100644
index 93e0130f4b..0000000000
--- a/frontend/src/plugins/demo/utils.ts
+++ /dev/null
@@ -1,174 +0,0 @@
-import { assign, isNumber, isNaN } from "lodash-es";
-
-// getStylePropertyValue returns the value of the given style property of the given element.
-export const getStylePropertyValue = (
- element: HTMLElement,
- propertyName: string
-) => {
- const propertyValue = window
- .getComputedStyle(element)
- .getPropertyValue(propertyName);
-
- return propertyValue;
-};
-
-// isElementFixed returns true if the element is fixed.
-export const isElementFixed = (element: HTMLElement): boolean => {
- const parentNode = element.parentNode;
-
- if (!parentNode || parentNode.nodeName === "HTML") {
- return false;
- }
-
- if (getStylePropertyValue(element, "position") === "fixed") {
- return true;
- }
-
- return isElementFixed(parentNode as HTMLElement);
-};
-
-// getElementBounding returns the bounding rectangle and position of the element.
-export const getElementBounding = (
- element: HTMLElement,
- relativeEl?: HTMLElement
-) => {
- const scrollTop =
- window.pageYOffset ||
- document.documentElement.scrollTop ||
- document.body.scrollTop;
- const scrollLeft =
- window.pageXOffset ||
- document.documentElement.scrollLeft ||
- document.body.scrollLeft;
-
- relativeEl = relativeEl || document.body;
-
- const elementRect = element.getBoundingClientRect();
- const relativeElRect = relativeEl.getBoundingClientRect();
- const relativeElPosition = getStylePropertyValue(relativeEl, "position");
-
- const bounding = {
- width: elementRect.width,
- height: elementRect.height,
- };
-
- if (
- (relativeEl.tagName !== "BODY" && relativeElPosition === "relative") ||
- relativeElPosition === "sticky"
- ) {
- return assign(bounding, {
- top: elementRect.top - relativeElRect.top,
- left: elementRect.left - relativeElRect.left,
- });
- }
-
- if (isElementFixed(element)) {
- return assign(bounding, {
- top: elementRect.top,
- left: elementRect.left,
- });
- }
-
- return assign(bounding, {
- top: elementRect.top + scrollTop,
- left: elementRect.left + scrollLeft,
- });
-};
-
-// getElementMaxZIndex returns the max z-index of the element and its parents.
-export const getElementMaxZIndex = (element: HTMLElement): number => {
- const zIndex = Number(getStylePropertyValue(element, "z-index"));
-
- if (element.parentElement && element.parentElement !== document.body) {
- if (isNumber(zIndex) && !isNaN(zIndex)) {
- return Math.max(zIndex, getElementMaxZIndex(element.parentElement));
- }
- return getElementMaxZIndex(element.parentElement);
- }
-
- return 0;
-};
-
-const getTargetElementWithSelector = (selector: string) => {
- let targetElement = null;
- try {
- targetElement = document.body.querySelector(selector) as HTMLElement;
- } catch (error) {
- // do nth
- }
- return targetElement;
-};
-
-// waitForTargetElement will wait for the target element to be available in the DOM.
-export const waitForTargetElement = (
- selector: string
-): Promise<HTMLElement> => {
- return new Promise((resolve) => {
- let targetElement = getTargetElementWithSelector(selector);
- if (targetElement) {
- return resolve(targetElement);
- }
-
- const observer = new MutationObserver(() => {
- targetElement = getTargetElementWithSelector(selector);
- if (targetElement) {
- observer.disconnect();
- return resolve(targetElement);
- }
- });
-
- observer.observe(document.body, {
- childList: true,
- subtree: true,
- });
- });
-};
-
-export const waitBodyLoaded = () => {
- return new Promise((resolve) => {
- let t = setTimeout(() => {
- resolve(undefined);
- }, 1000);
-
- const observer = new MutationObserver(() => {
- clearTimeout(t);
- t = setTimeout(() => {
- resolve(undefined);
- }, 1000);
- });
-
- observer.observe(document.body, {
- childList: true,
- subtree: true,
- });
- });
-};
-
-// checkUrlMatched is used to check if the given url's pathname is matched with the location pathname.
-export const checkUrlPathnameMatched = (url: string) => {
- const urlObject = new URL(url);
- return urlObject.pathname === window.location.pathname;
-};
-
-export const checkUrlMatched = (url: string) => {
- const regex = new RegExp(url);
- return regex.test(window.location.href);
-};
-
-export const isNullOrUndefined = (value: any) => {
- return value === null || value === undefined;
-};
-
-export const getScrollParent = (
- element: HTMLElement | null | undefined
-): HTMLElement => {
- if (!element) {
- return document.body;
- }
-
- if (element.scrollHeight > element.clientHeight) {
- return element;
- } else {
- return getScrollParent(element.parentElement);
- }
-};
diff --git a/frontend/src/store/modules/help.ts b/frontend/src/store/modules/help.ts
index 753dea86b9..c615b7c145 100644
--- a/frontend/src/store/modules/help.ts
+++ b/frontend/src/store/modules/help.ts
@@ -1,5 +1,5 @@
import { defineStore } from "pinia";
-import { useActuatorV1Store, useOnboardingGuideStore } from "@/store";
+import { useActuatorV1Store } from "@/store";
export const useHelpStore = defineStore("help", {
state: (): {
@@ -14,15 +14,14 @@ export const useHelpStore = defineStore("help", {
actions: {
showHelp(id: string, openByDefault: boolean): void {
const actuatorStore = useActuatorV1Store();
- const onboardingGuideName = useOnboardingGuideStore().guideName;
const demoName = actuatorStore.serverInfo?.demoName;
const invalidFeatureDemoNameList = ["dev", "prod"];
const isFeatureDemo =
demoName && !invalidFeatureDemoNameList.includes(demoName);
- // Do not show help in live demo and onboarding guide
- if (!isFeatureDemo && !onboardingGuideName) {
+ // Do not show help in live demo.
+ if (!isFeatureDemo) {
this.currHelpId = id;
this.openByDefault = openByDefault;
}
diff --git a/frontend/src/store/modules/index.ts b/frontend/src/store/modules/index.ts
index 46c3ff9547..8bfdd51913 100644
--- a/frontend/src/store/modules/index.ts
+++ b/frontend/src/store/modules/index.ts
@@ -22,7 +22,6 @@ export * from "./task";
export * from "./uistate";
export * from "./sqlReview";
export * from "./onboardingState";
-export * from "./onboardingGuide";
export * from "./idp";
export * from "./user";
export * from "./risk";
@@ -30,7 +29,5 @@ export * from "./workspaceApprovalSetting";
export * from "./slowQuery";
export * from "./role";
export * from "./dbGroup";
-
-export * from "./v1";
-
export * from "./utils";
+export * from "./v1";
diff --git a/frontend/src/store/modules/onboardingGuide.ts b/frontend/src/store/modules/onboardingGuide.ts
deleted file mode 100644
index 80a08ecc28..0000000000
--- a/frontend/src/store/modules/onboardingGuide.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { defineStore } from "pinia";
-import { OnboardingGuideType, OnboardingGuideState } from "@/types";
-
-export const useOnboardingGuideStore = defineStore("onboarding_guide", {
- state: (): OnboardingGuideState => ({
- guideName: undefined,
- }),
- actions: {
- setGuideName(guideName: OnboardingGuideType) {
- this.guideName = guideName;
- },
- removeGuide() {
- this.guideName = undefined;
- },
- },
-});
diff --git a/frontend/src/store/modules/sqlEditor.ts b/frontend/src/store/modules/sqlEditor.ts
index 9eff927b59..d25906d0f6 100644
--- a/frontend/src/store/modules/sqlEditor.ts
+++ b/frontend/src/store/modules/sqlEditor.ts
@@ -4,7 +4,6 @@ import {
QueryInfo,
QueryHistory,
ActivitySQLEditorQueryPayload,
- SingleSQLResult,
} from "@/types";
import { UNKNOWN_ID } from "@/types";
import { QueryResult } from "@/types/proto/v1/sql_service";
@@ -101,13 +100,6 @@ export const useSQLEditorStore = defineStore("sqlEditor", {
},
});
-export const mockAffectedRows0 = (): SingleSQLResult => {
- return {
- data: [["Affected Rows"], ["BIGINT"], [[0]], [false]],
- error: "",
- };
-};
-
export const mockAffectedV1Rows0 = (): QueryResult => {
return QueryResult.fromPartial({
columnNames: ["Affected Rows"],
diff --git a/frontend/src/types/onboardingGuide.ts b/frontend/src/types/onboardingGuide.ts
index 279b10fcb5..e69de29bb2 100644
--- a/frontend/src/types/onboardingGuide.ts
+++ b/frontend/src/types/onboardingGuide.ts
@@ -1,2 +0,0 @@
-// OnboardingGuideType is type for the unique names of onboarding guide.
-export type OnboardingGuideType = "create-database";
diff --git a/frontend/src/types/store.ts b/frontend/src/types/store.ts
index 79941a053b..943478bec5 100644
--- a/frontend/src/types/store.ts
+++ b/frontend/src/types/store.ts
@@ -1,4 +1,4 @@
-import { MigrationHistoryId, QueryHistory, OnboardingGuideType } from ".";
+import { MigrationHistoryId, QueryHistory } from ".";
import { InstanceUser } from "./InstanceUser";
import { Backup } from "./backup";
import { Command } from "./common";
@@ -105,7 +105,3 @@ export interface SQLEditorState {
export interface DebugState {
isDebug: boolean;
}
-
-export interface OnboardingGuideState {
- guideName?: OnboardingGuideType;
-}
diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts
index be6b124b84..d77697023d 100644
--- a/frontend/src/utils/util.ts
+++ b/frontend/src/utils/util.ts
@@ -297,3 +297,21 @@ export const keyboardShortcutStr = (str: string) => {
})
.join("+");
};
+
+export const isNullOrUndefined = (value: any) => {
+ return value === null || value === undefined;
+};
+
+export const getScrollParent = (
+ element: HTMLElement | null | undefined
+): HTMLElement => {
+ if (!element) {
+ return document.body;
+ }
+
+ if (element.scrollHeight > element.clientHeight) {
+ return element;
+ } else {
+ return getScrollParent(element.parentElement);
+ }
+};