Skip to content

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

chore: validate guide step data (#1704)

boojackbbbf2952ab0e
diff --git a/frontend/src/plugins/demo/data.ts b/frontend/src/plugins/demo/data.ts
index 8a2b825add..9a5ce26d73 100644
--- a/frontend/src/plugins/demo/data.ts
+++ b/frontend/src/plugins/demo/data.ts
@@ -1,4 +1,5 @@
import { merge } from "lodash-es";
+import { validateStepData } from "./guide";
import { GuideData } from "./types";
const fetchJSONData = async (path: string) => {
@@ -11,8 +12,6 @@ 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) => s.type === "click" || s.type === "change"
- );
+ guideData.steps = guideData.steps.filter((s) => validateStepData(s));
return guideData;
};
diff --git a/frontend/src/plugins/demo/guide.ts b/frontend/src/plugins/demo/guide.ts
index 1468a5187c..4f77450cab 100644
--- a/frontend/src/plugins/demo/guide.ts
+++ b/frontend/src/plugins/demo/guide.ts
@@ -8,6 +8,24 @@ import {
import * as storage from "./storage";
import { GuideData, GuidePosition, StepData } from "./types";
+// 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 (typeof stepData.title !== "string") {
+ return false;
+ }
+ // description is required
+ if (typeof stepData.description !== "string") {
+ return false;
+ }
+
+ return true;
+};
+
export const showGuideDialog = async (
guideData: GuideData,
stepIndex: number
diff --git a/frontend/src/plugins/demo/style.css b/frontend/src/plugins/demo/style.css
index f0d721a0b0..ac035de65b 100644
--- a/frontend/src/plugins/demo/style.css
+++ b/frontend/src/plugins/demo/style.css
@@ -25,20 +25,20 @@
}
.bb-guide-close-button {
- @apply absolute top-0 right-1 px-1 rounded cursor-pointer opacity-60 hover:opacity-50;
+ @apply absolute top-0 right-0.5 px-1 font-thin rounded cursor-pointer opacity-60 hover:opacity-50;
font-size: 24px;
}
.bb-guide-title-text {
- @apply text-lg text-black leading-6 py-1 my-1 pr-3;
+ @apply text-lg text-black leading-6 py-1 my-1 pr-3 break-words;
}
.bb-guide-description-text {
- @apply text-base text-gray-700;
+ @apply text-base text-gray-700 break-words;
}
.bb-guide-btns-container {
- @apply mt-3 w-full flex flex-row justify-between items-center;
+ @apply mt-1 w-full flex flex-row justify-end items-center;
}
.bb-guide-btns-container > button {