From 0c9ef91507e8c6b7b7f0994b1bb9897cd0701bbe Mon Sep 17 00:00:00 2001 From: Rob Fellows Date: Fri, 10 May 2024 16:50:23 -0400 Subject: [PATCH] NIFI-13127 Add branching support to Registry dialogs This closes #8817 Signed-off-by: David Handermann --- .../flow-designer/service/registry.service.ts | 33 ++- .../flow-designer/state/flow/flow.effects.ts | 59 +++- .../pages/flow-designer/state/flow/index.ts | 2 + .../change-version-dialog.html | 32 ++- .../change-version-dialog.scss | 6 +- .../import-from-registry.component.html | 265 ++++++++++-------- .../import-from-registry.component.scss | 6 +- .../import-from-registry.component.ts | 88 +++++- .../save-version-dialog.component.html | 20 ++ .../save-version-dialog.component.ts | 65 ++++- .../main/nifi/src/app/state/shared/index.ts | 11 + 11 files changed, 414 insertions(+), 173 deletions(-) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/registry.service.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/registry.service.ts index 971fb4b455..b18583d2ca 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/registry.service.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/registry.service.ts @@ -17,7 +17,7 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { HttpClient } from '@angular/common/http'; +import { HttpClient, HttpParams } from '@angular/common/http'; import { ImportFromRegistryRequest } from '../state/flow'; @Injectable({ providedIn: 'root' }) @@ -30,17 +30,36 @@ export class RegistryService { return this.httpClient.get(`${RegistryService.API}/flow/registries`); } - getBuckets(registryId: string): Observable { - return this.httpClient.get(`${RegistryService.API}/flow/registries/${registryId}/buckets`); + getBranches(registryId: string): Observable { + return this.httpClient.get(`${RegistryService.API}/flow/registries/${registryId}/branches`); } - getFlows(registryId: string, bucketId: string): Observable { - return this.httpClient.get(`${RegistryService.API}/flow/registries/${registryId}/buckets/${bucketId}/flows`); + getBuckets(registryId: string, branch?: string): Observable { + const params: HttpParams = new HttpParams(); + if (branch) { + params.set('branch', branch); + } + return this.httpClient.get(`${RegistryService.API}/flow/registries/${registryId}/buckets`, { params }); } - getFlowVersions(registryId: string, bucketId: string, flowId: string): Observable { + getFlows(registryId: string, bucketId: string, branch?: string): Observable { + const params: HttpParams = new HttpParams(); + if (branch) { + params.set('branch', branch); + } + return this.httpClient.get(`${RegistryService.API}/flow/registries/${registryId}/buckets/${bucketId}/flows`, { + params + }); + } + + getFlowVersions(registryId: string, bucketId: string, flowId: string, branch?: string): Observable { + const params: HttpParams = new HttpParams(); + if (branch) { + params.set('branch', branch); + } return this.httpClient.get( - `${RegistryService.API}/flow/registries/${registryId}/buckets/${bucketId}/flows/${flowId}/versions` + `${RegistryService.API}/flow/registries/${registryId}/buckets/${bucketId}/flows/${flowId}/versions`, + { params } ); } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts index 643e8bb5b9..5ef0b2d05b 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts @@ -86,6 +86,7 @@ import { MatDialog } from '@angular/material/dialog'; import { CreatePort } from '../../ui/canvas/items/port/create-port/create-port.component'; import { EditPort } from '../../ui/canvas/items/port/edit-port/edit-port.component'; import { + BranchEntity, BucketEntity, ComponentType, isDefinedAndNotNull, @@ -809,10 +810,29 @@ export class FlowEffects { data: request }); - dialogReference.componentInstance.getBuckets = ( + dialogReference.componentInstance.getBranches = ( registryId: string + ): Observable => { + return this.registryService.getBranches(registryId).pipe( + take(1), + map((response) => response.branches), + tap({ + error: (errorResponse: HttpErrorResponse) => { + this.store.dispatch( + FlowActions.flowBannerError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ); + } + }) + ); + }; + + dialogReference.componentInstance.getBuckets = ( + registryId: string, + branch?: string ): Observable => { - return this.registryService.getBuckets(registryId).pipe( + return this.registryService.getBuckets(registryId, branch).pipe( take(1), map((response) => response.buckets), tap({ @@ -829,9 +849,10 @@ export class FlowEffects { dialogReference.componentInstance.getFlows = ( registryId: string, - bucketId: string + bucketId: string, + branch?: string ): Observable => { - return this.registryService.getFlows(registryId, bucketId).pipe( + return this.registryService.getFlows(registryId, bucketId, branch).pipe( take(1), map((response) => response.versionedFlows), tap({ @@ -849,9 +870,10 @@ export class FlowEffects { dialogReference.componentInstance.getFlowVersions = ( registryId: string, bucketId: string, - flowId: string + flowId: string, + branch?: string ): Observable => { - return this.registryService.getFlowVersions(registryId, bucketId, flowId).pipe( + return this.registryService.getFlowVersions(registryId, bucketId, flowId, branch).pipe( take(1), map((response) => response.versionedFlowSnapshotMetadataSet), tap({ @@ -3192,8 +3214,29 @@ export class FlowEffects { data: request }); - dialogReference.componentInstance.getBuckets = (registryId: string): Observable => { - return this.registryService.getBuckets(registryId).pipe( + dialogReference.componentInstance.getBranches = ( + registryId: string + ): Observable => { + return this.registryService.getBranches(registryId).pipe( + take(1), + map((response) => response.branches), + tap({ + error: (errorResponse: HttpErrorResponse) => { + this.store.dispatch( + FlowActions.flowBannerError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ); + } + }) + ); + }; + + dialogReference.componentInstance.getBuckets = ( + registryId: string, + branch?: string + ): Observable => { + return this.registryService.getBuckets(registryId, branch).pipe( take(1), map((response) => response.buckets), tap({ diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/index.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/index.ts index c1729ddc0b..bff002bfa8 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/index.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/index.ts @@ -238,6 +238,7 @@ export interface SaveVersionRequest { flowDescription?: string; comments?: string; existingFlowId?: string; + branch?: string; } export interface VersionControlInformation { @@ -253,6 +254,7 @@ export interface VersionControlInformation { storageLocation?: string; state: string; stateExplanation: string; + branch?: string; } export interface VersionControlInformationEntity { diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/flow/change-version-dialog/change-version-dialog.html b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/flow/change-version-dialog/change-version-dialog.html index 2c91bbb379..05f5ae39eb 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/flow/change-version-dialog/change-version-dialog.html +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/flow/change-version-dialog/change-version-dialog.html @@ -15,7 +15,9 @@ ~ limitations under the License. --> -

