rfellows commented on code in PR #11997:
URL: https://github.com/apache/nifi/pull/11997#discussion_r4788289688
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas/connector-canvas.effects.ts:
##########
@@ -987,6 +1100,433 @@ export class ConnectorCanvasEffects {
dialogRef.componentInstance.saving$ = of(false);
}
+ /**
+ * Opens EditProcessor in editable mode after fetching the full processor
entity and its
+ * component history, so fields omitted from the canvas listing
(descriptors, properties)
+ * are populated. Mirrors the Flow Designer's processor dialog.
+ */
+ private openEditProcessorDialog(request: EditComponentDialogRequest): void
{
+ const processorId = request.entity.id;
+
+ combineLatest([
+ this.flowService.getProcessor(processorId),
+ this.propertyTableHelperService.getComponentHistory(processorId)
+ ])
+ .pipe(
+ take(1),
+ takeUntilDestroyed(this.destroyRef),
+ catchError((error: HttpErrorResponse) => {
+ this.store.dispatch(
+ ErrorActions.addBannerError({
+ errorContext: {
+ errors:
[this.errorHelper.getErrorString(error)],
+ context: ErrorContextKey.CONNECTOR_CANVAS
+ }
+ })
+ );
+ return EMPTY;
+ })
+ )
+ .subscribe(([freshEntity, history]) => {
+ this.openEditProcessorDialogWithFreshEntity({
+ ...request,
+ entity: freshEntity,
+ history: history.componentHistory
+ });
+ });
+ }
+
+ private openEditProcessorDialogWithFreshEntity(request:
EditComponentDialogRequest): void {
+ const processorId = request.entity.id;
+ // A repeated request that arrives after its fetch would reuse the
open dialog's id.
+ if (this.dialog.getDialogById(processorId)) {
+ return;
+ }
+ const processGroupId = this.currentProcessGroupId();
+
+ const dialogRef = this.dialog.open(EditProcessor, {
+ ...XL_DIALOG,
+ data: request,
+ id: processorId
+ });
+ this.closeOnTroubleshootingExit(dialogRef);
+
+ const instance = dialogRef.componentInstance;
+ instance.saving$ = this.store.select(selectSaving);
+
+ // Push store updates into the dialog only after a run-status change
from this dialog,
+ // and only for the server's acknowledgement of this client's request.
+ let runStatusChanged = false;
+
+ this.store
+ .select(selectProcessor(processorId))
+ .pipe(
+ takeUntil(dialogRef.afterClosed()),
+ filter(
+ (entity) => !!entity && runStatusChanged &&
entity.revision?.clientId === this.client.getClientId()
+ )
+ )
+ .subscribe((entity) => {
+ instance.processorUpdates = entity;
+ });
+
+ instance.createNewProperty =
this.propertyTableHelperService.createNewProperty(processorId,
this.flowService);
+
+ instance.createNewService =
this.propertyTableHelperService.createNewService(
+ processorId,
+ this.controllerServiceService,
+ this.flowService,
+ processGroupId,
+ (createdService) => {
+ this.store.dispatch(
+
ConnectorControllerServicesActions.inlineCreateConnectorControllerServiceSuccess({
+ response: { controllerService: createdService }
+ })
+ );
+ }
+ );
+
+ // `goToParameter` and `convertToParameter` stay unset: parameters
belong to the Connector.
+ this.wireGoToService(instance);
+
+ instance.verify
+ .pipe(takeUntil(dialogRef.afterClosed()))
+ .subscribe((verificationRequest: VerifyPropertiesRequestContext)
=> {
+ this.store.dispatch(VerificationActions.verifyProperties({
request: verificationRequest }));
+ });
+
+ instance.propertyVerificationResults$ =
this.store.select(selectPropertyVerificationResults);
+ instance.propertyVerificationStatus$ =
this.store.select(selectPropertyVerificationStatus);
+
+ bindConnectorParameterContext(this.store, dialogRef.afterClosed(),
(parameterContext, supportsParameters) => {
+ instance.parameterContext = parameterContext ?? undefined;
+ instance.supportsParameters = supportsParameters;
+ });
+
+
instance.editProcessor.pipe(takeUntil(dialogRef.afterClosed())).subscribe((updateRequest)
=> {
+ this.store.dispatch(
+ ConnectorCanvasActions.updateProcessor({
+ request: { ...updateRequest, errorContextKey:
ErrorContextKey.PROCESSOR }
+ })
+ );
+ });
+
+ instance.stopComponentRequest
+ .pipe(takeUntil(dialogRef.afterClosed()))
+ .subscribe((stopRequest: StopComponentRequest) => {
+ runStatusChanged = true;
+ this.store.dispatch(ConnectorCanvasActions.stopComponent({
request: stopRequest }));
+ });
+
+ instance.startComponentRequest
+ .pipe(takeUntil(dialogRef.afterClosed()))
+ .subscribe((startRequest: StartComponentRequest) => {
+ runStatusChanged = true;
+ this.store.dispatch(ConnectorCanvasActions.startComponent({
request: startRequest }));
+ });
+
+ instance.disableComponentRequest
+ .pipe(takeUntil(dialogRef.afterClosed()))
+ .subscribe((disableRequest: DisableComponentRequest) => {
+ runStatusChanged = true;
+ this.store.dispatch(ConnectorCanvasActions.disableComponent({
request: disableRequest }));
+ });
+
+ instance.enableComponentRequest
+ .pipe(takeUntil(dialogRef.afterClosed()))
+ .subscribe((enableRequest: EnableComponentRequest) => {
+ runStatusChanged = true;
+ this.store.dispatch(ConnectorCanvasActions.enableComponent({
request: enableRequest }));
+ });
+
+ dialogRef
+ .afterClosed()
+ .pipe(take(1))
+ .subscribe(() =>
this.store.dispatch(VerificationActions.resetPropertyVerificationState()));
+ }
+
+ /**
+ * Wires `goToService` for an editable processor dialog. Unsaved edits
cannot survive the
+ * navigation, so a dirty form asks for confirmation first.
+ */
+ private wireGoToService(instance: EditProcessor): void {
+ instance.goToService = (serviceId: string) => {
+ const reportError = (error: string) =>
+ this.store.dispatch(
+ ErrorActions.addBannerError({
+ errorContext: {
+ errors: [error],
+ context: this.resolveInlineErrorContext(
+ ErrorContextKey.PROCESSOR,
+
ConnectorCanvasEffects.CONFIGURATION_DIALOG_ERROR_HOSTS
+ )
+ }
+ })
+ );
+ const navigateToService = () => {
+ this.controllerServiceService
+ .getControllerService(serviceId)
+ .pipe(takeUntilDestroyed(this.destroyRef))
+ .subscribe({
+ next: (serviceEntity) => {
+ const processGroupId = serviceEntity.parentGroupId;
+ if (!processGroupId) {
+ reportError('Unable to determine the
Controller Service parent group.');
+ return;
+ }
+ this.store.dispatch(
+
ConnectorCanvasActions.navigateToControllerService({
+ processGroupId,
+ serviceId: serviceEntity.id
+ })
+ );
+ },
+ error: (error: HttpErrorResponse) =>
reportError(this.errorHelper.getErrorString(error))
+ });
+ };
+
+ if (instance.editProcessorForm?.dirty) {
+ const confirmRef = this.dialog.open(YesNoDialog, {
+ ...SMALL_DIALOG,
+ data: {
+ title: 'Processor Configuration',
+ message: 'Navigate to this Controller Service? Unsaved
changes will be lost.'
+ }
+ });
+ confirmRef.componentInstance.yes
+ .pipe(takeUntil(confirmRef.afterClosed()), take(1))
+ .subscribe(() => navigateToService());
+ } else {
+ navigateToService();
+ }
+ };
+ }
+
+ private openEditPortDialog(request: EditComponentDialogRequest): void {
+ const dialogRef = this.dialog.open(EditPort, {
+ ...MEDIUM_DIALOG,
+ data: request
+ });
+ this.closeOnTroubleshootingExit(dialogRef);
+
+ const instance = dialogRef.componentInstance;
+ instance.saving$ = this.store.select(selectSaving);
+
+
instance.editPort.pipe(takeUntil(dialogRef.afterClosed())).subscribe((updateRequest)
=> {
+ this.store.dispatch(
+ ConnectorCanvasActions.updatePort({
+ request: { ...updateRequest, errorContextKey:
ErrorContextKey.PORT }
+ })
+ );
+ });
+ }
+
+ private openEditRemoteProcessGroupDialog(request:
EditComponentDialogRequest): void {
+ const dialogRef = this.dialog.open(EditRemoteProcessGroup, {
+ ...LARGE_DIALOG,
+ data: request
+ });
+ this.closeOnTroubleshootingExit(dialogRef);
+
+ const instance = dialogRef.componentInstance;
+ instance.saving$ = this.store.select(selectSaving);
+
+
instance.editRemoteProcessGroup.pipe(takeUntil(dialogRef.afterClosed())).subscribe((payload)
=> {
+ this.store.dispatch(
+ ConnectorCanvasActions.updateRemoteProcessGroup({
+ request: {
+ id: request.entity.id,
+ type: request.type,
+ payload,
+ errorContextKey: ErrorContextKey.REMOTE_PROCESS_GROUP
+ }
+ })
+ );
+ });
+ }
+
+ /**
+ * Opens EditConnectionComponent in editable mode. The save goes through
+ * `saveEditedConnection` so a destination change reloads the endpoints
the connection
+ * left and joined, as in the Flow Designer.
+ */
+ private openEditConnectionDialog(request: EditComponentDialogRequest):
void {
+ const connection = request.entity as ConnectionEntity;
+ const previousDestination = connection.component?.destination;
+ const dialogRef = this.dialog.open(EditConnectionComponent, {
+ ...LARGE_DIALOG,
+ data: request as EditConnectionDialogRequest
+ });
+ this.closeOnTroubleshootingExit(dialogRef);
+
+ const instance = dialogRef.componentInstance;
+ instance.saving$ = this.store.select(selectSaving);
+ this.wireConnectionEndpointCallbacks(instance);
+
+ const afterClosed$ = dialogRef.afterClosed().pipe(take(1));
+
instance.editConnection.pipe(takeUntil(afterClosed$)).subscribe((updateRequest:
UpdateConnectionRequest) => {
+ this.store.dispatch(
+ ConnectorCanvasActions.saveEditedConnection({
+ request: { ...updateRequest, previousDestination }
+ })
+ );
+ });
+ this.actions$
+ .pipe(
+
ofType(ConnectorCanvasActions.updateConnectionDestinationSuccess),
+ filter(({ connectionId }) => connectionId === connection.id),
+ takeUntil(afterClosed$)
+ )
+ .subscribe(() => dialogRef.close());
+ }
+
+ /**
+ * Opens EditProcessGroup in editable mode. The parameter context section
is hidden
+ * because the Connector owns the group's parameter context.
+ */
+ private openEditProcessGroupDialog(request: EditComponentDialogRequest):
MatDialogRef<EditProcessGroup> {
+ const dialogRef = this.dialog.open(EditProcessGroup, {
+ ...LARGE_DIALOG,
+ data: request
+ });
+ this.closeOnTroubleshootingExit(dialogRef);
+
+ const instance = dialogRef.componentInstance;
+ instance.saving$ = this.store.select(selectSaving);
+ instance.supportsParameters = false;
+ instance.currentUser$ = this.store.select(selectCurrentUser);
+ instance.parameterContexts = [];
+
+
instance.editProcessGroup.pipe(takeUntil(dialogRef.afterClosed())).subscribe((payload)
=> {
+ this.store.dispatch(
+ ConnectorCanvasActions.updateProcessGroup({
+ request: {
+ id: request.entity.id,
+ type: request.type,
+ payload,
+ errorContextKey: ErrorContextKey.PROCESS_GROUP
+ }
+ })
+ );
+ });
+
+ return dialogRef;
+ }
+
+ private openEditLabelDialog(request: EditComponentDialogRequest): void {
+ const dialogRef = this.dialog.open(EditLabel, {
+ ...MEDIUM_DIALOG,
+ data: request
+ });
+ this.closeOnTroubleshootingExit(dialogRef);
+
+ const instance = dialogRef.componentInstance;
+ instance.saving$ = this.store.select(selectSaving);
+
+
instance.editLabel.pipe(takeUntil(dialogRef.afterClosed())).subscribe((updateRequest)
=> {
+ this.store.dispatch(
+ ConnectorCanvasActions.updateLabel({
+ request: { ...updateRequest, errorContextKey:
ErrorContextKey.LABEL }
+ })
+ );
+ });
+ }
+
+ /**
+ * Closes an editable dialog once the Connector leaves troubleshooting,
since the
+ * framework rejects modifications outside of it.
+ */
+ private closeOnTroubleshootingExit(dialogRef: MatDialogRef<unknown>): void
{
+ this.store
+ .select(selectConnectorCanvasEntity)
+ .pipe(
+ filter((connectorEntity) => connectorEntity !== null &&
!isConnectorInTroubleshooting(connectorEntity)),
+ take(1),
+ takeUntil(dialogRef.afterClosed())
+ )
+ .subscribe(() => dialogRef.close());
+ }
+
+ /**
+ * Forwards a single-component update from a configuration dialog. A
failure is routed to
+ * the submitting dialog's banner while that dialog is open, otherwise to
the canvas banner.
+ */
+ updateCanvasComponent$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(
+ ConnectorCanvasActions.updateProcessor,
+ ConnectorCanvasActions.updatePort,
+ ConnectorCanvasActions.updateRemoteProcessGroup,
+ ConnectorCanvasActions.updateProcessGroup,
+ ConnectorCanvasActions.updateLabel
+ ),
+ map((action) => action.request),
+ mergeMap((request: CanvasComponentUpdateRequest) =>
+
this.connectorEditService.updateComponent<ConnectorCanvasComponentEntity>(request).pipe(
+ map((component) =>
+ ConnectorCanvasActions.updateCanvasComponentSuccess({
+ componentId: request.id,
+ componentType: request.type,
+ component
+ })
+ ),
+ catchError((error: HttpErrorResponse) =>
+ of(
+
ConnectorCanvasActions.updateCanvasComponentFailure({
+ errorContext: {
+ errors:
[this.errorHelper.getErrorString(error)],
+ context: this.resolveInlineErrorContext(
+ request.errorContextKey ??
ErrorContextKey.CONNECTOR_CANVAS,
+
ConnectorCanvasEffects.CONFIGURATION_DIALOG_ERROR_HOSTS
+ )
+ }
+ })
+ )
+ )
+ )
+ )
+ )
+ );
+
+ /**
+ * Closes the configuration dialog after a successful update. A processor
update also
+ * reloads the processor's connections, whose validity may depend on it.
+ */
+ updateCanvasComponentSuccess$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(ConnectorCanvasActions.updateCanvasComponentSuccess),
+ tap(() => this.dialog.closeAll()),
+ filter(({ componentType }) => componentType ===
ComponentType.Processor),
+ map(({ componentId }) =>
ConnectorCanvasActions.loadConnectionsForComponent({ id: componentId }))
+ )
+ );
+
+ updateCanvasComponentFailure$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(ConnectorCanvasActions.updateCanvasComponentFailure),
+ map(({ errorContext }) => ErrorActions.addBannerError({
errorContext }))
+ )
+ );
+
+ /**
+ * An inline context is only used while a dialog that renders it is still
open. Otherwise the
+ * error goes to the canvas banner, so it cannot surface later in an
unrelated dialog that
+ * renders the same context.
+ */
+ private resolveInlineErrorContext(
Review Comment:
`resolveInlineErrorContext` keeps configure failures out of a closed
dialog's banner, but the create paths still post straight to the dialog
context: `submitCreateConnection$` (around line 1698, `CONNECTION`),
`createCanvasComponent$` (around line 2918, `PORT` / `PROCESS_GROUP`) and
`uploadProcessGroup$` (around line 3080, `PROCESS_GROUP`). If the create dialog
is closed before the request fails, the error stays in that context and appears
the next time a dialog renders it. With this PR, that's now likely to be Edit
Port, Edit Process Group or Edit Connection. Could the create paths use the
same check, with a create-dialog host map next to
`CONFIGURATION_DIALOG_ERROR_HOSTS`? A follow-up JIRA is fine if you'd prefer to
keep this PR focused.
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas/connector-canvas.effects.ts:
##########
@@ -632,23 +697,80 @@ export class ConnectorCanvasEffects {
case ComponentType.OutputPort:
this.openReadOnlyPortDialog(dialogRequest);
break;
- case ComponentType.Label:
- this.openReadOnlyLabelDialog(dialogRequest);
- break;
case ComponentType.ProcessGroup:
this.openReadOnlyProcessGroupDialog(dialogRequest);
break;
case ComponentType.RemoteProcessGroup:
this.openReadOnlyRemoteProcessGroupDialog(dialogRequest);
break;
default:
+ // Label has no read-only viewer; the menu item
+ // is only surfaced while the Label is
configurable.
break;
}
})
),
{ dispatch: false }
);
+ /**
+ * Fetches the process group currently displayed on the canvas and opens
it in the
+ * EditProcessGroup dialog, editable when the group is configurable and
read-only otherwise.
+ * After an editable dialog closes the current group is reloaded so the
canvas reflects any
+ * accepted change. Triggered from the canvas-background Configure / View
Configuration item.
+ */
+ viewCurrentProcessGroupConfig$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(ConnectorCanvasActions.viewCurrentProcessGroupConfig),
+ concatLatestFrom(() => [
+ this.store.select(selectConnectorCanvasEntity),
+ this.store.select(selectConnectorId)
+ ]),
+ filter(([, , connectorId]) => connectorId !== ''),
+ switchMap(([action, connectorEntity, connectorId]) =>
+ this.connectorService.getProcessGroup(connectorId,
action.processGroupId).pipe(
+ tap((entity) => {
+ if
(isCurrentProcessGroupConfigurable(entity.permissions, connectorEntity)) {
+ const dialogRef =
this.openEditProcessGroupDialog({
+ type: ComponentType.ProcessGroup,
+ uri: entity.uri,
+ entity
+ });
+ dialogRef
+ .afterClosed()
+ .pipe(take(1))
Review Comment:
Nit: this reloads the flow on any close, including Cancel. Successful saves
already update the store, so is the reload still needed here? If it is, could
it run only after a save?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas/index.ts:
##########
@@ -91,6 +92,18 @@ export const REFRESHING_REMOTE_PROCESS_GROUP =
'Refreshing...';
/** Polls a Remote Process Group refresh session makes before giving up on the
remote. */
export const MAX_REMOTE_PROCESS_GROUP_REFRESH_POLLS = 20;
+/**
+ * A single-component update dispatched from a canvas dialog.
`errorContextKey` names the banner
+ * of the dialog that submitted it; the failure is shown there while that
dialog is open,
+ * otherwise on the canvas banner.
+ */
+export interface CanvasComponentUpdateRequest {
Review Comment:
Nit: this repeats `ConnectorComponentUpdateRequest` from
`connector-edit.service.ts`. Could it be `ConnectorComponentUpdateRequest & {
errorContextKey?: ErrorContextKey }`?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas/connector-canvas.effects.ts:
##########
@@ -987,6 +1100,433 @@ export class ConnectorCanvasEffects {
dialogRef.componentInstance.saving$ = of(false);
}
+ /**
+ * Opens EditProcessor in editable mode after fetching the full processor
entity and its
+ * component history, so fields omitted from the canvas listing
(descriptors, properties)
+ * are populated. Mirrors the Flow Designer's processor dialog.
+ */
+ private openEditProcessorDialog(request: EditComponentDialogRequest): void
{
+ const processorId = request.entity.id;
+
+ combineLatest([
+ this.flowService.getProcessor(processorId),
+ this.propertyTableHelperService.getComponentHistory(processorId)
+ ])
+ .pipe(
+ take(1),
+ takeUntilDestroyed(this.destroyRef),
+ catchError((error: HttpErrorResponse) => {
+ this.store.dispatch(
+ ErrorActions.addBannerError({
+ errorContext: {
+ errors:
[this.errorHelper.getErrorString(error)],
+ context: ErrorContextKey.CONNECTOR_CANVAS
+ }
+ })
+ );
+ return EMPTY;
+ })
+ )
+ .subscribe(([freshEntity, history]) => {
+ this.openEditProcessorDialogWithFreshEntity({
+ ...request,
+ entity: freshEntity,
+ history: history.componentHistory
+ });
+ });
+ }
+
+ private openEditProcessorDialogWithFreshEntity(request:
EditComponentDialogRequest): void {
+ const processorId = request.entity.id;
+ // A repeated request that arrives after its fetch would reuse the
open dialog's id.
+ if (this.dialog.getDialogById(processorId)) {
+ return;
+ }
+ const processGroupId = this.currentProcessGroupId();
+
+ const dialogRef = this.dialog.open(EditProcessor, {
+ ...XL_DIALOG,
+ data: request,
+ id: processorId
+ });
+ this.closeOnTroubleshootingExit(dialogRef);
+
+ const instance = dialogRef.componentInstance;
+ instance.saving$ = this.store.select(selectSaving);
+
+ // Push store updates into the dialog only after a run-status change
from this dialog,
+ // and only for the server's acknowledgement of this client's request.
+ let runStatusChanged = false;
+
+ this.store
+ .select(selectProcessor(processorId))
+ .pipe(
+ takeUntil(dialogRef.afterClosed()),
+ filter(
+ (entity) => !!entity && runStatusChanged &&
entity.revision?.clientId === this.client.getClientId()
+ )
+ )
+ .subscribe((entity) => {
+ instance.processorUpdates = entity;
+ });
+
+ instance.createNewProperty =
this.propertyTableHelperService.createNewProperty(processorId,
this.flowService);
+
+ instance.createNewService =
this.propertyTableHelperService.createNewService(
+ processorId,
+ this.controllerServiceService,
+ this.flowService,
+ processGroupId,
+ (createdService) => {
+ this.store.dispatch(
+
ConnectorControllerServicesActions.inlineCreateConnectorControllerServiceSuccess({
+ response: { controllerService: createdService }
+ })
+ );
+ }
+ );
+
+ // `goToParameter` and `convertToParameter` stay unset: parameters
belong to the Connector.
+ this.wireGoToService(instance);
+
+ instance.verify
+ .pipe(takeUntil(dialogRef.afterClosed()))
+ .subscribe((verificationRequest: VerifyPropertiesRequestContext)
=> {
+ this.store.dispatch(VerificationActions.verifyProperties({
request: verificationRequest }));
+ });
+
+ instance.propertyVerificationResults$ =
this.store.select(selectPropertyVerificationResults);
+ instance.propertyVerificationStatus$ =
this.store.select(selectPropertyVerificationStatus);
+
+ bindConnectorParameterContext(this.store, dialogRef.afterClosed(),
(parameterContext, supportsParameters) => {
+ instance.parameterContext = parameterContext ?? undefined;
+ instance.supportsParameters = supportsParameters;
+ });
+
+
instance.editProcessor.pipe(takeUntil(dialogRef.afterClosed())).subscribe((updateRequest)
=> {
+ this.store.dispatch(
+ ConnectorCanvasActions.updateProcessor({
+ request: { ...updateRequest, errorContextKey:
ErrorContextKey.PROCESSOR }
+ })
+ );
+ });
+
+ instance.stopComponentRequest
+ .pipe(takeUntil(dialogRef.afterClosed()))
+ .subscribe((stopRequest: StopComponentRequest) => {
+ runStatusChanged = true;
+ this.store.dispatch(ConnectorCanvasActions.stopComponent({
request: stopRequest }));
+ });
+
+ instance.startComponentRequest
+ .pipe(takeUntil(dialogRef.afterClosed()))
+ .subscribe((startRequest: StartComponentRequest) => {
+ runStatusChanged = true;
+ this.store.dispatch(ConnectorCanvasActions.startComponent({
request: startRequest }));
+ });
+
+ instance.disableComponentRequest
+ .pipe(takeUntil(dialogRef.afterClosed()))
+ .subscribe((disableRequest: DisableComponentRequest) => {
+ runStatusChanged = true;
+ this.store.dispatch(ConnectorCanvasActions.disableComponent({
request: disableRequest }));
+ });
+
+ instance.enableComponentRequest
+ .pipe(takeUntil(dialogRef.afterClosed()))
+ .subscribe((enableRequest: EnableComponentRequest) => {
+ runStatusChanged = true;
+ this.store.dispatch(ConnectorCanvasActions.enableComponent({
request: enableRequest }));
+ });
+
+ dialogRef
+ .afterClosed()
+ .pipe(take(1))
+ .subscribe(() =>
this.store.dispatch(VerificationActions.resetPropertyVerificationState()));
+ }
+
+ /**
+ * Wires `goToService` for an editable processor dialog. Unsaved edits
cannot survive the
+ * navigation, so a dirty form asks for confirmation first.
+ */
+ private wireGoToService(instance: EditProcessor): void {
+ instance.goToService = (serviceId: string) => {
+ const reportError = (error: string) =>
+ this.store.dispatch(
+ ErrorActions.addBannerError({
+ errorContext: {
+ errors: [error],
+ context: this.resolveInlineErrorContext(
+ ErrorContextKey.PROCESSOR,
+
ConnectorCanvasEffects.CONFIGURATION_DIALOG_ERROR_HOSTS
+ )
+ }
+ })
+ );
+ const navigateToService = () => {
+ this.controllerServiceService
+ .getControllerService(serviceId)
+ .pipe(takeUntilDestroyed(this.destroyRef))
+ .subscribe({
+ next: (serviceEntity) => {
+ const processGroupId = serviceEntity.parentGroupId;
+ if (!processGroupId) {
+ reportError('Unable to determine the
Controller Service parent group.');
+ return;
+ }
+ this.store.dispatch(
+
ConnectorCanvasActions.navigateToControllerService({
+ processGroupId,
+ serviceId: serviceEntity.id
+ })
+ );
+ },
+ error: (error: HttpErrorResponse) =>
reportError(this.errorHelper.getErrorString(error))
+ });
+ };
+
+ if (instance.editProcessorForm?.dirty) {
+ const confirmRef = this.dialog.open(YesNoDialog, {
+ ...SMALL_DIALOG,
+ data: {
+ title: 'Processor Configuration',
+ message: 'Navigate to this Controller Service? Unsaved
changes will be lost.'
+ }
+ });
+ confirmRef.componentInstance.yes
+ .pipe(takeUntil(confirmRef.afterClosed()), take(1))
+ .subscribe(() => navigateToService());
+ } else {
+ navigateToService();
+ }
+ };
+ }
+
+ private openEditPortDialog(request: EditComponentDialogRequest): void {
+ const dialogRef = this.dialog.open(EditPort, {
+ ...MEDIUM_DIALOG,
+ data: request
+ });
+ this.closeOnTroubleshootingExit(dialogRef);
+
+ const instance = dialogRef.componentInstance;
+ instance.saving$ = this.store.select(selectSaving);
+
+
instance.editPort.pipe(takeUntil(dialogRef.afterClosed())).subscribe((updateRequest)
=> {
+ this.store.dispatch(
+ ConnectorCanvasActions.updatePort({
+ request: { ...updateRequest, errorContextKey:
ErrorContextKey.PORT }
+ })
+ );
+ });
+ }
+
+ private openEditRemoteProcessGroupDialog(request:
EditComponentDialogRequest): void {
+ const dialogRef = this.dialog.open(EditRemoteProcessGroup, {
+ ...LARGE_DIALOG,
+ data: request
+ });
+ this.closeOnTroubleshootingExit(dialogRef);
+
+ const instance = dialogRef.componentInstance;
+ instance.saving$ = this.store.select(selectSaving);
+
+
instance.editRemoteProcessGroup.pipe(takeUntil(dialogRef.afterClosed())).subscribe((payload)
=> {
+ this.store.dispatch(
+ ConnectorCanvasActions.updateRemoteProcessGroup({
+ request: {
+ id: request.entity.id,
+ type: request.type,
+ payload,
+ errorContextKey: ErrorContextKey.REMOTE_PROCESS_GROUP
+ }
+ })
+ );
+ });
+ }
+
+ /**
+ * Opens EditConnectionComponent in editable mode. The save goes through
+ * `saveEditedConnection` so a destination change reloads the endpoints
the connection
+ * left and joined, as in the Flow Designer.
+ */
+ private openEditConnectionDialog(request: EditComponentDialogRequest):
void {
+ const connection = request.entity as ConnectionEntity;
+ const previousDestination = connection.component?.destination;
+ const dialogRef = this.dialog.open(EditConnectionComponent, {
+ ...LARGE_DIALOG,
+ data: request as EditConnectionDialogRequest
+ });
+ this.closeOnTroubleshootingExit(dialogRef);
+
+ const instance = dialogRef.componentInstance;
+ instance.saving$ = this.store.select(selectSaving);
+ this.wireConnectionEndpointCallbacks(instance);
+
+ const afterClosed$ = dialogRef.afterClosed().pipe(take(1));
+
instance.editConnection.pipe(takeUntil(afterClosed$)).subscribe((updateRequest:
UpdateConnectionRequest) => {
+ this.store.dispatch(
+ ConnectorCanvasActions.saveEditedConnection({
+ request: { ...updateRequest, previousDestination }
+ })
+ );
+ });
+ this.actions$
+ .pipe(
+
ofType(ConnectorCanvasActions.updateConnectionDestinationSuccess),
+ filter(({ connectionId }) => connectionId === connection.id),
+ takeUntil(afterClosed$)
+ )
+ .subscribe(() => dialogRef.close());
+ }
+
+ /**
+ * Opens EditProcessGroup in editable mode. The parameter context section
is hidden
+ * because the Connector owns the group's parameter context.
+ */
+ private openEditProcessGroupDialog(request: EditComponentDialogRequest):
MatDialogRef<EditProcessGroup> {
+ const dialogRef = this.dialog.open(EditProcessGroup, {
+ ...LARGE_DIALOG,
+ data: request
+ });
+ this.closeOnTroubleshootingExit(dialogRef);
+
+ const instance = dialogRef.componentInstance;
+ instance.saving$ = this.store.select(selectSaving);
+ instance.supportsParameters = false;
+ instance.currentUser$ = this.store.select(selectCurrentUser);
+ instance.parameterContexts = [];
+
+
instance.editProcessGroup.pipe(takeUntil(dialogRef.afterClosed())).subscribe((payload)
=> {
+ this.store.dispatch(
+ ConnectorCanvasActions.updateProcessGroup({
+ request: {
+ id: request.entity.id,
+ type: request.type,
+ payload,
+ errorContextKey: ErrorContextKey.PROCESS_GROUP
+ }
+ })
+ );
+ });
+
+ return dialogRef;
+ }
+
+ private openEditLabelDialog(request: EditComponentDialogRequest): void {
+ const dialogRef = this.dialog.open(EditLabel, {
+ ...MEDIUM_DIALOG,
+ data: request
+ });
+ this.closeOnTroubleshootingExit(dialogRef);
+
+ const instance = dialogRef.componentInstance;
+ instance.saving$ = this.store.select(selectSaving);
+
+
instance.editLabel.pipe(takeUntil(dialogRef.afterClosed())).subscribe((updateRequest)
=> {
+ this.store.dispatch(
+ ConnectorCanvasActions.updateLabel({
+ request: { ...updateRequest, errorContextKey:
ErrorContextKey.LABEL }
+ })
+ );
+ });
+ }
+
+ /**
+ * Closes an editable dialog once the Connector leaves troubleshooting,
since the
+ * framework rejects modifications outside of it.
+ */
+ private closeOnTroubleshootingExit(dialogRef: MatDialogRef<unknown>): void
{
Review Comment:
Two small things:
1. When this fires, unsaved edits are discarded without explanation. A short
canvas banner ("Troubleshooting ended; changes were not saved") would make that
clearer.
2. It covers the six configure dialogs, but the reconnect dialog, the create
dialogs and the editable controller service dialog stay open after
troubleshooting ends. Was that intentional?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas/connector-canvas.effects.ts:
##########
@@ -609,16 +638,52 @@ export class ConnectorCanvasEffects {
);
/**
- * Open a read-only configuration dialog for the given canvas component.
- * Forces read-only mode by overriding canWrite regardless of entity
permissions
- * since the connector canvas is a view-only interface.
+ * Open a configuration dialog for the given canvas component. The dialog
is editable when
+ * the component is configurable (see `isComponentConfigurable`);
otherwise it is forced
+ * read-only.
*/
viewComponentConfiguration$ = createEffect(
() =>
this.actions$.pipe(
ofType(ConnectorCanvasActions.viewComponentConfiguration),
map((action) => action.request),
- tap(({ entity, componentType }) => {
+ concatLatestFrom(() => [
+ this.store.select(selectConnectorCanvasEntity),
+ this.store.select(selectProcessGroupId),
+ this.store.select(selectCanvasRunnables)
+ ]),
+ tap(([{ entity, componentType }, connectorEntity,
processGroupId, runnables]) => {
+ if (isComponentConfigurable(entity, componentType,
connectorEntity, processGroupId, runnables)) {
Review Comment:
For a running processor the user can write, `isComponentConfigurable` is
false, so this falls through to `openReadOnlyProcessorDialog` via
`withReadonlyPermissions`, which also sets `operatePermissions.canWrite` to
false. `EditProcessor.canOperate()` then hides Stop, so the user has to close
the dialog, stop the processor from the context menu, and reopen it. In the
Flow Designer the same dialog opens with real permissions: `EditProcessor`
makes itself read-only while running (`runnableSupportsModification`) but still
offers Stop, and the form unlocks once it stops. Would it make sense, while
troubleshooting, to open the editable processor dialog whenever the user can
write it, and keep `isComponentConfigurable` for the Configure / View
Configuration menu label? Mainly asking whether this was intentional.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]