Skip to content

Commit

Permalink
NIFI-3785: Fixed recursion issue. Removed need to clone.
Browse files Browse the repository at this point in the history
  • Loading branch information
Freedom9339 committed Oct 8, 2024
1 parent bffcc16 commit 712413e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import {
import { VerifyPropertiesRequestContext } from '../../../../state/property-verification';
import { BackNavigation } from '../../../../state/navigation';
import { NiFiCommon, Storage, SelectOption, ComponentType, LARGE_DIALOG, SMALL_DIALOG, XL_DIALOG } from '@nifi/shared';
import { ComponentEntity } from './../flow/index';
import { ComponentEntity } from '../flow';

@Injectable()
export class ControllerServicesEffects {
Expand Down Expand Up @@ -693,16 +693,17 @@ export class ControllerServicesEffects {
)
),
tap((request) => {
const clone = Object.assign({}, request.request);
clone.processGroupEntity = request.processGroupEntity;
clone.childProcessGroupOptions = request.childProcessGroupOptions;
clone.parentControllerServices = request.controllerServices;
clone.breadcrumb = request.breadcrumb;
const serviceId: string = request.request.id;
const moveDialogReference = this.dialog.open(MoveControllerService, {
...LARGE_DIALOG,
data: clone,
id: serviceId
data: {
id: request.request.id,
controllerService: request.request.controllerService,
childProcessGroupOptions: request.childProcessGroupOptions,
processGroupEntity: request.processGroupEntity,
parentControllerServices: request.controllerServices,
breadcrumb: request.breadcrumb
},
id: request.request.id
});

moveDialogReference.componentInstance.goToReferencingComponent = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { SelectOption } from '@nifi/shared';
import { ControllerServiceEntity, ParameterContextReferenceEntity } from '../../../../state/shared';
import { BreadcrumbEntity } from '../shared';
import { Revision } from './../../../../state/shared/index';
import { Revision } from '../../../../state/shared';

export const controllerServicesFeatureKey = 'controllerServiceListing';

Expand Down Expand Up @@ -57,10 +57,15 @@ export interface ConfigureControllerServiceSuccess {
export interface MoveControllerServiceDialogRequest {
id: string;
controllerService: ControllerServiceEntity;
}

export interface MoveControllerServiceDialogRequestSuccess {
id: string;
controllerService: ControllerServiceEntity;
childProcessGroupOptions: SelectOption[];
processGroupEntity?: any;
processGroupEntity: any;
parentControllerServices: ControllerServiceEntity[];
breadcrumb?: BreadcrumbEntity;
breadcrumb: BreadcrumbEntity;
}

export interface MoveControllerServiceRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@ export class ControllerServices implements OnDestroy {
openMoveControllerServiceDialog({
request: {
id: entity.id,
controllerService: entity,
parentControllerServices: [],
childProcessGroupOptions: []
controllerService: entity
}
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { provideMockStore } from '@ngrx/store/testing';
import { initialState } from '../../../../state/contoller-service-state/controller-service-state.reducer';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { MoveControllerServiceDialogRequest } from '../../state/controller-services';
import { MoveControllerServiceDialogRequestSuccess } from '../../state/controller-services';
import { BreadcrumbEntity } from '../../state/shared';
import { ComponentType, SelectOption } from '@nifi/shared';

Expand Down Expand Up @@ -3430,7 +3430,7 @@ describe('MoveControllerService', () => {
}
};

const data: MoveControllerServiceDialogRequest = {
const data: MoveControllerServiceDialogRequestSuccess = {
id: '92db6ee4-018c-1000-1061-e3476c3f4e9f',
breadcrumb: breadrumb,
childProcessGroupOptions: chldren,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { Store } from '@ngrx/store';
import { CloseOnEscapeDialog } from '@nifi/shared';
import { moveControllerService } from '../../state/controller-services/controller-services.actions';
import { NiFiState } from 'apps/nifi/src/app/state';
import { MoveControllerServiceDialogRequest } from '../../state/controller-services';
import { MoveControllerServiceDialogRequestSuccess } from '../../state/controller-services';
import { NgIf } from '@angular/common';
import { BreadcrumbEntity } from '../../state/shared';

Expand Down Expand Up @@ -75,7 +75,7 @@ export class MoveControllerService extends CloseOnEscapeDialog {
moveControllerServiceForm: FormGroup;

constructor(
@Inject(MAT_DIALOG_DATA) public request: MoveControllerServiceDialogRequest,
@Inject(MAT_DIALOG_DATA) public request: MoveControllerServiceDialogRequestSuccess,
private store: Store<NiFiState>,
private formBuilder: FormBuilder
) {
Expand All @@ -93,9 +93,8 @@ export class MoveControllerService extends CloseOnEscapeDialog {
);

const processGroups: SelectOption[] = [];
if (request.breadcrumb != undefined) {
this.loadParentOption(request.breadcrumb, parentControllerServices, processGroups);
}
this.loadParentOption(request.breadcrumb, parentControllerServices, processGroups);

this.loadChildOptions(request.childProcessGroupOptions, request.processGroupEntity, processGroups);
this.controllerServiceActionProcessGroups = processGroups;

Expand Down Expand Up @@ -186,7 +185,9 @@ export class MoveControllerService extends CloseOnEscapeDialog {
return true;
} else {
for (const pg of processGroup.contents.processGroups) {
return this.processGroupContainsComponent(pg, groupId);
if (this.processGroupContainsComponent(pg, groupId)) {
return true;
}
}
return false;
}
Expand All @@ -195,13 +196,17 @@ export class MoveControllerService extends CloseOnEscapeDialog {
}

getProcessGroupById(root: any, processGroupId: string): any {
console.log('a');
if (root != undefined) {
if (root.id == processGroupId) {
return root;
} else {
if (root.contents != undefined) {
for (const pg of root.contents.processGroups) {
return this.getProcessGroupById(pg, processGroupId);
const result = this.getProcessGroupById(pg, processGroupId);
if (result != null) {
return result;
}
}
}
return null;
Expand Down

0 comments on commit 712413e

Please sign in to comment.