Change Version

+

+ Change Version ({{ versionControlInformation.version }}) +

@@ -26,18 +28,20 @@
{{ versionControlInformation.registryName }}
-
Flow Name
-
{{ versionControlInformation.flowName }}
+
Bucket
+
{{ versionControlInformation.bucketName }}
-
Bucket
-
{{ versionControlInformation.bucketName }}
+ @if (versionControlInformation.branch) { +
Branch
+
{{ versionControlInformation.branch }}
+ }
-
Current Version
-
{{ versionControlInformation.version }}
+
Flow Name
+
{{ versionControlInformation.flowName }}
@@ -61,7 +65,11 @@ Version - {{ item.version }} + +
+ {{ item.version }} +
+
@@ -73,7 +81,13 @@ Comments - {{ item.comments }} + +
+ {{ item.comments }} +
+
diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/flow/change-version-dialog/change-version-dialog.scss b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/flow/change-version-dialog/change-version-dialog.scss index a4bf3bf04e..715a724c71 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/flow/change-version-dialog/change-version-dialog.scss +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/flow/change-version-dialog/change-version-dialog.scss @@ -22,14 +22,12 @@ .listing-table { table { - table-layout: unset; - .mat-column-version { - width: 75px; + width: 180px; } .mat-column-created { - width: 200px; + width: 180px; } } } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/flow/import-from-registry/import-from-registry.component.html b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/flow/import-from-registry/import-from-registry.component.html index c20b00b439..f25a4309a9 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/flow/import-from-registry/import-from-registry.component.html +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/flow/import-from-registry/import-from-registry.component.html @@ -19,138 +19,163 @@
- - Registry - - - - +
+ + Registry + + + + {{ option.text }} + + + {{ option.text }} + + + + + + @if (supportsBranching) { + + Branch + + + {{ option.text }} + + + @if (importFromRegistryForm.controls['branch'].hasError('required')) { + No branches available + } + + } + + + Bucket + + + + {{ option.text }} + + + {{ option.text }} + + + + No buckets available + + + Flow + + + + {{ option.text }} + + + {{ option.text }} + + + + No flows available + +
+ + Keep existing Parameter Contexts + {{ option.text }} - - - {{ option.text }} - - - - - - Bucket - - - - {{ option.text }} - - - {{ option.text }} - - - - No buckets available - - - Flow - - - - {{ option.text }} - - - {{ option.text }} - - - - No flows available - -
- - Keep existing Parameter Contexts - - -
-
-
Flow Description
-
- {{ selectedFlowDescription || 'No description provided' }} + tooltipInputData="When not selected, only directly associated Parameter Contexts will be copied, inherited Contexts with no direct assignment to a Process Group are ignored."> + +
+
+
Flow Description
+
+ {{ selectedFlowDescription || 'No description provided' }} +
+
-
-
-
- - - - - - +
+
+
Version - {{ item.version }} -
+ + + + + - - - - - + + + + + - - - - - + + + + + - - -
Version +
+ {{ item.version }} +
+
Created - {{ formatTimestamp(item) }} - Created + {{ formatTimestamp(item) }} + Comments - {{ item.comments }} - Comments +
+ {{ item.comments }} +
+
+ + + +