Skip to content

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

fix: update sheet payload with issue information (#5950)

boojack59b168f9891e
diff --git a/frontend/src/components/Issue/IssueTaskStatementPanel.vue b/frontend/src/components/Issue/IssueTaskStatementPanel.vue
index 80e599c368..04ba7b5523 100644
--- a/frontend/src/components/Issue/IssueTaskStatementPanel.vue
+++ b/frontend/src/components/Issue/IssueTaskStatementPanel.vue
@@ -135,6 +135,8 @@ import { useIssueLogic } from "./logic";
import {
Database,
dialectOfEngine,
+ Issue,
+ SheetCreate,
SheetId,
SQLDialect,
Task,
@@ -142,7 +144,11 @@ import {
TaskId,
UNKNOWN_ID,
} from "@/types";
-import { sheetIdOfTask, useInstanceEditorLanguage } from "@/utils";
+import {
+ getBacktracePayloadWithIssue,
+ sheetIdOfTask,
+ useInstanceEditorLanguage,
+} from "@/utils";
import { TableMetadata } from "@/types/proto/store/database";
import MonacoEditor from "../MonacoEditor/MonacoEditor.vue";
import { useSQLAdviceMarkers } from "./logic/useSQLAdviceMarkers";
@@ -173,6 +179,7 @@ defineProps({
const {
create,
+ issue,
allowEditStatement,
selectedDatabase,
selectedStatement: statement,
@@ -456,28 +463,29 @@ const handleUploadFile = async (event: Event, tick: (p: number) => void) => {
);
const uploadStatementAsSheet = async (statement: string) => {
- const sheet = await sheetStore.createSheet(
- {
- projectId: projectId,
- name: filename,
- statement,
- visibility: "PROJECT",
- source: "BYTEBASE_ARTIFACT",
- payload: {},
+ const sheetCreate: SheetCreate = {
+ projectId: projectId,
+ name: filename,
+ statement,
+ visibility: "PROJECT",
+ source: "BYTEBASE_ARTIFACT",
+ payload: {},
+ };
+ if (!create.value) {
+ sheetCreate.payload = getBacktracePayloadWithIssue(issue.value as Issue);
+ }
+ const sheet = await sheetStore.createSheet(sheetCreate, {
+ timeout: 10 * 60 * 1000, // 10 minutes
+ onUploadProgress: (event) => {
+ console.debug("upload progress", event);
+ const progress = event.progress;
+ if (isNumber(progress)) {
+ tick(progress * 100);
+ } else {
+ tick(-1); // -1 to show a simple spinner instead of progress
+ }
},
- {
- timeout: 10 * 60 * 1000, // 10 minutes
- onUploadProgress: (event) => {
- console.debug("upload progress", event);
- const progress = event.progress;
- if (isNumber(progress)) {
- tick(progress * 100);
- } else {
- tick(-1); // -1 to show a simple spinner instead of progress
- }
- },
- }
- );
+ });
state.isUploadingFile = false;
updateSheetId(sheet.id);
diff --git a/frontend/src/components/Issue/logic/GhostModeProvider.ts b/frontend/src/components/Issue/logic/GhostModeProvider.ts
index 5dcf713e4d..6498323c41 100644
--- a/frontend/src/components/Issue/logic/GhostModeProvider.ts
+++ b/frontend/src/components/Issue/logic/GhostModeProvider.ts
@@ -111,20 +111,17 @@ export default defineComponent({
});
} else {
const sheetId = sheetIdOfTask(selectedTask.value as Task);
- if (sheetId || sheetId !== UNKNOWN_ID) {
+ if (sheetId && sheetId !== UNKNOWN_ID) {
// Call patchAllTasksInIssue for tenant mode
const issueEntity = issue.value as Issue;
- taskStore
- .patchAllTasksInIssue({
- issueId: issueEntity.id,
- pipelineId: issueEntity.pipeline.id,
- taskPatch: {
- sheetId,
- },
- })
- .then(() => {
- onStatusChanged(true);
- });
+ await taskStore.patchAllTasksInIssue({
+ issueId: issueEntity.id,
+ pipelineId: issueEntity.pipeline.id,
+ taskPatch: {
+ sheetId,
+ },
+ });
+ onStatusChanged(true);
}
}
} else {
diff --git a/frontend/src/components/Issue/logic/TenantModeProvider.ts b/frontend/src/components/Issue/logic/TenantModeProvider.ts
index 0a2f7e89df..efd91d14b4 100644
--- a/frontend/src/components/Issue/logic/TenantModeProvider.ts
+++ b/frontend/src/components/Issue/logic/TenantModeProvider.ts
@@ -19,7 +19,7 @@ import {
useCommonLogic,
} from "./common";
import { provideIssueLogic, useIssueLogic } from "./index";
-import { sheetIdOfTask } from "@/utils";
+import { getBacktracePayloadWithIssue, sheetIdOfTask } from "@/utils";
export default defineComponent({
name: "TenantModeProvider",
@@ -79,7 +79,7 @@ export default defineComponent({
statement: newStatement,
visibility: "PROJECT",
source: "BYTEBASE_ARTIFACT",
- payload: {},
+ payload: getBacktracePayloadWithIssue(issue.value as Issue),
});
updateSheetId(sheet.id);
}
diff --git a/frontend/src/components/Issue/logic/common.ts b/frontend/src/components/Issue/logic/common.ts
index 54caae4ce4..257e6ce8d3 100644
--- a/frontend/src/components/Issue/logic/common.ts
+++ b/frontend/src/components/Issue/logic/common.ts
@@ -33,6 +33,7 @@ import {
import { IssueLogic, useIssueLogic } from "./index";
import {
defer,
+ getBacktracePayloadWithIssue,
isDev,
isTaskTriggeredByVCS,
taskCheckRunSummary,
@@ -202,13 +203,13 @@ export const useCommonLogic = () => {
statement: newStatement,
visibility: "PROJECT",
source: "BYTEBASE_ARTIFACT",
- payload: {},
+ payload: getBacktracePayloadWithIssue(issue.value as Issue),
});
const patchRequestList = patchingTaskList.map((task) => {
patchTask(task.id, { sheetId: sheet.id });
});
- return Promise.allSettled(patchRequestList);
+ await Promise.allSettled(patchRequestList);
}
};
diff --git a/frontend/src/utils/sheet.ts b/frontend/src/utils/sheet.ts
index 221b11b7aa..ceb5460ba0 100644
--- a/frontend/src/utils/sheet.ts
+++ b/frontend/src/utils/sheet.ts
@@ -21,6 +21,7 @@ import {
hasWorkspacePermission,
isMemberOfProject,
} from "../utils";
+import { flattenTaskList } from "@/components/Issue/logic";
export const isSheetReadable = (sheet: Sheet, currentUser: Principal) => {
// readable to
@@ -149,13 +150,11 @@ export const sheetIdOfTask = (task: Task) => {
export const maybeSetSheetBacktracePayloadByIssue = async (issue: Issue) => {
const sheetIdList: SheetId[] = [];
- issue.pipeline.stageList.forEach((stage) => {
- stage.taskList.forEach((task) => {
- const sheetId = sheetIdOfTask(task);
- if (sheetId) {
- sheetIdList.push(sheetId);
- }
- });
+ flattenTaskList(issue).forEach((task) => {
+ const sheetId = sheetIdOfTask(task as Task);
+ if (sheetId) {
+ sheetIdList.push(sheetId);
+ }
});
const store = useSheetStore();
@@ -178,6 +177,14 @@ export const maybeSetSheetBacktracePayloadByIssue = async (issue: Issue) => {
}
};
+export const getBacktracePayloadWithIssue = (issue: Issue) => {
+ return {
+ type: "bb.sheet.issue-backtrace",
+ issueId: issue.id,
+ issueName: issue.name,
+ };
+};
+
export const getSheetIssueBacktracePayload = (sheet: Sheet) => {
const maybePayload = (sheet.payload ?? {}) as SheetIssueBacktracePayload;
if (
diff --git a/frontend/src/views/SheetDashboard.vue b/frontend/src/views/SheetDashboard.vue
index bbdf0d081d..ca0f836175 100644
--- a/frontend/src/views/SheetDashboard.vue
+++ b/frontend/src/views/SheetDashboard.vue
@@ -99,6 +99,7 @@ import {
useSheetStore,
} from "@/store";
import { Sheet } from "@/types";
+import { getSheetIssueBacktracePayload } from "@/utils";
import {
type SheetViewMode,
SheetTable,
@@ -213,13 +214,19 @@ const currentSheetViewMode = computed((): SheetViewMode => {
});
const fetchSheetData = async () => {
+ let sheetList: Sheet[] = [];
if (currentSheetViewMode.value === "my") {
- state.sheetList = await sheetStore.fetchMySheetList();
+ sheetList = await sheetStore.fetchMySheetList();
} else if (currentSheetViewMode.value === "starred") {
- state.sheetList = await sheetStore.fetchStarredSheetList();
+ sheetList = await sheetStore.fetchStarredSheetList();
} else if (currentSheetViewMode.value === "shared") {
- state.sheetList = await sheetStore.fetchSharedSheetList();
+ sheetList = await sheetStore.fetchSharedSheetList();
}
+
+ // Hide those sheets from issue.
+ state.sheetList = sheetList.filter((sheet) => {
+ return !getSheetIssueBacktracePayload(sheet);
+ });
};
onMounted(async () => {
diff --git a/frontend/src/views/sql-editor/Sheet/SheetTable/IssueLink.vue b/frontend/src/views/sql-editor/Sheet/SheetTable/IssueLink.vue
deleted file mode 100644
index 874d186d87..0000000000
--- a/frontend/src/views/sql-editor/Sheet/SheetTable/IssueLink.vue
+++ /dev/null
@@ -1,33 +0,0 @@
-<template>
- <NTooltip v-if="payload">
- <template #trigger>
- <a
- class="normal-link"
- target="_blank"
- :href="`/issue/${issueSlug(payload.issueName, payload.issueId)}`"
- @click.stop=""
- >#{{ payload.issueId }}</a
- >
- </template>
-
- <div class="max-w-[20rem]">
- {{ payload.issueName }}
- </div>
- </NTooltip>
-</template>
-
-<script lang="ts" setup>
-import { computed } from "vue";
-import { NTooltip } from "naive-ui";
-
-import { Sheet } from "@/types";
-import { getSheetIssueBacktracePayload, issueSlug } from "@/utils";
-
-const props = defineProps<{
- sheet: Sheet;
-}>();
-
-const payload = computed(() => {
- return getSheetIssueBacktracePayload(props.sheet);
-});
-</script>
diff --git a/frontend/src/views/sql-editor/Sheet/SheetTable/SheetTable.vue b/frontend/src/views/sql-editor/Sheet/SheetTable/SheetTable.vue
index 3e9d6c64d6..54960a4805 100644
--- a/frontend/src/views/sql-editor/Sheet/SheetTable/SheetTable.vue
+++ b/frontend/src/views/sql-editor/Sheet/SheetTable/SheetTable.vue
@@ -26,9 +26,6 @@
class="truncate w-5/6"
>{{ value.value }}</span
>
- <div>
- <IssueLink :sheet="sheet" />
- </div>
<div class="flex flex-row justify-end items-center" @click.stop>
<Dropdown :sheet="sheet" :view="view" @refresh="$emit('refresh')" />
</div>
@@ -53,7 +50,6 @@ import dayjs from "dayjs";
import type { Sheet } from "@/types";
import { SheetViewMode } from "../types";
-import IssueLink from "./IssueLink.vue";
import Dropdown from "./Dropdown.vue";
import { useRouter } from "vue-router";
import { sheetSlug } from "@/utils";
@@ -118,11 +114,6 @@ const headers = computed(() => {
label: t("common.updated-at"),
});
- labelList.push({
- key: "linked-issue",
- label: t("sheet.linked-issue"),
- });
-
return labelList;
});