Skip to content

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

chore: statement change activity improvements (#9216)

Liu Ji28962ca79f63
diff --git a/frontend/src/bbkit/BBModal.vue b/frontend/src/bbkit/BBModal.vue
index a42ba11297..f66793b22e 100644
--- a/frontend/src/bbkit/BBModal.vue
+++ b/frontend/src/bbkit/BBModal.vue
@@ -9,7 +9,7 @@
@mask-click="maskClosable && tryClose()"
>
<div v-bind="$attrs" class="bb-modal">
- <div class="modal-header">
+ <div class="modal-header" :class="headerClass">
<div class="text-xl text-main mr-2 flex-1 overflow-hidden">
<slot name="title"><component :is="renderTitle" /></slot>
<slot name="subtitle"><component :is="renderSubtitle" /></slot>
diff --git a/frontend/src/components/IssueV1/components/ActivitySection/Activity/ActionSentence.vue b/frontend/src/components/IssueV1/components/ActivitySection/Activity/ActionSentence.vue
index eb0334b720..aa56be8edd 100644
--- a/frontend/src/components/IssueV1/components/ActivitySection/Activity/ActionSentence.vue
+++ b/frontend/src/components/IssueV1/components/ActivitySection/Activity/ActionSentence.vue
@@ -4,10 +4,8 @@
<script lang="ts" setup>
import dayjs from "dayjs";
-import { defineComponent, h, watch } from "vue";
+import { defineComponent, h } from "vue";
import { Translation, useI18n } from "vue-i18n";
-import TextOverflowPopover from "@/components/misc/TextOverflowPopover.vue";
-import { useSheetV1Store, useSheetStatementByUID } from "@/store";
import {
ActivityIssueCommentCreatePayload,
ActivityPipelineTaskRunStatusUpdatePayload,
@@ -28,6 +26,7 @@ import {
} from "@/utils";
import { extractUserResourceName } from "@/utils";
import StageName from "./StageName.vue";
+import StatementUpdate from "./StatementUpdate.vue";
import TaskName from "./TaskName.vue";
type RenderedContent = string | ReturnType<typeof h>;
@@ -38,7 +37,6 @@ const props = defineProps<{
}>();
const { t } = useI18n();
-const sheetV1Store = useSheetV1Store();
const renderActionSentence = () => {
const renderSpan = (content: string, props?: object) => {
@@ -251,24 +249,21 @@ const renderActionSentence = () => {
const payload = JSON.parse(
activity.payload
) as ActivityTaskStatementUpdatePayload;
- const oldStatement =
- useSheetStatementByUID(String(payload.oldSheetId || UNKNOWN_ID))
- .value || payload.oldStatement;
- const newStatement =
- useSheetStatementByUID(String(payload.newSheetId || UNKNOWN_ID))
- .value || payload.newStatement;
return h(
"span",
{},
h(
Translation,
{
- keypath: "activity.sentence.changed-from-to",
+ keypath: "activity.sentence.changed-x-link",
},
{
name: () => "SQL",
- oldValue: () => renderStatement(oldStatement),
- newValue: () => renderStatement(newStatement),
+ link: () =>
+ h(StatementUpdate, {
+ oldSheetId: String(payload.oldSheetId || UNKNOWN_ID),
+ newSheetId: String(payload.newSheetId || UNKNOWN_ID),
+ }),
}
)
);
@@ -332,40 +327,4 @@ const Renderer = defineComponent({
name: "ActionSentenceRenderer",
render: renderActionSentence,
});
-
-const renderStatement = (content: string) => {
- return h(TextOverflowPopover, {
- content,
- maxLength: 50,
- width: 400,
- contentClass: "text-main",
- });
-};
-
-watch(
- () => props.activity,
- async () => {
- const activity = props.activity;
- // Prepare sheet data for rendering.
- if (
- activity.action === LogEntity_Action.ACTION_PIPELINE_TASK_STATEMENT_UPDATE
- ) {
- sheetV1Store.getOrFetchSheetByUID(
- String(
- (JSON.parse(activity.payload) as ActivityTaskStatementUpdatePayload)
- .newSheetId || UNKNOWN_ID
- )
- );
- sheetV1Store.getOrFetchSheetByUID(
- String(
- (JSON.parse(activity.payload) as ActivityTaskStatementUpdatePayload)
- .oldSheetId || UNKNOWN_ID
- )
- );
- }
- },
- {
- immediate: true,
- }
-);
</script>
diff --git a/frontend/src/components/IssueV1/components/ActivitySection/Activity/StatementUpdate.vue b/frontend/src/components/IssueV1/components/ActivitySection/Activity/StatementUpdate.vue
new file mode 100644
index 0000000000..36e38e0b13
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/ActivitySection/Activity/StatementUpdate.vue
@@ -0,0 +1,80 @@
+<template>
+ <NButton text type="primary" v-bind="$attrs" @click="showPanel = true">
+ {{ $t("common.view-details") }}
+ </NButton>
+
+ <BBModal
+ v-if="showPanel"
+ :title="$t('common.detail')"
+ header-class="!border-0"
+ container-class="!pt-0"
+ @close="showPanel = false"
+ >
+ <div
+ style="width: calc(100vw - 9rem); height: calc(100vh - 10rem)"
+ class="relative"
+ >
+ <DiffEditor
+ v-if="!isPreparingOldStatement && !isPreparingNewStatement"
+ class="w-full h-full border rounded-md overflow-clip"
+ :original="oldStatement"
+ :value="newStatement"
+ :readonly="true"
+ />
+ <div
+ v-else
+ class="absolute inset-0 flex flex-col items-center justify-center"
+ >
+ <BBSpin />
+ </div>
+ </div>
+ </BBModal>
+</template>
+
+<script setup lang="ts">
+import { asyncComputed } from "@vueuse/core";
+import { NButton } from "naive-ui";
+import { ref } from "vue";
+import { BBModal, BBSpin } from "@/bbkit";
+import DiffEditor from "@/components/MonacoEditor/DiffEditor.vue";
+import { useSheetV1Store } from "@/store";
+import { UNKNOWN_ID } from "@/types";
+import { getSheetStatement } from "@/utils";
+
+const props = defineProps<{
+ oldSheetId: string;
+ newSheetId: string;
+}>();
+
+const showPanel = ref(false);
+
+const prepareStatement = async (uid: string) => {
+ if (uid === String(UNKNOWN_ID)) return "";
+ const sheet = await useSheetV1Store().getOrFetchSheetByUID(uid);
+ if (!sheet) return "";
+ return getSheetStatement(sheet);
+};
+const isPreparingOldStatement = ref(false);
+const isPreparingNewStatement = ref(false);
+
+const oldStatement = asyncComputed(
+ () => {
+ return prepareStatement(props.oldSheetId);
+ },
+ "",
+ {
+ evaluating: isPreparingOldStatement,
+ lazy: true,
+ }
+);
+const newStatement = asyncComputed(
+ () => {
+ return prepareStatement(props.newSheetId);
+ },
+ "",
+ {
+ evaluating: isPreparingNewStatement,
+ lazy: true,
+ }
+);
+</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index ba84745ac7..2ca1dca08a 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -275,7 +275,8 @@
"filter-by-name": "Filter by name",
"tenant": "Tenant",
"license": "License",
- "show-all": "Show all"
+ "show-all": "Show all",
+ "view-details": "View details"
},
"error-page": {
"go-back-home": "Go back home"
@@ -866,7 +867,8 @@
"schema-version": "schema version {version}",
"xxx-automatically": "{verb} automatically",
"verb-type-target-by-people": "{verb} {type} {target}",
- "verb-type-target-by-system-bot": "{type} {target} {verb}"
+ "verb-type-target-by-system-bot": "{type} {target} {verb}",
+ "changed-x-link": "changed {name}. {link}"
},
"subject-prefix": {
"task": "Task",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index e957aeebf4..73b710f835 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -275,7 +275,8 @@
"filter-by-name": "Filtrar por nombre",
"tenant": "Arrendataria",
"license": "Licencia",
- "show-all": "Mostrar todo"
+ "show-all": "Mostrar todo",
+ "view-details": "Ver detalles"
},
"error-page": {
"go-back-home": "Volver al inicio"
@@ -865,7 +866,8 @@
"schema-version": "versión de esquema {version}",
"xxx-automatically": "{verb} automáticamente",
"verb-type-target-by-people": "{verb} {type} {target}",
- "verb-type-target-by-system-bot": "{type} {target} {verb}"
+ "verb-type-target-by-system-bot": "{type} {target} {verb}",
+ "changed-x-link": "cambiado {name}. \n{link}"
},
"subject-prefix": {
"task": "Tarea",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 4c4acd1a85..387294fc4c 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -273,7 +273,8 @@
"filter-by-name": "按名称过滤",
"tenant": "租户",
"license": "证书",
- "show-all": "显示全部"
+ "show-all": "显示全部",
+ "view-details": "查看详情"
},
"error-page": {
"go-back-home": "回到主页"
@@ -863,7 +864,8 @@
"schema-version": "schema 版本 {version}",
"xxx-automatically": "自动{verb}",
"verb-type-target-by-people": "{verb}{type} {target}",
- "verb-type-target-by-system-bot": "{type} {target} {verb}"
+ "verb-type-target-by-system-bot": "{type} {target} {verb}",
+ "changed-x-link": "修改了 {name}。{link}"
},
"subject-prefix": {
"task": "任务",