knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smol...@apache.org
Subject [knox] branch master updated: KNOX-2161 - CM generated descriptors are read-only on Admin UI (#265)
Date Tue, 18 Feb 2020 16:53:15 GMT
This is an automated email from the ASF dual-hosted git repository.

smolnar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git


The following commit(s) were added to refs/heads/master by this push:
     new 03f62b0  KNOX-2161 - CM generated descriptors are read-only on Admin UI (#265)
03f62b0 is described below

commit 03f62b0025d78f17791e995666b684d91e88431e
Author: Sandor Molnar <smolnar@apache.org>
AuthorDate: Tue Feb 18 17:53:07 2020 +0100

    KNOX-2161 - CM generated descriptors are read-only on Admin UI (#265)
---
 .../admin-ui/app/resource-detail/descriptor.ts             |  1 +
 .../app/resource-detail/resource-detail.component.html     | 14 +++++++++-----
 .../app/resource-detail/resource-detail.component.ts       |  8 ++++++++
 gateway-admin-ui/admin-ui/app/resource/resource.service.ts |  3 +++
 .../cm/descriptor/ClouderaManagerDescriptorParser.java     |  1 +
 .../cm/descriptor/ClouderaManagerDescriptorParserTest.java |  2 ++
 .../knox/gateway/topology/simple/SimpleDescriptor.java     |  2 ++
 .../knox/gateway/topology/simple/SimpleDescriptorImpl.java | 12 ++++++++++++
 8 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/gateway-admin-ui/admin-ui/app/resource-detail/descriptor.ts b/gateway-admin-ui/admin-ui/app/resource-detail/descriptor.ts
index 0a22117..85d90ae 100644
--- a/gateway-admin-ui/admin-ui/app/resource-detail/descriptor.ts
+++ b/gateway-admin-ui/admin-ui/app/resource-detail/descriptor.ts
@@ -23,6 +23,7 @@ export class Descriptor {
     discoveryPassAlias: string;
     discoveryCluster: string;
     providerConfig: string;
+    readOnly: boolean;
     services: Service[];
 
     private dirty = false;
diff --git a/gateway-admin-ui/admin-ui/app/resource-detail/resource-detail.component.html
b/gateway-admin-ui/admin-ui/app/resource-detail/resource-detail.component.html
index ab554c9..a4e5ea9 100644
--- a/gateway-admin-ui/admin-ui/app/resource-detail/resource-detail.component.html
+++ b/gateway-admin-ui/admin-ui/app/resource-detail/resource-detail.component.html
@@ -1,8 +1,9 @@
 <div *ngIf="resourceType && resourceType !== 'Topologies' && resourceType
!== 'Service Definitions'" class="panel panel-default">
     <div class="panel-heading">
         <h4 class="panel-title">
-            {{ getTitleSubject() }} Detail <span *ngIf="hasSelectedResource()"
-                                                 class="pull-right">{{resourceService.getResourceDisplayName(resource)}}</span>
+            {{ getTitleSubject() }} Detail
+            <span *ngIf="showEditOptions() == false" style="padding-left: 15%;" class="text-danger
text-center"> Read Only (generated file) </span>
+            <span *ngIf="hasSelectedResource()" class="pull-right">{{resourceService.getResourceDisplayName(resource)}}</span>
         </h4>
     </div>
 
@@ -479,7 +480,8 @@
                     title="Remove Descriptor"
                     class="btn btn-default btn-sm pull-left"
                     (click)="deleteConfirmModal.open('md')"
-                    data-toggle="tooltip">
+                    data-toggle="tooltip"
+                    *ngIf="showEditOptions()">
                 <span class="glyphicon glyphicon-trash"></span>
             </button>
             <span class="pull-right">
@@ -488,7 +490,8 @@
                 class="btn btn-default btn-sm"
                 [disabled]="!descriptor.isDirty()"
                 (click)="discardConfirmModal.open('md')"
-                data-toggle="tooltip">
+                data-toggle="tooltip"
+                *ngIf="showEditOptions()">
           <span class="glyphicon glyphicon-refresh"></span>
         </button>
         <span>&nbsp;</span>
@@ -497,7 +500,8 @@
                 class="btn btn-default btn-sm"
                 [disabled]="!descriptor.isDirty()"
                 (click)="persistChanges()"
-                data-toggle="tooltip">
+                data-toggle="tooltip"
+                *ngIf="showEditOptions()">
           <span class="glyphicon glyphicon-floppy-disk"></span>
         </button>
       </span>
diff --git a/gateway-admin-ui/admin-ui/app/resource-detail/resource-detail.component.ts b/gateway-admin-ui/admin-ui/app/resource-detail/resource-detail.component.ts
index 234e2ff..b6ad220 100644
--- a/gateway-admin-ui/admin-ui/app/resource-detail/resource-detail.component.ts
+++ b/gateway-admin-ui/admin-ui/app/resource-detail/resource-detail.component.ts
@@ -175,6 +175,7 @@ export class ResourceDetailComponent implements OnInit {
                     tempDesc.discoveryPassAlias = contentObj['discovery-pwd-alias'];
                     tempDesc.discoveryCluster = contentObj['cluster'];
                     tempDesc.providerConfig = contentObj['provider-config-ref'];
+                    tempDesc.readOnly = contentObj['read-only'];
                     tempDesc.services = contentObj['services'];
                 }
                 this.descriptor = tempDesc;
@@ -557,4 +558,11 @@ export class ResourceDetailComponent implements OnInit {
             }
         }
     }
+
+    showEditOptions(): boolean {
+        if (this.resourceType === 'Descriptors' && this.descriptor.readOnly) {
+            return !Boolean(this.descriptor.readOnly);
+        }
+        return true;
+    }
 }
diff --git a/gateway-admin-ui/admin-ui/app/resource/resource.service.ts b/gateway-admin-ui/admin-ui/app/resource/resource.service.ts
index 4f88bc5..0b1bbdd 100644
--- a/gateway-admin-ui/admin-ui/app/resource/resource.service.ts
+++ b/gateway-admin-ui/admin-ui/app/resource/resource.service.ts
@@ -247,6 +247,9 @@ export class ResourceService {
         if (desc.discoveryCluster) {
             tmp['cluster'] = desc.discoveryCluster;
         }
+        if (desc.readOnly) {
+            tmp['read-only'] = desc.readOnly;
+        }
         tmp['provider-config-ref'] = desc.providerConfig;
         tmp['services'] = desc.services;
 
diff --git a/gateway-cm-integration/src/main/java/org/apache/knox/gateway/cm/descriptor/ClouderaManagerDescriptorParser.java
b/gateway-cm-integration/src/main/java/org/apache/knox/gateway/cm/descriptor/ClouderaManagerDescriptorParser.java
index 0366f5c..fc8ed8f 100644
--- a/gateway-cm-integration/src/main/java/org/apache/knox/gateway/cm/descriptor/ClouderaManagerDescriptorParser.java
+++ b/gateway-cm-integration/src/main/java/org/apache/knox/gateway/cm/descriptor/ClouderaManagerDescriptorParser.java
@@ -106,6 +106,7 @@ public class ClouderaManagerDescriptorParser implements AdvancedServiceDiscovery
   private SimpleDescriptor parseXmlDescriptor(String name, String xmlValue) {
     try {
       final SimpleDescriptorImpl descriptor = new SimpleDescriptorImpl();
+      descriptor.setReadOnly(true);
       descriptor.setName(name);
       final String[] configurationPairs = xmlValue.split(";");
       for (String configurationPair : configurationPairs) {
diff --git a/gateway-cm-integration/src/test/java/org/apache/knox/gateway/cm/descriptor/ClouderaManagerDescriptorParserTest.java
b/gateway-cm-integration/src/test/java/org/apache/knox/gateway/cm/descriptor/ClouderaManagerDescriptorParserTest.java
index 4bf12ac..f65d36c 100644
--- a/gateway-cm-integration/src/test/java/org/apache/knox/gateway/cm/descriptor/ClouderaManagerDescriptorParserTest.java
+++ b/gateway-cm-integration/src/test/java/org/apache/knox/gateway/cm/descriptor/ClouderaManagerDescriptorParserTest.java
@@ -150,6 +150,7 @@ public class ClouderaManagerDescriptorParserTest {
   }
 
   private void validateTopology1(SimpleDescriptor descriptor) {
+    assertTrue(descriptor.isReadOnly());
     assertEquals("topology1", descriptor.getName());
     assertEquals("ClouderaManager", descriptor.getDiscoveryType());
     assertEquals("http://host:123", descriptor.getDiscoveryAddress());
@@ -168,6 +169,7 @@ public class ClouderaManagerDescriptorParserTest {
   }
 
   private void validateTopology2(SimpleDescriptor descriptor, boolean nifiExpected) {
+    assertTrue(descriptor.isReadOnly());
     assertEquals("topology2", descriptor.getName());
     assertEquals("Ambari", descriptor.getDiscoveryType());
     assertEquals("http://host:456", descriptor.getDiscoveryAddress());
diff --git a/gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptor.java
b/gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptor.java
index 5b32662..4ffc3ba 100644
--- a/gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptor.java
+++ b/gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptor.java
@@ -38,6 +38,8 @@ public interface SimpleDescriptor {
 
     String getProviderConfig();
 
+    boolean isReadOnly();
+
     List<Service> getServices();
 
     Service getService(String serviceName);
diff --git a/gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorImpl.java
b/gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorImpl.java
index 41e7f9b..c7b1c3f 100644
--- a/gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorImpl.java
+++ b/gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorImpl.java
@@ -42,6 +42,9 @@ public class SimpleDescriptorImpl implements SimpleDescriptor {
     @JsonProperty("provider-config-ref")
     private String providerConfig;
 
+    @JsonProperty("read-only")
+    private boolean readOnly;
+
     @JsonProperty("cluster")
     private String cluster;
 
@@ -116,6 +119,15 @@ public class SimpleDescriptorImpl implements SimpleDescriptor {
         return providerConfig;
     }
 
+    @Override
+    public boolean isReadOnly() {
+      return readOnly;
+    }
+
+    public void setReadOnly(boolean readOnly) {
+      this.readOnly = readOnly;
+    }
+
     public void addService(Service service) {
       if (services == null) {
         services = new ArrayList<>();


Mime
View raw message