Skip to content

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

feat(frontend): implement sync external approval node button (#6688)

Liu Jic0ff119a47b5
diff --git a/frontend/src/components/Issue/review/ApprovalTimeline.vue b/frontend/src/components/Issue/review/ApprovalTimeline.vue
index cda689feb0..d5a9d4f513 100644
--- a/frontend/src/components/Issue/review/ApprovalTimeline.vue
+++ b/frontend/src/components/Issue/review/ApprovalTimeline.vue
@@ -28,10 +28,10 @@
</template>
<div class="flex-1 flex text-sm overflow-hidden" :class="itemClass(step)">
- <div class="whitespace-nowrap shrink-0">
- {{ approvalNodeText(step.step.nodes[0]) }}
- </div>
<template v-if="!isExternalApprovalStep(step.step)">
+ <div class="whitespace-nowrap shrink-0">
+ {{ approvalNodeText(step.step.nodes[0]) }}
+ </div>
<div class="mr-1.5 shrink-0">:</div>
<div class="flex-1 overflow-hidden">
<NEllipsis
@@ -53,6 +53,12 @@
<Candidates v-else :step="step" />
</div>
</template>
+ <template v-else>
+ <div class="whitespace-nowrap shrink-0">
+ {{ approvalNodeText(step.step.nodes[0]) }}
+ </div>
+ <ExternalApprovalSyncButton />
+ </template>
</div>
</NTimelineItem>
</NTimeline>
@@ -66,6 +72,7 @@ import { approvalNodeText } from "@/utils";
import { storeToRefs } from "pinia";
import { useAuthStore } from "@/store";
import Candidates from "./Candidates.vue";
+import ExternalApprovalSyncButton from "./ExternalApprovalNodeSyncButton.vue";
import { ApprovalStep } from "@/types/proto/v1/review_service";
const USER_SYSTEM_BOT = "users/1";
diff --git a/frontend/src/components/Issue/review/ExternalApprovalNodeSyncButton.vue b/frontend/src/components/Issue/review/ExternalApprovalNodeSyncButton.vue
new file mode 100644
index 0000000000..233b50762e
--- /dev/null
+++ b/frontend/src/components/Issue/review/ExternalApprovalNodeSyncButton.vue
@@ -0,0 +1,64 @@
+<template>
+ <NTooltip>
+ <template #trigger>
+ <NButton
+ size="tiny"
+ circle
+ class="!ml-1"
+ :loading="syncing"
+ :tertiary="synced"
+ :type="synced ? 'success' : 'default'"
+ @click="syncNow"
+ >
+ <template #icon>
+ <heroicons:arrow-path v-if="!synced" class="w-4 h-4" />
+ <heroicons:check v-else class="w-4 h-4" />
+ </template>
+ </NButton>
+ </template>
+
+ <div class="whitespace-nowrap">
+ {{ $t("common.sync-now") }}
+ </div>
+ </NTooltip>
+</template>
+
+<script setup lang="ts">
+import { ref, Ref } from "vue";
+import { NButton, NTooltip } from "naive-ui";
+import { useI18n } from "vue-i18n";
+
+import { Issue } from "@/types";
+import { useIssueLogic } from "../logic";
+import { pushNotification, useReviewStore } from "@/store";
+
+const { t } = useI18n();
+const syncing = ref(false);
+const synced = ref(false);
+const issueLogic = useIssueLogic();
+const issue = issueLogic.issue as Ref<Issue>;
+
+const syncNow = async () => {
+ if (syncing.value || synced.value) return;
+
+ syncing.value = true;
+ try {
+ await useReviewStore().fetchReviewByIssue(issue.value, true /* force */);
+
+ synced.value = true;
+ // Show 'synced' status for several seconds to avoid user clicking sync
+ // button too frequently.
+ setTimeout(() => {
+ synced.value = false;
+ }, 5000);
+
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.success"),
+ });
+ } finally {
+ syncing.value = false;
+ }
+};
+</script>
diff --git a/frontend/src/store/modules/review.ts b/frontend/src/store/modules/review.ts
index 7fb47a9994..f4787c90c2 100644
--- a/frontend/src/store/modules/review.ts
+++ b/frontend/src/store/modules/review.ts
@@ -38,12 +38,13 @@ export const useReviewStore = defineStore("review", () => {
reviewsByName.value.set(reviewName(issue), review);
};
- const fetchReviewByIssue = async (issue: Issue, ignoreCache = false) => {
+ const fetchReviewByIssue = async (issue: Issue, force = false) => {
const name = reviewName(issue);
try {
const review = await reviewServiceClient.getReview({
name,
+ force,
});
await setReviewByIssue(issue, review);
return review;