Explorar o código

feature: public namespace support different formats (#3836)

* feature: allow create public namespace in many formats

- change front-end and portal service to allow create new namespace in format json/yaml/xml/txt

- can not associating namespace of these formats now

- todo: change some documents on front-end page

* feature: portal front-end can request associate namespace info

* feature: public namespace in many formats

Co-authored-by: wxq <Anilople@outlook.com>
Zoe Wong %!s(int64=3) %!d(string=hai) anos
pai
achega
109c98d2f6

+ 3 - 3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppNamespaceService.java

@@ -128,9 +128,9 @@ public class AppNamespaceService {
     }
 
     // public namespaces only allow properties format
-    if (appNamespace.isPublic()) {
-      appNamespace.setFormat(ConfigFileFormat.Properties.getValue());
-    }
+//    if (appNamespace.isPublic()) {
+//      appNamespace.setFormat(ConfigFileFormat.Properties.getValue());
+//    }
 
     StringBuilder appNamespaceName = new StringBuilder();
     //add prefix postfix

+ 1 - 1
apollo-portal/src/main/resources/static/namespace.html

@@ -123,7 +123,7 @@
                                 </div>
 
                                 <!--public namespace can only be properties -->
-                                <div class="col-sm-2" ng-show="!appNamespace.isPublic">
+                                <div class="col-sm-2">
                                     <select class="form-control" name="format" ng-model="appNamespace.format">
                                         <option value="properties">properties</option>
                                         <option value="xml">xml</option>

+ 5 - 4
apollo-portal/src/main/resources/static/scripts/controller/NamespaceController.js

@@ -86,7 +86,8 @@ namespace_module.controller("LinkNamespaceController",
             };
 
             function shouldAppendNamespacePrefix() {
-                 return $scope.appNamespace.isPublic ? $scope.appendNamespacePrefix : false;
+                //return $scope.appNamespace.isPublic ? $scope.appendNamespacePrefix : false;
+                return  $scope.appendNamespacePrefix;
             }
 
             var selectedClusters = [];
@@ -150,9 +151,9 @@ namespace_module.controller("LinkNamespaceController",
                     }
 
                     // public namespaces only allow properties format
-                    if ($scope.appNamespace.isPublic) {
-                        $scope.appNamespace.format = 'properties';
-                    }
+                    // if ($scope.appNamespace.isPublic) {
+                    //     $scope.appNamespace.format = 'properties';
+                    // }
 
                     $scope.submitBtnDisabled = true;
                     //only append namespace prefix for public app namespace

+ 8 - 2
apollo-portal/src/main/resources/static/scripts/directive/namespace-panel-directive.js

@@ -312,7 +312,7 @@ function directive($window, $translate, toastr, AppUtil, EventManager, Permissio
                 }
 
                 function initLinkedNamespace(namespace) {
-                    if (!namespace.isPublic || !namespace.isLinkedNamespace || namespace.format != 'properties') {
+                    if (!namespace.isPublic || !namespace.isLinkedNamespace) {
                         return;
                     }
                     //load public namespace
@@ -344,9 +344,15 @@ function directive($window, $translate, toastr, AppUtil, EventManager, Permissio
                                     publicNamespace.hasPublishedItem = true;
                                 }
                             });
-
+                            loadParentNamespaceText(namespace);
                         });
+                }
 
+                function loadParentNamespaceText(namespace){
+                    namespace.publicNamespaceText = "";
+                    if(namespace.isLinkedNamespace) {
+                        namespace.publicNamespaceText = parseModel2Text(namespace.publicNamespace)
+                    }
                 }
 
                 function initNamespaceViewName(namespace) {

+ 37 - 0
apollo-portal/src/main/resources/static/views/component/namespace-panel-master-tab.html

@@ -713,11 +713,23 @@
             </div>
 
             <!--text view-->
+
+            <div class="panel-heading" ng-show="namespace.viewType == 'text' && namespace.isLinkedNamespace">
+                <div class="row">
+                    <div class="padding-top-5 col-md-4 col-sm-4">
+                        {{'Component.Namespace.Master.Items.Body.Link.Title' | translate }}
+                    </div>
+                </div>
+            </div>
+
             <!--只读模式下的文本内容,不替换换行符-->
             <div ui-ace="aceConfig" readonly="true" class="form-control no-radius"
                 rows="{{namespace.itemCnt < 10 ? 10: namespace.itemCnt>20 ? 20:namespace.itemCnt}}"
                 ng-show="namespace.viewType == 'text' && !namespace.isTextEditing" ng-model="namespace.text">
             </div>
+
+
+
             <!--编辑状态下的文本内容,会过滤掉换行符-->
             <div ui-ace="aceConfig" class="form-control no-radius"
                 rows="{{namespace.itemCnt < 10 ? 10: namespace.itemCnt>20 ? 20:namespace.itemCnt}}"
@@ -725,6 +737,31 @@
                 ng-model="namespace.editText">
             </div>
 
+
+
+            <div class="panel-heading" ng-show="namespace.viewType == 'text' && namespace.isLinkedNamespace">
+                <div class="row">
+                    <div class="padding-top-5 col-md-4 col-sm-4">
+                        {{'Component.Namespace.Master.Items.Body.Public.Title' | translate }}
+                        <a href="{{ '/config.html' | prefixPath }}?#/appid={{namespace.publicNamespace.baseInfo.appId}}&env={{env}}&cluster={{namespace.publicNamespace.baseInfo.clusterName}}"
+                           target="_blank">
+                            <small>
+                                ({{'Common.AppId' | translate }}:{{namespace.publicNamespace.baseInfo.appId}},
+                                {{'Common.Cluster' | translate }}:{{namespace.publicNamespace.baseInfo.clusterName}})
+                            </small>
+                        </a>
+                    </div>
+                </div>
+            </div>
+
+
+            <!--关联的 Parent Namespace 内容,只读模式,不替换换行符-->
+            <div ui-ace="aceConfig" readonly="true" class="form-control no-radius"
+                 rows="{{namespace.itemCnt < 10 ? 10: namespace.itemCnt>20 ? 20:namespace.itemCnt}}"
+                 ng-show="namespace.viewType == 'text' && namespace.isLinkedNamespace"
+                 ng-model="namespace.publicNamespaceText">
+            </div>
+
             <!--history view-->
             <div class="J_historyview history-view" ng-show="namespace.viewType == 'history'">
                 <div class="media" ng-show="namespace.commits && namespace.commits.length"