Skip to content

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

chore: support set im (#12315)

ecmadao20837e14c16c
diff --git a/frontend/src/components/ProjectWebhookForm.vue b/frontend/src/components/ProjectWebhookForm.vue
index 40b885ac4e..ad611caf4c 100644
--- a/frontend/src/components/ProjectWebhookForm.vue
+++ b/frontend/src/components/ProjectWebhookForm.vue
@@ -2,17 +2,14 @@
<div class="flex flex-col gap-y-4">
<div v-if="create">
<div>
- <label for="name" class="textlabel">
+ <label for="name" class="font-medium text-main">
{{ $t("project.webhook.destination") }}
<span class="text-red-600">*</span>
</label>
</div>
<NRadioGroup class="w-full mt-1" :value="state.webhook.type">
<div class="grid grid-cols-1 gap-4 sm:grid-cols-7">
- <template
- v-for="(item, index) in projectWebhookV1TypeItemList()"
- :key="index"
- >
+ <template v-for="(item, index) in webhookTypeItemList" :key="index">
<div
class="flex justify-center px-2 py-4 rounded border border-control-border hover:bg-control-bg-hover cursor-pointer"
@click.capture="state.webhook.type = item.type"
@@ -32,7 +29,7 @@
</NRadioGroup>
</div>
<div>
- <label for="name" class="textlabel">
+ <label for="name" class="font-medium text-main">
{{ $t("common.name") }} <span class="text-red-600">*</span>
</label>
<NInput
@@ -40,148 +37,38 @@
v-model:value="state.webhook.title"
name="name"
class="mt-1 w-full"
- :placeholder="namePlaceholder"
+ :placeholder="`${selectedWebhook?.name ?? 'My'} Webhook`"
:disabled="!allowEdit"
/>
</div>
<div>
- <label for="url" class="textlabel">
+ <label for="url" class="font-medium text-main">
{{ $t("project.webhook.webhook-url") }}
<span class="text-red-600">*</span>
</label>
<div class="mt-1 textinfolabel">
- <template v-if="state.webhook.type === Webhook_Type.TYPE_SLACK">
- {{
- $t("project.webhook.creation.desc", {
- destination: $t("common.slack"),
- })
- }}
- <a
- href="https://api.slack.com/messaging/webhooks"
- target="__blank"
- class="normal-link"
- >{{
- $t("project.webhook.creation.view-doc", {
- destination: $t("common.slack"),
- })
- }}</a
- >.
- </template>
- <template v-else-if="state.webhook.type === Webhook_Type.TYPE_DISCORD">
- {{
- $t("project.webhook.creation.desc", {
- destination: $t("common.discord"),
- })
- }}
- <a
- href="https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks"
- target="__blank"
- class="normal-link"
- >{{
- $t("project.webhook.creation.view-doc", {
- destination: $t("common.discord"),
- })
- }}</a
- >.
- </template>
- <template v-else-if="state.webhook.type === Webhook_Type.TYPE_TEAMS">
- {{
- $t("project.webhook.creation.desc", {
- destination: $t("common.teams"),
- })
- }}
- <a
- href="https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook"
- target="__blank"
- class="normal-link"
- >{{
- $t("project.webhook.creation.view-doc", {
- destination: $t("common.teams"),
- })
- }}</a
- >.
- </template>
- <template v-else-if="state.webhook.type === Webhook_Type.TYPE_DINGTALK">
- {{
- $t("project.webhook.creation.desc", {
- destination: $t("common.dingtalk"),
- }) +
- ". " +
- $t("project.webhook.creation.how-to-protect")
- }}
- <a
- href="https://developers.dingtalk.com/document/robots/custom-robot-access"
- target="__blank"
- class="normal-link"
- >{{
- $t("project.webhook.creation.view-doc", {
- destination: $t("common.dingtalk"),
- })
- }}</a
- >.
- </template>
- <template v-else-if="state.webhook.type === Webhook_Type.TYPE_FEISHU">
- {{
- $t("project.webhook.creation.desc", {
- destination: $t("common.feishu"),
- }) +
- ". " +
- $t("project.webhook.creation.how-to-protect")
- }}
-
- <a
- href="https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot"
- target="__blank"
- class="normal-link"
- >{{
- $t("project.webhook.creation.view-doc", {
- destination: $t("common.feishu"),
- })
- }}</a
- >.
- </template>
- <!-- WeCom doesn't seem to provide official webhook setup guide for the enduser -->
- <template v-else-if="state.webhook.type === Webhook_Type.TYPE_WECOM">
- {{
- $t("project.webhook.creation.desc", {
- destination: $t("common.wecom"),
+ {{
+ $t("project.webhook.creation.desc", {
+ destination: selectedWebhook?.name,
+ })
+ }}
+ <a
+ :href="selectedWebhook?.docUrl"
+ target="__blank"
+ class="normal-link"
+ >{{
+ $t("project.webhook.creation.view-doc", {
+ destination: selectedWebhook?.name,
})
- }}
- <a
- href="https://open.work.weixin.qq.com/help2/pc/14931"
- target="__blank"
- class="normal-link"
- >{{
- $t("project.webhook.creation.view-doc", {
- destination: $t("common.wecom"),
- })
- }}</a
- >.
- </template>
- <template v-else-if="state.webhook.type === Webhook_Type.TYPE_CUSTOM">
- {{
- $t("project.webhook.creation.desc", {
- destination: $t("common.custom"),
- })
- }}
- <a
- href="https://www.bytebase.com/docs/change-database/webhook#custom?source=console"
- target="__blank"
- class="normal-link"
- >{{
- $t("project.webhook.creation.view-doc", {
- destination: $t("common.custom"),
- })
- }}</a
- >.
- </template>
+ }}</a
+ >.
</div>
<NInput
id="url"
v-model:value="state.webhook.url"
name="url"
class="mt-1 w-full"
- :placeholder="urlPlaceholder"
+ :placeholder="selectedWebhook?.urlPlaceholder"
:disabled="!allowEdit"
/>
</div>
@@ -191,28 +78,64 @@
<span class="text-red-600">*</span>
</div>
<div
- v-for="(item, index) in projectWebhookV1ActivityItemList()"
+ v-for="(item, index) in webhookActivityItemList"
:key="index"
class="mt-4 space-y-4"
>
<div>
- <NCheckbox
- :label="item.title"
- :checked="isEventOn(item.activity)"
- @update:checked="
- (on: boolean) => {
- toggleEvent(item.activity, on);
- }
- "
- />
+ <div class="flex items-center">
+ <NCheckbox
+ :label="item.title"
+ :checked="isEventOn(item.activity)"
+ @update:checked="
+ (on: boolean) => {
+ toggleEvent(item.activity, on);
+ }
+ "
+ />
+ <NTooltip
+ v-if="webhookSupportDirectMessage && item.supportDirectMessage"
+ >
+ <template #trigger>
+ <InfoIcon class="w-4 h-auto text-gray-500" />
+ </template>
+ {{ $t("project.webhook.activity-support-direct-message") }}
+ </NTooltip>
+ </div>
<div class="textinfolabel">{{ item.label }}</div>
</div>
</div>
+ <div class="mt-4">
+ <NButton @click.prevent="testWebhook">
+ {{ $t("project.webhook.test-webhook") }}
+ </NButton>
+ </div>
</div>
- <div>
- <NButton @click.prevent="testWebhook">
- {{ $t("project.webhook.test-webhook") }}
- </NButton>
+ <div v-if="webhookSupportDirectMessage && avtivitySupportDirectMessage">
+ <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 }"
+ >
+ {{ $t("settings.sidebar.im-integration") }}
+ </router-link>
+ </template>
+ </i18n-t>
+ <div class="flex items-center mt-2">
+ <NCheckbox
+ v-model:checked="state.webhook.directMessage"
+ :label="$t('project.webhook.enable-direct-messages')"
+ />
+ </div>
</div>
<div
class="flex mt-2 pt-4 border-t"
@@ -264,6 +187,7 @@
<script lang="ts" setup>
import { cloneDeep, isEmpty, isEqual } from "lodash-es";
+import { InfoIcon } from "lucide-vue-next";
import { NCheckbox, NRadio, NRadioGroup } from "naive-ui";
import type { PropType } from "vue";
import { reactive, computed, watch } from "vue";
@@ -273,6 +197,7 @@ import {
PROJECT_V1_ROUTE_WEBHOOKS,
PROJECT_V1_ROUTE_WEBHOOK_DETAIL,
} from "@/router/dashboard/projectV1";
+import { WORKSPACE_ROUTE_IM } from "@/router/dashboard/workspaceRoutes";
import {
pushNotification,
useProjectWebhookV1Store,
@@ -287,7 +212,6 @@ import type {
Project,
Webhook,
} from "@/types/proto/v1/project_service";
-import { Webhook_Type } from "@/types/proto/v1/project_service";
import { projectWebhookV1Slug } from "../utils";
interface LocalState {
@@ -328,46 +252,6 @@ watch(
}
);
-const namePlaceholder = computed(() => {
- if (state.webhook.type === Webhook_Type.TYPE_SLACK) {
- return `${t("common.slack")} Webhook`;
- } else if (state.webhook.type === Webhook_Type.TYPE_DISCORD) {
- return `${t("common.discord")} Webhook`;
- } else if (state.webhook.type === Webhook_Type.TYPE_TEAMS) {
- return `${t("common.teams")} Webhook`;
- } else if (state.webhook.type === Webhook_Type.TYPE_DINGTALK) {
- return `${t("common.dingtalk")} Webhook`;
- } else if (state.webhook.type === Webhook_Type.TYPE_FEISHU) {
- return `${t("common.feishu")} Webhook`;
- } else if (state.webhook.type === Webhook_Type.TYPE_WECOM) {
- return `${t("common.wecom")} Webhook`;
- } else if (state.webhook.type === Webhook_Type.TYPE_CUSTOM) {
- return `${t("common.custom")} Webhook`;
- }
-
- return "My Webhook";
-});
-
-const urlPlaceholder = computed(() => {
- if (state.webhook.type === Webhook_Type.TYPE_SLACK) {
- return "https://hooks.slack.com/services/...";
- } else if (state.webhook.type === Webhook_Type.TYPE_DISCORD) {
- return "https://discord.com/api/webhooks/...";
- } else if (state.webhook.type === Webhook_Type.TYPE_TEAMS) {
- return "https://acme123.webhook.office.com/webhookb2/...";
- } else if (state.webhook.type === Webhook_Type.TYPE_DINGTALK) {
- return "https://oapi.dingtalk.com/robot/...";
- } else if (state.webhook.type === Webhook_Type.TYPE_FEISHU) {
- return "https://open.feishu.cn/open-apis/bot/v2/hook/...";
- } else if (state.webhook.type === Webhook_Type.TYPE_WECOM) {
- return "https://qyapi.weixin.qq.com/cgi-bin/webhook/...";
- } else if (state.webhook.type === Webhook_Type.TYPE_CUSTOM) {
- return "https://example.com/api/webhook/...";
- }
-
- return "Webhook URL";
-});
-
const valueChanged = computed(() => {
return !isEqual(props.webhook, state.webhook);
});
@@ -388,6 +272,30 @@ const isEventOn = (type: Activity_Type) => {
return state.webhook.notificationTypes.includes(type);
};
+const webhookActivityItemList = computed(() =>
+ projectWebhookV1ActivityItemList()
+);
+
+const webhookTypeItemList = computed(() => projectWebhookV1TypeItemList());
+
+const selectedWebhook = computed(() => {
+ return webhookTypeItemList.value.find(
+ (item) => item.type === state.webhook.type
+ );
+});
+
+const webhookSupportDirectMessage = computed(
+ () => selectedWebhook.value?.supportDirectMessage
+);
+
+const avtivitySupportDirectMessage = computed(() => {
+ return state.webhook.notificationTypes.some(
+ (event) =>
+ webhookActivityItemList.value.find((item) => item.activity === event)
+ ?.supportDirectMessage
+ );
+});
+
const toggleEvent = (type: Activity_Type, on: boolean) => {
if (on) {
if (state.webhook.notificationTypes.includes(type)) {
@@ -451,6 +359,9 @@ const updateWebhook = () => {
if (state.webhook.url !== props.webhook.url) {
updateMask.push("url");
}
+ if (state.webhook.directMessage !== props.webhook.directMessage) {
+ updateMask.push("direct_message");
+ }
if (
!isEqual(state.webhook.notificationTypes, props.webhook.notificationTypes)
) {
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 922a2e0911..b108fb885e 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -549,9 +549,7 @@
"workspace-role-at-least-one": "At least one workspace role is required"
},
"im-integration": {
- "enable": "Enable",
- "description": "Allow users to approve issues from IM directly.",
- "feishu-updated-tip": "Successfully updated the Feishu integration"
+ "description": "Push direct messages to users for specific issue events. Works with project webhook."
},
"sso": {
"create": "Create SSO",
@@ -1878,7 +1876,7 @@
"create-webhook": "Create webhook",
"last-updated-by": "Last updated by",
"destination": "Destination",
- "webhook-url": "Webhook url",
+ "webhook-url": "Webhook URL",
"triggering-activity": "Triggering activities",
"test-webhook": "Test Webhook",
"no-webhook": {
@@ -1895,6 +1893,10 @@
"btn-text": "Delete this webhook",
"confirm-title": "Delete webhook '{title}' and all its execution history?"
},
+ "direct-messages": "Direct messages",
+ "enable-direct-messages": "Enable direct messages",
+ "direct-messages-tip": "Once enabled, Bytebase will send direct messages for specific acticitiesto related users (matched by email). You need to configure {im} to make it work.",
+ "activity-support-direct-message": "Support send direct messages to related users",
"activity-item": {
"issue-creation": {
"title": "Issue creation",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 819e01b973..8eb50f2311 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -549,9 +549,7 @@
"workspace-role-at-least-one": "El espacio de trabajo debe tener al menos un administrador"
},
"im-integration": {
- "enable": "Habilitar",
- "description": "Permitir a los usuarios aprobar incidencias directamente desde IM.",
- "feishu-updated-tip": "Integración con Feishu actualizada correctamente"
+ "description": "Envíe mensajes directos a los usuarios para eventos de problemas específicos. Funciona con el webhook del proyecto."
},
"sso": {
"create": "Crear SSO",
@@ -1895,6 +1893,10 @@
"btn-text": "Eliminar este webhook",
"confirm-title": "¿Eliminar el '{title}' del webhook y todo su historial de ejecución?"
},
+ "direct-messages": "Mensajes directos",
+ "enable-direct-messages": "Habilitar mensajes directos",
+ "direct-messages-tip": "Una vez habilitado, Bytebase enviará mensajes directos para actividades específicas a usuarios relacionados (vinculados por correo electrónico). Debes configurar {im} para que funcione.",
+ "activity-support-direct-message": "Soporte para enviar mensajes directos a usuarios relacionados.",
"activity-item": {
"issue-creation": {
"title": "Creación de incidencia",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index cc10e4eff4..c4edc29a11 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -549,9 +549,7 @@
"workspace-role-at-least-one": "少なくとも 1 つのワークスペースレベルの役割を選択してください"
},
"im-integration": {
- "enable": "有効にする",
- "description": "ユーザーが IM で作業指示書を直接承認できるようにします。",
- "feishu-updated-tip": "フェイシュの設定が正常に更新されました"
+ "description": "特定の作業指示イベントについて、プライベート メッセージをユーザーにプッシュします。プロジェクト Webhook で使用する必要があります。"
},
"sso": {
"create": "SSOの作成",
@@ -1895,6 +1893,10 @@
"btn-text": "この Webhook を削除します",
"confirm-title": "Webhook '{title}' とすべての実行履歴を削除しますか?"
},
+ "direct-messages": "プライベートメッセージ通知",
+ "enable-direct-messages": "プライベートメッセージ通知を有効にする",
+ "direct-messages-tip": "有効にすると、Bytebase は特定のイベントのプライベート メッセージ通知を関連するユーザーに (電子メールの一致を介して) 送信します。正しく動作するには、{im} を構成する必要があります。",
+ "activity-support-direct-message": "関連するユーザーへのプライベート メッセージ通知の送信のサポート",
"activity-item": {
"issue-creation": {
"title": "@:common.issue を作成する",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 4d8821ba7e..8837303983 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -549,9 +549,7 @@
"workspace-role-at-least-one": "至少选择一个工作空间级别的角色"
},
"im-integration": {
- "enable": "启用",
- "description": "可以让用户在 IM 里直接审批工单。",
- "feishu-updated-tip": "飞书配置更新成功"
+ "description": "针对特定工单事件向用户推送私信消息。需要与项目 webhook 配合使用。"
},
"sso": {
"create": "创建 SSO",
@@ -1878,7 +1876,7 @@
"create-webhook": "创建 webhook",
"last-updated-by": "最后修改人",
"destination": "外部应用",
- "webhook-url": "Webhook url",
+ "webhook-url": "Webhook URL",
"triggering-activity": "触发事件",
"test-webhook": "测试 Webhook",
"no-webhook": {
@@ -1895,6 +1893,10 @@
"btn-text": "删除这个 webhook",
"confirm-title": "删除 webhook '{title}' 以及所有的执行历史?"
},
+ "direct-messages": "私信通知",
+ "enable-direct-messages": "启用私信通知",
+ "direct-messages-tip": "启用后,Bytebase 将向相关用户(通过电子邮件匹配)发送特定事件的私信通知。您需要配置 {im} 才能使其正常工作。",
+ "activity-support-direct-message": "支持向相关用户发送私信通知",
"activity-item": {
"issue-creation": {
"title": "创建@:common.issue",
diff --git a/frontend/src/router/dashboard/workspace.ts b/frontend/src/router/dashboard/workspace.ts
index d42e22ac34..29ef8417b4 100644
--- a/frontend/src/router/dashboard/workspace.ts
+++ b/frontend/src/router/dashboard/workspace.ts
@@ -31,6 +31,7 @@ import {
WORKSPACE_ROUTE_REVIEW_CENTER,
WORKSPACE_ROUTE_MEMBERS,
WORKSPACE_ROUTE_ROLES,
+ WORKSPACE_ROUTE_IM,
} from "./workspaceRoutes";
const workspaceRoutes: RouteRecordRaw[] = [
@@ -435,6 +436,16 @@ const workspaceRoutes: RouteRecordRaw[] = [
component: () => import("@/views/SettingWorkspaceRole.vue"),
props: true,
},
+ {
+ path: "im",
+ name: WORKSPACE_ROUTE_IM,
+ meta: {
+ title: () => t("settings.sidebar.im-integration"),
+ requiredWorkspacePermissionList: () => ["bb.settings.get"],
+ },
+ component: () => import("@/views/SettingWorkspaceIM.vue"),
+ props: true,
+ },
],
},
];
diff --git a/frontend/src/router/dashboard/workspaceRoutes.ts b/frontend/src/router/dashboard/workspaceRoutes.ts
index f793dd8c67..1520314b16 100644
--- a/frontend/src/router/dashboard/workspaceRoutes.ts
+++ b/frontend/src/router/dashboard/workspaceRoutes.ts
@@ -31,3 +31,5 @@ export const WORKSPACE_ROUTE_GITOPS_DETAIL = `${WORKSPACE_ROUTE_GITOPS}.detail`;
export const WORKSPACE_ROUTE_SSO = "workspace.sso";
export const WORKSPACE_ROUTE_SSO_CREATE = `${WORKSPACE_ROUTE_SSO}.create`;
export const WORKSPACE_ROUTE_SSO_DETAIL = `${WORKSPACE_ROUTE_SSO}.detail`;
+
+export const WORKSPACE_ROUTE_IM = "workspace.im";
diff --git a/frontend/src/store/modules/v1/setting.ts b/frontend/src/store/modules/v1/setting.ts
index 71c6b94df0..62c551dec8 100644
--- a/frontend/src/store/modules/v1/setting.ts
+++ b/frontend/src/store/modules/v1/setting.ts
@@ -85,10 +85,12 @@ export const useSettingV1Store = defineStore("setting_v1", {
name,
value,
validateOnly = false,
+ updateMask,
}: {
name: SettingName;
value: SettingValue;
validateOnly?: boolean;
+ updateMask?: string[] | undefined;
}) {
const resp = await settingServiceClient.updateSetting({
setting: {
@@ -97,6 +99,7 @@ export const useSettingV1Store = defineStore("setting_v1", {
},
validateOnly,
allowMissing: true,
+ updateMask,
});
this.settingMapByName.set(resp.name, resp);
return resp;
diff --git a/frontend/src/types/v1/projectWebhook.ts b/frontend/src/types/v1/projectWebhook.ts
index e4ff295ba9..483341b564 100644
--- a/frontend/src/types/v1/projectWebhook.ts
+++ b/frontend/src/types/v1/projectWebhook.ts
@@ -20,6 +20,9 @@ type ProjectWebhookV1TypeItem = {
type: Webhook_Type;
name: string;
urlPrefix: string;
+ urlPlaceholder: string;
+ docUrl: string;
+ supportDirectMessage: boolean;
};
export const projectWebhookV1TypeItemList = (): ProjectWebhookV1TypeItem[] => {
@@ -28,37 +31,63 @@ export const projectWebhookV1TypeItemList = (): ProjectWebhookV1TypeItem[] => {
type: Webhook_Type.TYPE_SLACK,
name: t("common.slack"),
urlPrefix: "https://hooks.slack.com/",
+ urlPlaceholder: "https://hooks.slack.com/services/...",
+ docUrl: "https://api.slack.com/messaging/webhooks",
+ supportDirectMessage: true,
},
{
type: Webhook_Type.TYPE_DISCORD,
name: t("common.discord"),
urlPrefix: "https://discord.com/api/webhooks",
+ urlPlaceholder: "https://discord.com/api/webhooks/...",
+ docUrl:
+ "https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks",
+ supportDirectMessage: false,
},
{
type: Webhook_Type.TYPE_TEAMS,
name: t("common.teams"),
urlPrefix: "",
+ urlPlaceholder: "https://acme123.webhook.office.com/webhookb2/...",
+ docUrl:
+ "https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook",
+ supportDirectMessage: false,
},
{
type: Webhook_Type.TYPE_DINGTALK,
name: t("common.dingtalk"),
urlPrefix: "https://oapi.dingtalk.com",
+ urlPlaceholder: "https://oapi.dingtalk.com/robot/...",
+ docUrl:
+ "https://developers.dingtalk.com/document/robots/custom-robot-access",
+ supportDirectMessage: false,
},
{
type: Webhook_Type.TYPE_FEISHU,
name: t("common.feishu"),
urlPrefix: "https://open.feishu.cn",
+ urlPlaceholder: "https://open.feishu.cn/open-apis/bot/v2/hook/...",
+ docUrl:
+ "https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot",
+ supportDirectMessage: true,
},
{
type: Webhook_Type.TYPE_WECOM,
name: t("common.wecom"),
urlPrefix: "https://qyapi.weixin.qq.com",
+ urlPlaceholder: "https://qyapi.weixin.qq.com/cgi-bin/webhook/...",
+ docUrl: "https://open.work.weixin.qq.com/help2/pc/14931",
+ supportDirectMessage: true,
},
{
type: Webhook_Type.TYPE_CUSTOM,
name: t("common.custom"),
urlPrefix:
"https://bytebase.com/docs/change-database/webhook#custom?source=console",
+ urlPlaceholder: "https://example.com/api/webhook/...",
+ docUrl:
+ "https://www.bytebase.com/docs/change-database/webhook#custom?source=console",
+ supportDirectMessage: false,
},
];
};
@@ -67,6 +96,7 @@ type ProjectWebhookV1ActivityItem = {
title: string;
label: string;
activity: Activity_Type;
+ supportDirectMessage: boolean;
};
export const projectWebhookV1ActivityItemList =
@@ -76,11 +106,13 @@ export const projectWebhookV1ActivityItemList =
title: t("project.webhook.activity-item.issue-creation.title"),
label: t("project.webhook.activity-item.issue-creation.label"),
activity: Activity_Type.TYPE_ISSUE_CREATE,
+ supportDirectMessage: false,
},
{
title: t("project.webhook.activity-item.issue-status-change.title"),
label: t("project.webhook.activity-item.issue-status-change.label"),
activity: Activity_Type.TYPE_ISSUE_STATUS_UPDATE,
+ supportDirectMessage: false,
},
{
title: t(
@@ -90,6 +122,7 @@ export const projectWebhookV1ActivityItemList =
"project.webhook.activity-item.issue-stage-status-change.label"
),
activity: Activity_Type.TYPE_ISSUE_PIPELINE_STAGE_STATUS_UPDATE,
+ supportDirectMessage: false,
},
{
title: t(
@@ -99,31 +132,37 @@ export const projectWebhookV1ActivityItemList =
"project.webhook.activity-item.issue-task-status-change.label"
),
activity: Activity_Type.TYPE_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE,
+ supportDirectMessage: false,
},
{
title: t("project.webhook.activity-item.issue-info-change.title"),
label: t("project.webhook.activity-item.issue-info-change.label"),
activity: Activity_Type.TYPE_ISSUE_FIELD_UPDATE,
+ supportDirectMessage: false,
},
{
title: t("project.webhook.activity-item.issue-comment-creation.title"),
label: t("project.webhook.activity-item.issue-comment-creation.label"),
activity: Activity_Type.TYPE_ISSUE_COMMENT_CREATE,
+ supportDirectMessage: false,
},
{
title: t("project.webhook.activity-item.issue-approval-notify.title"),
label: t("project.webhook.activity-item.issue-approval-notify.label"),
activity: Activity_Type.TYPE_ISSUE_APPROVAL_NOTIFY,
+ supportDirectMessage: true,
},
{
title: t("project.webhook.activity-item.notify-issue-approved.title"),
label: t("project.webhook.activity-item.notify-issue-approved.label"),
activity: Activity_Type.TYPE_NOTIFY_ISSUE_APPROVED,
+ supportDirectMessage: true,
},
{
title: t("project.webhook.activity-item.notify-pipeline-rollout.title"),
label: t("project.webhook.activity-item.notify-pipeline-rollout.label"),
activity: Activity_Type.TYPE_NOTIFY_PIPELINE_ROLLOUT,
+ supportDirectMessage: true,
},
];
};
diff --git a/frontend/src/views/DashboardSidebar.vue b/frontend/src/views/DashboardSidebar.vue
index a57381f65f..0368297ac0 100644
--- a/frontend/src/views/DashboardSidebar.vue
+++ b/frontend/src/views/DashboardSidebar.vue
@@ -52,6 +52,7 @@ import {
WORKSPACE_ROUTE_MEMBERS,
WORKSPACE_ROUTE_ROLES,
WORKSPACE_ROUTE_USER_PROFILE,
+ WORKSPACE_ROUTE_IM,
} from "@/router/dashboard/workspaceRoutes";
import { useCurrentUserV1 } from "@/store";
import type { WorkspacePermission } from "@/types";
@@ -312,6 +313,11 @@ const dashboardSidebarItemList = computed((): DashboardSidebarItem[] => {
name: WORKSPACE_ROUTE_MAIL_DELIVERY,
type: "route",
},
+ {
+ title: t("settings.sidebar.im-integration"),
+ name: WORKSPACE_ROUTE_IM,
+ type: "route",
+ },
],
},
];
diff --git a/frontend/src/views/SettingWorkspaceIM.vue b/frontend/src/views/SettingWorkspaceIM.vue
new file mode 100644
index 0000000000..93c3d2ef32
--- /dev/null
+++ b/frontend/src/views/SettingWorkspaceIM.vue
@@ -0,0 +1,307 @@
+<template>
+ <div class="w-full space-y-4">
+ <div class="textinfolabel">
+ {{ $t("settings.im-integration.description") }}
+ <a
+ class="normal-link inline-flex items-center"
+ href="https://www.bytebase.com/docs/administration/im?source=console"
+ target="__BLANK"
+ >
+ {{ $t("common.learn-more") }}
+ <heroicons-outline:external-link class="w-4 h-4 ml-1" />
+ </a>
+ </div>
+ <NTabs v-model:value="state.selectedTab" type="line" animated>
+ <NTabPane v-for="item in imList" :key="item.type" :name="item.type">
+ <template #tab>
+ <div class="flex items-center gap-x-2">
+ <WebhookTypeIcon :type="item.type" class="h-5 w-5" />
+ {{ item.name }}
+ </div>
+ </template>
+ <component :is="() => item.render()" />
+ </NTabPane>
+ </NTabs>
+ <div class="flex items-center justify-end space-x-2 pt-2">
+ <NButton
+ v-if="dataChanged"
+ :disabled="state.loading"
+ @click="discardChanges"
+ >
+ {{ $t("common.discard-changes") }}
+ </NButton>
+ <NButton
+ type="primary"
+ :disabled="!allowEdit || !canSave"
+ :loading="state.loading"
+ @click="onSave"
+ >
+ {{ $t("common.save") }}
+ </NButton>
+ </div>
+ </div>
+</template>
+
+<script lang="tsx" setup>
+import { cloneDeep, isEqual } from "lodash-es";
+import { NTabs, NTabPane } from "naive-ui";
+import { computed, watch, reactive } from "vue";
+import { useI18n } from "vue-i18n";
+import BBTextField from "@/bbkit/BBTextField.vue";
+import { useSettingV1Store, pushNotification } from "@/store";
+import { Webhook_Type } from "@/types/proto/v1/project_service";
+import {
+ AppIMSetting,
+ AppIMSetting_Feishu,
+ AppIMSetting_Slack,
+ AppIMSetting_Wecom,
+} from "@/types/proto/v1/setting_service";
+
+interface LocalState {
+ selectedTab: Webhook_Type;
+ loading: boolean;
+ setting: AppIMSetting;
+}
+
+defineProps<{
+ allowEdit: boolean;
+}>();
+
+const { t } = useI18n();
+const state = reactive<LocalState>({
+ selectedTab: Webhook_Type.TYPE_SLACK,
+ loading: false,
+ setting: AppIMSetting.fromPartial({}),
+});
+
+const settingStore = useSettingV1Store();
+
+const imSetting = computed(
+ () =>
+ settingStore.getSettingByName("bb.app.im")?.value?.appImSettingValue ??
+ AppIMSetting.fromPartial({})
+);
+
+watch(
+ () => imSetting.value,
+ (setting) => {
+ console.log("setting change");
+ console.log(setting);
+ state.setting = cloneDeep(setting);
+ },
+ { once: true, immediate: true }
+);
+
+watch(
+ () => state.selectedTab,
+ (tab) => {
+ switch (tab) {
+ case Webhook_Type.TYPE_SLACK:
+ if (!state.setting.slack) {
+ state.setting.slack = AppIMSetting_Slack.fromPartial({});
+ }
+ break;
+ case Webhook_Type.TYPE_DINGTALK:
+ if (!state.setting.feishu) {
+ state.setting.feishu = AppIMSetting_Feishu.fromPartial({});
+ }
+ break;
+ case Webhook_Type.TYPE_WECOM:
+ if (!state.setting.wecom) {
+ state.setting.wecom = AppIMSetting_Wecom.fromPartial({});
+ }
+ break;
+ }
+ },
+ { immediate: true }
+);
+
+const imList = computed(() => {
+ return [
+ {
+ name: t("common.slack"),
+ type: Webhook_Type.TYPE_SLACK,
+ render: () => {
+ return (
+ <div>
+ <div class="textlabel">Token</div>
+ <BBTextField
+ class="mt-2"
+ placeholder={t("common.write-only")}
+ value={state.setting.slack?.token ?? ""}
+ onUpdate:value={(val: string) => {
+ state.setting.slack!.token = val;
+ }}
+ />
+ </div>
+ );
+ },
+ },
+ {
+ name: t("common.feishu"),
+ type: Webhook_Type.TYPE_DINGTALK,
+ render: () => {
+ return (
+ <div class="space-y-4">
+ <div>
+ <div class="textlabel">App ID</div>
+ <BBTextField
+ class="mt-2"
+ placeholder={t("common.write-only")}
+ value={state.setting.feishu?.appId ?? ""}
+ onUpdate:value={(val: string) => {
+ state.setting.feishu!.appId = val;
+ }}
+ />
+ </div>
+ <div>
+ <div class="textlabel">App Secret</div>
+ <BBTextField
+ class="mt-2"
+ placeholder={t("common.write-only")}
+ value={state.setting.feishu?.appSecret ?? ""}
+ onUpdate:value={(val: string) => {
+ state.setting.feishu!.appSecret = val;
+ }}
+ />
+ </div>
+ </div>
+ );
+ },
+ },
+ {
+ name: t("common.wecom"),
+ type: Webhook_Type.TYPE_WECOM,
+ render: () => {
+ return (
+ <div class="space-y-4">
+ <div>
+ <div class="textlabel">ID</div>
+ <BBTextField
+ class="mt-2"
+ placeholder={t("common.write-only")}
+ value={state.setting.wecom?.id ?? ""}
+ onUpdate:value={(val: string) => {
+ state.setting.wecom!.id = val;
+ }}
+ />
+ </div>
+ <div>
+ <div class="textlabel">Secret</div>
+ <BBTextField
+ class="mt-2"
+ placeholder={t("common.write-only")}
+ value={state.setting.wecom?.secret ?? ""}
+ onUpdate:value={(val: string) => {
+ state.setting.wecom!.secret = val;
+ }}
+ />
+ </div>
+ </div>
+ );
+ },
+ },
+ ];
+});
+
+const dataChanged = computed(() => {
+ switch (state.selectedTab) {
+ case Webhook_Type.TYPE_SLACK:
+ return !isEqual(
+ state.setting.slack,
+ imSetting.value.slack ?? AppIMSetting_Slack.fromPartial({})
+ );
+ case Webhook_Type.TYPE_DINGTALK:
+ return !isEqual(
+ state.setting.feishu,
+ imSetting.value.feishu ?? AppIMSetting_Feishu.fromPartial({})
+ );
+ case Webhook_Type.TYPE_WECOM:
+ return !isEqual(
+ state.setting.wecom,
+ imSetting.value.wecom ?? AppIMSetting_Wecom.fromPartial({})
+ );
+ default:
+ return false;
+ }
+});
+
+const canSave = computed(() => {
+ switch (state.selectedTab) {
+ case Webhook_Type.TYPE_SLACK:
+ return !!state.setting.slack?.token;
+ case Webhook_Type.TYPE_DINGTALK:
+ return !!state.setting.feishu?.appId && !!state.setting.feishu?.appSecret;
+ case Webhook_Type.TYPE_WECOM:
+ return !!state.setting.wecom?.id && !!state.setting.wecom?.secret;
+ default:
+ return false;
+ }
+});
+
+const discardChanges = () => {
+ switch (state.selectedTab) {
+ case Webhook_Type.TYPE_SLACK:
+ state.setting.slack = AppIMSetting_Slack.fromPartial({});
+ break;
+ case Webhook_Type.TYPE_DINGTALK:
+ state.setting.feishu = AppIMSetting_Feishu.fromPartial({});
+ break;
+ case Webhook_Type.TYPE_WECOM:
+ state.setting.wecom = AppIMSetting_Wecom.fromPartial({});
+ break;
+ }
+};
+
+const onSave = async () => {
+ state.loading = true;
+ const updateMask: string[] = [];
+ switch (state.selectedTab) {
+ case Webhook_Type.TYPE_SLACK:
+ updateMask.push("value.app_im_setting_value.slack");
+ break;
+ case Webhook_Type.TYPE_DINGTALK:
+ updateMask.push("value.app_im_setting_value.feishu");
+ break;
+ case Webhook_Type.TYPE_WECOM:
+ updateMask.push("value.app_im_setting_value.wecom");
+ break;
+ }
+
+ try {
+ const setting = await settingStore.upsertSetting({
+ name: "bb.app.im",
+ value: {
+ appImSettingValue: state.setting,
+ },
+ updateMask,
+ });
+
+ switch (state.selectedTab) {
+ case Webhook_Type.TYPE_SLACK:
+ state.setting.slack =
+ setting.value?.appImSettingValue?.slack ??
+ AppIMSetting_Slack.fromPartial({});
+ break;
+ case Webhook_Type.TYPE_DINGTALK:
+ state.setting.feishu =
+ setting.value?.appImSettingValue?.feishu ??
+ AppIMSetting_Feishu.fromPartial({});
+ break;
+ case Webhook_Type.TYPE_WECOM:
+ state.setting.wecom =
+ setting.value?.appImSettingValue?.wecom ??
+ AppIMSetting_Wecom.fromPartial({});
+ break;
+ }
+
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.updated"),
+ });
+ } finally {
+ state.loading = false;
+ }
+};
+</script>
diff --git a/frontend/src/views/SettingWorkspaceIntegrationSlack.vue b/frontend/src/views/SettingWorkspaceIntegrationSlack.vue
deleted file mode 100644
index 99ae60e08f..0000000000
--- a/frontend/src/views/SettingWorkspaceIntegrationSlack.vue
+++ /dev/null
@@ -1,9 +0,0 @@
-<template>
- <h1>Slack</h1>
-</template>
-
-<script lang="ts">
-export default {
- name: "SettingWorkspaceIntegrationSlack",
-};
-</script>