diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.effects.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.effects.ts index f8b2757929af4..f0f2ea7696061 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.effects.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.effects.ts @@ -36,12 +36,13 @@ import { } from '../../../../state/shared'; import { Router } from '@angular/router'; import { - selectProcessGroupFlow, + selectChildProcessGroupOptions, selectCurrentProcessGroupId, selectParameterContext, selectSaving, selectStatus, - selectServices + selectServices, + selectBreadcrumb } from './controller-services.selectors'; import { ControllerServiceService } from '../../service/controller-service.service'; import { EnableControllerService } from '../../../../ui/common/controller-service/enable-controller-service/enable-controller-service.component'; @@ -52,7 +53,6 @@ import * as ErrorActions from '../../../../state/error/error.actions'; import { ErrorHelper } from '../../../../service/error-helper.service'; import { HttpErrorResponse } from '@angular/common/http'; import { ParameterHelperService } from '../../service/parameter-helper.service'; -import { ComponentType, LARGE_DIALOG, SMALL_DIALOG, XL_DIALOG } from 'libs/shared/src'; import { ExtensionTypesService } from '../../../../service/extension-types.service'; import { ChangeComponentVersionDialog } from '../../../../ui/common/change-component-version-dialog/change-component-version-dialog'; import { FlowService } from '../../service/flow.service'; @@ -66,7 +66,8 @@ import { } from '../../../../state/property-verification/property-verification.selectors'; import { VerifyPropertiesRequestContext } from '../../../../state/property-verification'; import { BackNavigation } from '../../../../state/navigation'; -import { NiFiCommon, Storage } from '@nifi/shared'; +import { NiFiCommon, Storage, SelectOption, ComponentType, LARGE_DIALOG, SMALL_DIALOG, XL_DIALOG } from '@nifi/shared'; +import { ComponentEntity } from './../flow/index'; @Injectable() export class ControllerServicesEffects { @@ -95,18 +96,28 @@ export class ControllerServicesEffects { this.controllerServiceService.getControllerServices(request.processGroupId), this.controllerServiceService.getFlow(request.processGroupId) ]).pipe( - map(([controllerServicesResponse, flowResponse]) => - ControllerServicesActions.loadControllerServicesSuccess({ + map(([controllerServicesResponse, flowResponse]) => { + const childProcessGroupOptions: SelectOption[] = []; + flowResponse.processGroupFlow.flow.processGroups.forEach((child: ComponentEntity) => { + if (child.permissions.canRead && child.permissions.canWrite) { + childProcessGroupOptions.push({ + text: child.component.name, + value: child.component.id + }); + } + }); + + return ControllerServicesActions.loadControllerServicesSuccess({ response: { processGroupId: flowResponse.processGroupFlow.id, controllerServices: controllerServicesResponse.controllerServices, loadedTimestamp: controllerServicesResponse.currentTime, breadcrumb: flowResponse.processGroupFlow.breadcrumb, parameterContext: flowResponse.processGroupFlow.parameterContext ?? null, - processGroupFlow: flowResponse.processGroupFlow + childProcessGroupOptions: childProcessGroupOptions } - }) - ), + }); + }), catchError((errorResponse: HttpErrorResponse) => of(this.errorHelper.handleLoadingError(status, errorResponse)) ) @@ -662,27 +673,31 @@ export class ControllerServicesEffects { map((action) => action.request), concatLatestFrom(() => [ this.store.select(selectCurrentProcessGroupId), - this.store.select(selectProcessGroupFlow), - this.store.select(selectServices) + this.store.select(selectChildProcessGroupOptions), + this.store.select(selectServices), + this.store.select(selectBreadcrumb) ]), - concatMap(([request, currentProcessGroupId, processGroupFlow, controllerServices]) => - combineLatest([this.flowService.getProcessGroupWithContent(currentProcessGroupId)]).pipe( - map(([processGroupEntity]) => { - return { - request, - currentProcessGroupId, - processGroupFlow, - processGroupEntity, - controllerServices - }; - }) - ) + concatMap( + ([request, currentProcessGroupId, childProcessGroupOptions, controllerServices, breadcrumb]) => + combineLatest([this.flowService.getProcessGroupWithContent(currentProcessGroupId)]).pipe( + map(([processGroupEntity]) => { + return { + request, + currentProcessGroupId, + childProcessGroupOptions, + processGroupEntity, + controllerServices, + breadcrumb + }; + }) + ) ), tap((request) => { const clone = Object.assign({}, request.request); clone.processGroupEntity = request.processGroupEntity; - clone.processGroupFlow = request.processGroupFlow; + 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, diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.reducer.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.reducer.ts index 2c8e80fde992a..46329e5aadcdf 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.reducer.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.reducer.ts @@ -35,6 +35,7 @@ import { ControllerServicesState } from './index'; export const initialState: ControllerServicesState = { processGroupId: 'root', + childProcessGroupOptions: [], controllerServices: [], breadcrumb: { id: '', @@ -70,7 +71,7 @@ export const controllerServicesReducer = createReducer( breadcrumb: response.breadcrumb, parameterContext: response.parameterContext, loadedTimestamp: response.loadedTimestamp, - processGroupFlow: response.processGroupFlow, + childProcessGroupOptions: response.childProcessGroupOptions, status: 'success' as const })), on(controllerServicesBannerApiError, (state) => ({ diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.selectors.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.selectors.ts index da66609a224c9..b7cad8339c4f2 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.selectors.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.selectors.ts @@ -41,9 +41,14 @@ export const selectCurrentProcessGroupId = createSelector( (state: ControllerServicesState) => state.processGroupId ); -export const selectProcessGroupFlow = createSelector( +export const selectChildProcessGroupOptions = createSelector( selectControllerServicesState, - (state: ControllerServicesState) => state.processGroupFlow + (state: ControllerServicesState) => state.childProcessGroupOptions +); + +export const selectBreadcrumb = createSelector( + selectControllerServicesState, + (state: ControllerServicesState) => state.breadcrumb ); export const selectParameterContext = createSelector( diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/index.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/index.ts index 90e27d795512b..5a1448a15b1bb 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/index.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/controller-services/index.ts @@ -15,8 +15,8 @@ * limitations under the License. */ +import { SelectOption } from '@nifi/shared'; import { ControllerServiceEntity, ParameterContextReferenceEntity } from '../../../../state/shared'; -import { ProcessGroupFlow } from '../flow'; import { BreadcrumbEntity } from '../shared'; import { Revision } from './../../../../state/shared/index'; @@ -32,7 +32,7 @@ export interface LoadControllerServicesResponse { controllerServices: ControllerServiceEntity[]; parameterContext: ParameterContextReferenceEntity | null; loadedTimestamp: string; - processGroupFlow: ProcessGroupFlow; + childProcessGroupOptions: SelectOption[]; } export interface CreateControllerServiceSuccess { @@ -57,9 +57,10 @@ export interface ConfigureControllerServiceSuccess { export interface MoveControllerServiceDialogRequest { id: string; controllerService: ControllerServiceEntity; - processGroupFlow?: ProcessGroupFlow; + childProcessGroupOptions: SelectOption[]; processGroupEntity?: any; parentControllerServices: ControllerServiceEntity[]; + breadcrumb?: BreadcrumbEntity; } export interface MoveControllerServiceRequest { @@ -91,7 +92,7 @@ export interface SelectControllerServiceRequest { export interface ControllerServicesState { processGroupId: string; - processGroupFlow?: ProcessGroupFlow; + childProcessGroupOptions: SelectOption[]; breadcrumb: BreadcrumbEntity; controllerServices: ControllerServiceEntity[]; parameterContext: ParameterContextReferenceEntity | null; diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/ui/controller-service/controller-services.component.html b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/ui/controller-service/controller-services.component.html index ae1f398bc7fea..511c2d4c1c49c 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/ui/controller-service/controller-services.component.html +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/ui/controller-service/controller-services.component.html @@ -44,7 +44,7 @@