Skip to content

Commit

Permalink
feat: support properties diff
Browse files Browse the repository at this point in the history
  • Loading branch information
WTIFS committed Nov 15, 2024
1 parent a90fb6b commit 2abd7aa
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 20 deletions.
21 changes: 15 additions & 6 deletions apollo-portal/src/main/resources/static/config/diff.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ <h4 class="modal-title">{{'Config.Diff.Title' | translate }}
</label>
</div>
<div class="col-sm-12 diff-content">
<table class="table table-bordered table-striped table-hover" ng-show="isTableDiff">
<thead>
<!--表格对比 properties mode-->
<table class="table table-bordered table-striped table-hover table-fixed" ng-show="isTableDiff">
<thead>
<tr>
<td>Key</td>
<td width="10%">Key</td>
<td ng-repeat="cluster in syncData.syncToNamespaces">
Value ( {{'Common.Environment' | translate }} : <label ng-bind="cluster.env"></label> , {{'Common.Cluster' | translate }} : <label ng-bind="cluster.clusterName"></label> )
</td>
Expand All @@ -142,16 +143,24 @@ <h4 class="modal-title">{{'Config.Diff.Title' | translate }}
<tbody>
<tr ng-repeat="(key, itemsKeyedByCluster) in itemsKeyedByKey" ng-if="(searchKey === '' || key.indexOf(searchKey) !== -1 ) && (!onlyShowDiffKeys || (onlyShowDiffKeys && !allNamespaceValueEqualed[key]))">
<td width="15%" ng-bind="key"></td>
<td ng-repeat="cluster in syncData.syncToNamespaces"
ng-bind="(itemsKeyedByCluster[cluster.env + ':' + cluster.clusterName + ':' + cluster.namespaceName] || {}).value">
<td ng-bind="(itemsKeyedByCluster[syncData.firstClusterKey] || {}).value"></td>
<td ng-repeat="cluster in syncData.syncToNamespaces.slice(1)">
<span ng-if="itemsKeyedByCluster[cluster.compositedKey]" >
<apollodiff old-str="(itemsKeyedByCluster[syncData.firstClusterKey] || {}).value"
new-str="(itemsKeyedByCluster[cluster.compositedKey] || {}).value"
apollo-id="'clusterDiff:' + key + ':' + cluster.compositedKey">
</apollodiff>
</span>
</td>
<td ng-show="showCommentDiff"
ng-repeat="cluster in syncData.syncToNamespaces"
ng-bind="(itemsKeyedByCluster[cluster.env + ':' + cluster.clusterName + ':' + cluster.namespaceName] || {}).comment">
ng-bind="(itemsKeyedByCluster[cluster.compositedKey] || {}).comment">
</td>
</tr>
</tbody>
</table>

