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

mcgilman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 57f684de97 [NIFI-13134] - Support No Value Set in Edit Parameter 
Context.  (#8733)
57f684de97 is described below

commit 57f684de97d21477c6eb23aecdf898fa0ec1d2a3
Author: Rob Fellows <[email protected]>
AuthorDate: Fri May 3 14:01:07 2024 -0400

    [NIFI-13134] - Support No Value Set in Edit Parameter Context.  (#8733)
    
    * [NIFI-13134] - Support No Value Set in Edit Parameter Context. 
[NIFI-13135] - Allow parameter table to be sortable by parameter name
    
    * retain the valueRemoved setting when editing parameters
    
    This closes #8733
---
 .../parameter-table/parameter-table.component.html | 11 +++++--
 .../parameter-table.component.spec.ts              |  3 +-
 .../parameter-table/parameter-table.component.ts   | 38 ++++++++++++++++++++--
 .../edit-parameter-dialog.component.ts             |  9 +++--
 4 files changed, 52 insertions(+), 9 deletions(-)

diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.html
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.html
index 6bdcb0d0c0..073a1ac03a 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.html
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.html
@@ -26,10 +26,17 @@
         }
         <div class="listing-table">
             <div class="h-96 overflow-y-auto overflow-x-hidden">
-                <table mat-table [dataSource]="dataSource">
+                <table
+                    mat-table
+                    [dataSource]="dataSource"
+                    matSort
+                    matSortDisableClear
+                    (matSortChange)="sortData($event)"
+                    [matSortActive]="initialSortColumn"
+                    [matSortDirection]="initialSortDirection">
                     <!-- Name Column -->
                     <ng-container matColumnDef="name">
-                        <th mat-header-cell *matHeaderCellDef>Name</th>
+                        <th mat-header-cell *matHeaderCellDef 
mat-sort-header>Name</th>
                         <td mat-cell *matCellDef="let item">
                             <div class="flex justify-between items-center">
                                 <div>
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.spec.ts
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.spec.ts
index e55f4d2e60..0299836d7d 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.spec.ts
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.spec.ts
@@ -20,6 +20,7 @@ import { ComponentFixture, TestBed } from 
'@angular/core/testing';
 import { ParameterTable } from './parameter-table.component';
 import { provideMockStore } from '@ngrx/store/testing';
 import { initialState } from 
'../../../state/parameter-context-listing/parameter-context-listing.reducer';
+import { NoopAnimationsModule } from '@angular/platform-browser/animations';
 
 describe('ParameterTable', () => {
     let component: ParameterTable;
@@ -27,7 +28,7 @@ describe('ParameterTable', () => {
 
     beforeEach(() => {
         TestBed.configureTestingModule({
-            imports: [ParameterTable],
+            imports: [ParameterTable, NoopAnimationsModule],
             providers: [provideMockStore({ initialState })]
         });
         fixture = TestBed.createComponent(ParameterTable);
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.ts
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.ts
index b5a7e2eb6e..4be84c9cc7 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.ts
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.ts
@@ -32,6 +32,7 @@ import { ParameterReferences } from 
'../../../../../ui/common/parameter-referenc
 import { Store } from '@ngrx/store';
 import { ParameterContextListingState } from 
'../../../state/parameter-context-listing';
 import { showOkDialog } from 
'../../../state/parameter-context-listing/parameter-context-listing.actions';
+import { MatSortModule, Sort } from '@angular/material/sort';
 
 export interface ParameterItem {
     deleted: boolean;
@@ -48,6 +49,7 @@ export interface ParameterItem {
         MatButtonModule,
         MatDialogModule,
         MatTableModule,
+        MatSortModule,
         NgTemplateOutlet,
         CdkOverlayOrigin,
         CdkConnectedOverlay,
@@ -72,10 +74,16 @@ export class ParameterTable implements AfterViewInit, 
ControlValueAccessor {
 
     protected readonly TextTip = TextTip;
 
+    initialSortColumn = 'name';
+    initialSortDirection: 'asc' | 'desc' = 'asc';
+
     displayedColumns: string[] = ['name', 'value', 'actions'];
     dataSource: MatTableDataSource<ParameterItem> = new 
MatTableDataSource<ParameterItem>();
     selectedItem: ParameterItem | null = null;
-
+    activeSort: Sort = {
+        active: this.initialSortColumn,
+        direction: this.initialSortDirection
+    };
     isDisabled = false;
     isTouched = false;
     onTouched!: () => void;
@@ -132,11 +140,34 @@ export class ParameterTable implements AfterViewInit, 
ControlValueAccessor {
         this.setPropertyItems(propertyItems);
     }
 
+    sortData(sort: Sort) {
+        this.activeSort = sort;
+        this.dataSource.data = this.sortEntities(this.dataSource.data, sort);
+    }
+
     private setPropertyItems(parameterItems: ParameterItem[]): void {
-        this.dataSource = new 
MatTableDataSource<ParameterItem>(parameterItems);
+        this.dataSource.data = this.sortEntities(parameterItems, 
this.activeSort);
         this.initFilter();
     }
 
+    private sortEntities(parameters: ParameterItem[], sort: Sort): 
ParameterItem[] {
+        if (!parameters) {
+            return [];
+        }
+        return parameters.slice().sort((a, b) => {
+            const isAsc = sort.direction === 'asc';
+            let retVal = 0;
+            switch (sort.active) {
+                case 'name':
+                    retVal = 
this.nifiCommon.compareString(a.entity.parameter.name, b.entity.parameter.name);
+                    break;
+                default:
+                    return 0;
+            }
+            return retVal * (isAsc ? 1 : -1);
+        });
+    }
+
     newParameterClicked(): void {
         // get the existing parameters to provide to the new parameter dialog 
but
         // exclude any items that are currently marked for deletion which can 
be
@@ -310,7 +341,8 @@ export class ParameterTable implements AfterViewInit, 
ControlValueAccessor {
                             name: item.entity.parameter.name,
                             sensitive: item.entity.parameter.sensitive,
                             description: item.entity.parameter.description,
-                            value: item.entity.parameter.value
+                            value: item.entity.parameter.value,
+                            valueRemoved: item.entity.parameter.valueRemoved
                         }
                     };
                 }
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/ui/common/edit-parameter-dialog/edit-parameter-dialog.component.ts
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/ui/common/edit-parameter-dialog/edit-parameter-dialog.component.ts
index db6209dccf..9a82c2d5f5 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/ui/common/edit-parameter-dialog/edit-parameter-dialog.component.ts
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/ui/common/edit-parameter-dialog/edit-parameter-dialog.component.ts
@@ -110,11 +110,14 @@ export class EditParameterDialog {
 
         this.editParameterForm = this.formBuilder.group({
             name: this.name,
-            value: new FormControl(parameter ? parameter.value : ''),
+            value: new FormControl(parameter ? parameter.value : null),
             empty: new FormControl(parameter ? parameter.value == '' : false),
             sensitive: this.sensitive,
             description: new FormControl(parameter ? parameter.description : 
'')
         });
+
+        // ensure the value input is enabled/disabled according to the empty 
value check box state
+        this.setEmptyStringChanged();
     }
 
     private existingParameterValidator(existingParameters: string[]): 
ValidatorFn {
@@ -163,8 +166,8 @@ export class EditParameterDialog {
         this.editParameter.next({
             parameter: {
                 name: this.editParameterForm.get('name')?.value,
-                value,
-                valueRemoved: value == '' && !empty,
+                value: value === '' && !empty ? null : value,
+                valueRemoved: value === '' && !empty,
                 sensitive: this.editParameterForm.get('sensitive')?.value,
                 description: this.editParameterForm.get('description')?.value
             }

Reply via email to