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

scottyaslan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-registry.git

commit 3f3190ac8ae1896cff4fe72897c5fd7489ddc792
Author: Bryan Bende <[email protected]>
AuthorDate: Tue Apr 23 11:21:03 2019 -0400

    NIFIREG-256 Updating manage buckets page
---
 .../org/apache/nifi/registry/bucket/Bucket.java    | 10 ++---
 .../nifi/registry/service/RegistryService.java     |  8 ++--
 .../registry/service/mapper/BucketMappings.java    |  4 +-
 .../web/api/UnsecuredNiFiRegistryClientIT.java     |  8 ++--
 .../manage-bucket/nf-registry-manage-bucket.html   | 28 +++++++++++-
 .../manage-bucket/nf-registry-manage-bucket.js     | 52 +++++++++++++++++++---
 .../src/main/webapp/services/nf-registry.api.js    | 12 +++--
 .../main/webapp/services/nf-registry.api.spec.js   | 12 ++++-
 .../main/webapp/theming/_structureElements.scss    |  8 ++++
 9 files changed, 109 insertions(+), 33 deletions(-)

diff --git 
a/nifi-registry-core/nifi-registry-data-model/src/main/java/org/apache/nifi/registry/bucket/Bucket.java
 
b/nifi-registry-core/nifi-registry-data-model/src/main/java/org/apache/nifi/registry/bucket/Bucket.java
index fcf27ca..6837a6d 100644
--- 
a/nifi-registry-core/nifi-registry-data-model/src/main/java/org/apache/nifi/registry/bucket/Bucket.java
+++ 
b/nifi-registry-core/nifi-registry-data-model/src/main/java/org/apache/nifi/registry/bucket/Bucket.java
@@ -41,7 +41,7 @@ public class Bucket extends LinkableEntity {
 
     private String description;
 
-    private Boolean allowExtensionBundleRedeploy;
+    private Boolean allowBundleRedeploy;
 
     private Permissions permissions;
 
@@ -82,12 +82,12 @@ public class Bucket extends LinkableEntity {
     }
 
     @ApiModelProperty("Indicates if this bucket allows the same version of an 
extension bundle to be redeployed and thus overwrite the existing artifact. By 
default this is false.")
-    public Boolean isAllowExtensionBundleRedeploy() {
-        return allowExtensionBundleRedeploy;
+    public Boolean isAllowBundleRedeploy() {
+        return allowBundleRedeploy;
     }
 
-    public void setAllowExtensionBundleRedeploy(final Boolean 
allowExtensionBundleRedeploy) {
-        this.allowExtensionBundleRedeploy = allowExtensionBundleRedeploy;
+    public void setAllowBundleRedeploy(final Boolean allowBundleRedeploy) {
+        this.allowBundleRedeploy = allowBundleRedeploy;
     }
 
     @ApiModelProperty(value = "The access that the current user has to this 
bucket.", readOnly = true)
diff --git 
a/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/RegistryService.java
 
b/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/RegistryService.java
index 606fca2..7a87ec0 100644
--- 
a/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/RegistryService.java
+++ 
b/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/RegistryService.java
@@ -155,8 +155,8 @@ public class RegistryService {
         bucket.setIdentifier(UUID.randomUUID().toString());
         bucket.setCreatedTimestamp(System.currentTimeMillis());
 
-        if (bucket.isAllowExtensionBundleRedeploy() == null) {
-            bucket.setAllowExtensionBundleRedeploy(false);
+        if (bucket.isAllowBundleRedeploy() == null) {
+            bucket.setAllowBundleRedeploy(false);
         }
 
         validate(bucket, "Cannot create Bucket");
@@ -277,8 +277,8 @@ public class RegistryService {
                 existingBucketById.setDescription(bucket.getDescription());
             }
 
-            if (bucket.isAllowExtensionBundleRedeploy() != null) {
-                
existingBucketById.setAllowExtensionBundleRedeploy(bucket.isAllowExtensionBundleRedeploy());
+            if (bucket.isAllowBundleRedeploy() != null) {
+                
existingBucketById.setAllowExtensionBundleRedeploy(bucket.isAllowBundleRedeploy());
             }
 
             // perform the actual update
diff --git 
a/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/mapper/BucketMappings.java
 
b/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/mapper/BucketMappings.java
index de5750f..22020a6 100644
--- 
a/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/mapper/BucketMappings.java
+++ 
b/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/mapper/BucketMappings.java
@@ -32,7 +32,7 @@ public class BucketMappings {
         bucketEntity.setName(bucket.getName());
         bucketEntity.setDescription(bucket.getDescription());
         bucketEntity.setCreated(new Date(bucket.getCreatedTimestamp()));
-        
bucketEntity.setAllowExtensionBundleRedeploy(bucket.isAllowExtensionBundleRedeploy());
+        
bucketEntity.setAllowExtensionBundleRedeploy(bucket.isAllowBundleRedeploy());
         return bucketEntity;
     }
 
@@ -42,7 +42,7 @@ public class BucketMappings {
         bucket.setName(bucketEntity.getName());
         bucket.setDescription(bucketEntity.getDescription());
         bucket.setCreatedTimestamp(bucketEntity.getCreated().getTime());
-        
bucket.setAllowExtensionBundleRedeploy(bucketEntity.isAllowExtensionBundleRedeploy());
+        
bucket.setAllowBundleRedeploy(bucketEntity.isAllowExtensionBundleRedeploy());
         return bucket;
     }
 
diff --git 
a/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/UnsecuredNiFiRegistryClientIT.java
 
b/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/UnsecuredNiFiRegistryClientIT.java
index f0e15b4..e16fa79 100644
--- 
a/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/UnsecuredNiFiRegistryClientIT.java
+++ 
b/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/UnsecuredNiFiRegistryClientIT.java
@@ -183,7 +183,7 @@ public class UnsecuredNiFiRegistryClientIT extends 
UnsecuredITBase {
         for (final Bucket bucket : createdBuckets) {
             final Bucket retrievedBucket = 
bucketClient.get(bucket.getIdentifier());
             assertNotNull(retrievedBucket);
-            assertFalse(retrievedBucket.isAllowExtensionBundleRedeploy());
+            assertFalse(retrievedBucket.isAllowBundleRedeploy());
             LOGGER.info("Retrieved bucket " + retrievedBucket.getIdentifier());
         }
 
@@ -427,7 +427,7 @@ public class UnsecuredNiFiRegistryClientIT extends 
UnsecuredITBase {
         LOGGER.info("Created bundle with id {}", new 
Object[]{fooNarV1Bundle.getIdentifier()});
 
         // verify that bucket 1 currently does not allow redeploying 
non-snapshot artifacts
-        assertFalse(bundlesBucket.isAllowExtensionBundleRedeploy());
+        assertFalse(bundlesBucket.isAllowBundleRedeploy());
 
         // try to re-deploy version 1.0.0 of nifi-foo-nar, should fail
         try {
@@ -438,9 +438,9 @@ public class UnsecuredNiFiRegistryClientIT extends 
UnsecuredITBase {
         }
 
         // now update bucket 1 to allow redeploy
-        bundlesBucket.setAllowExtensionBundleRedeploy(true);
+        bundlesBucket.setAllowBundleRedeploy(true);
         final Bucket updatedBundlesBucket = bucketClient.update(bundlesBucket);
-        assertTrue(updatedBundlesBucket.isAllowExtensionBundleRedeploy());
+        assertTrue(updatedBundlesBucket.isAllowBundleRedeploy());
 
         // try to re-deploy version 1.0.0 of nifi-foo-nar again, this time 
should work
         assertNotNull(createExtensionBundleVersionWithFile(bundlesBucket, 
bundleVersionClient, fooNar, null));
diff --git 
a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/sidenav/manage-bucket/nf-registry-manage-bucket.html
 
b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/sidenav/manage-bucket/nf-registry-manage-bucket.html
index 3728fce..ed4b260 100644
--- 
a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/sidenav/manage-bucket/nf-registry-manage-bucket.html
+++ 
b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/sidenav/manage-bucket/nf-registry-manage-bucket.html
@@ -30,9 +30,9 @@ limitations under the License.
                        
[disabled]="!nfRegistryService.currentUser.resourcePermissions.buckets.canWrite"
                        placeholder="Identity/Bucket Name"
                        value="{{nfRegistryService.bucket.name}}"
-                       [(ngModel)]="_bucketname">
+                       [(ngModel)]="bucketname">
             </mat-input-container>
-            <button [disabled]="nfRegistryService.bucket.name === _bucketname"
+            <button [disabled]="nfRegistryService.bucket.name === bucketname"
                     (click)="updateBucketName(bucketnameInput.value)"
                     id="nf-registry-manage-bucket-save-side-nav"
                     class="input-button"
@@ -41,6 +41,21 @@ limitations under the License.
                 Save
             </button>
         </div>
+        <div class="pad-top-md pad-bottom-sm pad-left-md pad-right-md">
+            <div class="pad-bottom-md">
+                <span class="md-card-title">Bundle Settings</span>
+            </div>
+            <div>
+                <mat-checkbox #bundleRedeployCheckbox
+                              
[disabled]="!nfRegistryService.currentUser.resourcePermissions.buckets.canWrite"
+                              
[(checked)]="nfRegistryService.bucket.allowBundleRedeploy"
+                              [(ngModel)]="allowBundleRedeploy"
+                              (change)="toggleBucketBundleRedeploy($event)"
+                              matTooltip="Allows released bundles in this 
bucket to be overwritten">
+                    Allow bundle overwrite
+                </mat-checkbox>
+            </div>
+        </div>
         <div *ngIf="!nfRegistryService.currentUser.anonymous || 
nfRegistryService.currentUser.resourcePermissions.policies.canRead" 
class="pad-top-md pad-bottom-sm pad-left-md pad-right-md">
             <div flex fxLayout="row" fxLayoutAlign="space-between center">
                 <span class="md-card-title">Policies 
({{userIdentitiesWithPolicies.length + 
groupIdentitiesWithPolicies.length}})</span>
@@ -121,6 +136,15 @@ limitations under the License.
                 </div>
             </div>
         </div>
+        <div class="pad-top-md pad-bottom-sm pad-left-md pad-right-md">
+            <div class="pad-bottom-md">
+                <span class="md-card-title">About</span>
+            </div>
+            <div>
+                <span class="field-header">Bucket Identifier</span>
+                <p class="ellipsis" 
matTooltip="{{nfRegistryService.bucket.identifier}}">{{nfRegistryService.bucket.identifier}}</p>
+            </div>
+        </div>
     </div>
     <button id="nf-registry-workflow-bucket-permissions-side-nav-container" 
class="push-right-md" mat-raised-button
             color="fds-primary"
diff --git 
a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/sidenav/manage-bucket/nf-registry-manage-bucket.js
 
b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/sidenav/manage-bucket/nf-registry-manage-bucket.js
index 023b9d4..4c671a1 100644
--- 
a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/sidenav/manage-bucket/nf-registry-manage-bucket.js
+++ 
b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/sidenav/manage-bucket/nf-registry-manage-bucket.js
@@ -61,7 +61,8 @@ function NfRegistryManageBucket(nfRegistryApi, 
nfRegistryService, tdDataTableSer
         }
     ];
     this.userPermsSearchTerms = [];
-    this._bucketname = '';
+    this.bucketname = '';
+    this.allowBundleRedeploy = false;
     this.bucketPolicies = [];
     this.userPerms = {};
     this.groupPerms = {};
@@ -101,7 +102,7 @@ NfRegistryManageBucket.prototype = {
                     self.nfRegistryService.sidenav.open();
                     var bucket = response[0];
                     self.nfRegistryService.bucket = bucket;
-                    self._bucketname = response[0].name;
+                    self.bucketname = response[0].name;
                     if (!self.nfRegistryService.currentUser.anonymous) {
                         if (!response[1].status || response[1].status === 200) 
{
                             var policies = response[1];
@@ -161,7 +162,7 @@ NfRegistryManageBucket.prototype = {
             
self.nfRegistryApi.getBucket(self.nfRegistryService.bucket.identifier)
                 .subscribe(function (response) {
                     self.nfRegistryService.bucket = response;
-                    self._bucketname = response.name;
+                    self.bucketname = response.name;
 
                     if (dialogResult) {
                         if (dialogResult.userOrGroup.type === 'user') {
@@ -198,7 +199,7 @@ NfRegistryManageBucket.prototype = {
             
self.nfRegistryApi.getBucket(self.nfRegistryService.bucket.identifier)
                 .subscribe(function (response) {
                     self.nfRegistryService.bucket = response;
-                    self._bucketname = response.name;
+                    self.bucketname = response.name;
 
                     if (dialogResult) {
                         if (dialogResult.userOrGroup.type === 'user') {
@@ -394,7 +395,10 @@ NfRegistryManageBucket.prototype = {
      */
     updateBucketName: function (bucketname) {
         var self = this;
-        
this.nfRegistryApi.updateBucket(this.nfRegistryService.bucket.identifier, 
bucketname).subscribe(function (response) {
+        this.nfRegistryApi.updateBucket({
+            'identifier': this.nfRegistryService.bucket.identifier,
+            'name': bucketname,
+        }).subscribe(function (response) {
             if (!response.status || response.status === 200) {
                 self.nfRegistryService.bucket = response;
                 // update the bucket identity in the buckets table
@@ -413,7 +417,7 @@ NfRegistryManageBucket.prototype = {
                     duration: 3000
                 });
             } else if (response.status === 409) {
-                self._bucketname = self.nfRegistryService.bucket.name;
+                self.bucketname = self.nfRegistryService.bucket.name;
                 self.dialogService.openConfirm({
                     title: 'Error',
                     message: 'This bucket already exists. Please enter a 
different identity/bucket name.',
@@ -421,7 +425,41 @@ NfRegistryManageBucket.prototype = {
                     acceptButtonColor: 'fds-warn'
                 });
             } else if (response.status === 400) {
-                self._bucketname = self.nfRegistryService.bucket.name;
+                self.bucketname = self.nfRegistryService.bucket.name;
+                self.dialogService.openConfirm({
+                    title: 'Error',
+                    message: response.error,
+                    acceptButton: 'Ok',
+                    acceptButtonColor: 'fds-warn'
+                });
+            }
+        });
+    },
+
+    /**
+     * Update allowBundleRedeploy flag.
+     *
+     * @param the checkbox change event
+     */
+    toggleBucketBundleRedeploy: function (event) {
+        var self = this;
+        this.nfRegistryApi.updateBucket({
+            'identifier': this.nfRegistryService.bucket.identifier,
+            'allowBundleRedeploy': event.checked,
+        }).subscribe(function (response) {
+            if (!response.status || response.status === 200) {
+                self.nfRegistryService.bucket = response;
+                var snackBarRef = self.snackBarService.openCoaster({
+                    title: 'Success',
+                    message: 'Bundle settings have been updated.',
+                    verticalPosition: 'bottom',
+                    horizontalPosition: 'right',
+                    icon: 'fa fa-check-circle-o',
+                    color: '#1EB475',
+                    duration: 3000
+                });
+            }  else if (response.status === 400) {
+                self.allowBundleRedeploy = 
self.nfRegistryService.bucket.allowBundleRedeploy;
                 self.dialogService.openConfirm({
                     title: 'Error',
                     message: response.error,
diff --git 
a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js
 
b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js
index e722f30..1c92f8d 100644
--- 
a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js
+++ 
b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js
@@ -248,16 +248,14 @@ NfRegistryApi.prototype = {
     /**
      * Updates a bucket.
      *
-     * @param {string} identifier   The identifier of the bucket.
-     * @param {string} name         The name of the bucket.
+     * @param {string} identifier           The identifier of the bucket.
+     * @param {string} name                 The name of the bucket.
+     * @param {string} allowBundleRedeploy  Whether or not the bucket allows 
redeploying released bundles
      * @returns {*}
      */
-    updateBucket: function (identifier, name) {
+    updateBucket: function (updatedBucket) {
         var self = this;
-        return this.http.put('/nifi-registry-api/buckets/' + identifier, {
-            'identifier': identifier,
-            'name': name
-        }, headers)
+        return this.http.put('/nifi-registry-api/buckets/' + 
updatedBucket.identifier, updatedBucket, headers)
             .map(function (response) {
                 return response;
             })
diff --git 
a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.spec.js
 
b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.spec.js
index 7fc7b47..c0e4e0b 100644
--- 
a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.spec.js
+++ 
b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.spec.js
@@ -627,7 +627,11 @@ describe('NfRegistry API w/ Angular testing utils', 
function () {
 
     it('should PUT to update a bucket name.', 
ngCoreTesting.inject([ngCommonHttpTesting.HttpTestingController], function 
(httpMock) {
         // api call
-        nfRegistryApi.updateBucket('2f7f9e54-dc09-4ceb-aa58-9fe581319cdc', 
'Bucket #1').subscribe(function (response) {
+        nfRegistryApi.updateBucket({
+            'identifier' : '2f7f9e54-dc09-4ceb-aa58-9fe581319cdc',
+            'name' : 'Bucket #1',
+            'allowBundleRedeploy' : false
+        }).subscribe(function (response) {
             
expect(response[0].identifier).toEqual('2f7f9e54-dc09-4ceb-aa58-9fe581319cdc');
             expect(response[0].name).toEqual('Bucket #1');
         });
@@ -647,7 +651,11 @@ describe('NfRegistry API w/ Angular testing utils', 
function () {
 
     it('should fail to PUT to update a bucket name.', 
ngCoreTesting.inject([ngCommonHttpTesting.HttpTestingController], function 
(httpMock) {
         // api call
-        nfRegistryApi.updateBucket('2f7f9e54-dc09-4ceb-aa58-9fe581319cdc', 
'Bucket #1').subscribe(function (response) {
+        nfRegistryApi.updateBucket({
+            'identifier' : '2f7f9e54-dc09-4ceb-aa58-9fe581319cdc',
+            'name' : 'Bucket #1',
+            'allowBundleRedeploy' : false
+        }).subscribe(function (response) {
             expect(response.message).toEqual('Http failure response for 
/nifi-registry-api/buckets/2f7f9e54-dc09-4ceb-aa58-9fe581319cdc: 401 PUT to 
update a bucket name mock error');
         });
 
diff --git 
a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/theming/_structureElements.scss
 
b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/theming/_structureElements.scss
index aebed59..fd4bb78 100644
--- 
a/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/theming/_structureElements.scss
+++ 
b/nifi-registry-core/nifi-registry-web-ui/src/main/webapp/theming/_structureElements.scss
@@ -138,6 +138,14 @@ mat-sidenav {
   overflow: auto;
 }
 
+.field-header {
+  font-size: 11px;
+  color: #999999;
+  font-weight: 300;
+  margin-bottom: 6px;
+  text-transform: uppercase;
+}
+
 body[fds] mat-form-field.td-chips-form-field.mat-input-container {
   width: unset;
 }

Reply via email to