Skip to content

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

feat: help integration (#1861)

ZhengX3d6b464d7416
diff --git a/frontend/package.json b/frontend/package.json
index a56308e43f..d2c2914d36 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -13,13 +13,16 @@
},
"dependencies": {
"@bytebase/vue-kbar": "^0.1.6",
+ "@markdoc/markdoc": "^0.1.3",
"@soerenmartius/vue3-clipboard": "^0.1.2",
"@vueuse/core": "^8.6.0",
"axios": "^0.26.0",
"dayjs": "^1.10.7",
+ "dompurify": "^2.3.9",
"escape-string-regexp": "^5.0.0",
"highlight.js": "^11.0.1",
"inter-ui": "^3.15.0",
+ "js-yaml": "^4.1.0",
"lodash-es": "^4.17.21",
"monaco-editor": "^0.33.0",
"naive-ui": "^2.30.0",
@@ -39,12 +42,14 @@
"vueuc": "^0.4.27"
},
"devDependencies": {
- "@rollup/plugin-yaml": "^3.1.0",
"@iconify/json": "^1.1.432",
"@intlify/vite-plugin-vue-i18n": "^3.2.1",
+ "@rollup/plugin-yaml": "^3.1.0",
"@tailwindcss/forms": "^0.5.0",
"@tailwindcss/line-clamp": "^0.3.1",
"@tailwindcss/typography": "^0.5.2",
+ "@types/dompurify": "^2.3.3",
+ "@types/js-yaml": "^4.0.5",
"@types/lodash-es": "^4.17.4",
"@types/node": "^16.11.9",
"@types/papaparse": "^5.3.1",
diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml
index 95c9b960a1..a1d0bc0aba 100644
--- a/frontend/pnpm-lock.yaml
+++ b/frontend/pnpm-lock.yaml
@@ -4,11 +4,14 @@ specifiers:
'@bytebase/vue-kbar': ^0.1.6
'@iconify/json': ^1.1.432
'@intlify/vite-plugin-vue-i18n': ^3.2.1
+ '@markdoc/markdoc': ^0.1.3
'@rollup/plugin-yaml': ^3.1.0
'@soerenmartius/vue3-clipboard': ^0.1.2
'@tailwindcss/forms': ^0.5.0
'@tailwindcss/line-clamp': ^0.3.1
'@tailwindcss/typography': ^0.5.2
+ '@types/dompurify': ^2.3.3
+ '@types/js-yaml': ^4.0.5
'@types/lodash-es': ^4.17.4
'@types/node': ^16.11.9
'@types/papaparse': ^5.3.1
@@ -27,6 +30,7 @@ specifiers:
autoprefixer: ^10.4.4
axios: ^0.26.0
dayjs: ^1.10.7
+ dompurify: ^2.3.9
escape-string-regexp: ^5.0.0
eslint: ^8.3.0
eslint-config-prettier: ^8.3.0
@@ -34,6 +38,7 @@ specifiers:
eslint-plugin-vue: ^8.1.1
highlight.js: ^11.0.1
inter-ui: ^3.15.0
+ js-yaml: ^4.1.0
lodash-es: ^4.17.21
monaco-editor: ^0.33.0
naive-ui: ^2.30.0
@@ -63,13 +68,16 @@ specifiers:
dependencies:
'@bytebase/vue-kbar': [email protected]
+ '@markdoc/markdoc': 0.1.3
'@soerenmartius/vue3-clipboard': 0.1.2
'@vueuse/core': [email protected]
axios: 0.26.1
dayjs: 1.10.8
+ dompurify: 2.3.9
escape-string-regexp: 5.0.0
highlight.js: 11.5.0
inter-ui: 3.19.3
+ js-yaml: 4.1.0
lodash-es: 4.17.21
monaco-editor: 0.33.0
@@ -95,6 +103,8 @@ devDependencies:
'@tailwindcss/forms': [email protected]
'@tailwindcss/line-clamp': [email protected]
'@tailwindcss/typography': [email protected]
+ '@types/dompurify': 2.3.3
+ '@types/js-yaml': 4.0.5
'@types/lodash-es': 4.17.6
'@types/node': 16.11.26
'@types/papaparse': 5.3.2
@@ -296,8 +306,8 @@ packages:
vue-i18n:
optional: true
dependencies:
- '@intlify/message-compiler': 9.2.0-beta.36
- '@intlify/shared': 9.2.0-beta.36
+ '@intlify/message-compiler': 9.2.0-beta.37
+ '@intlify/shared': 9.2.0-beta.37
jsonc-eslint-parser: 1.4.1
source-map: 0.6.1
@@ -326,11 +336,11 @@ packages:
'@intlify/shared': 9.2.0-beta.32
source-map: 0.6.1
- /@intlify/message-compiler/9.2.0-beta.36:
- resolution: {integrity: sha512-u4EwW/U9Mc50G7vM1p24UQ3aPrrkm0eM60xKRLVib1XKpH+TK8taLeetSVPI/8mNOBkLNpXmysMfhD3HlsXHIA==}
- engines: {node: '>= 12'}
+ /@intlify/message-compiler/9.2.0-beta.37:
+ resolution: {integrity: sha512-7V5bJ5b5OqYTOa+Pfl4ugB6p/16yB4R/37i5vIaPzNW3Lhg8hdNoo+mtLPp1VKs1zmgpSjYi/rvDobGkHJvr2g==}
+ engines: {node: '>= 14'}
dependencies:
- '@intlify/shared': 9.2.0-beta.36
+ '@intlify/shared': 9.2.0-beta.37
source-map: 0.6.1
dev: true
@@ -338,9 +348,9 @@ packages:
resolution: {integrity: sha512-lVaHnKFNg16eWlfDLzDFLapurrf0WK7xLWEkz8DMYNIXJshRQOZCkH7sQaqtONPoOT0LqjyPo1+sV0Wq85/HRQ==}
engines: {node: '>= 12'}
- /@intlify/shared/9.2.0-beta.36:
- resolution: {integrity: sha512-+IXLiQ0V+9muzEf7RT9t9wEh6hNIK+kq+34Lce8W+DYny/jaFxPWIU4REYja3xC16kV7q+fz4I3vFz03gh7ysA==}
- engines: {node: '>= 12'}
+ /@intlify/shared/9.2.0-beta.37:
+ resolution: {integrity: sha512-TVh69KwsY1A4Vo/ODJEp9NPW9O6zO1id4hwohaMdcibPdTp9ieX00QU9OiPRJ8Iz6W6A9xjU0Q30RAX1ba4+5g==}
+ engines: {node: '>= 14'}
dev: true
/@intlify/vite-plugin-vue-i18n/3.3.1_5zistg762mnnb5dqki47v4swhy:
@@ -357,7 +367,7 @@ packages:
optional: true
dependencies:
'@intlify/bundle-utils': [email protected]
- '@intlify/shared': 9.2.0-beta.36
+ '@intlify/shared': 9.2.0-beta.37
'@rollup/pluginutils': 4.2.0
debug: 4.3.3
fast-glob: 3.2.11
@@ -379,6 +389,11 @@ packages:
resolution: {integrity: sha512-zMM9Ds+SawiUkakS7y94Ymqx+S0ORzpG3frZirN3l+UlXUmSUR7hF4wxCVqW+ei94JzV5kt0uXBcoOEAuiydrw==}
dev: false
+ /@markdoc/markdoc/0.1.3:
+ resolution: {integrity: sha512-4n2cobUSeOob+237wZhpNiOEHCSfOydlQnKHTFdRY6ug/DupXGaxkkkszJYQxRftiMs8jmb10XvVO1svEYD43Q==}
+ engines: {node: '>=14.7.0'}
+ dev: false
+
/@nodelib/fs.scandir/2.1.5:
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
engines: {node: '>= 8'}
@@ -474,6 +489,12 @@ packages:
resolution: {integrity: sha512-/ceqdqeRraGolFTcfoXNiqjyQhZzbINDngeoAq9GoHa8PPK1yNzTaxWjA6BFWp5Ua9JpXEMSS4s5i9tS0hOJtw==}
dev: true
+ /@types/dompurify/2.3.3:
+ resolution: {integrity: sha512-nnVQSgRVuZ/843oAfhA25eRSNzUFcBPk/LOiw5gm8mD9/X7CNcbRkQu/OsjCewO8+VIYfPxUnXvPEVGenw14+w==}
+ dependencies:
+ '@types/trusted-types': 2.0.2
+ dev: true
+
/@types/estree/0.0.39:
resolution: {integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==}
dev: true
@@ -485,6 +506,10 @@ packages:
pretty-format: 27.5.1
dev: false
+ /@types/js-yaml/4.0.5:
+ resolution: {integrity: sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA==}
+ dev: true
+
/@types/json-schema/7.0.9:
resolution: {integrity: sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==}
dev: true
@@ -545,6 +570,10 @@ packages:
resolution: {integrity: sha512-5eQEtSCoESnh2FsiLTxE121IiE60hnMqcb435fShf4bpLRjEu1Eoekht23y6zXS9Ts3l+Szu3TARnTsA0GkOkQ==}
dev: true
+ /@types/trusted-types/2.0.2:
+ resolution: {integrity: sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg==}
+ dev: true
+
/@types/uuid/8.3.4:
resolution: {integrity: sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==}
dev: true
@@ -862,7 +891,7 @@ packages:
optional: true
dependencies:
vue: 3.2.31
- vue-demi: [email protected]
+ vue-demi: [email protected]
dev: false
/@vueuse/shared/[email protected]:
@@ -1303,6 +1332,10 @@ packages:
esutils: 2.0.3
dev: true
+ /dompurify/2.3.9:
+ resolution: {integrity: sha512-3zOnuTwup4lPV/GfGS6UzG4ub9nhSYagR/5tB3AvDEwqyy5dtyCM2dVjwGDCnrPerXifBKTYh/UWCGKK7ydhhw==}
+ dev: false
+
/electron-to-chromium/1.4.89:
resolution: {integrity: sha512-z1Axg0Fu54fse8wN4fd+GAINdU5mJmLtcl6bqIcYyzNVGONcfHAeeJi88KYMQVKalhXlYuVPzKkFIU5VD0raUw==}
dev: true
@@ -2087,7 +2120,6 @@ packages:
hasBin: true
dependencies:
argparse: 2.0.1
- dev: true
/json-parse-even-better-errors/2.3.1:
resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==}
@@ -2962,7 +2994,7 @@ packages:
diff2html: 3.4.16
highlight.js: 10.7.3
vue: 3.2.31
- vue-demi: [email protected]
+ vue-demi: [email protected]
dev: false
/v8-compile-cache/2.3.0:
@@ -3097,8 +3129,8 @@ packages:
vue: 3.2.31
dev: false
- /vue-demi/[email protected]:
- resolution: {integrity: sha512-41ukrclEbMddAyP7PvxMSYqnOSzPV6r7GNnyTSKSCNTaz19GehxmTiXyP9kwHSUv2+Dr6hHqiUiF7L1VAw2KdQ==}
+ /vue-demi/[email protected]:
+ resolution: {integrity: sha512-KP4lq9uSz0KZbaqCllRhnxMV3mYRsRWJfdsAhZyt5bV5O1RTpoeDptBRV9NOa/JgOpfaA9ane88VF7OjWNK/DA==}
engines: {node: '>=12'}
hasBin: true
requiresBuild: true
diff --git a/frontend/public/help/README.md b/frontend/public/help/README.md
new file mode 100644
index 0000000000..676ff67135
--- /dev/null
+++ b/frontend/public/help/README.md
@@ -0,0 +1,5 @@
+## Help file naming rules
+
+Let's name our help files based on routes/domains, and all files should start with `help.` to indicate that it is a help doc. For example, `help.environment.md` is the help file that stands for the whole `/environment` page. If you want to create a more detailed help file to explain *Approval Policy* under `\environment`, you can name the file to `help.environment.approval-policy.md`.
+
+If the objective of the explanation doesn't belong to any specific route/domain, we can name it with `help.global...`.
diff --git a/frontend/public/help/config.ts b/frontend/public/help/config.ts
new file mode 100644
index 0000000000..280abf60d1
--- /dev/null
+++ b/frontend/public/help/config.ts
@@ -0,0 +1,20 @@
+// This file contains the configuration for the help system.
+
+// Below is a mapping object from the route name to the help document name.
+// If you're going to add a new mapping rule, you can add a new line between the curly brackets {}.
+// The format is:
+//
+// "name of route": "markdown's file name without '.md'",
+//
+// For example, "workspace.project": "help.project" means let's connect the help.project.md file with the route "/project".
+//
+// Note: 1. Configs here only works on /issue, /project, /db, /instance, /environment and /setting. If you
+// want to add help in other places, please ask developers for help.
+// 2. Make sure that the markdown file is in both /en and /zh directory.
+
+export const routeHelpNameMap = {
+ "workspace.project": "help.project",
+ "workspace.instance": "help.instance",
+ "workspace.database": "help.database",
+ "workspace.environment": "help.environment",
+};
diff --git a/frontend/public/help/en/help.database.md b/frontend/public/help/en/help.database.md
new file mode 100644
index 0000000000..06ed5d9a52
--- /dev/null
+++ b/frontend/public/help/en/help.database.md
@@ -0,0 +1,7 @@
+---
+title: How to setup 'Database' ?
+---
+
+- Each Bytebase database maps to the one created by 'CREATE DATABASE xxx'. In Bytebase, a database always belongs to a single project.
+
+- Bytebase will periodically sync the database info for every recorded instance. You can also create a new database from the dashboard.
diff --git a/frontend/public/help/en/help.environment.md b/frontend/public/help/en/help.environment.md
new file mode 100644
index 0000000000..c075769467
--- /dev/null
+++ b/frontend/public/help/en/help.environment.md
@@ -0,0 +1,7 @@
+---
+title: How to setup 'Environment' ?
+---
+
+- Each environment maps to one of your testing, staging, prod environment respectively.\n\nEnvironment is a global setting, one Bytebase deployment only contains a single set of environments.
+
+- Database instances are created under a particular environment.
\ No newline at end of file
diff --git a/frontend/public/help/en/help.instance.md b/frontend/public/help/en/help.instance.md
new file mode 100644
index 0000000000..c4ddfc26b8
--- /dev/null
+++ b/frontend/public/help/en/help.instance.md
@@ -0,0 +1,7 @@
+---
+title: How to setup 'Instance' ?
+---
+
+- Each Bytebase instance belongs to an environment. An instance usually maps to one of your database instance represented by an host:port address. This could be your on-premises MySQL instance or RDS instance.
+
+- Bytebase requires read/write (NOT the super privilege) access to the instance in order to perform database operations on behalf of the user.
diff --git a/frontend/public/help/en/help.project.md b/frontend/public/help/en/help.project.md
new file mode 100644
index 0000000000..607d8742aa
--- /dev/null
+++ b/frontend/public/help/en/help.project.md
@@ -0,0 +1,9 @@
+---
+title: How to setup 'project' ?
+---
+
+- Bytebase project is similar to the project concept in other common dev tools.
+
+- A project has its own members, and every issue and database always belongs to a single project.
+
+- A project can also be configured to link to a repository to enable version control workflow.
diff --git a/frontend/public/help/zh/help.database.md b/frontend/public/help/zh/help.database.md
new file mode 100644
index 0000000000..846abf46eb
--- /dev/null
+++ b/frontend/public/help/zh/help.database.md
@@ -0,0 +1,9 @@
+---
+title: 如何设置「数据库」?
+---
+
+- 每个 Bytebase 数据库都映射到由「CREATE DATABASE xxx」创建的一个数据库。
+
+- 在 Bytebase 中,一个数据库始终属于单个项目。Bytebase 将定期同步每个实例的数据库信息。
+
+- 您还可以从仪表板创建新数据库。
\ No newline at end of file
diff --git a/frontend/public/help/zh/help.environment.md b/frontend/public/help/zh/help.environment.md
new file mode 100644
index 0000000000..b0d8846556
--- /dev/null
+++ b/frontend/public/help/zh/help.environment.md
@@ -0,0 +1,9 @@
+---
+title: 如何创建「环境」?
+---
+
+- 每个环境与您的诸如测试,预发,生产环境一一对应。
+
+- 环境是一个全局配置,一套 Bytebase 的部署也只包含一套环境配置的集合。
+
+- 数据库实例是创建在某个特定环境下面的。
\ No newline at end of file
diff --git a/frontend/public/help/zh/help.instance.md b/frontend/public/help/zh/help.instance.md
new file mode 100644
index 0000000000..2426fd95c3
--- /dev/null
+++ b/frontend/public/help/zh/help.instance.md
@@ -0,0 +1,8 @@
+---
+title: 如何设置「实例」?
+---
+
+- 每个 Bytebase 实例属于一个环境。一个实例通常映射到您的一个由 host:port 地址所代表的数据库实例。这可能是您在诸如 AWS 上的
+RDS 实例,也可能是您私有化部署的 MySQL 实例。
+
+- Bytebase 要求实例的读写权限(而不是 super 权限)以代表用户执行数据库操作。
diff --git a/frontend/public/help/zh/help.project.md b/frontend/public/help/zh/help.project.md
new file mode 100644
index 0000000000..bda282a61f
--- /dev/null
+++ b/frontend/public/help/zh/help.project.md
@@ -0,0 +1,9 @@
+---
+title: 如何创建您的「项目」 ?
+---
+
+- 在 Bytebase 中,项目的概念与其他常见的的开发工具类似。
+
+- 一个项目会有属于他的协作成员,并且每一个数据库和工单总是归属于某一个项目。
+
+- 同时,一个项目可以关联一个代码仓库,并以此来进行版本控制。
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index 81f9c0e304..bf4dd676d9 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -16,6 +16,7 @@
@close="removeNotification"
/>
</template>
+ <HelpDrawer />
</KBarWrapper>
</BBModalStack>
</NDialogProvider>
@@ -30,6 +31,7 @@ import { isDev } from "./utils";
import { BBNotificationItem } from "./bbkit/types";
import KBarWrapper from "./components/KBar/KBarWrapper.vue";
import BBModalStack from "./bbkit/BBModalStack.vue";
+import HelpDrawer from "@/components/HelpDrawer.vue";
import { NConfigProvider, NDialogProvider } from "naive-ui";
import { themeOverrides, dateLang, generalLang } from "../naive-ui.config";
diff --git a/frontend/src/components/Breadcrumb.vue b/frontend/src/components/Breadcrumb.vue
index 4c9975cdf2..e224912020 100644
--- a/frontend/src/components/Breadcrumb.vue
+++ b/frontend/src/components/Breadcrumb.vue
@@ -1,5 +1,5 @@
<template>
- <nav class="flex" aria-label="Breadcrumb" data-label="bb-breadcrumb">
+ <nav class="flex flex-row justify-between" aria-label="Breadcrumb" data-label="bb-breadcrumb">
<div v-for="(item, index) in breadcrumbList" :key="index">
<div class="flex items-center space-x-2">
<router-link
@@ -44,6 +44,11 @@
</button>
</div>
</div>
+ <HelpTriggerIcon
+ v-if="currentRoute.name in routeHelpNameMap"
+ :name="routeHelpNameMap[currentRoute.name]"
+ :is-guide="true"
+ />
</nav>
</template>
@@ -61,6 +66,8 @@ import {
useDatabaseStore,
useProjectStore,
} from "@/store";
+import HelpTriggerIcon from "@/components/HelpTriggerIcon.vue";
+import { routeHelpNameMap } from "../../public/help/config";
interface BreadcrumbItem {
name: string;
@@ -69,7 +76,9 @@ interface BreadcrumbItem {
export default defineComponent({
name: "Breadcrumb",
- components: {},
+ components: {
+ HelpTriggerIcon,
+ },
setup() {
const routerStore = useRouterStore();
const currentRoute = useRouter().currentRoute;
@@ -198,6 +207,8 @@ export default defineComponent({
isBookmarked,
breadcrumbList,
toggleBookmark,
+ currentRoute,
+ routeHelpNameMap,
};
},
});
diff --git a/frontend/src/components/HelpDrawer.vue b/frontend/src/components/HelpDrawer.vue
new file mode 100644
index 0000000000..bd111d6416
--- /dev/null
+++ b/frontend/src/components/HelpDrawer.vue
@@ -0,0 +1,115 @@
+<template>
+ <n-drawer
+ v-model:show="active"
+ :width="380"
+ :placement="placement"
+ :on-after-leave="onClose"
+ >
+ <n-drawer-content
+ :title="state.frontmatter.title"
+ closable
+ :native-scrollbar="false"
+ >
+ <template #default>
+ <!-- eslint-disable-next-line vue/no-v-html -->
+ <div v-if="state.html" v-html="state.html"></div>
+ </template>
+ </n-drawer-content>
+ </n-drawer>
+</template>
+
+<script lang="ts">
+import {
+ defineComponent,
+ ref,
+ inject,
+ onMounted,
+ onUnmounted,
+ reactive,
+} from "vue";
+import { NDrawer, NDrawerContent, DrawerPlacement } from "naive-ui";
+import Markdoc, { Node, Tag } from "@markdoc/markdoc";
+import DOMPurify from "dompurify";
+import yaml from "js-yaml";
+import { Event } from "@/utils";
+import { useLanguage } from "@/composables/useLanguage";
+import { useUIStateStore } from "@/store";
+import { EventType } from "@/types";
+
+interface State {
+ frontmatter: Record<string, string>;
+ html: string;
+}
+
+export default defineComponent({
+ components: { NDrawer, NDrawerContent },
+ setup() {
+ const event = inject("event") as Event;
+ const helpName = ref<string>("");
+ const isHelpGuide = ref<boolean>(false);
+ const active = ref(false);
+ const placement = ref<DrawerPlacement>("right");
+ const { locale } = useLanguage();
+ const uiStateStore = useUIStateStore();
+
+ const state = reactive<State>({
+ frontmatter: {},
+ html: "",
+ });
+
+ const showHelp = async (name: string, isGuide?: boolean) => {
+ if (name) {
+ helpName.value = name;
+ if (isGuide) {
+ isHelpGuide.value = true;
+ }
+ const { default: markdown } = await import(
+ `../../../public/help/${
+ locale.value === "zh-CN" ? "zh" : "en"
+ }/${name}.md?raw`
+ );
+ const ast: Node = Markdoc.parse(markdown);
+ const content = Markdoc.transform(ast) as Tag;
+ content.attributes.class = "prose"; // style help content
+ const html: string = Markdoc.renderers.html(content);
+
+ state.frontmatter = ast.attributes.frontmatter
+ ? (yaml.load(ast.attributes.frontmatter) as Record<string, string>)
+ : {};
+ state.html = DOMPurify.sanitize(html);
+ activate("right");
+ }
+ };
+
+ const onClose = () => {
+ if (isHelpGuide.value) {
+ if (!uiStateStore.getIntroStateByKey(`guide.${helpName.value}`)) {
+ uiStateStore.saveIntroStateByKey({
+ key: `guide.${helpName.value}`,
+ newState: true,
+ });
+ }
+ }
+ // else do nth
+ };
+
+ onMounted(() => {
+ event.on(EventType.EVENT_HELP, showHelp);
+ });
+ onUnmounted(() => {
+ event.off(EventType.EVENT_HELP);
+ });
+ const activate = (place: DrawerPlacement) => {
+ active.value = true;
+ placement.value = place;
+ };
+ return {
+ active,
+ placement,
+ activate,
+ state,
+ onClose,
+ };
+ },
+});
+</script>
diff --git a/frontend/src/components/HelpTriggerIcon.vue b/frontend/src/components/HelpTriggerIcon.vue
new file mode 100644
index 0000000000..bfde11131e
--- /dev/null
+++ b/frontend/src/components/HelpTriggerIcon.vue
@@ -0,0 +1,39 @@
+<template>
+ <heroicons-outline:question-mark-circle
+ class="w-5 h-5 cursor-pointer"
+ @click="handleClick"
+ />
+</template>
+
+<script lang="ts">
+import { defineComponent, inject } from "vue";
+import { Event } from "@/utils";
+import { EventType } from "@/types";
+
+export default defineComponent({
+ name: "HelpTrigger",
+ props: {
+ name: {
+ type: String,
+ required: true,
+ default: "",
+ },
+ isGuide: {
+ type: Boolean,
+ required: false,
+ default: false,
+ },
+ },
+ setup: (props) => {
+ const event = inject("event") as Event;
+ const handleClick = () => {
+ event.emit(EventType.EVENT_HELP, props.name, props.isGuide);
+ };
+ return {
+ handleClick,
+ };
+ },
+});
+</script>
+
+<style></style>
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index 888b40ecec..7db6a2d80e 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -30,6 +30,7 @@ import {
projectSlug,
sizeToFit,
urlfy,
+ event,
} from "./utils";
import dataSourceType from "./directives/data-source-type";
import App from "./App.vue";
@@ -129,6 +130,7 @@ app
// The normal hljs.initHighlightingOnLoad() won't work because router change would cause vue
// to re-render the page and remove the event listener required for
.directive("data-source-type", dataSourceType)
+ .provide("event", event)
.use(highlight)
.use(pinia)
.use(router)
diff --git a/frontend/src/types/event.ts b/frontend/src/types/event.ts
new file mode 100644
index 0000000000..7f8a1d0150
--- /dev/null
+++ b/frontend/src/types/event.ts
@@ -0,0 +1,3 @@
+export enum EventType {
+ EVENT_HELP = "help",
+}
diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts
index 27d9e7a1e0..8fb654a77b 100644
--- a/frontend/src/types/index.ts
+++ b/frontend/src/types/index.ts
@@ -11,6 +11,7 @@ export * from "./dataSource";
export * from "./environment";
export * from "./error";
export * from "./errorList";
+export * from "./event";
export * from "./id";
export * from "./inbox";
export * from "./instance";
diff --git a/frontend/src/utils/event.ts b/frontend/src/utils/event.ts
new file mode 100644
index 0000000000..5ef1e56dd6
--- /dev/null
+++ b/frontend/src/utils/event.ts
@@ -0,0 +1,31 @@
+// a publish-subscribe pattern
+import { EventType } from "@/types";
+
+class Event {
+ eventList: Partial<Record<EventType, (...args: any[]) => any>>;
+ constructor() {
+ this.eventList = {};
+ }
+
+ on(event: EventType, handler: (...args: any[]) => any) {
+ if (!this.eventList[event]) {
+ this.eventList[event] = handler;
+ }
+ }
+
+ off(event: EventType) {
+ if (this.eventList[event]) {
+ delete this.eventList[event];
+ }
+ }
+
+ emit(event: EventType, ...params: any[]) {
+ if (this.eventList[event]) {
+ this.eventList[event]?.(...params);
+ }
+ }
+}
+
+const event = new Event();
+
+export { event, Event };
diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts
index 4c7f5f84e7..b21aa4e15e 100644
--- a/frontend/src/utils/index.ts
+++ b/frontend/src/utils/index.ts
@@ -11,3 +11,4 @@ export * from "./slug";
export * from "./util";
export * from "./label";
export * from "./deployment";
+export * from "./event";
diff --git a/frontend/src/views/DatabaseDashboard.vue b/frontend/src/views/DatabaseDashboard.vue
index 4125583e8f..352fc4a1b3 100644
--- a/frontend/src/views/DatabaseDashboard.vue
+++ b/frontend/src/views/DatabaseDashboard.vue
@@ -14,22 +14,6 @@
</div>
<DatabaseTable :bordered="false" :database-list="filteredList" />
</div>
-
- <BBAlert
- v-if="state.showGuide"
- :style="'INFO'"
- :ok-text="$t('common.do-not-show-again')"
- :cancel-text="$t('common.dismiss')"
- :title="$t('database.how-to-setup-database')"
- :description="$t('database.show-guide-description')"
- @ok="
- () => {
- doDismissGuide();
- }
- "
- @cancel="state.showGuide = false"
- >
- </BBAlert>
</template>
<script lang="ts">
@@ -40,12 +24,13 @@ import {
reactive,
ref,
defineComponent,
+ inject,
} from "vue";
import { useRouter } from "vue-router";
import EnvironmentTabFilter from "../components/EnvironmentTabFilter.vue";
import DatabaseTable from "../components/DatabaseTable.vue";
-import { Environment, Database, UNKNOWN_ID } from "../types";
-import { sortDatabaseList } from "../utils";
+import { Environment, Database, UNKNOWN_ID, EventType } from "../types";
+import { sortDatabaseList, Event } from "../utils";
import { cloneDeep } from "lodash-es";
import {
useCurrentUser,
@@ -59,7 +44,6 @@ interface LocalState {
searchText: string;
databaseList: Database[];
selectedEnvironment?: Environment;
- showGuide: boolean;
}
export default defineComponent({
@@ -70,6 +54,7 @@ export default defineComponent({
},
setup() {
const searchField = ref();
+ const event = inject<Event>("event");
const uiStateStore = useUIStateStore();
const router = useRouter();
@@ -82,7 +67,6 @@ export default defineComponent({
parseInt(router.currentRoute.value.query.environment as string, 10)
)
: undefined,
- showGuide: false,
});
const currentUser = useCurrentUser();
@@ -93,9 +77,9 @@ export default defineComponent({
// Focus on the internal search field when mounted
searchField.value.$el.querySelector("#search").focus();
- if (!uiStateStore.getIntroStateByKey("guide.database")) {
+ if (!uiStateStore.getIntroStateByKey("guide.help.database")) {
setTimeout(() => {
- state.showGuide = true;
+ event?.emit(EventType.EVENT_HELP, "help.database", true);
uiStateStore.saveIntroStateByKey({
key: "database.visit",
newState: true,
@@ -120,14 +104,6 @@ export default defineComponent({
watchEffect(prepareDatabaseList);
- const doDismissGuide = () => {
- uiStateStore.saveIntroStateByKey({
- key: "guide.database",
- newState: true,
- });
- state.showGuide = false;
- };
-
const selectEnvironment = (environment: Environment) => {
state.selectedEnvironment = environment;
if (environment) {
@@ -165,7 +141,6 @@ export default defineComponent({
searchField,
state,
filteredList,
- doDismissGuide,
selectEnvironment,
changeSearchText,
};
diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vue
index c170b10720..4fc6ba8dec 100644
--- a/frontend/src/views/EnvironmentDashboard.vue
+++ b/frontend/src/views/EnvironmentDashboard.vue
@@ -52,22 +52,6 @@
/>
</BBModal>
- <BBAlert
- v-if="state.showGuide"
- :style="'INFO'"
- :ok-text="$t('common.do-not-show-again')"
- :cancel-text="$t('common.dismiss')"
- :title="$t('environment.how-to-setup-environment')"
- :description="$t('environment.how-to-setup-environment-description')"
- @ok="
- () => {
- doDismissGuide();
- }
- "
- @cancel="state.showGuide = false"
- >
- </BBAlert>
-
<FeatureModal
v-if="state.missingRequiredFeature != undefined"
:feature="state.missingRequiredFeature"
@@ -76,9 +60,16 @@
</template>
<script lang="ts">
-import { onMounted, computed, reactive, watch, defineComponent } from "vue";
+import {
+ onMounted,
+ computed,
+ reactive,
+ watch,
+ defineComponent,
+ inject,
+} from "vue";
import { useRouter } from "vue-router";
-import { array_swap } from "../utils";
+import { array_swap, Event } from "../utils";
import EnvironmentDetail from "../views/EnvironmentDetail.vue";
import EnvironmentForm from "../components/EnvironmentForm.vue";
import {
@@ -90,6 +81,7 @@ import {
DefaultSchedulePolicy,
PipelineApporvalPolicyPayload,
BackupPlanPolicyPayload,
+ EventType,
} from "../types";
import { BBTabItem } from "../bbkit/types";
import {
@@ -124,7 +116,6 @@ interface LocalState {
selectedIndex: number;
showCreateModal: boolean;
reorder: boolean;
- showGuide: boolean;
missingRequiredFeature?:
| "bb.feature.approval-policy"
| "bb.feature.backup-policy";
@@ -142,13 +133,13 @@ export default defineComponent({
const uiStateStore = useUIStateStore();
const policyStore = usePolicyStore();
const router = useRouter();
+ const event = inject<Event>("event");
const state = reactive<LocalState>({
reorderedEnvironmentList: [],
selectedIndex: -1,
showCreateModal: false,
reorder: false,
- showGuide: false,
});
const selectEnvironmentOnHash = () => {
@@ -172,9 +163,9 @@ export default defineComponent({
onMounted(() => {
selectEnvironmentOnHash();
- if (!uiStateStore.getIntroStateByKey("guide.environment")) {
+ if (!uiStateStore.getIntroStateByKey("guide.help.environment")) {
setTimeout(() => {
- state.showGuide = true;
+ event?.emit(EventType.EVENT_HELP, "help.environment", true);
uiStateStore.saveIntroStateByKey({
key: "environment.visit",
newState: true,
@@ -271,14 +262,6 @@ export default defineComponent({
});
};
- const doDismissGuide = () => {
- uiStateStore.saveIntroStateByKey({
- key: "guide.environment",
- newState: true,
- });
- state.showGuide = false;
- };
-
const startReorder = () => {
state.reorderedEnvironmentList = [...environmentList.value];
state.reorder = true;
@@ -343,7 +326,6 @@ export default defineComponent({
createEnvironment,
doCreate,
doArchive,
- doDismissGuide,
reorderEnvironment,
orderChanged,
discardReorder,
diff --git a/frontend/src/views/InstanceDashboard.vue b/frontend/src/views/InstanceDashboard.vue
index 6eb8136b67..d82aceead2 100644
--- a/frontend/src/views/InstanceDashboard.vue
+++ b/frontend/src/views/InstanceDashboard.vue
@@ -20,32 +20,23 @@
</div>
<InstanceTable :instance-list="filteredList(instanceList)" />
</div>
-
- <BBAlert
- v-if="state.showGuide"
- :style="'INFO'"
- :ok-text="$t('common.do-not-show-again')"
- :cancel-text="$t('common.dismiss')"
- :title="$t('instance.how-to-setup-instance')"
- :description="$t('instance.how-to-setup-instance-description')"
- @ok="
- () => {
- doDismissGuide();
- }
- "
- @cancel="state.showGuide = false"
- >
- </BBAlert>
</template>
<script lang="ts">
-import { computed, onMounted, reactive, ref, defineComponent } from "vue";
+import {
+ computed,
+ onMounted,
+ reactive,
+ ref,
+ defineComponent,
+ inject,
+} from "vue";
import { useRouter } from "vue-router";
import EnvironmentTabFilter from "../components/EnvironmentTabFilter.vue";
import InstanceTable from "../components/InstanceTable.vue";
-import { Environment, Instance } from "../types";
+import { Environment, Instance, EventType } from "../types";
import { cloneDeep } from "lodash-es";
-import { sortInstanceList } from "../utils";
+import { sortInstanceList, Event } from "../utils";
import { useI18n } from "vue-i18n";
import {
useUIStateStore,
@@ -59,7 +50,6 @@ import {
interface LocalState {
searchText: string;
selectedEnvironment?: Environment;
- showGuide: boolean;
}
export default defineComponent({
@@ -70,6 +60,7 @@ export default defineComponent({
},
setup() {
const searchField = ref();
+ const event = inject<Event>("event");
const instanceStore = useInstanceStore();
const subscriptionStore = useSubscriptionStore();
@@ -86,16 +77,15 @@ export default defineComponent({
parseInt(router.currentRoute.value.query.environment as string, 10)
)
: undefined,
- showGuide: false,
});
onMounted(() => {
// Focus on the internal search field when mounted
searchField.value.$el.querySelector("#search").focus();
- if (!uiStateStore.getIntroStateByKey("guide.instance")) {
+ if (!uiStateStore.getIntroStateByKey("guide.help.instance")) {
setTimeout(() => {
- state.showGuide = true;
+ event?.emit(EventType.EVENT_HELP, "help.instance", true);
uiStateStore.saveIntroStateByKey({
key: "instance.visit",
newState: true,
@@ -120,14 +110,6 @@ export default defineComponent({
state.searchText = searchText;
};
- const doDismissGuide = () => {
- uiStateStore.saveIntroStateByKey({
- key: "guide.instance",
- newState: true,
- });
- state.showGuide = false;
- };
-
const rawInstanceList = useInstanceList();
const instanceList = computed(() => {
@@ -193,7 +175,6 @@ export default defineComponent({
filteredList,
selectEnvironment,
changeSearchText,
- doDismissGuide,
remainingInstanceCount,
instanceCountAttention,
};
diff --git a/frontend/src/views/ProjectDashboard.vue b/frontend/src/views/ProjectDashboard.vue
index e335cdf8a9..d5227e31de 100644
--- a/frontend/src/views/ProjectDashboard.vue
+++ b/frontend/src/views/ProjectDashboard.vue
@@ -21,35 +21,26 @@
</div>
<ProjectTable :project-list="filteredList(state.projectList)" />
</div>
-
- <BBAlert
- v-if="state.showGuide"
- :style="'INFO'"
- :ok-text="$t('project.dashboard.modal.confirm')"
- :cancel-text="$t('project.dashboard.modal.cancel')"
- :title="$t('project.dashboard.modal.title')"
- :description="$t('project.dashboard.modal.content')"
- @ok="
- () => {
- doDismissGuide();
- }
- "
- @cancel="state.showGuide = false"
- >
- </BBAlert>
</template>
<script lang="ts">
import { useCurrentUser, useUIStateStore, useProjectStore } from "@/store";
import { useRouter } from "vue-router";
-import { watchEffect, onMounted, reactive, ref, defineComponent } from "vue";
+import {
+ watchEffect,
+ onMounted,
+ reactive,
+ ref,
+ defineComponent,
+ inject,
+} from "vue";
import ProjectTable from "../components/ProjectTable.vue";
-import { Project, UNKNOWN_ID, DEFAULT_PROJECT_ID } from "../types";
+import { Event } from "../utils";
+import { Project, UNKNOWN_ID, DEFAULT_PROJECT_ID, EventType } from "../types";
interface LocalState {
projectList: Project[];
searchText: string;
- showGuide: boolean;
}
export default defineComponent({
@@ -60,6 +51,7 @@ export default defineComponent({
setup() {
const router = useRouter();
const searchField = ref();
+ const event = inject<Event>("event");
const uiStateStore = useUIStateStore();
const currentUser = useCurrentUser();
@@ -68,16 +60,15 @@ export default defineComponent({
const state = reactive<LocalState>({
projectList: [],
searchText: "",
- showGuide: false,
});
onMounted(() => {
// Focus on the internal search field when mounted
searchField.value.$el.querySelector("#search").focus();
- if (!uiStateStore.getIntroStateByKey("guide.project")) {
+ if (!uiStateStore.getIntroStateByKey("guide.help.project")) {
setTimeout(() => {
- state.showGuide = true;
+ event?.emit(EventType.EVENT_HELP, "help.project", true);
uiStateStore.saveIntroStateByKey({
key: "project.visit",
newState: true,
@@ -106,14 +97,6 @@ export default defineComponent({
state.searchText = searchText;
};
- const doDismissGuide = () => {
- uiStateStore.saveIntroStateByKey({
- key: "guide.project",
- newState: true,
- });
- state.showGuide = false;
- };
-
const goDefaultProject = () => {
router.push({
name: "workspace.project.detail",
@@ -140,7 +123,6 @@ export default defineComponent({
searchField,
state,
filteredList,
- doDismissGuide,
changeSearchText,
goDefaultProject,
};