Skip to content

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

chore: optimize IM config (#12334)

ecmadao676ba991660f
diff --git a/backend/api/v1/setting_service.go b/backend/api/v1/setting_service.go
index 2627336bdd..c54bd96de2 100644
--- a/backend/api/v1/setting_service.go
+++ b/backend/api/v1/setting_service.go
@@ -577,11 +577,25 @@ func (s *SettingService) convertToSettingMessage(ctx context.Context, setting *s
},
})
case api.SettingAppIM:
+ storeValue := new(storepb.AppIMSetting)
+ if err := protojson.Unmarshal([]byte(setting.Value), storeValue); err != nil {
+ return nil, status.Errorf(codes.Internal, "failed to unmarshal setting value for %s with error: %v", setting.Name, err)
+ }
return &v1pb.Setting{
Name: settingName,
Value: &v1pb.Value{
Value: &v1pb.Value_AppImSettingValue{
- AppImSettingValue: &v1pb.AppIMSetting{},
+ AppImSettingValue: &v1pb.AppIMSetting{
+ Slack: &v1pb.AppIMSetting_Slack{
+ Enabled: storeValue.Slack != nil && storeValue.Slack.Enabled,
+ },
+ Feishu: &v1pb.AppIMSetting_Feishu{
+ Enabled: storeValue.Feishu != nil && storeValue.Feishu.Enabled,
+ },
+ Wecom: &v1pb.AppIMSetting_Wecom{
+ Enabled: storeValue.Wecom != nil && storeValue.Wecom.Enabled,
+ },
+ },
},
},
}, nil
diff --git a/frontend/src/components/ProjectWebhookForm.vue b/frontend/src/components/ProjectWebhookForm.vue
index ad611caf4c..0dc0f9e392 100644
--- a/frontend/src/components/ProjectWebhookForm.vue
+++ b/frontend/src/components/ProjectWebhookForm.vue
@@ -115,21 +115,28 @@
<div class="text-md leading-6 font-medium text-main">
{{ $t("project.webhook.direct-messages") }}
</div>
- <i18n-t
- class="mt-1 textinfolabel"
- tag="div"
- keypath="project.webhook.direct-messages-tip"
- >
- <template #im>
- <router-link
- target="_blank"
- class="normal-link"
- :to="{ name: WORKSPACE_ROUTE_IM }"
+ <span class="mt-1 textinfolabel">
+ {{ $t("project.webhook.direct-messages-tip") }}
+ </span>
+ <BBAttention v-if="!imApp?.enabled" class="mt-2 mb-4" type="warning">
+ <template #default>
+ <i18n-t
+ class="textinfolabel"
+ tag="div"
+ keypath="project.webhook.direct-messages-warning"
>
- {{ $t("settings.sidebar.im-integration") }}
- </router-link>
+ <template #im>
+ <router-link
+ target="_blank"
+ class="normal-link"
+ :to="{ name: WORKSPACE_ROUTE_IM }"
+ >
+ {{ $t("settings.sidebar.im-integration") }}
+ </router-link>
+ </template>
+ </i18n-t>
</template>
- </i18n-t>
+ </BBAttention>
<div class="flex items-center mt-2">
<NCheckbox
v-model:checked="state.webhook.directMessage"
@@ -202,15 +209,17 @@ import {
pushNotification,
useProjectWebhookV1Store,
useGracefulRequest,
+ useSettingV1Store,
} from "@/store";
import {
projectWebhookV1ActivityItemList,
projectWebhookV1TypeItemList,
} from "@/types";
-import type {
- Activity_Type,
- Project,
- Webhook,
+import {
+ Webhook_Type,
+ type Activity_Type,
+ type Project,
+ type Webhook,
} from "@/types/proto/v1/project_service";
import { projectWebhookV1Slug } from "../utils";
@@ -240,7 +249,9 @@ const props = defineProps({
const router = useRouter();
const { t } = useI18n();
+const settingStore = useSettingV1Store();
const projectWebhookV1Store = useProjectWebhookV1Store();
+
const state = reactive<LocalState>({
webhook: cloneDeep(props.webhook),
});
@@ -284,6 +295,25 @@ const selectedWebhook = computed(() => {
);
});
+const imSetting = computed(
+ () => settingStore.getSettingByName("bb.app.im")?.value?.appImSettingValue
+);
+
+const imApp = computed(() => {
+ if (!selectedWebhook.value?.supportDirectMessage) {
+ return undefined;
+ }
+ switch (selectedWebhook.value.type) {
+ case Webhook_Type.TYPE_SLACK:
+ return imSetting.value?.slack;
+ case Webhook_Type.TYPE_FEISHU:
+ return imSetting.value?.feishu;
+ case Webhook_Type.TYPE_WECOM:
+ return imSetting.value?.wecom;
+ }
+ return undefined;
+});
+
const webhookSupportDirectMessage = computed(
() => selectedWebhook.value?.supportDirectMessage
);
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 86e7b42a6c..3a9a47f7f6 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1895,7 +1895,8 @@
},
"direct-messages": "Direct messages",
"enable-direct-messages": "Enable direct messages",
- "direct-messages-tip": "Once enabled, Bytebase will send direct messages to the related users (matched by email). You need to configure {im} to make it work.",
+ "direct-messages-tip": "Once enabled, Bytebase will send direct messages to the related users (matched by email).",
+ "direct-messages-warning": "You need to configure {im} to make it work.",
"activity-support-direct-message": "Support send direct messages to related users",
"activity-item": {
"issue-creation": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 7313a7b1d0..1b065e2933 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1895,7 +1895,8 @@
},
"direct-messages": "Mensajes directos",
"enable-direct-messages": "Habilitar mensajes directos",
- "direct-messages-tip": "Una vez habilitado, Bytebase enviará mensajes directos a los usuarios relacionados (emparejados por correo electrónico). \nDebes configurar {im} para que funcione.",
+ "direct-messages-tip": "Una vez habilitado, Bytebase enviará mensajes directos a los usuarios relacionados (emparejados por correo electrónico).",
+ "direct-messages-warning": "Debes configurar {im} para que funcione.",
"activity-support-direct-message": "Soporte para enviar mensajes directos a usuarios relacionados.",
"activity-item": {
"issue-creation": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index c21ffbb082..fc9920d7a3 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1895,7 +1895,8 @@
},
"direct-messages": "プライベートメッセージ通知",
"enable-direct-messages": "プライベートメッセージ通知を有効にする",
- "direct-messages-tip": "有効にすると、Bytebase は関連ユーザー (電子メールで一致) にダイレクト メッセージを送信します。\nこれを機能させるには、{im} を構成する必要があります。",
+ "direct-messages-tip": "有効にすると、Bytebase は関連ユーザー (電子メールで一致) にダイレクト メッセージを送信します。",
+ "direct-messages-warning": "これを機能させるには、{im} を構成する必要があります。",
"activity-support-direct-message": "関連するユーザーへのプライベート メッセージ通知の送信のサポート",
"activity-item": {
"issue-creation": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 93d03a3c7e..b42523afee 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1895,7 +1895,8 @@
},
"direct-messages": "私信通知",
"enable-direct-messages": "启用私信通知",
- "direct-messages-tip": "启用后,Bytebase 将私信通知相关用户(通过电子邮件匹配)。您需要配置 {im} 才能使其正常工作。",
+ "direct-messages-tip": "启用后,Bytebase 将私信通知相关用户(通过电子邮件匹配)。",
+ "direct-messages-warning": "您需要配置 {im} 才能使其正常工作。",
"activity-support-direct-message": "支持向相关用户发送私信通知",
"activity-item": {
"issue-creation": {
diff --git a/frontend/src/views/SettingWorkspaceIM.vue b/frontend/src/views/SettingWorkspaceIM.vue
index 99083cfec3..1ed7119d4c 100644
--- a/frontend/src/views/SettingWorkspaceIM.vue
+++ b/frontend/src/views/SettingWorkspaceIM.vue
@@ -19,7 +19,12 @@
{{ item.name }}
</div>
</template>
- <component :is="() => item.render()" />
+ <div>
+ <BBAttention v-if="item.enabled" class="mt-2 mb-4" type="success">
+ <template #default>IM App Enabled</template>
+ </BBAttention>
+ <component :is="() => item.render()" />
+ </div>
</NTabPane>
</NTabs>
<div class="flex items-center justify-end space-x-2 pt-2">
@@ -120,6 +125,7 @@ const imList = computed(() => {
{
name: t("common.slack"),
type: Webhook_Type.TYPE_SLACK,
+ enabled: state.setting.slack?.enabled,
render: () => {
return (
<div>
@@ -139,6 +145,7 @@ const imList = computed(() => {
{
name: t("common.feishu"),
type: Webhook_Type.TYPE_DINGTALK,
+ enabled: state.setting.feishu?.enabled,
hide: !isDev(),
render: () => {
return (
@@ -172,6 +179,7 @@ const imList = computed(() => {
{
name: t("common.wecom"),
type: Webhook_Type.TYPE_WECOM,
+ enabled: state.setting.wecom?.enabled,
hide: !isDev(),
render: () => {
return (
@@ -257,15 +265,20 @@ const discardChanges = () => {
const onSave = async () => {
state.loading = true;
const updateMask: string[] = [];
+ const data = cloneDeep(state.setting);
+
switch (state.selectedTab) {
case Webhook_Type.TYPE_SLACK:
updateMask.push("value.app_im_setting_value.slack");
+ data.slack!.enabled = true;
break;
case Webhook_Type.TYPE_DINGTALK:
updateMask.push("value.app_im_setting_value.feishu");
+ data.feishu!.enabled = true;
break;
case Webhook_Type.TYPE_WECOM:
updateMask.push("value.app_im_setting_value.wecom");
+ data.wecom!.enabled = true;
break;
}
@@ -273,7 +286,7 @@ const onSave = async () => {
const setting = await settingStore.upsertSetting({
name: "bb.app.im",
value: {
- appImSettingValue: state.setting,
+ appImSettingValue: data,
},
updateMask,
});