Skip to content

Commit

Permalink
feature: public namespace support different formats (#3836)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
dake0805 and Anilople authored Aug 5, 2021
1 parent 7afe23b commit 109c98d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ public AppNamespace createAppNamespaceInLocal(AppNamespace appNamespace, boolean
}

// 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
Expand Down
2 changes: 1 addition & 1 deletion apollo-portal/src/main/resources/static/namespace.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,18 +713,55 @@ <h5>{{'Component.Namespace.Master.Items.Body.NoPublished.Title' | translate }}</
</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}}"
ng-show="namespace.viewType == 'text' && namespace.isTextEditing" ng-disabled="!namespace.isTextEditing"
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"
Expand Down

0 comments on commit 109c98d

Please sign in to comment.