You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2021/05/20 07:48:22 UTC

[servicecomb-service-center] branch master updated: fix: 自定义配置优化 (#990)

This is an automated email from the ASF dual-hosted git repository.

littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git


The following commit(s) were added to refs/heads/master by this push:
     new 641fe1a  fix: 自定义配置优化 (#990)
641fe1a is described below

commit 641fe1a8f9998265cf4c36824119f5b65c607ea2
Author: tuan <ya...@126.com>
AuthorDate: Thu May 20 15:47:52 2021 +0800

    fix: 自定义配置优化 (#990)
    
    close #982
    修改创建的配置默认启用
    创建配置时添加的标签可删除
    标签key唯一
    
    Co-authored-by: tuan <>
---
 .../pages/config-create/config-create.component.html    |  2 ++
 .../pages/config-create/config-create.component.ts      | 17 +++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/ux/src/app/config-list/pages/config-create/config-create.component.html b/ux/src/app/config-list/pages/config-create/config-create.component.html
index a1ccb00..a235f8d 100644
--- a/ux/src/app/config-list/pages/config-create/config-create.component.html
+++ b/ux/src/app/config-list/pages/config-create/config-create.component.html
@@ -117,7 +117,9 @@ limitations under the License.
             class="cse-mg-right-xs"
             *ngFor="let tag of tags; let i = index"
             [tag]="tag"
+            [deletable]="configType === 'custom' && type === 'create'"
             [customViewTemplate]="customTag"
+            (tagDelete)="onDeleteTag(i)"
           ></d-tag>
           <ng-template #customTag let-tag="tag">
             <span title="{{ tag }}">{{ tag }}</span>
diff --git a/ux/src/app/config-list/pages/config-create/config-create.component.ts b/ux/src/app/config-list/pages/config-create/config-create.component.ts
index b7f7fa9..4604c8d 100644
--- a/ux/src/app/config-list/pages/config-create/config-create.component.ts
+++ b/ux/src/app/config-list/pages/config-create/config-create.component.ts
@@ -18,6 +18,7 @@ import { Component, OnInit, ViewChild } from '@angular/core';
 import { FormControl, FormGroup } from '@angular/forms';
 import { ActivatedRoute, Router } from '@angular/router';
 import { TranslateService } from '@ngx-translate/core';
+import { uniqBy } from 'lodash';
 import { DValidateRules, FormLayout, ModalService } from 'ng-devui';
 import { EditorComponent } from 'ngx-monaco-editor';
 import { ConfigService, getTagsByObj } from '../../../../common/config.service';
@@ -144,6 +145,8 @@ export class ConfigCreateComponent implements OnInit {
           // todo 提示
         }
       );
+    } else {
+      this.formGroup.controls.isAvailable.setValue(true);
     }
   }
 
@@ -210,10 +213,20 @@ export class ConfigCreateComponent implements OnInit {
   }
 
   onAddTage(): void {
-    this.tags.push(`${this.configTageKey}=${this.configTageValue}`);
+    if (!this.configTageKey) {
+      return;
+    }
+    this.tags.push(`${this.configTageKey}=${this.configTageValue || ''}`);
+    // key需要 唯一
+    this.tags = uniqBy(this.tags, (tag) => {
+      return tag.split('=')[0];
+    });
     this.configTageKey = '';
     this.configTageValue = '';
   }
+  onDeleteTag(index: number): void {
+    this.tags.splice(index, 1);
+  }
 
   onSubmit(): void {
     const labels = this.tags.reduce((pre: any, tag) => {
@@ -222,7 +235,7 @@ export class ConfigCreateComponent implements OnInit {
       pre[key] = value;
       return pre;
     }, {});
-    if (this.configTageKey) {
+    if (this.configTageKey && labels[this.configTageKey] === undefined) {
       labels[this.configTageKey] = this.configTageValue || '';
     }
     const param = {