<!--纯文本对比 text mode-->
<apollodiff ng-show="!isTableDiff" old-str="syncData.syncToNamespaces[0].originTextInfo"
new-str="syncData.syncToNamespaces[1].originTextInfo" apollo-id="'releaseStrDiff'">
</apollodiff>
Expand Down
4 changes: 2 additions & 2 deletions apollo-portal/src/main/resources/static/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@
"Component.Publish.ToSeeChange": "查看变更",
"Component.Publish.CompareWithMasterValue": "与主版本对比",
"Component.Publish.CompareWithPublishedValue": "与已发布对比",
"Component.Publish.PublishedValue": "待发布的值",
"Component.Publish.PublishedValue": "已发布的值",
"Component.Publish.Changes": "Changes",
"Component.Publish.Key": "Key",
"Component.Publish.NoPublishedValue": "未发布的值",
"Component.Publish.NoPublishedValue": "待发布的值",
"Component.Publish.ModifyUser": "修改人",
"Component.Publish.ModifyTime": "修改时间",
"Component.Publish.NewAdded": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,19 @@ diff_item_module.controller("DiffItemController",
function parseSyncSourceData() {
var syncData = {
syncToNamespaces: [],
syncItems: []
syncItems: [],
firstClusterKey: "",
};
var namespaceName = $scope.pageContext.namespaceName;
selectedClusters.forEach(function (cluster) {
if (cluster.checked) {
cluster.clusterName = cluster.name;
cluster.namespaceName = namespaceName;
cluster.compositedKey = cluster.env + ':' + cluster.clusterName + ':' + cluster.namespaceName;
syncData.syncToNamespaces.push(cluster);
}
});

syncData.firstClusterKey = selectedClusters[0].compositedKey;
return syncData;
}

Expand Down
15 changes: 14 additions & 1 deletion apollo-portal/src/main/resources/static/styles/common-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,18 @@ p, td, span {
color: #797979;
}

pre, .pre {
pre {
white-space: pre-wrap; /* Since CSS 2.1 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}

.pre {
white-space: pre;
}

.hover:hover {
background: #f5f5f5;
cursor: pointer
Expand Down Expand Up @@ -1172,4 +1176,13 @@ table th {
#consumer-list .create-btn img {
width: 16px;
height: 16px;
}

.left-overflow {
overflow-x: auto;
text-align: left;
}

.table-fixed{
table-layout: fixed;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<pre class="no-radius" id="{{apolloId}}">
<pre class="no-radius pre" id="{{apolloId}}">
<!--
~ Copyright 2024 Apollo Authors
~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ <h4 class="modal-title" ng-show="toReleaseNamespace.isBranch && toReleaseNamespa

<!--properties format-->
<!--normal release-->
<table class="table table-bordered table-striped text-center table-hover"
<!--主版本发布-->
<table class="table table-bordered table-striped text-center table-hover table-fixed"
ng-if="toReleaseNamespace.isPropertiesFormat && !toReleaseNamespace.isBranch">
<thead>
<tr>
Expand All @@ -78,7 +79,7 @@ <h4 class="modal-title" ng-show="toReleaseNamespace.isBranch && toReleaseNamespa
<th>
{{'Component.Publish.PublishedValue' | translate }}
</th>
<th>
<th width="40%">
{{'Component.Publish.NoPublishedValue' | translate }}
</th>
<th>
Expand Down Expand Up @@ -108,8 +109,8 @@ <h4 class="modal-title" ng-show="toReleaseNamespace.isBranch && toReleaseNamespa
<td width="25%" title="{{config.oldValue}}">
<span ng-bind="config.oldValue"></span>
</td>
<td width="25%" title="{{config.newValue}}">
<span ng-bind="config.newValue"></span>
<td width="25%" title="{{config.newValue}}" class="left-overflow">
<apollodiff old-str="config.oldValue" new-str="config.newValue" apollo-id="'unpublishedDiffPublished:'+config.item.key"></apollodiff>
</td>
<td width="15%" ng-bind="config.item.dataChangeLastModifiedBy">
</td>
Expand All @@ -121,6 +122,7 @@ <h4 class="modal-title" ng-show="toReleaseNamespace.isBranch && toReleaseNamespa
</table>

<!--branch gray release-->
<!--灰度发布-->
<table class="table table-bordered table-striped text-center table-hover" ng-if="toReleaseNamespace.isPropertiesFormat &&
toReleaseNamespace.isBranch && !toReleaseNamespace.mergeAndPublish">
<thead>
Expand Down Expand Up @@ -172,7 +174,8 @@ <h4 class="modal-title" ng-show="toReleaseNamespace.isBranch && toReleaseNamespa
</table>

<!--branch updateAndPublish and publish-->
<table class="table table-bordered table-striped text-center table-hover" ng-if="toReleaseNamespace.isPropertiesFormat &&
<!--灰度推全-->
<table class="table table-bordered table-striped text-center table-hover table-fixed" ng-if="toReleaseNamespace.isPropertiesFormat &&
toReleaseNamespace.isBranch && toReleaseNamespace.mergeAndPublish">
<thead>
<tr>
Expand All @@ -182,7 +185,7 @@ <h4 class="modal-title" ng-show="toReleaseNamespace.isBranch && toReleaseNamespa
<th ng-if="toReleaseNamespace.isBranch">
{{'Component.Publish.MasterValue' | translate }}
</th>
<th ng-if="toReleaseNamespace.isBranch && toReleaseNamespace.mergeAndPublish">
<th width="40%" ng-if="toReleaseNamespace.isBranch && toReleaseNamespace.mergeAndPublish">
{{'Component.Publish.GrayValue' | translate }}
</th>
<th ng-if="!toReleaseNamespace.isBranch || !toReleaseNamespace.mergeAndPublish">
Expand All @@ -207,8 +210,8 @@ <h4 class="modal-title" ng-show="toReleaseNamespace.isBranch && toReleaseNamespa
<td width="25%" title="{{config.masterReleaseValue}}">
<span ng-bind="config.masterReleaseValue"></span>
</td>
<td width="25%" title="{{config.item.value}}">
<span ng-bind="config.item.value"></span>
<td width="25%" title="{{config.item.value}}" class="left-overflow">
<apollodiff old-str="config.masterReleaseValue" new-str="config.item.value" apollo-id="'grayDiffMaster:' + config.item.key"></apollodiff>
</td>
<td width="15%" ng-bind="config.item.dataChangeLastModifiedBy">
</td>
Expand Down

0 comments on commit 2abd7aa

Please sign in to comment.