Skip to content

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

feat: emit window events (#9098)

Liu Ji03a472beeb10
diff --git a/frontend/src/components/IssueV1/components/DescriptionSection/DescriptionSection.vue b/frontend/src/components/IssueV1/components/DescriptionSection/DescriptionSection.vue
index 2a500ca0e5..86ab741ad9 100644
--- a/frontend/src/components/IssueV1/components/DescriptionSection/DescriptionSection.vue
+++ b/frontend/src/components/IssueV1/components/DescriptionSection/DescriptionSection.vue
@@ -66,6 +66,7 @@ import { NInput, NButton } from "naive-ui";
import { computed, nextTick, reactive, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { issueServiceClient } from "@/grpcweb";
+import { emitWindowEvent } from "@/plugins";
import { pushNotification, useCurrentUserV1 } from "@/store";
import { Issue, IssueStatus } from "@/types/proto/v1/issue_service";
import {
@@ -158,6 +159,7 @@ const saveEdit = async () => {
style: "SUCCESS",
title: t("common.updated"),
});
+ emitWindowEvent("bb.issue-field-update");
state.isEditing = false;
} finally {
state.isUpdating = false;
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
index b1711d65e4..b3db90c4da 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
@@ -41,6 +41,7 @@ import {
import formatSQL from "@/components/MonacoEditor/sqlFormatter";
import { useSQLCheckContext } from "@/components/SQLCheck";
import { issueServiceClient, rolloutServiceClient } from "@/grpcweb";
+import { emitWindowEvent } from "@/plugins";
import { useDatabaseV1Store, useSheetV1Store } from "@/store";
import { ComposedIssue, dialectOfEngineV1, languageOfEngineV1 } from "@/types";
import { Issue } from "@/types/proto/v1/issue_service";
@@ -113,6 +114,9 @@ const doCreateIssue = async () => {
rolloutEntity: createdRollout,
};
+ emitWindowEvent("bb.issue-create", {
+ uid: composedIssue.uid,
+ });
nextTick(() => {
router.push(`/issue/${composedIssue.uid}`);
});
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Assignee/Assignee.vue b/frontend/src/components/IssueV1/components/HeaderSection/Assignee/Assignee.vue
index e2d621f9dd..9d5ddaa907 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Assignee/Assignee.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Assignee/Assignee.vue
@@ -53,6 +53,7 @@ import {
import ErrorList, { ErrorItem } from "@/components/misc/ErrorList.vue";
import { UserSelect } from "@/components/v2";
import { issueServiceClient } from "@/grpcweb";
+import { emitWindowEvent } from "@/plugins";
import { pushNotification, useCurrentUserV1, useUserStore } from "@/store";
import {
PresetRoleType,
@@ -165,6 +166,7 @@ const changeAssigneeUID = async (uid: string | undefined) => {
style: "SUCCESS",
title: t("common.updated"),
});
+ emitWindowEvent("bb.issue-field-update");
} finally {
isUpdating.value = false;
}
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Title.vue b/frontend/src/components/IssueV1/components/HeaderSection/Title.vue
index d4a088795e..f7c624ce19 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Title.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Title.vue
@@ -21,6 +21,7 @@ import { NInput } from "naive-ui";
import { CSSProperties, computed, reactive, watch } from "vue";
import { useI18n } from "vue-i18n";
import { issueServiceClient } from "@/grpcweb";
+import { emitWindowEvent } from "@/plugins";
import { pushNotification, useCurrentUserV1 } from "@/store";
import { Issue, IssueStatus } from "@/types/proto/v1/issue_service";
import { extractUserResourceName, hasWorkspacePermissionV1 } from "@/utils";
@@ -120,6 +121,7 @@ const onBlur = async () => {
style: "SUCCESS",
title: t("common.updated"),
});
+ emitWindowEvent("bb.issue-field-update");
} finally {
cleanup();
}
diff --git a/frontend/src/components/IssueV1/components/StageSection/Actions/EarliestAllowedTime.vue b/frontend/src/components/IssueV1/components/StageSection/Actions/EarliestAllowedTime.vue
index 9564d7f044..97dba3e08a 100644
--- a/frontend/src/components/IssueV1/components/StageSection/Actions/EarliestAllowedTime.vue
+++ b/frontend/src/components/IssueV1/components/StageSection/Actions/EarliestAllowedTime.vue
@@ -67,6 +67,7 @@ import {
useIssueContext,
} from "@/components/IssueV1";
import { rolloutServiceClient } from "@/grpcweb";
+import { emitWindowEvent } from "@/plugins";
import { hasFeature, pushNotification, useCurrentUserV1 } from "@/store";
import { IssueStatus } from "@/types/proto/v1/issue_service";
import {
@@ -214,6 +215,7 @@ const handleUpdateEarliestAllowedTime = async (timestampMS: number | null) => {
style: "SUCCESS",
title: t("common.updated"),
});
+ emitWindowEvent("bb.pipeline-task-earliest-allowed-time-update");
} finally {
isUpdating.value = false;
}
diff --git a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
index 434ca2cb2e..63369bd619 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
+++ b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
@@ -179,6 +179,7 @@ import MonacoEditor from "@/components/MonacoEditor";
import DownloadSheetButton from "@/components/Sheet/DownloadSheetButton.vue";
import UploadProgressButton from "@/components/misc/UploadProgressButton.vue";
import { rolloutServiceClient } from "@/grpcweb";
+import { emitWindowEvent } from "@/plugins";
import {
hasFeature,
pushNotification,
@@ -641,6 +642,8 @@ const updateStatement = async (statement: string) => {
style: "SUCCESS",
title: t("common.updated"),
});
+
+ emitWindowEvent("bb.pipeline-task-statement-update");
};
const handleStatementChange = (value: string) => {
diff --git a/frontend/src/plugins/index.ts b/frontend/src/plugins/index.ts
index 61b384d73c..43a4b004c3 100644
--- a/frontend/src/plugins/index.ts
+++ b/frontend/src/plugins/index.ts
@@ -1,3 +1,4 @@
export * from "./issue/template";
export * from "./types";
export * from "./pitr";
+export * from "./window-events";
diff --git a/frontend/src/plugins/window-events.ts b/frontend/src/plugins/window-events.ts
new file mode 100644
index 0000000000..64fee8d2d5
--- /dev/null
+++ b/frontend/src/plugins/window-events.ts
@@ -0,0 +1,16 @@
+export type WindowEventActivityType =
+ | "bb.issue-create"
+ | "bb.issue-field-update"
+ | "bb.pipeline-task-statement-update"
+ | "bb.pipeline-task-earliest-allowed-time-update";
+
+export const emitWindowEvent = (
+ activity: WindowEventActivityType,
+ params: any = undefined
+) => {
+ const data: Record<string, any> = { activity };
+ if (params) {
+ data.params = params;
+ }
+ window.parent.postMessage(data, "*");
+};