Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NIFI-13641] - Remove parameter value from parameter context update request if there are referenced assets #9173

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down Expand Up @@ -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
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ export interface BulletinEntity {
};
}

export interface ReferencedAsset {
id: string;
name: string;
}

export interface ParameterEntity {
canWrite?: boolean;
parameter: Parameter;
Expand All @@ -327,6 +332,7 @@ export interface Parameter {
referencingComponents?: AffectedComponentEntity[];
parameterContext?: ParameterContextReferenceEntity;
inherited?: boolean;
referencedAssets?: ReferencedAsset[];
}

export interface ParameterContextEntity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -162,14 +165,20 @@ 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: {
name: this.editParameterForm.get('name')?.value,
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
}
});
}
Expand Down