Skip to content

Commit

Permalink
支持选择部分项目发布
Browse files Browse the repository at this point in the history
  • Loading branch information
agile.zhou committed May 16, 2023
1 parent e536cda commit 19470c3
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 17 deletions.
4 changes: 2 additions & 2 deletions AgileConfig.Server.Apisite/AgileConfig.Server.Apisite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<AssemblyVersion>1.6.15</AssemblyVersion>
<Version>1.6.15</Version>
<AssemblyVersion>1.6.16</AssemblyVersion>
<Version>1.6.16</Version>
<PackageVersion>1.6.15</PackageVersion>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<FileVersion>1.6.15</FileVersion>
Expand Down
2 changes: 1 addition & 1 deletion AgileConfig.Server.Apisite/Controllers/ConfigController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ public async Task<IActionResult> 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)
{
Expand Down
2 changes: 2 additions & 0 deletions AgileConfig.Server.Apisite/Models/PublishLogVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ public class PublishLogVM: IAppIdModel
{
public string AppId { get; set; }
public string Log { get; set; }

public string[] Ids { get; set; }
}
}
5 changes: 3 additions & 2 deletions AgileConfig.Server.IService/IConfigService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ public interface IConfigService: IDisposable
Task<string> IfEnvEmptySetDefaultAsync(string env);

/// <summary>
/// 发布当前待发布的配置项
/// 发布当前待发布的配置项,如果传ids那么就是只发布这些项目,如果不传ids,那么就是全部发布
/// </summary>
/// <param name="appId"></param>
/// <param name="ids"></param>
/// <param name="log"></param>
/// <param name="operatorr"></param>
/// <returns></returns>
(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<Config> GetAsync(string id, string env);

Expand Down
8 changes: 7 additions & 1 deletion AgileConfig.Server.Service/ConfigService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,11 @@ public void Dispose()
/// 发布当前待发布的配置项
/// </summary>
/// <param name="appId">应用id</param>
/// <param name="ids">待发布的id列表</param>
/// <param name="log">发布日志</param>
/// <param name="operatorr">操作员</param>
/// <returns></returns>
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)
{
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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': '历史',

Expand Down
16 changes: 9 additions & 7 deletions AgileConfig.Server.UI/react-ui-antd/src/pages/Configs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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: <div>
{
'确定发布当前所有待发布的配置项吗?'
`确定发布当前【${msg}】的待发布配置项吗?`
}
<br />
<br />
Expand All @@ -243,7 +246,8 @@ const configs: React.FC = (props: any) => {
</div>
</div>,
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();
Expand Down Expand Up @@ -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 ? '发布选择项' : '发布全部'
}
</Button>
</AuthorizedEle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
});
}
Expand Down

0 comments on commit 19470c3

Please sign in to comment.