Skip to content

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

feat(frontend): display vcs push info in CI/CD UI (#7778)

Liu Ji7211fb3b074c
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/VCSInfo.vue b/frontend/src/components/IssueV1/components/HeaderSection/VCSInfo.vue
index 7c17da2d3b..836726addf 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/VCSInfo.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/VCSInfo.vue
@@ -1,83 +1,86 @@
<template>
- <div class="issue-debug">
- issue vcs push event info if needed
- <!-- <p
- v-if="pushEvent"
- class="mt-1 text-sm text-control-light flex flex-row items-center space-x-1"
+ <p
+ v-if="pushEvent"
+ class="mt-1 text-sm text-control-light flex flex-row items-center space-x-1"
+ >
+ <template v-if="pushEvent.vcsType === VcsType.GITLAB">
+ <img class="h-4 w-auto" src="@/assets/gitlab-logo.svg" />
+ </template>
+ <template v-else-if="pushEvent.vcsType === VcsType.GITHUB">
+ <img class="h-4 w-auto" src="@/assets/github-logo.svg" />
+ </template>
+ <template v-else-if="pushEvent.vcsType === VcsType.BITBUCKET">
+ <img class="h-4 w-auto" src="@/assets/bitbucket-logo.svg" />
+ </template>
+ <a :href="vcsBranchUrl" target="_blank" class="normal-link">{{
+ `${vcsBranch}@${pushEvent.repositoryFullPath}`
+ }}</a>
+
+ <i18n-t
+ v-if="commit && commit.id && commit.url"
+ keypath="issue.commit-by-at"
+ tag="span"
>
- <template v-if="pushEvent.vcsType.startsWith('GITLAB')">
- <img class="h-4 w-auto" src="../../assets/gitlab-logo.svg" />
+ <template #id>
+ <a :href="commit.url" target="_blank" class="normal-link"
+ >{{ commit.id.substring(0, 7) }}:</a
+ >
</template>
- <template v-else-if="pushEvent.vcsType.startsWith('GITHUB')">
- <img class="h-4 w-auto" src="../../assets/github-logo.svg" />
+ <template #title>
+ <span class="text-main">{{ commit.title }}</span>
</template>
- <template v-else-if="pushEvent.vcsType.startsWith('BITBUCKET')">
- <img class="h-4 w-auto" src="../../assets/bitbucket-logo.svg" />
+ <template #author>{{ pushEvent.authorName }}</template>
+ <template #time>
+ <HumanizeDate :date="commit.createdTime" />
</template>
- <a :href="vcsBranchUrl" target="_blank" class="normal-link">{{
- `${vcsBranch}@${pushEvent.repositoryFullPath}`
- }}</a>
-
- <i18n-t
- v-if="commit && commit.id && commit.url"
- keypath="issue.commit-by-at"
- tag="span"
- >
- <template #id>
- <a :href="commit.url" target="_blank" class="normal-link"
- >{{ commit.id.substring(0, 7) }}:</a
- >
- </template>
- <template #title>
- <span class="text-main">{{ commit.title }}</span>
- </template>
- <template #author>{{ pushEvent.authorName }}</template>
- <template #time>{{
- dayjs(commit.createdTs * 1000).format("LLL")
- }}</template>
- </i18n-t>
- </p> -->
- </div>
+ </i18n-t>
+ </p>
</template>
<script setup lang="ts">
-// const pushEvent = computed((): VCSPushEvent | undefined => {
-// if (issue.value.type == "bb.issue.database.schema.update") {
-// const payload = activeTask(issue.value.pipeline!)
-// .payload as TaskDatabaseSchemaUpdatePayload;
-// return payload?.pushEvent;
-// } else if (issue.value.type == "bb.issue.database.data.update") {
-// const payload = activeTask(issue.value.pipeline!)
-// .payload as TaskDatabaseDataUpdatePayload;
-// return payload?.pushEvent;
-// }
-// return undefined;
-// });
+import { head } from "lodash-es";
+import { computed } from "vue";
+import HumanizeDate from "@/components/misc/HumanizeDate.vue";
+import { PushEvent, VcsType } from "@/types/proto/v1/vcs";
+import { useIssueContext } from "../../logic";
+import { useActiveTaskSheet } from "./useActiveTaskSheet";
+
+const { isCreating } = useIssueContext();
+
+const { sheet, sheetReady } = useActiveTaskSheet();
+
+const pushEvent = computed((): PushEvent | undefined => {
+ if (isCreating.value) return undefined;
+
+ if (!sheetReady.value) return undefined;
+ if (!sheet.value) return undefined;
+ return sheet.value.pushEvent;
+});
-// const commit = computed(() => {
-// // Use commits[0] for new format
-// // Use fileCommit for legacy data (if possible)
-// // Use undefined otherwise
-// return head(pushEvent.value?.commits) ?? pushEvent.value?.fileCommit;
-// });
+const commit = computed(() => {
+ // Use commits[0] for new format
+ // Use fileCommit for legacy data (if possible)
+ // Use undefined otherwise
+ return head(pushEvent.value?.commits) ?? pushEvent.value?.fileCommit;
+});
-// const vcsBranch = computed((): string => {
-// if (pushEvent.value) {
-// return pushEvent.value.ref.replace(/^refs\/heads\//g, "");
-// }
-// return "";
-// });
+const vcsBranch = computed((): string => {
+ if (pushEvent.value) {
+ return pushEvent.value.ref.replace(/^refs\/heads\//g, "");
+ }
+ return "";
+});
-// const vcsBranchUrl = computed((): string => {
-// if (pushEvent.value) {
-// if (pushEvent.value.vcsType == "GITLAB") {
-// return `${pushEvent.value.repositoryUrl}/-/tree/${vcsBranch.value}`;
-// } else if (pushEvent.value.vcsType == "GITHUB") {
-// return `${pushEvent.value.repositoryUrl}/tree/${vcsBranch.value}`;
-// } else if (pushEvent.value.vcsType == "BITBUCKET") {
-// return `${pushEvent.value.repositoryUrl}/src/${vcsBranch.value}`;
-// }
-// }
-// return "";
-// });
+const vcsBranchUrl = computed((): string => {
+ if (pushEvent.value) {
+ if (pushEvent.value.vcsType === VcsType.GITLAB) {
+ return `${pushEvent.value.repositoryUrl}/-/tree/${vcsBranch.value}`;
+ } else if (pushEvent.value.vcsType === VcsType.GITHUB) {
+ return `${pushEvent.value.repositoryUrl}/tree/${vcsBranch.value}`;
+ } else if (pushEvent.value.vcsType === VcsType.BITBUCKET) {
+ return `${pushEvent.value.repositoryUrl}/src/${vcsBranch.value}`;
+ }
+ }
+ return "";
+});
</script>
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/useActiveTaskSheet.ts b/frontend/src/components/IssueV1/components/HeaderSection/useActiveTaskSheet.ts
new file mode 100644
index 0000000000..b01daf5fc1
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/HeaderSection/useActiveTaskSheet.ts
@@ -0,0 +1,43 @@
+import { computed, ref, watch } from "vue";
+import { useIssueContext } from "@/components/IssueV1/logic";
+import { useSheetV1Store } from "@/store";
+import { extractSheetUID, sheetNameOfTaskV1 } from "@/utils";
+
+export const useActiveTaskSheet = () => {
+ const sheetStore = useSheetV1Store();
+ const { isCreating, activeTask } = useIssueContext();
+
+ const sheetName = computed(() => {
+ return sheetNameOfTaskV1(activeTask.value);
+ });
+ const sheetReady = ref(false);
+ const sheet = computed(() => {
+ if (isCreating.value) {
+ return undefined;
+ }
+ const name = sheetName.value;
+ return sheetStore.getSheetByName(name);
+ });
+ watch(
+ [sheetName, isCreating],
+ ([sheetName, isCreating]) => {
+ if (isCreating) {
+ sheetReady.value = true;
+ return;
+ }
+ const uid = extractSheetUID(sheetName);
+ if (!uid) return;
+ sheetReady.value = false;
+ sheetStore.getOrFetchSheetByName(sheetName).finally(() => {
+ sheetReady.value = true;
+ });
+ },
+ { immediate: true }
+ );
+
+ return {
+ sheet,
+ sheetName,
+ sheetReady,
+ };
+};
diff --git a/frontend/src/components/IssueV1/components/StatementSection/SDLView/useSDLState.ts b/frontend/src/components/IssueV1/components/StatementSection/SDLView/useSDLState.ts
index b48def3187..05d21bda92 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/SDLView/useSDLState.ts
+++ b/frontend/src/components/IssueV1/components/StatementSection/SDLView/useSDLState.ts
@@ -34,7 +34,7 @@ export type SDLEvents = Emittery<{
export const useSDLState = () => {
const { issue, selectedTask } = useIssueContext();
- const { sheetStatement } = useTaskSheet();
+ const { sheetStatement, sheetReady } = useTaskSheet();
const databaseStore = useDatabaseV1Store();
const events: SDLEvents = new Emittery();
@@ -91,11 +91,16 @@ export const useSDLState = () => {
};
const diffDDL = await useSilentRequest(getSchemaDiff);
- const { currentSchema, expectedSchema } = await sqlServiceClient.pretty({
- engine: database.instanceEntity.engine,
- currentSchema: previousSDL ?? "",
- expectedSchema: expectedSDL ?? "",
- });
+ const { currentSchema, expectedSchema } = await sqlServiceClient.pretty(
+ {
+ engine: database.instanceEntity.engine,
+ currentSchema: previousSDL ?? "",
+ expectedSchema: expectedSDL ?? "",
+ },
+ {
+ silent: true,
+ }
+ );
if (task.status === Task_Status.DONE) {
throw new Error();
@@ -138,8 +143,15 @@ export const useSDLState = () => {
};
watch(
- [() => selectedTask.value.name, sheetStatement, changeHistoryName],
- async ([taskName, statement, changeHistoryName]) => {
+ [
+ () => selectedTask.value.name,
+ sheetStatement,
+ sheetReady,
+ changeHistoryName,
+ ],
+ async ([taskName, statement, sheetReady, changeHistoryName]) => {
+ if (!sheetReady) return;
+
const task = selectedTask.value;
if (!map.has(taskName)) {
map.set(taskName, emptyState(task));