diff --git a/frontend/src/domain/dataSource/DataSourceRegistry.ts b/frontend/src/domain/dataSource/DataSourceRegistry.ts index 0ffdae58..a5180dbf 100644 --- a/frontend/src/domain/dataSource/DataSourceRegistry.ts +++ b/frontend/src/domain/dataSource/DataSourceRegistry.ts @@ -14,6 +14,7 @@ import { applicationsConfig, notificationChannelTypesConfig, notificationChannelsConfig, + notificationTemplatesConfig, usersConfig, rolesConfig, departmentsConfig @@ -32,6 +33,7 @@ class DataSourceRegistryImpl extends BaseRegistry { + return data.map((item: any) => ({ + label: `(${item.channelType})-${item.name}`, + value: item.id + })); + } +}; + diff --git a/frontend/src/domain/dataSource/types.ts b/frontend/src/domain/dataSource/types.ts index 0ae5cd37..8fb404eb 100644 --- a/frontend/src/domain/dataSource/types.ts +++ b/frontend/src/domain/dataSource/types.ts @@ -12,6 +12,7 @@ export enum DataSourceType { DOCKER_REGISTRIES = 'DOCKER_REGISTRIES', NOTIFICATION_CHANNEL_TYPES = 'NOTIFICATION_CHANNEL_TYPES', NOTIFICATION_CHANNELS = 'NOTIFICATION_CHANNELS', + NOTIFICATION_TEMPLATES = 'NOTIFICATION_TEMPLATES', USERS = 'USERS', ROLES = 'ROLES', DEPARTMENTS = 'DEPARTMENTS', diff --git a/frontend/src/pages/Dashboard/components/DeploymentFormModal.tsx b/frontend/src/pages/Dashboard/components/DeploymentFormModal.tsx index 67363389..4a07b2e1 100644 --- a/frontend/src/pages/Dashboard/components/DeploymentFormModal.tsx +++ b/frontend/src/pages/Dashboard/components/DeploymentFormModal.tsx @@ -67,9 +67,13 @@ const DeploymentFormModal: React.FC = ({ }, // 通知信息(使用环境配置的通知设置) notification: { - required: environment.notificationConfig?.deployNotificationEnabled ? 'true' : 'false', - channelId: environment.notificationConfig?.notificationChannelId?.toString() || '', - channelName: environment.notificationConfig?.notificationChannelName || '', + notificationChannelId: environment.notificationConfig?.notificationChannelId, + deployNotificationEnabled: environment.notificationConfig?.deployNotificationEnabled, + deployNotificationTemplateId: environment.notificationConfig?.deployNotificationTemplateId, + buildNotificationEnabled: environment.notificationConfig?.buildNotificationEnabled, + buildNotificationTemplateId: environment.notificationConfig?.buildNotificationTemplateId, + buildFailureFileEnabled: environment.notificationConfig?.buildFailureFileEnabled, + buildFailureNotificationTemplateId: environment.notificationConfig?.buildFailureNotificationTemplateId, }, }; }, [app, environment, teamId]); // 只在这些依赖变化时重新生成 diff --git a/frontend/src/pages/Dashboard/types.ts b/frontend/src/pages/Dashboard/types.ts index 2a7c17ba..31a7672c 100644 --- a/frontend/src/pages/Dashboard/types.ts +++ b/frontend/src/pages/Dashboard/types.ts @@ -61,9 +61,11 @@ export interface ApplicationConfig { export interface NotificationConfig { notificationChannelId: number; deployNotificationEnabled: boolean; + deployNotificationTemplateId: number; buildNotificationEnabled: boolean; + buildNotificationTemplateId: number; buildFailureFileEnabled: boolean; - notificationChannelName: string; + buildFailureNotificationTemplateId: number; } export interface DeployEnvironment { diff --git a/frontend/src/pages/Deploy/NotificationTemplate/List/components/NotificationTemplateDialog.tsx b/frontend/src/pages/Deploy/NotificationTemplate/List/components/NotificationTemplateDialog.tsx index e0dec962..8c6e9231 100644 --- a/frontend/src/pages/Deploy/NotificationTemplate/List/components/NotificationTemplateDialog.tsx +++ b/frontend/src/pages/Deploy/NotificationTemplate/List/components/NotificationTemplateDialog.tsx @@ -56,6 +56,7 @@ const formSchema = z.object({ .regex(/^[a-zA-Z][a-zA-Z0-9_]*$/, '模板编码只能包含字母、数字和下划线,且以字母开头'), description: z.string().max(500, '描述不能超过500个字符').optional(), channelType: z.nativeEnum(NotificationChannelType), + titleTemplate: z.string().min(1, '请输入标题模板'), contentTemplate: z.string().min(1, '请输入模板内容'), templateConfig: z.object({ // 用于后端多态反序列化,必须存在 @@ -100,6 +101,7 @@ export const NotificationTemplateDialog: React.FC + {/* 标题模板 */} +
+ + + {errors.titleTemplate && ( +

{errors.titleTemplate.message}

+ )} +
+ {/* 模板配置 */} {watchedChannelType && (
diff --git a/frontend/src/pages/Deploy/NotificationTemplate/List/index.tsx b/frontend/src/pages/Deploy/NotificationTemplate/List/index.tsx index d4fab275..2d0d23f7 100644 --- a/frontend/src/pages/Deploy/NotificationTemplate/List/index.tsx +++ b/frontend/src/pages/Deploy/NotificationTemplate/List/index.tsx @@ -356,6 +356,7 @@ const NotificationTemplateList: React.FC = () => { 模板名称 模板编码 + 标题模板 渠道类型 状态 创建时间 @@ -365,13 +366,13 @@ const NotificationTemplateList: React.FC = () => { {loading ? ( - + ) : list.length === 0 ? ( - + 暂无数据 @@ -380,6 +381,9 @@ const NotificationTemplateList: React.FC = () => { {template.name} {template.code} + + {template.titleTemplate || '-'} + {getChannelTypeLabel(template.channelType)} diff --git a/frontend/src/pages/Deploy/NotificationTemplate/List/service.ts b/frontend/src/pages/Deploy/NotificationTemplate/List/service.ts index 1c24ee9f..b48a796a 100644 --- a/frontend/src/pages/Deploy/NotificationTemplate/List/service.ts +++ b/frontend/src/pages/Deploy/NotificationTemplate/List/service.ts @@ -44,7 +44,7 @@ export const getTemplateById = async (id: number): Promise + template: Pick ): Promise => { // 确保 channelType 在 templateConfig 之前 const payload = { @@ -52,6 +52,7 @@ export const createTemplate = async ( code: template.code, description: template.description, channelType: template.channelType, + titleTemplate: template.titleTemplate, contentTemplate: template.contentTemplate, templateConfig: template.templateConfig, enabled: true, // 默认启用 @@ -64,7 +65,7 @@ export const createTemplate = async ( */ export const updateTemplate = async ( id: number, - template: Pick + template: Pick ): Promise => { // 确保字段顺序:channelType 必须在 templateConfig 之前 const payload = { @@ -73,6 +74,7 @@ export const updateTemplate = async ( code: template.code, description: template.description, channelType: template.channelType, + titleTemplate: template.titleTemplate, contentTemplate: template.contentTemplate, enabled: template.enabled, templateConfig: template.templateConfig, diff --git a/frontend/src/pages/Deploy/NotificationTemplate/List/types.ts b/frontend/src/pages/Deploy/NotificationTemplate/List/types.ts index 84afd954..fd794606 100644 --- a/frontend/src/pages/Deploy/NotificationTemplate/List/types.ts +++ b/frontend/src/pages/Deploy/NotificationTemplate/List/types.ts @@ -20,6 +20,9 @@ export interface NotificationTemplateDTO extends BaseResponse { /** 渠道类型 */ channelType: NotificationChannelType; + /** 标题模板(FreeMarker格式) */ + titleTemplate: string; + /** 内容模板(FreeMarker格式) */ contentTemplate: string; diff --git a/frontend/src/pages/Workflow/Design/nodes/NotificationNode.tsx b/frontend/src/pages/Workflow/Design/nodes/NotificationNode.tsx index 457764c0..22cbc076 100644 --- a/frontend/src/pages/Workflow/Design/nodes/NotificationNode.tsx +++ b/frontend/src/pages/Workflow/Design/nodes/NotificationNode.tsx @@ -71,21 +71,16 @@ export const NotificationNodeDefinition: ConfigurableNodeDefinition = { "x-dataSource": DataSourceType.NOTIFICATION_CHANNELS, "x-allow-variable": true }, - title: { - type: "string", - title: "通知标题", - description: "通知消息的标题", - default: "${notification.title}" - }, - content: { - type: "string", - title: "通知内容", - description: "通知消息的正文内容,支持变量表达式", - format: "textarea", - default: "${notification.context}" + notificationTemplateId: { + type: "number", + title: "通知模板", + description: "选择通知模板,或输入动态值", + "x-dataSource": DataSourceType.NOTIFICATION_TEMPLATES, + "x-allow-variable": true, + "x-depends-on": "channelId" } }, - required: ["channelId", "title", "content"] + required: ["channelId", "notificationTemplateId"] }, outputs: defineNodeOutputs() };