Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): re-write help drawer component (#2046)
ZhengX19f6abcbe8be
diff --git a/frontend/src/App.vue b/frontend/src/App.vueindex b09203575a..902ada8aa2 100644--- a/frontend/src/App.vue+++ b/frontend/src/App.vue@@ -128,6 +128,9 @@ watch(const uiStateStore = useUIStateStore();const helpStore = useHelpStore();+ // Hide opened help drawer if route changed.+ helpStore.exitHelp();+if (!state.RouteMapList) {const res = await fetch("/help/routeMapList.json");state.RouteMapList = await res.json();@@ -139,13 +142,17 @@ watch(state.helpTimer = null;}- const helpName = state.RouteMapList?.find(+ const helpId = state.RouteMapList?.find((pair) => pair.routeName === routeName)?.helpName;- if (helpName && !uiStateStore.getIntroStateByKey(`${helpName}`)) {+ if (helpId && !uiStateStore.getIntroStateByKey(`${helpId}`)) {state.helpTimer = window.setTimeout(() => {- helpStore.showHelp(helpName, true);+ helpStore.showHelp(helpId, true);+ uiStateStore.saveIntroStateByKey({+ key: `${helpId}`,+ newState: true,+ });}, 1000);}}diff --git a/frontend/src/components/Drawer.vue b/frontend/src/components/Drawer.vuenew file mode 100644index 0000000000..4710aafad8--- /dev/null+++ b/frontend/src/components/Drawer.vue@@ -0,0 +1,72 @@+<template>+ <Transition name="slide">+ <div+ v-if="show"+ class="absolute top-0 right-0 h-screen bg-white shadow-xl outline-none"+ :style="`width: ${width}px`"+ tabindex="0"+ @keyup.esc="handleClose"+ >+ <header+ class="flex flex-row justify-between items-center w-full h-16 p-4 border-b"+ >+ <h2 class="font-semibold">{{ title }}</h2>++ <i+ class="w-6 h-6 hover:bg-slate-200 hover:cursor-pointer rounded-md"+ @click="handleClose"+ ><heroicons-outline:x class="h-6 w-6"+ /></i>+ </header>+ <section class="p-4">+ <slot name="body"></slot>+ </section>+ </div>+ </Transition>+</template>++<script lang="ts" setup>+import { defineProps, defineEmits } from "vue";++const props = defineProps({+ show: {+ type: Boolean,+ default: false,+ },+ width: {+ type: Number,+ default: 320,+ },+ title: {+ type: String,+ default: "",+ },+ onClose: {+ type: Function,+ required: false,+ default: () => {+ /* do nth by default */+ },+ },+});++const emit = defineEmits(["close-drawer"]);++const handleClose = () => {+ const { onClose } = props;+ emit("close-drawer");+ onClose();+};+</script>++<style scope>+.slide-enter-active,+.slide-leave-active {+ transition: all 0.3s ease;+}++.slide-enter-from,+.slide-leave-to {+ transform: translateX(100%);+}+</style>diff --git a/frontend/src/components/HelpDrawer.vue b/frontend/src/components/HelpDrawer.vueindex 51e68d885b..208da78c65 100644--- a/frontend/src/components/HelpDrawer.vue+++ b/frontend/src/components/HelpDrawer.vue@@ -1,32 +1,26 @@<template>- <n-drawer- v-model:show="active"- :width="380"- :placement="placement"- :on-after-leave="onClose"+ <Drawer+ :show="active"+ :on-close="onClose"+ :title="state.frontmatter.title"+ @close-drawer="active = false">- <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 #body>+ <!-- eslint-disable-next-line vue/no-v-html -->+ <div v-if="state.html" v-html="state.html"></div>+ </template>+ </Drawer></template><script lang="ts">import { defineComponent, ref, reactive, watch, computed } 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 { storeToRefs } from "pinia";import { useLanguage } from "@/composables/useLanguage";import { useUIStateStore, useHelpStore } from "@/store";+import Drawer from "@/components/Drawer.vue";interface State {frontmatter: Record<string, string>;@@ -34,10 +28,9 @@ interface State {}export default defineComponent({- components: { NDrawer, NDrawerContent },+ components: { Drawer },setup() {const active = ref(false);- const placement = ref<DrawerPlacement>("right");const { locale } = useLanguage();const uiStateStore = useUIStateStore();const helpStore = useHelpStore();@@ -65,7 +58,11 @@ export default defineComponent({? (yaml.load(ast.attributes.frontmatter) as Record<string, string>): {};state.html = DOMPurify.sanitize(html);- activate("right");+ activate();+ } else {+ state.frontmatter = {};+ state.html = "";+ deactivate();}});@@ -81,14 +78,12 @@ export default defineComponent({helpStore.exitHelp();};- const activate = (place: DrawerPlacement) => {- active.value = true;- placement.value = place;- };+ const activate = () => (active.value = true);++ const deactivate = () => (active.value = false);+return {active,- placement,- activate,state,onClose,};