diff --git a/AgileConfig.Server.Apisite/AgileConfig.Server.Apisite.csproj b/AgileConfig.Server.Apisite/AgileConfig.Server.Apisite.csproj index 99297019..a03d9c33 100644 --- a/AgileConfig.Server.Apisite/AgileConfig.Server.Apisite.csproj +++ b/AgileConfig.Server.Apisite/AgileConfig.Server.Apisite.csproj @@ -3,8 +3,8 @@ net6.0 InProcess - 1.6.15 - 1.6.15 + 1.6.16 + 1.6.16 1.6.15 Linux 1.6.15 diff --git a/AgileConfig.Server.Apisite/Controllers/ConfigController.cs b/AgileConfig.Server.Apisite/Controllers/ConfigController.cs index de558986..630b3bfb 100644 --- a/AgileConfig.Server.Apisite/Controllers/ConfigController.cs +++ b/AgileConfig.Server.Apisite/Controllers/ConfigController.cs @@ -572,7 +572,7 @@ public async Task Publish([FromBody] PublishLogVM model, string e var appId = model.AppId; var userId = await this.GetCurrentUserId(_userService); - var ret = _configService.Publish(appId, model.Log, userId, env); + var ret = _configService.Publish(appId, model.Ids, model.Log, userId, env); if (ret.result) { diff --git a/AgileConfig.Server.Apisite/Models/PublishLogVM.cs b/AgileConfig.Server.Apisite/Models/PublishLogVM.cs index 5be63823..eff65973 100644 --- a/AgileConfig.Server.Apisite/Models/PublishLogVM.cs +++ b/AgileConfig.Server.Apisite/Models/PublishLogVM.cs @@ -9,5 +9,7 @@ public class PublishLogVM: IAppIdModel { public string AppId { get; set; } public string Log { get; set; } + + public string[] Ids { get; set; } } } diff --git a/AgileConfig.Server.IService/IConfigService.cs b/AgileConfig.Server.IService/IConfigService.cs index d8d72e18..5039d14e 100644 --- a/AgileConfig.Server.IService/IConfigService.cs +++ b/AgileConfig.Server.IService/IConfigService.cs @@ -15,13 +15,14 @@ public interface IConfigService: IDisposable Task IfEnvEmptySetDefaultAsync(string env); /// - /// 发布当前待发布的配置项 + /// 发布当前待发布的配置项,如果传ids那么就是只发布这些项目,如果不传ids,那么就是全部发布 /// /// + /// /// /// /// - (bool result, string publishTimelineId) Publish(string appId, string log, string operatorr, string env); + (bool result, string publishTimelineId) Publish(string appId,string[] ids, string log, string operatorr, string env); Task GetAsync(string id, string env); diff --git a/AgileConfig.Server.Service/ConfigService.cs b/AgileConfig.Server.Service/ConfigService.cs index 8e8399a0..de2e31de 100644 --- a/AgileConfig.Server.Service/ConfigService.cs +++ b/AgileConfig.Server.Service/ConfigService.cs @@ -470,10 +470,11 @@ public void Dispose() /// 发布当前待发布的配置项 /// /// 应用id + /// 待发布的id列表 /// 发布日志 /// 操作员 /// - public (bool result, string publishTimelineId) Publish(string appId, string log, string operatorr, string env) + public (bool result, string publishTimelineId) Publish(string appId, string[] ids, string log, string operatorr, string env) { lock (Lockobj) { @@ -484,6 +485,11 @@ public void Dispose() x.Env == env && x.Status == ConfigStatus.Enabled && x.EditStatus != EditStatus.Commit).ToList(); + if (ids != null && ids.Any()) + { + //如果ids传值了,过滤一下 + waitPublishConfigs = waitPublishConfigs.Where(x => ids.Contains(x.Id)).ToList(); + } //这里默认admin console 实例只部署一个,如果部署多个同步操作,高并发的时候这个version会有问题 var versionMax = dbcontext.PublishTimeline.Select.Where(x => x.AppId == appId).Max(x => x.Version); diff --git a/AgileConfig.Server.UI/react-ui-antd/src/locales/en-US/pages.ts b/AgileConfig.Server.UI/react-ui-antd/src/locales/en-US/pages.ts index e7a9237b..cce309a4 100644 --- a/AgileConfig.Server.UI/react-ui-antd/src/locales/en-US/pages.ts +++ b/AgileConfig.Server.UI/react-ui-antd/src/locales/en-US/pages.ts @@ -165,7 +165,7 @@ export default { 'pages.configs.table.cols.action.exportJson': 'Export', 'pages.configs.table.cols.action.edit': 'Edit', 'pages.configs.table.cols.action.delete': 'Delete', - 'pages.configs.table.cols.action.publish': 'Publish', + 'pages.configs.table.cols.action.publish': 'Publish All', 'pages.configs.table.cols.action.offline': 'Offline', 'pages.configs.table.cols.action.history': 'History', diff --git a/AgileConfig.Server.UI/react-ui-antd/src/locales/zh-CN/pages.ts b/AgileConfig.Server.UI/react-ui-antd/src/locales/zh-CN/pages.ts index f51b6c80..192060ad 100644 --- a/AgileConfig.Server.UI/react-ui-antd/src/locales/zh-CN/pages.ts +++ b/AgileConfig.Server.UI/react-ui-antd/src/locales/zh-CN/pages.ts @@ -163,7 +163,7 @@ export default { 'pages.configs.table.cols.action.edit': '编辑', 'pages.configs.table.cols.action.delete': '删除', - 'pages.configs.table.cols.action.publish': '发布', + 'pages.configs.table.cols.action.publish': '发布全部', 'pages.configs.table.cols.action.offline': '下线', 'pages.configs.table.cols.action.history': '历史', diff --git a/AgileConfig.Server.UI/react-ui-antd/src/pages/Configs/index.tsx b/AgileConfig.Server.UI/react-ui-antd/src/pages/Configs/index.tsx index dc2a504d..24b2a8ff 100644 --- a/AgileConfig.Server.UI/react-ui-antd/src/pages/Configs/index.tsx +++ b/AgileConfig.Server.UI/react-ui-antd/src/pages/Configs/index.tsx @@ -26,10 +26,10 @@ import { saveVisitApp } from '@/utils/latestVisitApps'; const { TextArea } = Input; const { confirm } = Modal; -const handlePublish = async (appId: string, log:string, env:string) => { +const handlePublish = async (appId: string, ids:string[], log:string, env:string) => { const hide = message.loading('正在发布'); try { - const result = await publish(appId, log, env); + const result = await publish(appId, ids, log, env); hide(); const success = result.success; if (success) { @@ -225,11 +225,14 @@ const configs: React.FC = (props: any) => { }, [tableData]); const publish = (appId: string) => { + const rows = selectedRowsState.filter(x=>x.editStatus !== 10).map(x=>x.id); + const isPublishAll = rows.length === 0; + const msg = isPublishAll ? '所有' : '已选择'; _publishLog = ''; confirm({ content:
{ - '确定发布当前所有待发布的配置项吗?' + `确定发布当前【${msg}】的待发布配置项吗?` }

@@ -243,7 +246,8 @@ const configs: React.FC = (props: any) => {
, onOk: async () => { - const result = await handlePublish(appId, _publishLog, currentEnv); + + const result = await handlePublish(appId, rows, _publishLog, currentEnv); if (result && actionRef.current) { if (actionRef.current?.clearSelected){ actionRef.current?.clearSelected(); @@ -499,9 +503,7 @@ const configs: React.FC = (props: any) => { hidden={(waitPublishStatus.addCount + waitPublishStatus.editCount + waitPublishStatus.deleteCount) === 0} onClick={()=>{publish(appId)}}> { - intl.formatMessage({ - id: 'pages.configs.table.cols.action.publish' - }) + selectedRowsState.filter(x=>x.editStatus !== 10).length > 0 ? '发布选择项' : '发布全部' } diff --git a/AgileConfig.Server.UI/react-ui-antd/src/pages/Configs/service.ts b/AgileConfig.Server.UI/react-ui-antd/src/pages/Configs/service.ts index 0241a7d2..eab6f820 100644 --- a/AgileConfig.Server.UI/react-ui-antd/src/pages/Configs/service.ts +++ b/AgileConfig.Server.UI/react-ui-antd/src/pages/Configs/service.ts @@ -111,12 +111,13 @@ export async function getWaitPublishStatus(appId: string, env: string) { }); } -export async function publish(appId: string, publistLog: string, env: string) { +export async function publish(appId: string, ids:string[], publistLog: string, env: string) { return request('config/publish?env=' + env, { method: 'POST', data: { log: publistLog, - appId: appId + appId: appId, + ids: ids } }); }