Skip to content

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

feat(frontend): assignee approval feature improvement (#3727)

Liu Jif6ab47b0d00c
diff --git a/frontend/src/components/Issue/AssigneeAttentionButton.vue b/frontend/src/components/Issue/AssigneeAttentionButton.vue
new file mode 100644
index 0000000000..2410fae0f4
--- /dev/null
+++ b/frontend/src/components/Issue/AssigneeAttentionButton.vue
@@ -0,0 +1,132 @@
+<template>
+ <NTooltip v-if="showNotifyAssignee">
+ <template #trigger>
+ <button
+ class="p-0.5 rounded"
+ :class="[
+ isAssigneeAttentionOn
+ ? 'cursor-default'
+ : 'cursor-pointer hover:bg-control-bg-hover',
+ ]"
+ v-bind="$attrs"
+ @click="notifyAssignee"
+ >
+ <heroicons-outline:bell-alert
+ class="w-4 h-4"
+ :class="[isAssigneeAttentionOn ? 'text-accent' : 'text-main']"
+ />
+ </button>
+ </template>
+
+ <span class="whitespace-nowrap">
+ <template v-if="isAssigneeAttentionOn">
+ {{ $t("issue.assignee-attention.needs-attention") }}
+ </template>
+ <template v-else>
+ {{ $t("issue.assignee-attention.click-to-mark") }}
+ </template>
+ </span>
+ </NTooltip>
+</template>
+
+<script lang="ts" setup>
+import { computed } from "vue";
+import { useI18n } from "vue-i18n";
+import { NTooltip } from "naive-ui";
+
+import {
+ pushNotification,
+ useCurrentUser,
+ useIssueStore,
+ useSettingStore,
+} from "@/store";
+import { useIssueLogic } from "./logic";
+import { Issue } from "@/types";
+import { SettingAppIMValue } from "@/types/setting";
+
+const { t } = useI18n();
+const currentUser = useCurrentUser();
+const settingStore = useSettingStore();
+const { create, project, issue } = useIssueLogic();
+
+const showNotifyAssignee = computed(() => {
+ if (create.value) {
+ return false;
+ }
+ if (project.value.workflowType === "VCS") {
+ return false;
+ }
+
+ const issueEntity = issue.value as Issue;
+
+ if (issueEntity.status !== "OPEN") {
+ return false;
+ }
+ if (
+ issueEntity.assigneeNeedAttention &&
+ currentUser.value.id === issueEntity.assignee.id
+ ) {
+ // Also show the icon for assignee if need attention.
+ return true;
+ }
+
+ return currentUser.value.id === issueEntity.creator.id;
+});
+
+const isAssigneeAttentionOn = computed(() => {
+ return (issue.value as Issue).assigneeNeedAttention;
+});
+
+const externalApprovalSetting = computed(
+ (): { enabled: boolean; type: string } => {
+ const setting = settingStore.getSettingByName("bb.app.im");
+ if (setting) {
+ const appFeishuValue = JSON.parse(
+ setting.value || "{}"
+ ) as SettingAppIMValue;
+ if (appFeishuValue.imType === "im.feishu") {
+ return {
+ type: "feishu",
+ enabled: appFeishuValue.externalApproval.enabled,
+ };
+ }
+ }
+ return {
+ enabled: false,
+ type: "",
+ };
+ }
+);
+
+const imTypeName = computed((): string => {
+ const { enabled, type } = externalApprovalSetting.value;
+ if (!enabled) return t("common.im");
+ return t(`common.${type}`);
+});
+
+const notifyAssignee = () => {
+ if (!showNotifyAssignee.value) return;
+ if (isAssigneeAttentionOn.value) return;
+
+ useIssueStore()
+ .patchIssue({
+ issueId: (issue.value as Issue).id,
+ issuePatch: {
+ assigneeNeedAttention: true,
+ },
+ })
+ .then(() => {
+ const message = externalApprovalSetting.value.enabled
+ ? t("issue.assignee-attention.send-approval-request-successfully", {
+ im: imTypeName.value,
+ })
+ : t("common.updated");
+
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: message,
+ });
+ });
+};
+</script>
diff --git a/frontend/src/components/Issue/IssueSidebar.vue b/frontend/src/components/Issue/IssueSidebar.vue
index 59b5e2e23e..1201a5c679 100644
--- a/frontend/src/components/Issue/IssueSidebar.vue
+++ b/frontend/src/components/Issue/IssueSidebar.vue
@@ -22,22 +22,7 @@
<h2 class="textlabel flex items-center col-span-1 col-start-1 gap-x-1">
<span>{{ $t("common.assignee") }}</span>
<span v-if="create" class="text-red-600">*</span>
- <button
- v-if="showNotifyAssignee"
- :disabled="isAssigneeAttentionOn"
- class="p-0.5 rounded tooltip-wrapper"
- :class="[
- !isAssigneeAttentionOn &&
- 'cursor-pointer hover:bg-control-bg-hover',
- ]"
- @click="notifyAssignee"
- >
- <heroicons-outline:bell-alert
- v-if="isAssigneeAttentionOn"
- class="w-4 h-4"
- />
- <heroicons-outline:bell v-else class="w-4 h-4" />
- </button>
+ <AssigneeAttentionButton />
</h2>
<!-- Only DBA can be assigned to the issue -->
<div class="col-span-2" data-label="bb-assignee-select-container">
@@ -294,7 +279,6 @@ import { NDatePicker } from "naive-ui";
import { useRouter } from "vue-router";
import dayjs from "dayjs";
import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
-import { useI18n } from "vue-i18n";
import StageSelect from "./StageSelect.vue";
import TaskSelect from "./TaskSelect.vue";
@@ -331,11 +315,9 @@ import {
} from "@/utils";
import {
hasFeature,
- pushNotification,
useCurrentUser,
useDatabaseStore,
useEnvironmentStore,
- useIssueStore,
useProjectStore,
} from "@/store";
import {
@@ -363,7 +345,6 @@ const props = defineProps({
},
});
-const { t } = useI18n();
const router = useRouter();
const projectStore = useProjectStore();
@@ -498,54 +479,6 @@ const allowEditAssignee = computed(() => {
return false;
});
-const showNotifyAssignee = computed(() => {
- if (create.value) {
- return false;
- }
- if (project.value.workflowType === "VCS") {
- return false;
- }
-
- const issueEntity = issue.value as Issue;
-
- if (issueEntity.status !== "OPEN") {
- return false;
- }
- if (
- issueEntity.assigneeNeedAttention &&
- currentUser.value.id === issueEntity.assignee.id
- ) {
- // Also show the icon for assignee if need attention.
- return true;
- }
-
- return currentUser.value.id === issueEntity.creator.id;
-});
-
-const isAssigneeAttentionOn = computed(() => {
- return (issue.value as Issue).assigneeNeedAttention;
-});
-
-const notifyAssignee = () => {
- if (!showNotifyAssignee.value) return;
- if (isAssigneeAttentionOn.value) return;
-
- useIssueStore()
- .patchIssue({
- issueId: (issue.value as Issue).id,
- issuePatch: {
- assigneeNeedAttention: true,
- },
- })
- .then(() => {
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("common.updated"),
- });
- });
-};
-
const allowEditEarliestAllowedTime = computed(() => {
if (create.value) {
return true;
diff --git a/frontend/src/components/Issue/IssueTable.vue b/frontend/src/components/Issue/IssueTable.vue
index 70cb1ac241..243951dd26 100644
--- a/frontend/src/components/Issue/IssueTable.vue
+++ b/frontend/src/components/Issue/IssueTable.vue
@@ -67,10 +67,18 @@
>
{{ issue.name }}
</div>
- <heroicons-outline:bell-alert
- v-if="isAssigneeAttentionOn(issue)"
- class="w-4 h-4 ml-1"
- />
+ <NTooltip v-if="isAssigneeAttentionOn(issue)">
+ <template #trigger>
+ <span>
+ <heroicons-outline:bell-alert
+ class="w-4 h-4 text-accent ml-1"
+ />
+ </span>
+ </template>
+ <span class="whitespace-nowrap">
+ {{ $t("issue.assignee-attention.needs-attention") }}
+ </span>
+ </NTooltip>
</div>
</BBTableCell>
<BBTableCell class="table-cell w-36">
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 723dff0c66..0a46902cff 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -11,6 +11,7 @@
"feishu": "Feishu",
"wecom": "WeCom",
"custom": "Custom",
+ "im": "IM",
"overview": "Overview",
"migration-history": "Migration History",
"webhook": "Webhook",
@@ -571,7 +572,12 @@
"snowflake": "Use <<schema>>.<<table>> to specify a Snowflake table"
},
"rollback-from": "This task rollbacks from {link}.",
- "issue-link-with-task": "Issue {issue} - task {task}"
+ "issue-link-with-task": "Issue {issue} - task {task}",
+ "assignee-attention": {
+ "send-approval-request-successfully": "Send a {im} approval request successfully",
+ "needs-attention": "Needs attention",
+ "click-to-mark": "Click to mark it as \"Needs attention\""
+ }
},
"alter-schema": {
"vcs-enabled": "This project has enabled VCS based version control and selecting database below will navigate you to the corresponding Git repository to initiate the change process.",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index c9911de07f..e59225d6a4 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -11,6 +11,7 @@
"feishu": "飞书",
"wecom": "企业微信",
"custom": "自定义",
+ "im": "IM",
"overview": "概览",
"migration-history": "变更历史",
"webhook": "Webhook",
@@ -571,7 +572,12 @@
"snowflake": "使用 <<schema>>.<<table>> 来标注一个 SnowFlake 的表"
},
"rollback-from": "当前任务回滚自 {link}。",
- "issue-link-with-task": "工单 {issue} - 任务 {task}"
+ "issue-link-with-task": "工单 {issue} - 任务 {task}",
+ "assignee-attention": {
+ "send-approval-request-successfully": "{im}审批请求发送成功",
+ "needs-attention": "需要关注",
+ "click-to-mark": "点击以标记为「需要关注」"
+ }
},
"alter-schema": {
"vcs-enabled": "该项目开启了基于 VCS 的版本管理,选择下面的数据库会将您导航到相应的 Git 仓库以发起变更流程。",