diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/parameter-contexts/state/parameter-context-listing/parameter-context-listing.effects.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/parameter-contexts/state/parameter-context-listing/parameter-context-listing.effects.ts index f161e03056..6da70b863d 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/parameter-contexts/state/parameter-context-listing/parameter-context-listing.effects.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/parameter-contexts/state/parameter-context-listing/parameter-context-listing.effects.ts @@ -59,7 +59,7 @@ import { ErrorHelper } from '../../../../service/error-helper.service'; import { HttpErrorResponse } from '@angular/common/http'; import { isDefinedAndNotNull, MEDIUM_DIALOG, SMALL_DIALOG, XL_DIALOG } from 'libs/shared/src'; import { BackNavigation } from '../../../../state/navigation'; -import { Storage, NiFiCommon } from '@nifi/shared'; +import { NiFiCommon, Storage } from '@nifi/shared'; @Injectable() export class ParameterContextListingEffects { diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/edit-parameter-context/edit-parameter-context.component.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/edit-parameter-context/edit-parameter-context.component.ts index bd4726901f..328e35154f 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/edit-parameter-context/edit-parameter-context.component.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/edit-parameter-context/edit-parameter-context.component.ts @@ -167,6 +167,16 @@ export class EditParameterContext extends TabbedDialog { this.parameters = []; } + // The backend api doesn't support providing both a parameter value and referenced assets + // even though it returns both from the GET api. We must strip the value out if there are + // referenced assets. + const updatedParameters: ParameterEntity[] = this.parameters.slice(); + updatedParameters.forEach((parameter: ParameterEntity) => { + if ((parameter.parameter.referencedAssets || []).length > 0) { + parameter.parameter.value = null; + } + }); + const payload: any = { revision: this.client.getRevision(pc), disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(), @@ -175,7 +185,7 @@ export class EditParameterContext extends TabbedDialog { id: pc.id, name: this.editParameterContextForm.get('name')?.value, description: this.editParameterContextForm.get('description')?.value, - parameters: this.parameters, + parameters: updatedParameters, inheritedParameterContexts: this.editParameterContextForm.get('inheritedParameterContexts')?.value } }; diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.ts index bfa87009ae..70f10fbb30 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.ts @@ -309,6 +309,10 @@ export class ParameterTable implements AfterViewInit, ControlValueAccessor { item.entity.parameter.valueRemoved = parameter.valueRemoved; item.dirty = true; + if (valueChanged) { + item.entity.parameter.referencedAssets = undefined; + } + this.handleChanged(); } }); @@ -368,7 +372,8 @@ export class ParameterTable implements AfterViewInit, ControlValueAccessor { sensitive: item.entity.parameter.sensitive, description: item.entity.parameter.description, value: item.entity.parameter.value, - valueRemoved: item.entity.parameter.valueRemoved + valueRemoved: item.entity.parameter.valueRemoved, + referencedAssets: item.entity.parameter.referencedAssets } }; } diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/shared/index.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/shared/index.ts index 5deab78f2c..3c1fddbbc3 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/shared/index.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/shared/index.ts @@ -312,6 +312,11 @@ export interface BulletinEntity { }; } +export interface ReferencedAsset { + id: string; + name: string; +} + export interface ParameterEntity { canWrite?: boolean; parameter: Parameter; @@ -327,6 +332,7 @@ export interface Parameter { referencingComponents?: AffectedComponentEntity[]; parameterContext?: ParameterContextReferenceEntity; inherited?: boolean; + referencedAssets?: ReferencedAsset[]; } export interface ParameterContextEntity { diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/ui/common/edit-parameter-dialog/edit-parameter-dialog.component.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/ui/common/edit-parameter-dialog/edit-parameter-dialog.component.ts index 0128521448..171879375f 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/ui/common/edit-parameter-dialog/edit-parameter-dialog.component.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/ui/common/edit-parameter-dialog/edit-parameter-dialog.component.ts @@ -17,7 +17,7 @@ import { Component, EventEmitter, Inject, Input, Output } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog'; -import { EditParameterRequest, EditParameterResponse, Parameter } from '../../../state/shared'; +import { EditParameterRequest, EditParameterResponse, Parameter, ReferencedAsset } from '../../../state/shared'; import { MatButtonModule } from '@angular/material/button'; import { AbstractControl, @@ -68,6 +68,8 @@ export class EditParameterDialog extends CloseOnEscapeDialog { editParameterForm: FormGroup; isNew: boolean; + private originalParameter: Parameter | undefined = undefined; + constructor( @Inject(MAT_DIALOG_DATA) public request: EditParameterRequest, private formBuilder: FormBuilder @@ -77,6 +79,7 @@ export class EditParameterDialog extends CloseOnEscapeDialog { // seed the form for the new parameter. when existingParameters are not specified, this is the // existing parameter that populates the form const parameter: Parameter | undefined = request.parameter; + this.originalParameter = parameter; const validators: any[] = [Validators.required]; if (request.existingParameters) { @@ -162,6 +165,11 @@ export class EditParameterDialog extends CloseOnEscapeDialog { okClicked(): void { const value: string = this.editParameterForm.get('value')?.value; const empty: boolean = this.editParameterForm.get('empty')?.value; + let referencedAssets: ReferencedAsset[] | undefined = undefined; + + if (this.originalParameter) { + referencedAssets = this.originalParameter.referencedAssets; + } this.editParameter.next({ parameter: { @@ -169,7 +177,8 @@ export class EditParameterDialog extends CloseOnEscapeDialog { value: value === '' && !empty ? null : value, valueRemoved: value === '' && !empty, sensitive: this.editParameterForm.get('sensitive')?.value, - description: this.editParameterForm.get('description')?.value + description: this.editParameterForm.get('description')?.value, + referencedAssets } }); }