This is an automated email from the ASF dual-hosted git repository.
rfellows pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new ea55a47c69d NIFI-15820: Adding an expandable side panel with a
Connector info car… (#11160)
ea55a47c69d is described below
commit ea55a47c69d05d8c8974d6c874b9690f903af067
Author: Matt Gilman <[email protected]>
AuthorDate: Thu Apr 23 08:38:33 2026 -0400
NIFI-15820: Adding an expandable side panel with a Connector info car…
(#11160)
* NIFI-15820: Adding an expandable side panel with a Connector info card to
the Connector canvas.
* NIFI-15820: Addressing review feedback.
This closes #11160
---
.../connector-canvas-entity.actions.ts | 56 ++
.../connector-canvas-entity.effects.spec.ts | 266 ++++++++-
.../connector-canvas-entity.effects.ts | 153 +++++-
.../connector-canvas-entity.reducer.spec.ts | 163 ++++++
.../connector-canvas-entity.reducer.ts | 34 ++
.../connectors-listing.effects.ts | 2 +-
.../_connector-canvas.component-theme.scss} | 28 +-
.../connector-canvas.component.html | 80 +--
.../connector-canvas.component.spec.ts | 128 ++++-
.../connector-canvas/connector-canvas.component.ts | 54 +-
.../connector-graph-controls.component.html | 26 +
.../connector-graph-controls.component.scss} | 19 -
.../connector-graph-controls.component.spec.ts | 67 +++
.../connector-graph-controls.component.ts} | 29 +-
.../connector-info-control.component.html | 110 ++++
.../connector-info-control.component.scss} | 19 -
.../connector-info-control.component.spec.ts | 601 +++++++++++++++++++++
.../connector-info-control.component.ts | 229 ++++++++
.../apps/nifi/src/app/state/error/index.ts | 1 +
.../src/main/frontend/apps/nifi/src/styles.scss | 3 +
.../connector-detail-header.component.html | 55 ++
.../connector-detail-header.component.scss} | 23 +-
.../connector-detail-header.component.spec.ts | 313 +++++++++++
.../connector-detail-header.component.ts | 86 +++
.../frontend/libs/shared/src/components/index.ts | 1 +
25 files changed, 2392 insertions(+), 154 deletions(-)
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
index 7a083b21f75..796b525005f 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
@@ -32,4 +32,60 @@ export const loadConnectorEntityFailure = createAction(
props<{ error: string }>()
);
+/**
+ * Prompt user to confirm draining FlowFiles.
+ */
+export const promptDrainConnector = createAction(
+ `${PREFIX} Prompt Drain Connector`,
+ props<{ connector: ConnectorEntity }>()
+);
+
+/**
+ * Initiate draining of FlowFiles for a connector.
+ */
+export const drainConnector = createAction(`${PREFIX} Drain Connector`,
props<{ connector: ConnectorEntity }>());
+
+export const drainConnectorSuccess = createAction(
+ `${PREFIX} Drain Connector Success`,
+ props<{ connector: ConnectorEntity }>()
+);
+
+/**
+ * Cancel an ongoing drain operation (no confirmation needed).
+ */
+export const cancelConnectorDrain = createAction(
+ `${PREFIX} Cancel Connector Drain`,
+ props<{ connector: ConnectorEntity }>()
+);
+
+export const cancelConnectorDrainSuccess = createAction(
+ `${PREFIX} Cancel Connector Drain Success`,
+ props<{ connector: ConnectorEntity }>()
+);
+
+/**
+ * Start a connector (transition to RUNNING).
+ */
+export const startConnector = createAction(`${PREFIX} Start Connector`,
props<{ connector: ConnectorEntity }>());
+
+export const startConnectorSuccess = createAction(
+ `${PREFIX} Start Connector Success`,
+ props<{ connector: ConnectorEntity }>()
+);
+
+/**
+ * Stop a connector (transition to STOPPED).
+ */
+export const stopConnector = createAction(`${PREFIX} Stop Connector`, props<{
connector: ConnectorEntity }>());
+
+export const stopConnectorSuccess = createAction(
+ `${PREFIX} Stop Connector Success`,
+ props<{ connector: ConnectorEntity }>()
+);
+
+/**
+ * API error during any connector action (drain, cancel drain, start, stop).
+ */
+export const connectorActionApiError = createAction(`${PREFIX} Connector
Action Api Error`, props<{ error: string }>());
+
export const resetConnectorCanvasEntityState = createAction(`${PREFIX} Reset
State`);
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.effects.spec.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.effects.spec.ts
index b7b1ab4c361..e3c0d097d2a 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.effects.spec.ts
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.effects.spec.ts
@@ -19,17 +19,32 @@ import { TestBed } from '@angular/core/testing';
import { provideMockActions } from '@ngrx/effects/testing';
import { Action } from '@ngrx/store';
import { provideMockStore } from '@ngrx/store/testing';
-import { firstValueFrom, of, ReplaySubject, throwError } from 'rxjs';
+import { firstValueFrom, Observable, of, ReplaySubject, Subject, throwError }
from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
+import { MatDialog } from '@angular/material/dialog';
+import { YesNoDialog } from '@nifi/shared';
import { ConnectorCanvasEntityEffects } from
'./connector-canvas-entity.effects';
import { ConnectorService } from '../../service/connector.service';
import { ErrorHelper } from '../../../../service/error-helper.service';
import * as ConnectorCanvasActions from
'../connector-canvas/connector-canvas.actions';
+import * as ErrorActions from '../../../../state/error/error.actions';
+import { ErrorContextKey } from '../../../../state/error';
import { selectConnectorCanvasEntity } from
'./connector-canvas-entity.selectors';
+import { selectConnectorIdFromRoute } from
'../connector-canvas/connector-canvas.selectors';
import {
+ cancelConnectorDrain,
+ cancelConnectorDrainSuccess,
+ connectorActionApiError,
+ drainConnector,
+ drainConnectorSuccess,
loadConnectorEntity,
loadConnectorEntityFailure,
- loadConnectorEntitySuccess
+ loadConnectorEntitySuccess,
+ promptDrainConnector,
+ startConnector,
+ startConnectorSuccess,
+ stopConnector,
+ stopConnectorSuccess
} from './connector-canvas-entity.actions';
import { ConnectorEntity } from '@nifi/shared';
import type { Mock } from 'vitest';
@@ -59,19 +74,32 @@ describe('ConnectorCanvasEntityEffects', () => {
interface SetupOptions {
existingConnectorEntity?: ConnectorEntity | null;
+ connectorIdFromRoute?: string | null;
+ }
+
+ function createMockDialogRef(data: Record<string, Observable<unknown> |
Subject<unknown>> = {}) {
+ return { componentInstance: data, afterClosed: () => new
Subject<void>() };
}
async function setup(options: SetupOptions = {}) {
const actions$ = new ReplaySubject<Action>(1);
const mockConnectorService = {
- getConnector:
vi.fn().mockReturnValue(of(createMockConnectorEntity()))
+ getConnector:
vi.fn().mockReturnValue(of(createMockConnectorEntity())),
+ drainConnector: vi.fn(),
+ cancelConnectorDrain: vi.fn(),
+ updateConnectorRunStatus: vi.fn()
};
const mockErrorHelper = {
getErrorString: vi.fn().mockReturnValue('Error message')
};
+ const mockDialog = {
+ open: vi.fn(),
+ closeAll: vi.fn()
+ };
+
await TestBed.configureTestingModule({
providers: [
ConnectorCanvasEntityEffects,
@@ -81,11 +109,16 @@ describe('ConnectorCanvasEntityEffects', () => {
{
selector: selectConnectorCanvasEntity,
value: options.existingConnectorEntity ?? null
+ },
+ {
+ selector: selectConnectorIdFromRoute,
+ value: options.connectorIdFromRoute ?? null
}
]
}),
{ provide: ConnectorService, useValue: mockConnectorService },
- { provide: ErrorHelper, useValue: mockErrorHelper }
+ { provide: ErrorHelper, useValue: mockErrorHelper },
+ { provide: MatDialog, useValue: mockDialog }
]
}).compileComponents();
@@ -95,7 +128,8 @@ describe('ConnectorCanvasEntityEffects', () => {
effects,
actions$,
mockConnectorService,
- mockErrorHelper
+ mockErrorHelper,
+ mockDialog
};
}
@@ -184,4 +218,226 @@ describe('ConnectorCanvasEntityEffects', () => {
expect(mockErrorHelper.getErrorString).toHaveBeenCalledWith(errorResponse);
});
});
+
+ describe('promptDrainConnector$', () => {
+ it('should open a confirmation dialog and dispatch drainConnector on
confirmation', () =>
+ new Promise<void>((resolve) => {
+ setup().then(({ effects, actions$, mockDialog }) => {
+ const mockDialogRef = createMockDialogRef({ yes: of(true)
});
+ mockDialog.open.mockReturnValue(mockDialogRef);
+ const store = (effects as unknown as { store: { dispatch:
(a: Action) => void } }).store;
+ const dispatchSpy = vi.spyOn(store, 'dispatch');
+
+ const entity = createMockConnectorEntity();
+ actions$.next(promptDrainConnector({ connector: entity }));
+
+ effects.promptDrainConnector$.subscribe(() => {
+ expect(mockDialog.open).toHaveBeenCalledWith(
+ YesNoDialog,
+ expect.objectContaining({
+ data: expect.objectContaining({
+ title: 'Drain Connector',
+ message: expect.stringContaining(
+ "Are you sure you want to drain
connector 'Test Connector'"
+ )
+ })
+ })
+ );
+
expect(dispatchSpy).toHaveBeenCalledWith(drainConnector({ connector: entity }));
+ resolve();
+ });
+ });
+ }));
+ });
+
+ describe('drainConnector$', () => {
+ it('should dispatch drainConnectorSuccess when drain succeeds', async
() => {
+ const refreshed = createMockConnectorEntity();
+ const { effects, actions$, mockConnectorService } = await setup();
+ (mockConnectorService.drainConnector as
Mock).mockReturnValue(of(refreshed));
+
+ actions$.next(drainConnector({ connector:
createMockConnectorEntity() }));
+
+ const result = await firstValueFrom(effects.drainConnector$);
+ expect(result).toEqual(drainConnectorSuccess({ connector:
refreshed }));
+ });
+
+ it('should dispatch connectorActionApiError when drain errors', async
() => {
+ const errorResponse = new HttpErrorResponse({ error: 'Error',
status: 500, statusText: 'ISE' });
+ const { effects, actions$, mockConnectorService } = await setup();
+ (mockConnectorService.drainConnector as
Mock).mockReturnValue(throwError(() => errorResponse));
+
+ actions$.next(drainConnector({ connector:
createMockConnectorEntity() }));
+
+ const result = await firstValueFrom(effects.drainConnector$);
+ expect(result).toEqual(connectorActionApiError({ error: 'Error
message' }));
+ });
+ });
+
+ describe('cancelConnectorDrain$', () => {
+ it('should dispatch cancelConnectorDrainSuccess when cancel succeeds',
async () => {
+ const refreshed = createMockConnectorEntity();
+ const { effects, actions$, mockConnectorService } = await setup();
+ (mockConnectorService.cancelConnectorDrain as
Mock).mockReturnValue(of(refreshed));
+
+ actions$.next(cancelConnectorDrain({ connector:
createMockConnectorEntity() }));
+
+ const result = await firstValueFrom(effects.cancelConnectorDrain$);
+ expect(result).toEqual(cancelConnectorDrainSuccess({ connector:
refreshed }));
+ });
+
+ it('should dispatch connectorActionApiError when cancel errors', async
() => {
+ const errorResponse = new HttpErrorResponse({ error: 'Error',
status: 500, statusText: 'ISE' });
+ const { effects, actions$, mockConnectorService } = await setup();
+ (mockConnectorService.cancelConnectorDrain as
Mock).mockReturnValue(throwError(() => errorResponse));
+
+ actions$.next(cancelConnectorDrain({ connector:
createMockConnectorEntity() }));
+
+ const result = await firstValueFrom(effects.cancelConnectorDrain$);
+ expect(result).toEqual(connectorActionApiError({ error: 'Error
message' }));
+ });
+ });
+
+ describe('startConnector$', () => {
+ it('should dispatch startConnectorSuccess when start succeeds', async
() => {
+ const refreshed = createMockConnectorEntity();
+ const { effects, actions$, mockConnectorService } = await setup();
+ (mockConnectorService.updateConnectorRunStatus as
Mock).mockReturnValue(of(refreshed));
+
+ const request = createMockConnectorEntity();
+ actions$.next(startConnector({ connector: request }));
+
+ const result = await firstValueFrom(effects.startConnector$);
+ expect(result).toEqual(startConnectorSuccess({ connector:
refreshed }));
+
expect(mockConnectorService.updateConnectorRunStatus).toHaveBeenCalledWith(request,
'RUNNING');
+ });
+
+ it('should dispatch connectorActionApiError when start errors', async
() => {
+ const errorResponse = new HttpErrorResponse({ error: 'Error',
status: 500, statusText: 'ISE' });
+ const { effects, actions$, mockConnectorService } = await setup();
+ (mockConnectorService.updateConnectorRunStatus as
Mock).mockReturnValue(throwError(() => errorResponse));
+
+ actions$.next(startConnector({ connector:
createMockConnectorEntity() }));
+
+ const result = await firstValueFrom(effects.startConnector$);
+ expect(result).toEqual(connectorActionApiError({ error: 'Error
message' }));
+ });
+ });
+
+ describe('stopConnector$', () => {
+ it('should dispatch stopConnectorSuccess when stop succeeds', async ()
=> {
+ const refreshed = createMockConnectorEntity();
+ const { effects, actions$, mockConnectorService } = await setup();
+ (mockConnectorService.updateConnectorRunStatus as
Mock).mockReturnValue(of(refreshed));
+
+ const request = createMockConnectorEntity();
+ actions$.next(stopConnector({ connector: request }));
+
+ const result = await firstValueFrom(effects.stopConnector$);
+ expect(result).toEqual(stopConnectorSuccess({ connector: refreshed
}));
+
expect(mockConnectorService.updateConnectorRunStatus).toHaveBeenCalledWith(request,
'STOPPED');
+ });
+
+ it('should dispatch connectorActionApiError when stop errors', async
() => {
+ const errorResponse = new HttpErrorResponse({ error: 'Error',
status: 500, statusText: 'ISE' });
+ const { effects, actions$, mockConnectorService } = await setup();
+ (mockConnectorService.updateConnectorRunStatus as
Mock).mockReturnValue(throwError(() => errorResponse));
+
+ actions$.next(stopConnector({ connector:
createMockConnectorEntity() }));
+
+ const result = await firstValueFrom(effects.stopConnector$);
+ expect(result).toEqual(connectorActionApiError({ error: 'Error
message' }));
+ });
+ });
+
+ describe('refreshAfterAction$', () => {
+ it('should dispatch loadConnectorEntity on drainConnectorSuccess when
connectorId is in route', async () => {
+ const { effects, actions$ } = await setup({ connectorIdFromRoute:
'connector-789' });
+
+ actions$.next(drainConnectorSuccess({ connector:
createMockConnectorEntity() }));
+
+ const result = await firstValueFrom(effects.refreshAfterAction$);
+ expect(result).toEqual(loadConnectorEntity({ connectorId:
'connector-789' }));
+ });
+
+ it('should dispatch loadConnectorEntity on cancelConnectorDrainSuccess
when connectorId is in route', async () => {
+ const { effects, actions$ } = await setup({ connectorIdFromRoute:
'connector-789' });
+
+ actions$.next(cancelConnectorDrainSuccess({ connector:
createMockConnectorEntity() }));
+
+ const result = await firstValueFrom(effects.refreshAfterAction$);
+ expect(result).toEqual(loadConnectorEntity({ connectorId:
'connector-789' }));
+ });
+
+ it('should dispatch loadConnectorEntity on startConnectorSuccess when
connectorId is in route', async () => {
+ const { effects, actions$ } = await setup({ connectorIdFromRoute:
'connector-789' });
+
+ actions$.next(startConnectorSuccess({ connector:
createMockConnectorEntity() }));
+
+ const result = await firstValueFrom(effects.refreshAfterAction$);
+ expect(result).toEqual(loadConnectorEntity({ connectorId:
'connector-789' }));
+ });
+
+ it('should dispatch loadConnectorEntity on stopConnectorSuccess when
connectorId is in route', async () => {
+ const { effects, actions$ } = await setup({ connectorIdFromRoute:
'connector-789' });
+
+ actions$.next(stopConnectorSuccess({ connector:
createMockConnectorEntity() }));
+
+ const result = await firstValueFrom(effects.refreshAfterAction$);
+ expect(result).toEqual(loadConnectorEntity({ connectorId:
'connector-789' }));
+ });
+
+ it('should not dispatch when no connectorId in route', () =>
+ new Promise<void>((resolve) => {
+ setup({ connectorIdFromRoute: null }).then(({ effects,
actions$ }) => {
+ let emissionCount = 0;
+ const subscription =
effects.refreshAfterAction$.subscribe(() => {
+ emissionCount++;
+ });
+
+ actions$.next(drainConnectorSuccess({ connector:
createMockConnectorEntity() }));
+
+ queueMicrotask(() => {
+ expect(emissionCount).toBe(0);
+ subscription.unsubscribe();
+ resolve();
+ });
+ });
+ }));
+ });
+
+ describe('connectorActionApiError$', () => {
+ it('should dispatch addBannerError with CONNECTOR_CANVAS context',
async () => {
+ const { effects, actions$ } = await setup();
+
+ actions$.next(connectorActionApiError({ error: 'boom' }));
+
+ const result = await
firstValueFrom(effects.connectorActionApiError$);
+ expect(result).toEqual(
+ ErrorActions.addBannerError({
+ errorContext: { errors: ['boom'], context:
ErrorContextKey.CONNECTOR_CANVAS }
+ })
+ );
+ });
+ });
+
+ describe('clearCanvasErrorsOnAction$', () => {
+ const actionFactories = [
+ { name: 'drainConnector', factory: drainConnector },
+ { name: 'cancelConnectorDrain', factory: cancelConnectorDrain },
+ { name: 'startConnector', factory: startConnector },
+ { name: 'stopConnector', factory: stopConnector }
+ ];
+
+ actionFactories.forEach(({ name, factory }) => {
+ it(`should dispatch clearBannerErrors on ${name}`, async () => {
+ const { effects, actions$ } = await setup();
+
+ actions$.next(factory({ connector: createMockConnectorEntity()
}));
+
+ const result = await
firstValueFrom(effects.clearCanvasErrorsOnAction$);
+ expect(result).toEqual(ErrorActions.clearBannerErrors({
context: ErrorContextKey.CONNECTOR_CANVAS }));
+ });
+ });
+ });
});
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.effects.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.effects.ts
index 4f41f3da444..20b04f1fd6a 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.effects.ts
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.effects.ts
@@ -19,16 +19,31 @@ import { Injectable, inject } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { concatLatestFrom } from '@ngrx/operators';
import { Store } from '@ngrx/store';
-import { catchError, filter, map, of, switchMap } from 'rxjs';
+import { MatDialog } from '@angular/material/dialog';
+import { catchError, filter, map, of, switchMap, take, tap } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
+import { SMALL_DIALOG, YesNoDialog } from '@nifi/shared';
import { ConnectorService } from '../../service/connector.service';
import { ErrorHelper } from '../../../../service/error-helper.service';
+import * as ErrorActions from '../../../../state/error/error.actions';
+import { ErrorContextKey } from '../../../../state/error';
import * as ConnectorCanvasActions from
'../connector-canvas/connector-canvas.actions';
+import { selectConnectorIdFromRoute } from
'../connector-canvas/connector-canvas.selectors';
import { selectConnectorCanvasEntity } from
'./connector-canvas-entity.selectors';
import {
loadConnectorEntity,
loadConnectorEntitySuccess,
- loadConnectorEntityFailure
+ loadConnectorEntityFailure,
+ promptDrainConnector,
+ drainConnector,
+ drainConnectorSuccess,
+ cancelConnectorDrain,
+ cancelConnectorDrainSuccess,
+ startConnector,
+ startConnectorSuccess,
+ stopConnector,
+ stopConnectorSuccess,
+ connectorActionApiError
} from './connector-canvas-entity.actions';
@Injectable()
@@ -37,6 +52,7 @@ export class ConnectorCanvasEntityEffects {
private store = inject(Store);
private connectorService = inject(ConnectorService);
private errorHelper = inject(ErrorHelper);
+ private dialog = inject(MatDialog);
triggerEntityLoad$ = createEffect(() =>
this.actions$.pipe(
@@ -60,4 +76,137 @@ export class ConnectorCanvasEntityEffects {
)
)
);
+
+ /**
+ * Prompt user to confirm draining FlowFiles.
+ */
+ promptDrainConnector$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(promptDrainConnector),
+ tap((action) => {
+ const dialogRef =
this.dialog.open<YesNoDialog>(YesNoDialog, {
+ ...SMALL_DIALOG,
+ data: {
+ title: 'Drain Connector',
+ message: `Are you sure you want to drain connector
'${action.connector.component.name}'? This will process existing FlowFiles but
prevent new data from being ingested.`
+ }
+ });
+
+
dialogRef.componentInstance!.yes.pipe(take(1)).subscribe(() => {
+ this.store.dispatch(drainConnector({ connector:
action.connector }));
+ });
+ })
+ ),
+ { dispatch: false }
+ );
+
+ /**
+ * Drain connector API call.
+ */
+ drainConnector$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(drainConnector),
+ switchMap((action) =>
+ this.connectorService.drainConnector(action.connector).pipe(
+ map((response) => drainConnectorSuccess({ connector:
response })),
+ catchError((errorResponse: HttpErrorResponse) =>
+ of(connectorActionApiError({ error:
this.errorHelper.getErrorString(errorResponse) }))
+ )
+ )
+ )
+ )
+ );
+
+ /**
+ * Cancel drain API call (no confirmation needed).
+ */
+ cancelConnectorDrain$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(cancelConnectorDrain),
+ switchMap((action) =>
+
this.connectorService.cancelConnectorDrain(action.connector).pipe(
+ map((response) => cancelConnectorDrainSuccess({ connector:
response })),
+ catchError((errorResponse: HttpErrorResponse) =>
+ of(connectorActionApiError({ error:
this.errorHelper.getErrorString(errorResponse) }))
+ )
+ )
+ )
+ )
+ );
+
+ /**
+ * Start connector API call (transition to RUNNING).
+ */
+ startConnector$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(startConnector),
+ switchMap((action) =>
+
this.connectorService.updateConnectorRunStatus(action.connector,
'RUNNING').pipe(
+ map((response) => startConnectorSuccess({ connector:
response })),
+ catchError((errorResponse: HttpErrorResponse) =>
+ of(connectorActionApiError({ error:
this.errorHelper.getErrorString(errorResponse) }))
+ )
+ )
+ )
+ )
+ );
+
+ /**
+ * Stop connector API call (transition to STOPPED).
+ */
+ stopConnector$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(stopConnector),
+ switchMap((action) =>
+
this.connectorService.updateConnectorRunStatus(action.connector,
'STOPPED').pipe(
+ map((response) => stopConnectorSuccess({ connector:
response })),
+ catchError((errorResponse: HttpErrorResponse) =>
+ of(connectorActionApiError({ error:
this.errorHelper.getErrorString(errorResponse) }))
+ )
+ )
+ )
+ )
+ );
+
+ /**
+ * On any successful connector action, reload the connector entity to
ensure
+ * availableActions and state are fully up to date.
+ */
+ refreshAfterAction$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(drainConnectorSuccess, cancelConnectorDrainSuccess,
startConnectorSuccess, stopConnectorSuccess),
+ concatLatestFrom(() =>
this.store.select(selectConnectorIdFromRoute)),
+ filter(([, connectorId]) => connectorId != null),
+ map(([, connectorId]) => loadConnectorEntity({ connectorId:
connectorId! }))
+ )
+ );
+
+ /**
+ * Handle connector action API errors by dispatching to the banner error
system.
+ */
+ connectorActionApiError$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(connectorActionApiError),
+ map((action) => action.error),
+ switchMap((error) =>
+ of(
+ ErrorActions.addBannerError({
+ errorContext: { errors: [error], context:
ErrorContextKey.CONNECTOR_CANVAS }
+ })
+ )
+ )
+ )
+ );
+
+ /**
+ * When a connector action is initiated, clear any lingering canvas banner
errors so
+ * a retry does not stack on top of a previous failure message.
+ */
+ clearCanvasErrorsOnAction$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(drainConnector, cancelConnectorDrain, startConnector,
stopConnector),
+ map(() => ErrorActions.clearBannerErrors({ context:
ErrorContextKey.CONNECTOR_CANVAS }))
+ )
+ );
}
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.reducer.spec.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.reducer.spec.ts
index 2cb3752ed14..0fc1e965649 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.reducer.spec.ts
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.reducer.spec.ts
@@ -22,6 +22,15 @@ import {
loadConnectorEntity,
loadConnectorEntitySuccess,
loadConnectorEntityFailure,
+ drainConnector,
+ drainConnectorSuccess,
+ cancelConnectorDrain,
+ cancelConnectorDrainSuccess,
+ startConnector,
+ startConnectorSuccess,
+ stopConnector,
+ stopConnectorSuccess,
+ connectorActionApiError,
resetConnectorCanvasEntityState
} from './connector-canvas-entity.actions';
@@ -105,6 +114,160 @@ describe('connectorCanvasEntityReducer', () => {
});
});
+ describe('drainConnector / cancelConnectorDrain', () => {
+ it('should set saving to true and clear error on drainConnector', ()
=> {
+ const entity = createMockConnectorEntity();
+ const priorState: ConnectorCanvasEntityState = {
+ ...initialConnectorCanvasEntityState,
+ connectorEntity: entity,
+ error: 'previous error'
+ };
+
+ const result = connectorCanvasEntityReducer(priorState,
drainConnector({ connector: entity }));
+
+ expect(result.saving).toBe(true);
+ expect(result.error).toBeNull();
+ expect(result.connectorEntity).toEqual(entity);
+ });
+
+ it('should set saving to true and clear error on
cancelConnectorDrain', () => {
+ const entity = createMockConnectorEntity();
+ const priorState: ConnectorCanvasEntityState = {
+ ...initialConnectorCanvasEntityState,
+ connectorEntity: entity,
+ error: 'previous error'
+ };
+
+ const result = connectorCanvasEntityReducer(priorState,
cancelConnectorDrain({ connector: entity }));
+
+ expect(result.saving).toBe(true);
+ expect(result.error).toBeNull();
+ });
+ });
+
+ describe('drainConnectorSuccess / cancelConnectorDrainSuccess', () => {
+ it('should replace connectorEntity and clear saving on
drainConnectorSuccess', () => {
+ const prior = createMockConnectorEntity({ id: 'connector-123' });
+ const refreshed = createMockConnectorEntity({ id: 'connector-123'
});
+ refreshed.component.state = 'RUNNING';
+
+ const priorState: ConnectorCanvasEntityState = {
+ ...initialConnectorCanvasEntityState,
+ connectorEntity: prior,
+ saving: true
+ };
+
+ const result = connectorCanvasEntityReducer(priorState,
drainConnectorSuccess({ connector: refreshed }));
+
+ expect(result.connectorEntity).toEqual(refreshed);
+ expect(result.saving).toBe(false);
+ expect(result.error).toBeNull();
+ });
+
+ it('should replace connectorEntity and clear saving on
cancelConnectorDrainSuccess', () => {
+ const prior = createMockConnectorEntity({ id: 'connector-123' });
+ const refreshed = createMockConnectorEntity({ id: 'connector-123'
});
+
+ const priorState: ConnectorCanvasEntityState = {
+ ...initialConnectorCanvasEntityState,
+ connectorEntity: prior,
+ saving: true
+ };
+
+ const result = connectorCanvasEntityReducer(
+ priorState,
+ cancelConnectorDrainSuccess({ connector: refreshed })
+ );
+
+ expect(result.connectorEntity).toEqual(refreshed);
+ expect(result.saving).toBe(false);
+ expect(result.error).toBeNull();
+ });
+ });
+
+ describe('startConnector / stopConnector', () => {
+ it('should set saving to true and clear error on startConnector', ()
=> {
+ const entity = createMockConnectorEntity();
+ const priorState: ConnectorCanvasEntityState = {
+ ...initialConnectorCanvasEntityState,
+ connectorEntity: entity,
+ error: 'previous error'
+ };
+
+ const result = connectorCanvasEntityReducer(priorState,
startConnector({ connector: entity }));
+
+ expect(result.saving).toBe(true);
+ expect(result.error).toBeNull();
+ expect(result.connectorEntity).toEqual(entity);
+ });
+
+ it('should set saving to true and clear error on stopConnector', () =>
{
+ const entity = createMockConnectorEntity();
+ const priorState: ConnectorCanvasEntityState = {
+ ...initialConnectorCanvasEntityState,
+ connectorEntity: entity,
+ error: 'previous error'
+ };
+
+ const result = connectorCanvasEntityReducer(priorState,
stopConnector({ connector: entity }));
+
+ expect(result.saving).toBe(true);
+ expect(result.error).toBeNull();
+ });
+ });
+
+ describe('startConnectorSuccess / stopConnectorSuccess', () => {
+ it('should replace connectorEntity and clear saving on
startConnectorSuccess', () => {
+ const prior = createMockConnectorEntity({ id: 'connector-123' });
+ const refreshed = createMockConnectorEntity({ id: 'connector-123'
});
+ refreshed.component.state = 'RUNNING';
+
+ const priorState: ConnectorCanvasEntityState = {
+ ...initialConnectorCanvasEntityState,
+ connectorEntity: prior,
+ saving: true
+ };
+
+ const result = connectorCanvasEntityReducer(priorState,
startConnectorSuccess({ connector: refreshed }));
+
+ expect(result.connectorEntity).toEqual(refreshed);
+ expect(result.saving).toBe(false);
+ expect(result.error).toBeNull();
+ });
+
+ it('should replace connectorEntity and clear saving on
stopConnectorSuccess', () => {
+ const prior = createMockConnectorEntity({ id: 'connector-123' });
+ const refreshed = createMockConnectorEntity({ id: 'connector-123'
});
+ refreshed.component.state = 'STOPPED';
+
+ const priorState: ConnectorCanvasEntityState = {
+ ...initialConnectorCanvasEntityState,
+ connectorEntity: prior,
+ saving: true
+ };
+
+ const result = connectorCanvasEntityReducer(priorState,
stopConnectorSuccess({ connector: refreshed }));
+
+ expect(result.connectorEntity).toEqual(refreshed);
+ expect(result.saving).toBe(false);
+ expect(result.error).toBeNull();
+ });
+ });
+
+ describe('connectorActionApiError', () => {
+ it('should clear saving and store the error', () => {
+ const priorState: ConnectorCanvasEntityState = {
+ ...initialConnectorCanvasEntityState,
+ saving: true
+ };
+
+ const result = connectorCanvasEntityReducer(priorState,
connectorActionApiError({ error: 'boom' }));
+
+ expect(result.saving).toBe(false);
+ expect(result.error).toBe('boom');
+ });
+ });
+
describe('resetConnectorCanvasEntityState', () => {
it('should return to initial state', () => {
const entity = createMockConnectorEntity();
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.reducer.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.reducer.ts
index de7d65a51a4..483e3f326d7 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.reducer.ts
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.reducer.ts
@@ -21,6 +21,15 @@ import {
loadConnectorEntity,
loadConnectorEntitySuccess,
loadConnectorEntityFailure,
+ drainConnector,
+ drainConnectorSuccess,
+ cancelConnectorDrain,
+ cancelConnectorDrainSuccess,
+ startConnector,
+ startConnectorSuccess,
+ stopConnector,
+ stopConnectorSuccess,
+ connectorActionApiError,
resetConnectorCanvasEntityState
} from './connector-canvas-entity.actions';
@@ -46,6 +55,31 @@ export const connectorCanvasEntityReducer = createReducer(
error
})),
+ on(drainConnector, cancelConnectorDrain, startConnector, stopConnector,
(state) => ({
+ ...state,
+ saving: true,
+ error: null
+ })),
+
+ on(
+ drainConnectorSuccess,
+ cancelConnectorDrainSuccess,
+ startConnectorSuccess,
+ stopConnectorSuccess,
+ (state, { connector }) => ({
+ ...state,
+ connectorEntity: connector,
+ saving: false,
+ error: null
+ })
+ ),
+
+ on(connectorActionApiError, (state, { error }) => ({
+ ...state,
+ saving: false,
+ error
+ })),
+
on(resetConnectorCanvasEntityState, () => ({
...initialConnectorCanvasEntityState
}))
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connectors-listing/connectors-listing.effects.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connectors-listing/connectors-listing.effects.ts
index ddbab92989d..2548206297f 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connectors-listing/connectors-listing.effects.ts
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connectors-listing/connectors-listing.effects.ts
@@ -451,7 +451,7 @@ export class ConnectorsListingEffects {
ofType(navigateToViewConnectorDetails),
tap(() => {
window.alert(
- 'TODO: View connector details is not yet implemented.
This feature will be ported in a future iteration.'
+ 'TODO: View connector details is not yet implemented.
This feature will be implemented in a future iteration.'
);
})
),
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/_connector-canvas.component-theme.scss
similarity index 55%
copy from
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
copy to
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/_connector-canvas.component-theme.scss
index 7a083b21f75..50a5ecfad6f 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/_connector-canvas.component-theme.scss
@@ -15,21 +15,13 @@
* limitations under the License.
*/
-import { createAction, props } from '@ngrx/store';
-import { ConnectorEntity } from '@nifi/shared';
-
-const PREFIX = '[Connector Canvas Entity]';
-
-export const loadConnectorEntity = createAction(`${PREFIX} Load Connector
Entity`, props<{ connectorId: string }>());
-
-export const loadConnectorEntitySuccess = createAction(
- `${PREFIX} Load Connector Entity Success`,
- props<{ connectorEntity: ConnectorEntity }>()
-);
-
-export const loadConnectorEntityFailure = createAction(
- `${PREFIX} Load Connector Entity Failure`,
- props<{ error: string }>()
-);
-
-export const resetConnectorCanvasEntityState = createAction(`${PREFIX} Reset
State`);
+@mixin generate-theme() {
+ context-error-banner.canvas-error-banner .banner-container {
+ background-color: var(--mat-sys-surface-container);
+ border: 1px solid var(--mat-sys-outline-variant);
+ border-radius: 4px;
+ box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
+ color: var(--mat-sys-on-surface);
+ margin-bottom: 0;
+ }
+}
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.html
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.html
index 75dbbe6e2c7..2a42714db7e 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.html
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.html
@@ -27,39 +27,53 @@
(toggleGraphControls)="toggleGraphControls()">
</connector-canvas-header-bar>
<div class="relative flex-1 min-h-0">
- @if ((hasError$ | async) === false) {
- <reusable-canvas
- [labels]="(labels$ | async) || []"
- [processors]="(processors$ | async) || []"
- [funnels]="(funnels$ | async) || []"
- [ports]="(allPorts$ | async) || []"
- [remoteProcessGroups]="(remoteProcessGroups$ | async) || []"
- [processGroups]="(processGroups$ | async) || []"
- [connections]="(connections$ | async) || []"
- [previewExtensions]="(previewExtensions$ | async) || []"
- [registryClients]="(registryClients$ | async) || []"
- [processGroupId]="currentProcessGroupId"
- [selectedComponentIds]="selectedComponentIds"
- [dataReady]="(dataReady$ | async) ?? false"
- [skipInitialCenter]="skipTransform()"
- (selectComponents)="onSelectComponents($event)"
- (deselectAll)="onDeselectAll()"
- (initialized)="onCanvasInitialized()"
- (transformChange)="onTransformChange($event)"
- (processGroupDoubleClick)="onProcessGroupDoubleClick($event)"
- [menuProvider]="contextMenuProvider"
- (contextMenuOpened)="onContextMenuOpened($event)">
- </reusable-canvas>
- }
- @if ((hasError$ | async) === true) {
- <div
- class="flex flex-col h-full items-center justify-center p-8
gap-4 tertiary-color"
- data-qa="not-found-state">
- <i class="fa fa-warning text-2xl" aria-hidden="true"></i>
- <p>Connector not found.</p>
- <button mat-flat-button
(click)="returnToConnectorListing()">Return to Connectors</button>
- </div>
- }
+ <mat-sidenav-container class="h-full">
+ <mat-sidenav disableClose="true" mode="side"
[opened]="graphControlsOpen" position="start">
+ <connector-graph-controls
[connectorEntity]="connectorEntity()" [entitySaving]="entitySaving()">
+ </connector-graph-controls>
+ </mat-sidenav>
+ <mat-sidenav-content>
+ <div class="relative h-full">
+ <context-error-banner
+ class="canvas-error-banner absolute top-4 left-4
right-4 z-10"
+ [context]="ErrorContextKey.CONNECTOR_CANVAS">
+ </context-error-banner>
+ @if ((hasError$ | async) === false) {
+ <reusable-canvas
+ [labels]="(labels$ | async) || []"
+ [processors]="(processors$ | async) || []"
+ [funnels]="(funnels$ | async) || []"
+ [ports]="(allPorts$ | async) || []"
+ [remoteProcessGroups]="(remoteProcessGroups$ |
async) || []"
+ [processGroups]="(processGroups$ | async) || []"
+ [connections]="(connections$ | async) || []"
+ [previewExtensions]="(previewExtensions$ | async)
|| []"
+ [registryClients]="(registryClients$ | async) ||
[]"
+ [processGroupId]="currentProcessGroupId"
+ [selectedComponentIds]="selectedComponentIds"
+ [dataReady]="(dataReady$ | async) ?? false"
+ [skipInitialCenter]="skipTransform()"
+ (selectComponents)="onSelectComponents($event)"
+ (deselectAll)="onDeselectAll()"
+ (initialized)="onCanvasInitialized()"
+ (transformChange)="onTransformChange($event)"
+
(processGroupDoubleClick)="onProcessGroupDoubleClick($event)"
+ [menuProvider]="contextMenuProvider"
+ (contextMenuOpened)="onContextMenuOpened($event)">
+ </reusable-canvas>
+ }
+ @if ((hasError$ | async) === true) {
+ <div
+ class="flex flex-col h-full items-center
justify-center p-8 gap-4 tertiary-color"
+ data-qa="not-found-state">
+ <i class="fa fa-warning text-2xl"
aria-hidden="true"></i>
+ <p>Connector not found.</p>
+ <button mat-flat-button
(click)="returnToConnectorListing()">Return to Connectors</button>
+ </div>
+ }
+ </div>
+ </mat-sidenav-content>
+ </mat-sidenav-container>
</div>
<connector-canvas-footer
[connectorId]="currentConnectorId"></connector-canvas-footer>
</div>
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.spec.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.spec.ts
index 4ea516320ae..0ad12230a85 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.spec.ts
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.spec.ts
@@ -33,8 +33,16 @@ import { Navigation } from
'../../../../ui/common/navigation/navigation.componen
import { ConnectorCanvasHeaderBarComponent } from
'./header-bar/connector-canvas-header-bar.component';
import { ConnectorCanvasFooterComponent } from './footer/footer.component';
import { selectCurrentUser } from
'../../../../state/current-user/current-user.selectors';
+import { ConnectorGraphControls } from
'./graph-controls/connector-graph-controls.component';
+import { ContextErrorBanner } from
'../../../../ui/common/context-error-banner/context-error-banner.component';
+import { ErrorContextKey } from '../../../../state/error';
+import { Storage } from '@nifi/shared';
import { setConfiguration } from
'../../../../state/canvas-ui/canvas-ui.actions';
import * as ConnectorCanvasSelectors from
'../../state/connector-canvas/connector-canvas.selectors';
+import {
+ selectConnectorCanvasEntity,
+ selectConnectorCanvasEntitySaving
+} from '../../state/connector-canvas-entity/connector-canvas-entity.selectors';
import { selectParentProcessGroupId } from
'../../state/connector-canvas/connector-canvas.selectors';
import {
deselectAllComponents,
@@ -114,6 +122,27 @@ class MockConnectorCanvasFooterComponent {
connectorId = input.required<string>();
}
+@Component({
+ selector: 'connector-graph-controls',
+ standalone: true,
+ imports: [CommonModule],
+ template: ''
+})
+class MockConnectorGraphControls {
+ connectorEntity = input<unknown>(null);
+ entitySaving = input<boolean>(false);
+}
+
+@Component({
+ selector: 'context-error-banner',
+ standalone: true,
+ imports: [CommonModule],
+ template: ''
+})
+class MockContextErrorBanner {
+ context = input.required<ErrorContextKey>();
+}
+
@Component({
selector: 'mock-blocking-dialog',
standalone: true,
@@ -181,44 +210,78 @@ function buildMockSelectors(options: SetupOptions = {}) {
{ selector: selectParentProcessGroupId, value: parentProcessGroupId },
{ selector: selectUrl, value: url },
{ selector: selectRouteParams, value: routeParamsValue },
- { selector: selectCurrentUser, value:
buildMockCurrentUser(canAccessProvenance) }
+ { selector: selectCurrentUser, value:
buildMockCurrentUser(canAccessProvenance) },
+ { selector: selectConnectorCanvasEntity, value: null },
+ { selector: selectConnectorCanvasEntitySaving, value: false }
];
}
-function configureConnectorCanvasTestBed(options: SetupOptions = {}) {
+function createMockStorage() {
+ const backingStore = new Map<string, unknown>();
+ return {
+ getItem: vi.fn((key: string) => backingStore.get(key) ?? null),
+ setItem: vi.fn((key: string, value: unknown) => {
+ backingStore.set(key, value);
+ }),
+ removeItem: vi.fn((key: string) => {
+ backingStore.delete(key);
+ }),
+ hasItem: vi.fn((key: string) => backingStore.has(key)),
+ getItemExpiration: vi.fn().mockReturnValue(null),
+ __store: backingStore
+ };
+}
+
+function configureConnectorCanvasTestBed(options: SetupOptions = {}, storage?:
ReturnType<typeof createMockStorage>) {
TestBed.resetTestingModule();
+ const storageMock = storage ?? createMockStorage();
TestBed.configureTestingModule({
imports: [ConnectorCanvasComponent, NoopAnimationsModule,
MatDialogModule],
- providers: [provideRouter([]), provideMockStore({ initialState: {},
selectors: buildMockSelectors(options) })]
+ providers: [
+ provideRouter([]),
+ provideMockStore({ initialState: {}, selectors:
buildMockSelectors(options) }),
+ { provide: Storage, useValue: storageMock }
+ ]
}).overrideComponent(ConnectorCanvasComponent, {
remove: {
- imports: [CanvasComponent, Navigation,
ConnectorCanvasHeaderBarComponent, ConnectorCanvasFooterComponent]
+ imports: [
+ CanvasComponent,
+ Navigation,
+ ConnectorCanvasHeaderBarComponent,
+ ConnectorCanvasFooterComponent,
+ ConnectorGraphControls,
+ ContextErrorBanner
+ ]
},
add: {
imports: [
MockReusableCanvasComponent,
MockNavigationComponent,
MockConnectorCanvasHeaderBarComponent,
- MockConnectorCanvasFooterComponent
+ MockConnectorCanvasFooterComponent,
+ MockConnectorGraphControls,
+ MockContextErrorBanner
]
}
});
+ return storageMock;
}
-function createConnectorCanvasFixture(): {
+function createConnectorCanvasFixture(storage: ReturnType<typeof
createMockStorage>): {
fixture: ComponentFixture<ConnectorCanvasComponent>;
component: ConnectorCanvasComponent;
dispatchSpy: ReturnType<typeof vi.spyOn>;
+ storage: ReturnType<typeof createMockStorage>;
} {
const store = TestBed.inject(MockStore);
const dispatchSpy = vi.spyOn(store, 'dispatch');
const fixture = TestBed.createComponent(ConnectorCanvasComponent);
- return { fixture, component: fixture.componentInstance, dispatchSpy };
+ return { fixture, component: fixture.componentInstance, dispatchSpy,
storage };
}
-function setup(options: SetupOptions = {}) {
- configureConnectorCanvasTestBed(options);
- return createConnectorCanvasFixture();
+function setup(options: SetupOptions = {}, storageOverride?: ReturnType<typeof
createMockStorage>) {
+ const storage = configureConnectorCanvasTestBed(options, storageOverride);
+ return createConnectorCanvasFixture(storage);
}
function dispatchWindowKeydown(key: string, modifiers: { ctrlKey?: boolean;
metaKey?: boolean } = {}) {
@@ -632,23 +695,54 @@ describe('ConnectorCanvasComponent', () => {
});
describe('Graph controls toggle', () => {
- it('should default graphControlsOpen to true', () => {
- localStorage.removeItem('connector-graph-controls');
+ it('should default graphControlsOpen to true when storage has no
entry', () => {
const { component } = setup();
expect(component.graphControlsOpen).toBe(true);
});
- it('should toggle graphControlsOpen and persist to localStorage', ()
=> {
- localStorage.removeItem('connector-graph-controls');
- const { component } = setup();
+ it('should restore graphControlsOpen from Storage service when
persisted as false', () => {
+ const storage = createMockStorage();
+ storage.getItem.mockImplementation((key: string) =>
+ key === 'graph-control-visibility' ? {
'connector-graph-controls': false } : null
+ );
+ const { component } = setup({}, storage);
+ expect(component.graphControlsOpen).toBe(false);
+ });
+
+ it('should toggle graphControlsOpen and persist state via Storage
service', () => {
+ const { component, storage } = setup();
component.toggleGraphControls();
expect(component.graphControlsOpen).toBe(false);
-
expect(localStorage.getItem('connector-graph-controls')).toBe('false');
+ expect(storage.setItem).toHaveBeenCalledWith(
+ 'graph-control-visibility',
+ expect.objectContaining({ 'connector-graph-controls': false })
+ );
component.toggleGraphControls();
expect(component.graphControlsOpen).toBe(true);
-
expect(localStorage.getItem('connector-graph-controls')).toBe('true');
+ expect(storage.setItem).toHaveBeenCalledWith(
+ 'graph-control-visibility',
+ expect.objectContaining({ 'connector-graph-controls': true })
+ );
+ });
+
+ it('should preserve sibling visibility keys when toggling', () => {
+ const storage = createMockStorage();
+ storage.getItem.mockImplementation((key: string) =>
+ key === 'graph-control-visibility' ? { 'other-control': true,
'connector-graph-controls': true } : null
+ );
+ const { component } = setup({}, storage);
+
+ component.toggleGraphControls();
+
+ expect(storage.setItem).toHaveBeenCalledWith(
+ 'graph-control-visibility',
+ expect.objectContaining({
+ 'other-control': true,
+ 'connector-graph-controls': false
+ })
+ );
});
});
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.ts
index 2fcce807855..c6fe1a341d2 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.ts
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.ts
@@ -20,9 +20,10 @@ import { CommonModule } from '@angular/common';
import { Router } from '@angular/router';
import { MatButton } from '@angular/material/button';
import { MatDialog } from '@angular/material/dialog';
+import { MatSidenav, MatSidenavContainer, MatSidenavContent } from
'@angular/material/sidenav';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Store } from '@ngrx/store';
-import { ComponentType, selectRouteParams, selectUrl } from '@nifi/shared';
+import { ComponentType, selectRouteParams, selectUrl, Storage } from
'@nifi/shared';
import { DocumentedType, RegistryClientEntity } from
'../../../../state/shared';
import { combineLatest, distinctUntilChanged, filter, map, Observable, of }
from 'rxjs';
import { NiFiState } from '../../../../state';
@@ -39,13 +40,18 @@ import {
import { Navigation } from
'../../../../ui/common/navigation/navigation.component';
import { ConnectorCanvasHeaderBarComponent } from
'./header-bar/connector-canvas-header-bar.component';
import { ConnectorCanvasFooterComponent } from './footer/footer.component';
+import { ConnectorGraphControls } from
'./graph-controls/connector-graph-controls.component';
+import { ContextErrorBanner } from
'../../../../ui/common/context-error-banner/context-error-banner.component';
+import { ErrorContextKey } from '../../../../state/error';
import * as ConnectorCanvasActions from
'../../state/connector-canvas/connector-canvas.actions';
import * as ConnectorCanvasSelectors from
'../../state/connector-canvas/connector-canvas.selectors';
import * as ConnectorCanvasEntityActions from
'../../state/connector-canvas-entity/connector-canvas-entity.actions';
+import {
+ selectConnectorCanvasEntity,
+ selectConnectorCanvasEntitySaving
+} from '../../state/connector-canvas-entity/connector-canvas-entity.selectors';
import { getComponentStateAndOpenDialog } from
'../../../../state/component-state/component-state.actions';
-const GRAPH_CONTROLS_STORAGE_KEY = 'connector-graph-controls';
-
@Component({
selector: 'connector-canvas',
standalone: true,
@@ -53,9 +59,14 @@ const GRAPH_CONTROLS_STORAGE_KEY =
'connector-graph-controls';
CommonModule,
CanvasComponent,
MatButton,
+ MatSidenav,
+ MatSidenavContainer,
+ MatSidenavContent,
Navigation,
ConnectorCanvasHeaderBarComponent,
- ConnectorCanvasFooterComponent
+ ConnectorCanvasFooterComponent,
+ ConnectorGraphControls,
+ ContextErrorBanner
],
templateUrl: './connector-canvas.component.html'
})
@@ -64,6 +75,10 @@ export class ConnectorCanvasComponent implements OnInit,
OnDestroy {
private destroyRef = inject(DestroyRef);
private router = inject(Router);
private dialog = inject(MatDialog);
+ private storage = inject(Storage);
+
+ private static readonly CONTROL_VISIBILITY_KEY =
'graph-control-visibility';
+ private static readonly GRAPH_CONTROL_KEY = 'connector-graph-controls';
canvasComponent = viewChild.required(CanvasComponent);
@@ -72,7 +87,25 @@ export class ConnectorCanvasComponent implements OnInit,
OnDestroy {
selectedComponentIds: string[] = [];
canNavigateToParent = false;
skipTransform =
this.store.selectSignal(ConnectorCanvasSelectors.selectSkipTransform);
- graphControlsOpen = localStorage.getItem(GRAPH_CONTROLS_STORAGE_KEY) !==
'false';
+ graphControlsOpen = true;
+
+ connectorEntity = this.store.selectSignal(selectConnectorCanvasEntity);
+ entitySaving = this.store.selectSignal(selectConnectorCanvasEntitySaving);
+
+ protected readonly ErrorContextKey = ErrorContextKey;
+
+ constructor() {
+ try {
+ const item: { [key: string]: boolean } | null =
this.storage.getItem(
+ ConnectorCanvasComponent.CONTROL_VISIBILITY_KEY
+ );
+ if (item) {
+ this.graphControlsOpen =
item[ConnectorCanvasComponent.GRAPH_CONTROL_KEY] === true;
+ }
+ } catch (_e) {
+ // likely could not parse item... ignoring
+ }
+ }
labels$: Observable<unknown[]> =
this.store.select(ConnectorCanvasSelectors.selectLabels);
processors$: Observable<unknown[]> =
this.store.select(ConnectorCanvasSelectors.selectProcessors);
@@ -391,7 +424,16 @@ export class ConnectorCanvasComponent implements OnInit,
OnDestroy {
toggleGraphControls(): void {
this.graphControlsOpen = !this.graphControlsOpen;
- localStorage.setItem(GRAPH_CONTROLS_STORAGE_KEY,
String(this.graphControlsOpen));
+
+ let item: { [key: string]: boolean } | null = this.storage.getItem(
+ ConnectorCanvasComponent.CONTROL_VISIBILITY_KEY
+ );
+ if (item == null) {
+ item = {};
+ }
+
+ item[ConnectorCanvasComponent.GRAPH_CONTROL_KEY] =
this.graphControlsOpen;
+ this.storage.setItem(ConnectorCanvasComponent.CONTROL_VISIBILITY_KEY,
item);
}
onSearchGoToComponent(event: { id: string; type: ComponentType; groupId:
string }): void {
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-graph-controls.component.html
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-graph-controls.component.html
new file mode 100644
index 00000000000..85fd960e8f5
--- /dev/null
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-graph-controls.component.html
@@ -0,0 +1,26 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<div class="connector-graph-controls w-96">
+ <div class="flex flex-col p-2 gap-y-2">
+ <!-- Navigation control will be added in Effort 3 (Canvas Navigation &
Birdseye). -->
+ <connector-info-control
+ [connectorEntity]="connectorEntity()"
+ [entitySaving]="entitySaving()"></connector-info-control>
+ <!-- Provenance preview will be added in Effort 7 (Provenance
Preview). -->
+ </div>
+</div>
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-graph-controls.component.scss
similarity index 55%
copy from
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
copy to
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-graph-controls.component.scss
index 7a083b21f75..2944f981947 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-graph-controls.component.scss
@@ -14,22 +14,3 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-import { createAction, props } from '@ngrx/store';
-import { ConnectorEntity } from '@nifi/shared';
-
-const PREFIX = '[Connector Canvas Entity]';
-
-export const loadConnectorEntity = createAction(`${PREFIX} Load Connector
Entity`, props<{ connectorId: string }>());
-
-export const loadConnectorEntitySuccess = createAction(
- `${PREFIX} Load Connector Entity Success`,
- props<{ connectorEntity: ConnectorEntity }>()
-);
-
-export const loadConnectorEntityFailure = createAction(
- `${PREFIX} Load Connector Entity Failure`,
- props<{ error: string }>()
-);
-
-export const resetConnectorCanvasEntityState = createAction(`${PREFIX} Reset
State`);
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-graph-controls.component.spec.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-graph-controls.component.spec.ts
new file mode 100644
index 00000000000..9e4d8609552
--- /dev/null
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-graph-controls.component.spec.ts
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Component, input } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { NoopAnimationsModule } from '@angular/platform-browser/animations';
+
+import { ConnectorGraphControls } from './connector-graph-controls.component';
+import { ConnectorInfoControl } from
'./connector-info-control/connector-info-control.component';
+import { ConnectorEntity } from '@nifi/shared';
+
+@Component({
+ selector: 'connector-info-control',
+ standalone: true,
+ imports: [CommonModule],
+ template: ''
+})
+class MockConnectorInfoControl {
+ connectorEntity = input<ConnectorEntity | null>(null);
+ entitySaving = input<boolean>(false);
+}
+
+async function setup(inputs: { connectorEntity?: ConnectorEntity | null;
entitySaving?: boolean } = {}) {
+ await TestBed.configureTestingModule({
+ imports: [ConnectorGraphControls, NoopAnimationsModule]
+ })
+ .overrideComponent(ConnectorGraphControls, {
+ remove: { imports: [ConnectorInfoControl] },
+ add: { imports: [MockConnectorInfoControl] }
+ })
+ .compileComponents();
+
+ const fixture: ComponentFixture<ConnectorGraphControls> =
TestBed.createComponent(ConnectorGraphControls);
+ fixture.componentRef.setInput('connectorEntity', inputs.connectorEntity ??
null);
+ fixture.componentRef.setInput('entitySaving', inputs.entitySaving ??
false);
+ fixture.detectChanges();
+
+ return { fixture, component: fixture.componentInstance };
+}
+
+describe('ConnectorGraphControls', () => {
+ it('should create', async () => {
+ const { component } = await setup();
+ expect(component).toBeTruthy();
+ });
+
+ it('should render the connector-info-control child component', async () =>
{
+ const { fixture } = await setup();
+ const infoControl =
fixture.nativeElement.querySelector('connector-info-control');
+ expect(infoControl).toBeTruthy();
+ });
+});
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-graph-controls.component.ts
similarity index 58%
copy from
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
copy to
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-graph-controls.component.ts
index 7a083b21f75..a04443a6d34 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-graph-controls.component.ts
@@ -15,21 +15,18 @@
* limitations under the License.
*/
-import { createAction, props } from '@ngrx/store';
+import { Component, input } from '@angular/core';
import { ConnectorEntity } from '@nifi/shared';
+import { ConnectorInfoControl } from
'./connector-info-control/connector-info-control.component';
-const PREFIX = '[Connector Canvas Entity]';
-
-export const loadConnectorEntity = createAction(`${PREFIX} Load Connector
Entity`, props<{ connectorId: string }>());
-
-export const loadConnectorEntitySuccess = createAction(
- `${PREFIX} Load Connector Entity Success`,
- props<{ connectorEntity: ConnectorEntity }>()
-);
-
-export const loadConnectorEntityFailure = createAction(
- `${PREFIX} Load Connector Entity Failure`,
- props<{ error: string }>()
-);
-
-export const resetConnectorCanvasEntityState = createAction(`${PREFIX} Reset
State`);
+@Component({
+ selector: 'connector-graph-controls',
+ standalone: true,
+ imports: [ConnectorInfoControl],
+ templateUrl: './connector-graph-controls.component.html',
+ styleUrls: ['./connector-graph-controls.component.scss']
+})
+export class ConnectorGraphControls {
+ connectorEntity = input<ConnectorEntity | null>(null);
+ entitySaving = input<boolean>(false);
+}
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-info-control/connector-info-control.component.html
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-info-control/connector-info-control.component.html
new file mode 100644
index 00000000000..6a3b3661315
--- /dev/null
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-info-control/connector-info-control.component.html
@@ -0,0 +1,110 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<mat-expansion-panel
+ [hideToggle]="true"
+ [expanded]="!connectorCollapsed"
+ (opened)="toggleCollapsed(false)"
+ (closed)="toggleCollapsed(true)">
+ <mat-expansion-panel-header>
+ <mat-panel-title>
+ <div class="flex items-center gap-x-2">
+ <div class="w-5 fa fa-plug primary-color"></div>
+ <div>Connector</div>
+ </div>
+ </mat-panel-title>
+ </mat-expansion-panel-header>
+ <div class="connector-info-control flex flex-col gap-y-2">
+ @if (connectorEntity(); as entity) {
+ <connector-detail-header [connector]="entity"
[condensed]="true"></connector-detail-header>
+ <div class="flex items-center gap-x-1">
+ @if (canRead()) {
+ <button
+ mat-icon-button
+ class="primary-icon-button"
+ type="button"
+ matTooltip="Details"
+ aria-label="Details"
+ data-qa="connector-panel-view-details"
+ (click)="viewDetails()">
+ <i class="fa fa-info-circle"></i>
+ </button>
+ }
+ @if (showConfigureButton()) {
+ <button
+ mat-icon-button
+ class="primary-icon-button"
+ type="button"
+ [disabled]="!canConfigure()"
+ [matTooltip]="canConfigure() ? 'Configure' :
getConfigureDisabledReason()"
+ aria-label="Configure"
+ data-qa="connector-panel-configure"
+ (click)="configureConnector()">
+ <i class="fa fa-cog"></i>
+ </button>
+ }
+ @if (showOperateButtons()) {
+ <button
+ mat-icon-button
+ class="primary-icon-button"
+ type="button"
+ [disabled]="!canStart()"
+ [matTooltip]="canStart() ? 'Start' :
getStartDisabledReason()"
+ aria-label="Start"
+ data-qa="connector-panel-start"
+ (click)="startConnector()">
+ <i class="fa fa-play"></i>
+ </button>
+ <button
+ mat-icon-button
+ class="primary-icon-button"
+ type="button"
+ [disabled]="!canStop()"
+ [matTooltip]="canStop() ? 'Stop' :
getStopDisabledReason()"
+ aria-label="Stop"
+ data-qa="connector-panel-stop"
+ (click)="stopConnector()">
+ <i class="fa fa-stop"></i>
+ </button>
+ }
+ </div>
+ @if (showDrain() || showCancelDrain()) {
+ <div class="flex gap-1 flex-wrap">
+ @if (showDrain()) {
+ <button
+ mat-stroked-button
+ type="button"
+ [disabled]="!canDrain()"
+ data-qa="connector-panel-drain"
+ (click)="drainConnector()">
+ Drain
+ </button>
+ } @else if (showCancelDrain()) {
+ <button
+ mat-stroked-button
+ type="button"
+ [disabled]="!canCancelDrain()"
+ data-qa="connector-panel-cancel-drain"
+ (click)="cancelDrain()">
+ Cancel Drain
+ </button>
+ }
+ </div>
+ }
+ }
+ </div>
+</mat-expansion-panel>
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-info-control/connector-info-control.component.scss
similarity index 55%
copy from
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
copy to
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-info-control/connector-info-control.component.scss
index 7a083b21f75..2944f981947 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-info-control/connector-info-control.component.scss
@@ -14,22 +14,3 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-import { createAction, props } from '@ngrx/store';
-import { ConnectorEntity } from '@nifi/shared';
-
-const PREFIX = '[Connector Canvas Entity]';
-
-export const loadConnectorEntity = createAction(`${PREFIX} Load Connector
Entity`, props<{ connectorId: string }>());
-
-export const loadConnectorEntitySuccess = createAction(
- `${PREFIX} Load Connector Entity Success`,
- props<{ connectorEntity: ConnectorEntity }>()
-);
-
-export const loadConnectorEntityFailure = createAction(
- `${PREFIX} Load Connector Entity Failure`,
- props<{ error: string }>()
-);
-
-export const resetConnectorCanvasEntityState = createAction(`${PREFIX} Reset
State`);
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-info-control/connector-info-control.component.spec.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-info-control/connector-info-control.component.spec.ts
new file mode 100644
index 00000000000..757137e0fa6
--- /dev/null
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-info-control/connector-info-control.component.spec.ts
@@ -0,0 +1,601 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { NoopAnimationsModule } from '@angular/platform-browser/animations';
+import { provideMockStore, MockStore } from '@ngrx/store/testing';
+import { ConnectorInfoControl } from './connector-info-control.component';
+import { ConnectorEntity, ConnectorStatus, Storage } from '@nifi/shared';
+import * as ConnectorCanvasEntityActions from
'../../../../state/connector-canvas-entity/connector-canvas-entity.actions';
+import {
+ navigateToViewConnectorDetails,
+ navigateToConfigureConnector
+} from '../../../../state/connectors-listing/connectors-listing.actions';
+
+function createMockConnectorEntity(overrides: Partial<ConnectorEntity> = {}):
ConnectorEntity {
+ return {
+ id: 'connector-1',
+ uri: '/api/connectors/connector-1',
+ revision: { version: 0 },
+ permissions: { canRead: true, canWrite: true },
+ operatePermissions: { canRead: true, canWrite: true },
+ bulletins: [],
+ status: {} as ConnectorStatus,
+ component: {
+ id: 'connector-1',
+ name: 'Test Connector',
+ type: 'org.apache.nifi.TestConnector',
+ state: 'RUNNING',
+ bundle: { group: 'org.apache.nifi', artifact: 'nifi-test-nar',
version: '1.0.0' },
+ availableActions: [
+ { name: 'DRAIN_FLOWFILES', description: 'Drain', allowed: true
},
+ { name: 'CANCEL_DRAIN_FLOWFILES', description: 'Cancel drain',
allowed: false },
+ { name: 'DISCARD_WORKING_CONFIGURATION', description:
'Discard', allowed: false },
+ { name: 'CONFIGURE', description: 'Configure', allowed: true },
+ { name: 'START', description: 'Start', allowed: false,
reasonNotAllowed: 'Already running' },
+ { name: 'STOP', description: 'Stop', allowed: true }
+ ],
+ managedProcessGroupId: 'pg-1'
+ },
+ ...overrides
+ };
+}
+
+interface SetupOptions {
+ connectorEntity?: ConnectorEntity | null;
+ entitySaving?: boolean;
+ storedVisibility?: { [key: string]: boolean } | null;
+}
+
+async function setup(options: SetupOptions = {}) {
+ const mockStorage = {
+ getItem: vi.fn().mockReturnValue(options.storedVisibility ?? null),
+ setItem: vi.fn(),
+ removeItem: vi.fn(),
+ hasItem: vi.fn().mockReturnValue(false),
+ getItemExpiration: vi.fn().mockReturnValue(null)
+ };
+
+ await TestBed.configureTestingModule({
+ imports: [ConnectorInfoControl, NoopAnimationsModule],
+ providers: [provideMockStore(), { provide: Storage, useValue:
mockStorage }]
+ }).compileComponents();
+
+ const store = TestBed.inject(MockStore);
+ const dispatchSpy = vi.spyOn(store, 'dispatch');
+ const fixture: ComponentFixture<ConnectorInfoControl> =
TestBed.createComponent(ConnectorInfoControl);
+ const component = fixture.componentInstance;
+
+ fixture.componentRef.setInput('connectorEntity', options.connectorEntity
?? null);
+ fixture.componentRef.setInput('entitySaving', options.entitySaving ??
false);
+
+ fixture.detectChanges();
+
+ return { fixture, component, store, dispatchSpy, mockStorage };
+}
+
+describe('ConnectorInfoControl', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ describe('Component initialization', () => {
+ it('should create', async () => {
+ const { component } = await setup();
+ expect(component).toBeTruthy();
+ });
+
+ it('should default to expanded state', async () => {
+ const { component } = await setup();
+ expect(component.connectorCollapsed).toBe(false);
+ });
+
+ it('should restore collapsed state from storage', async () => {
+ const { component } = await setup({
+ storedVisibility: { 'connector-info-control': false }
+ });
+ expect(component.connectorCollapsed).toBe(true);
+ });
+
+ it('should remain expanded when stored state indicates visible', async
() => {
+ const { component } = await setup({
+ storedVisibility: { 'connector-info-control': true }
+ });
+ expect(component.connectorCollapsed).toBe(false);
+ });
+ });
+
+ describe('Connector info display', () => {
+ it('should render the connector-detail-header when entity is
provided', async () => {
+ const entity = createMockConnectorEntity();
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const header =
fixture.nativeElement.querySelector('connector-detail-header');
+ expect(header).toBeTruthy();
+ });
+
+ it('should display connector name via connector-detail-header', async
() => {
+ const entity = createMockConnectorEntity();
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const name =
fixture.nativeElement.querySelector('[data-qa="connector-name"]');
+ expect(name).toBeTruthy();
+ expect(name.textContent.trim()).toBe('Test Connector');
+ });
+
+ it('should display connector state badge via connector-detail-header',
async () => {
+ const entity = createMockConnectorEntity();
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const badge =
fixture.nativeElement.querySelector('[data-qa="connector-state"]');
+ expect(badge).toBeTruthy();
+ });
+
+ it('should display simple connector type via connector-detail-header',
async () => {
+ const entity = createMockConnectorEntity();
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const type =
fixture.nativeElement.querySelector('[data-qa="connector-type"]');
+ expect(type).toBeTruthy();
+ expect(type.textContent.trim()).toBe('TestConnector');
+ });
+
+ it('should not render content when connectorEntity is null', async ()
=> {
+ const { fixture } = await setup({ connectorEntity: null });
+
+ const header =
fixture.nativeElement.querySelector('connector-detail-header');
+ expect(header).toBeNull();
+ });
+ });
+
+ describe('View details action', () => {
+ it('should show view details button when canRead is true', async () =>
{
+ const entity = createMockConnectorEntity();
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-view-details"]');
+ expect(button).toBeTruthy();
+ expect(button.getAttribute('aria-label')).toBe('Details');
+ });
+
+ it('should not show view details button when canRead is false', async
() => {
+ const entity = createMockConnectorEntity({
+ permissions: { canRead: false, canWrite: false }
+ });
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-view-details"]');
+ expect(button).toBeNull();
+ });
+
+ it('should dispatch navigateToViewConnectorDetails when clicked',
async () => {
+ const entity = createMockConnectorEntity();
+ const { fixture, dispatchSpy } = await setup({ connectorEntity:
entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-view-details"]');
+ button.click();
+
+
expect(dispatchSpy).toHaveBeenCalledWith(navigateToViewConnectorDetails({ id:
entity.id }));
+ });
+ });
+
+ describe('Configure action', () => {
+ it('should show configure button when canRead and canModify', async ()
=> {
+ const entity = createMockConnectorEntity();
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-configure"]');
+ expect(button).toBeTruthy();
+ expect(button.getAttribute('aria-label')).toBe('Configure');
+ });
+
+ it('should not show configure button when canModify is false', async
() => {
+ const entity = createMockConnectorEntity({
+ permissions: { canRead: true, canWrite: false }
+ });
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-configure"]');
+ expect(button).toBeNull();
+ });
+
+ it('should disable configure button when CONFIGURE action is not
allowed', async () => {
+ const entity = createMockConnectorEntity({
+ component: {
+ ...createMockConnectorEntity().component,
+ availableActions: [
+ { name: 'DRAIN_FLOWFILES', description: 'Drain',
allowed: true },
+ { name: 'CANCEL_DRAIN_FLOWFILES', description:
'Cancel', allowed: false },
+ { name: 'DISCARD_WORKING_CONFIGURATION', description:
'Discard', allowed: false },
+ {
+ name: 'CONFIGURE',
+ description: 'Configure',
+ allowed: false,
+ reasonNotAllowed: 'Connector is running'
+ }
+ ]
+ }
+ });
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-configure"]');
+ expect(button).toBeTruthy();
+ expect(button.disabled).toBe(true);
+ });
+
+ it('should dispatch navigateToConfigureConnector when clicked', async
() => {
+ const entity = createMockConnectorEntity();
+ const { fixture, dispatchSpy } = await setup({ connectorEntity:
entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-configure"]');
+ button.click();
+
+ expect(dispatchSpy).toHaveBeenCalledWith(
+ navigateToConfigureConnector({ request: { id: entity.id,
connector: entity } })
+ );
+ });
+ });
+
+ describe('Drain action', () => {
+ it('should show drain button when canDrain is true', async () => {
+ const entity = createMockConnectorEntity();
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-drain"]');
+ expect(button).toBeTruthy();
+ expect(button.textContent).toContain('Drain');
+ });
+
+ it('should not show drain button when DRAIN_FLOWFILES is not allowed',
async () => {
+ const entity = createMockConnectorEntity({
+ component: {
+ ...createMockConnectorEntity().component,
+ availableActions: [
+ { name: 'DRAIN_FLOWFILES', description: 'Drain',
allowed: false },
+ { name: 'CANCEL_DRAIN_FLOWFILES', description:
'Cancel', allowed: false },
+ { name: 'DISCARD_WORKING_CONFIGURATION', description:
'Discard', allowed: false },
+ { name: 'CONFIGURE', description: 'Configure',
allowed: true }
+ ]
+ }
+ });
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-drain"]');
+ expect(button).toBeNull();
+ });
+
+ it('should render but disable drain button when entity is saving',
async () => {
+ const entity = createMockConnectorEntity();
+ const { fixture } = await setup({ connectorEntity: entity,
entitySaving: true });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-drain"]');
+ expect(button).toBeTruthy();
+ expect(button.disabled).toBe(true);
+ });
+
+ it('should dispatch promptDrainConnector when drain button is
clicked', async () => {
+ const entity = createMockConnectorEntity();
+ const { fixture, dispatchSpy } = await setup({ connectorEntity:
entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-drain"]');
+ button.click();
+
+ expect(dispatchSpy).toHaveBeenCalledWith(
+ ConnectorCanvasEntityActions.promptDrainConnector({ connector:
entity })
+ );
+ });
+
+ it('showDrain should remain true while entity is saving so the button
stays mounted', async () => {
+ const entity = createMockConnectorEntity();
+ const { component } = await setup({ connectorEntity: entity,
entitySaving: true });
+
+ expect(component.showDrain()).toBe(true);
+ });
+
+ it('canDrain should be false while entity is saving', async () => {
+ const entity = createMockConnectorEntity();
+ const { component } = await setup({ connectorEntity: entity,
entitySaving: true });
+
+ expect(component.canDrain()).toBe(false);
+ });
+ });
+
+ describe('Cancel drain action', () => {
+ it('should show cancel drain button when canCancelDrain is true',
async () => {
+ const entity = createMockConnectorEntity({
+ component: {
+ ...createMockConnectorEntity().component,
+ availableActions: [
+ { name: 'DRAIN_FLOWFILES', description: 'Drain',
allowed: false },
+ { name: 'CANCEL_DRAIN_FLOWFILES', description: 'Cancel
drain', allowed: true },
+ { name: 'DISCARD_WORKING_CONFIGURATION', description:
'Discard', allowed: false },
+ { name: 'CONFIGURE', description: 'Configure',
allowed: true }
+ ]
+ }
+ });
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-cancel-drain"]');
+ expect(button).toBeTruthy();
+ expect(button.textContent).toContain('Cancel Drain');
+ });
+
+ it('should not show cancel drain button when CANCEL_DRAIN_FLOWFILES is
not allowed', async () => {
+ const entity = createMockConnectorEntity();
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-cancel-drain"]');
+ expect(button).toBeNull();
+ });
+
+ it('should render but disable cancel drain button when entity is
saving', async () => {
+ const entity = createMockConnectorEntity({
+ component: {
+ ...createMockConnectorEntity().component,
+ availableActions: [
+ { name: 'DRAIN_FLOWFILES', description: 'Drain',
allowed: false },
+ { name: 'CANCEL_DRAIN_FLOWFILES', description: 'Cancel
drain', allowed: true },
+ { name: 'DISCARD_WORKING_CONFIGURATION', description:
'Discard', allowed: false },
+ { name: 'CONFIGURE', description: 'Configure',
allowed: true },
+ { name: 'START', description: 'Start', allowed: false,
reasonNotAllowed: 'Already running' },
+ { name: 'STOP', description: 'Stop', allowed: true }
+ ]
+ }
+ });
+ const { fixture } = await setup({ connectorEntity: entity,
entitySaving: true });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-cancel-drain"]');
+ expect(button).toBeTruthy();
+ expect(button.disabled).toBe(true);
+ });
+
+ it('should dispatch cancelConnectorDrain when cancel drain button is
clicked', async () => {
+ const entity = createMockConnectorEntity({
+ component: {
+ ...createMockConnectorEntity().component,
+ availableActions: [
+ { name: 'DRAIN_FLOWFILES', description: 'Drain',
allowed: false },
+ { name: 'CANCEL_DRAIN_FLOWFILES', description: 'Cancel
drain', allowed: true },
+ { name: 'DISCARD_WORKING_CONFIGURATION', description:
'Discard', allowed: false },
+ { name: 'CONFIGURE', description: 'Configure',
allowed: true }
+ ]
+ }
+ });
+ const { fixture, dispatchSpy } = await setup({ connectorEntity:
entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-cancel-drain"]');
+ button.click();
+
+ expect(dispatchSpy).toHaveBeenCalledWith(
+ ConnectorCanvasEntityActions.cancelConnectorDrain({ connector:
entity })
+ );
+ });
+
+ it('showCancelDrain should remain true while entity is saving so the
button stays mounted', async () => {
+ const entity = createMockConnectorEntity({
+ component: {
+ ...createMockConnectorEntity().component,
+ availableActions: [
+ { name: 'DRAIN_FLOWFILES', description: 'Drain',
allowed: false },
+ { name: 'CANCEL_DRAIN_FLOWFILES', description: 'Cancel
drain', allowed: true },
+ { name: 'DISCARD_WORKING_CONFIGURATION', description:
'Discard', allowed: false },
+ { name: 'CONFIGURE', description: 'Configure',
allowed: true }
+ ]
+ }
+ });
+ const { component } = await setup({ connectorEntity: entity,
entitySaving: true });
+
+ expect(component.showCancelDrain()).toBe(true);
+ });
+
+ it('canCancelDrain should be false while entity is saving', async ()
=> {
+ const entity = createMockConnectorEntity({
+ component: {
+ ...createMockConnectorEntity().component,
+ availableActions: [
+ { name: 'DRAIN_FLOWFILES', description: 'Drain',
allowed: false },
+ { name: 'CANCEL_DRAIN_FLOWFILES', description: 'Cancel
drain', allowed: true },
+ { name: 'DISCARD_WORKING_CONFIGURATION', description:
'Discard', allowed: false },
+ { name: 'CONFIGURE', description: 'Configure',
allowed: true }
+ ]
+ }
+ });
+ const { component } = await setup({ connectorEntity: entity,
entitySaving: true });
+
+ expect(component.canCancelDrain()).toBe(false);
+ });
+ });
+
+ describe('No operate permissions', () => {
+ it('should not show drain button when user lacks operate permissions',
async () => {
+ const entity = createMockConnectorEntity({
+ permissions: { canRead: true, canWrite: false },
+ operatePermissions: { canRead: true, canWrite: false }
+ });
+ const { fixture } = await setup({ connectorEntity: entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-drain"]');
+ expect(button).toBeNull();
+ });
+
+ it('should not show start/stop buttons when user lacks operate
permissions', async () => {
+ const entity = createMockConnectorEntity({
+ permissions: { canRead: true, canWrite: false },
+ operatePermissions: { canRead: true, canWrite: false }
+ });
+ const { fixture } = await setup({ connectorEntity: entity });
+
+
expect(fixture.nativeElement.querySelector('[data-qa="connector-panel-start"]')).toBeNull();
+
expect(fixture.nativeElement.querySelector('[data-qa="connector-panel-stop"]')).toBeNull();
+ });
+ });
+
+ describe('Start action', () => {
+ function runningEntity(): ConnectorEntity {
+ return createMockConnectorEntity();
+ }
+
+ function stoppedEntity(): ConnectorEntity {
+ return createMockConnectorEntity({
+ component: {
+ ...createMockConnectorEntity().component,
+ state: 'STOPPED',
+ availableActions: [
+ { name: 'DRAIN_FLOWFILES', description: 'Drain',
allowed: false },
+ { name: 'CANCEL_DRAIN_FLOWFILES', description:
'Cancel', allowed: false },
+ { name: 'DISCARD_WORKING_CONFIGURATION', description:
'Discard', allowed: false },
+ { name: 'CONFIGURE', description: 'Configure',
allowed: true },
+ { name: 'START', description: 'Start', allowed: true },
+ { name: 'STOP', description: 'Stop', allowed: false,
reasonNotAllowed: 'Not running' }
+ ]
+ }
+ });
+ }
+
+ it('should render start button when operate permissions are granted',
async () => {
+ const { fixture } = await setup({ connectorEntity: runningEntity()
});
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-start"]');
+ expect(button).toBeTruthy();
+ expect(button.getAttribute('aria-label')).toBe('Start');
+ });
+
+ it('should enable start button when START is allowed', async () => {
+ const { fixture } = await setup({ connectorEntity: stoppedEntity()
});
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-start"]');
+ expect(button.disabled).toBe(false);
+ });
+
+ it('should disable start button when START is not allowed', async ()
=> {
+ const { fixture } = await setup({ connectorEntity: runningEntity()
});
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-start"]');
+ expect(button.disabled).toBe(true);
+ });
+
+ it('should disable start button when entity is saving', async () => {
+ const { fixture } = await setup({ connectorEntity:
stoppedEntity(), entitySaving: true });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-start"]');
+ expect(button.disabled).toBe(true);
+ });
+
+ it('should dispatch startConnector when start button is clicked',
async () => {
+ const entity = stoppedEntity();
+ const { fixture, dispatchSpy } = await setup({ connectorEntity:
entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-start"]');
+ button.click();
+
+ expect(dispatchSpy).toHaveBeenCalledWith(
+ ConnectorCanvasEntityActions.startConnector({ connector:
entity })
+ );
+ });
+ });
+
+ describe('Stop action', () => {
+ function runningEntity(): ConnectorEntity {
+ return createMockConnectorEntity();
+ }
+
+ function stoppedEntity(): ConnectorEntity {
+ return createMockConnectorEntity({
+ component: {
+ ...createMockConnectorEntity().component,
+ state: 'STOPPED',
+ availableActions: [
+ { name: 'DRAIN_FLOWFILES', description: 'Drain',
allowed: false },
+ { name: 'CANCEL_DRAIN_FLOWFILES', description:
'Cancel', allowed: false },
+ { name: 'DISCARD_WORKING_CONFIGURATION', description:
'Discard', allowed: false },
+ { name: 'CONFIGURE', description: 'Configure',
allowed: true },
+ { name: 'START', description: 'Start', allowed: true },
+ { name: 'STOP', description: 'Stop', allowed: false,
reasonNotAllowed: 'Not running' }
+ ]
+ }
+ });
+ }
+
+ it('should render stop button when operate permissions are granted',
async () => {
+ const { fixture } = await setup({ connectorEntity: runningEntity()
});
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-stop"]');
+ expect(button).toBeTruthy();
+ expect(button.getAttribute('aria-label')).toBe('Stop');
+ });
+
+ it('should enable stop button when STOP is allowed', async () => {
+ const { fixture } = await setup({ connectorEntity: runningEntity()
});
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-stop"]');
+ expect(button.disabled).toBe(false);
+ });
+
+ it('should disable stop button when STOP is not allowed', async () => {
+ const { fixture } = await setup({ connectorEntity: stoppedEntity()
});
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-stop"]');
+ expect(button.disabled).toBe(true);
+ });
+
+ it('should disable stop button when entity is saving', async () => {
+ const { fixture } = await setup({ connectorEntity:
runningEntity(), entitySaving: true });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-stop"]');
+ expect(button.disabled).toBe(true);
+ });
+
+ it('should dispatch stopConnector when stop button is clicked', async
() => {
+ const entity = runningEntity();
+ const { fixture, dispatchSpy } = await setup({ connectorEntity:
entity });
+
+ const button =
fixture.nativeElement.querySelector('[data-qa="connector-panel-stop"]');
+ button.click();
+
+
expect(dispatchSpy).toHaveBeenCalledWith(ConnectorCanvasEntityActions.stopConnector({
connector: entity }));
+ });
+ });
+
+ describe('Collapse persistence', () => {
+ it('should save collapsed state to Storage under the
graph-control-visibility key', async () => {
+ const { component, mockStorage } = await setup();
+
+ component.toggleCollapsed(true);
+
+
expect(mockStorage.setItem).toHaveBeenCalledWith('graph-control-visibility', {
+ 'connector-info-control': false
+ });
+ });
+
+ it('should preserve sibling control keys when toggling visibility',
async () => {
+ const { component, mockStorage } = await setup({
+ storedVisibility: { 'other-control': true,
'connector-info-control': true }
+ });
+ mockStorage.getItem.mockReturnValue({ 'other-control': true,
'connector-info-control': true });
+
+ component.toggleCollapsed(true);
+
+ expect(mockStorage.setItem).toHaveBeenCalledWith(
+ 'graph-control-visibility',
+ expect.objectContaining({
+ 'other-control': true,
+ 'connector-info-control': false
+ })
+ );
+ });
+ });
+});
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-info-control/connector-info-control.component.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-info-control/connector-info-control.component.ts
new file mode 100644
index 00000000000..5e25d700778
--- /dev/null
+++
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-info-control/connector-info-control.component.ts
@@ -0,0 +1,229 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Component, inject, input } from '@angular/core';
+import { MatButtonModule } from '@angular/material/button';
+import { MatExpansionPanel, MatExpansionPanelHeader, MatExpansionPanelTitle }
from '@angular/material/expansion';
+import { MatTooltip } from '@angular/material/tooltip';
+import { Store } from '@ngrx/store';
+import {
+ ConnectorDetailHeader,
+ ConnectorEntity,
+ Storage,
+ canReadConnector,
+ canModifyConnector,
+ canOperateConnector,
+ isConnectorActionAllowed,
+ getConnectorActionDisabledReason
+} from '@nifi/shared';
+import * as ConnectorCanvasEntityActions from
'../../../../state/connector-canvas-entity/connector-canvas-entity.actions';
+import {
+ navigateToViewConnectorDetails,
+ navigateToConfigureConnector
+} from '../../../../state/connectors-listing/connectors-listing.actions';
+
+@Component({
+ selector: 'connector-info-control',
+ standalone: true,
+ imports: [
+ ConnectorDetailHeader,
+ MatButtonModule,
+ MatExpansionPanel,
+ MatExpansionPanelHeader,
+ MatExpansionPanelTitle,
+ MatTooltip
+ ],
+ templateUrl: './connector-info-control.component.html',
+ styleUrls: ['./connector-info-control.component.scss']
+})
+export class ConnectorInfoControl {
+ private store = inject(Store);
+ private storage = inject(Storage);
+
+ private static readonly CONTROL_VISIBILITY_KEY =
'graph-control-visibility';
+ private static readonly CONNECTOR_KEY = 'connector-info-control';
+
+ connectorCollapsed = false;
+
+ connectorEntity = input<ConnectorEntity | null>(null);
+ entitySaving = input<boolean>(false);
+
+ constructor() {
+ try {
+ const item: { [key: string]: boolean } | null =
this.storage.getItem(
+ ConnectorInfoControl.CONTROL_VISIBILITY_KEY
+ );
+ if (item) {
+ this.connectorCollapsed =
item[ConnectorInfoControl.CONNECTOR_KEY] === false;
+ }
+ } catch (_e) {
+ // likely could not parse item... ignoring
+ }
+ }
+
+ toggleCollapsed(collapsed: boolean): void {
+ this.connectorCollapsed = collapsed;
+
+ let item: { [key: string]: boolean } | null =
this.storage.getItem(ConnectorInfoControl.CONTROL_VISIBILITY_KEY);
+ if (item == null) {
+ item = {};
+ }
+
+ item[ConnectorInfoControl.CONNECTOR_KEY] = !this.connectorCollapsed;
+ this.storage.setItem(ConnectorInfoControl.CONTROL_VISIBILITY_KEY,
item);
+ }
+
+ canRead(): boolean {
+ const entity = this.connectorEntity();
+ return !!entity && canReadConnector(entity);
+ }
+
+ canConfigure(): boolean {
+ const entity = this.connectorEntity();
+ if (!entity || this.entitySaving()) {
+ return false;
+ }
+ return canReadConnector(entity) && canModifyConnector(entity) &&
isConnectorActionAllowed(entity, 'CONFIGURE');
+ }
+
+ getConfigureDisabledReason(): string {
+ const entity = this.connectorEntity();
+ if (!entity) {
+ return '';
+ }
+ return getConnectorActionDisabledReason(entity, 'CONFIGURE');
+ }
+
+ showConfigureButton(): boolean {
+ const entity = this.connectorEntity();
+ if (!entity) {
+ return false;
+ }
+ return canReadConnector(entity) && canModifyConnector(entity);
+ }
+
+ showDrain(): boolean {
+ const entity = this.connectorEntity();
+ if (!entity) {
+ return false;
+ }
+ return canOperateConnector(entity) && isConnectorActionAllowed(entity,
'DRAIN_FLOWFILES');
+ }
+
+ showCancelDrain(): boolean {
+ const entity = this.connectorEntity();
+ if (!entity) {
+ return false;
+ }
+ return canOperateConnector(entity) && isConnectorActionAllowed(entity,
'CANCEL_DRAIN_FLOWFILES');
+ }
+
+ canDrain(): boolean {
+ const entity = this.connectorEntity();
+ if (!entity || this.entitySaving()) {
+ return false;
+ }
+ return canOperateConnector(entity) && isConnectorActionAllowed(entity,
'DRAIN_FLOWFILES');
+ }
+
+ canCancelDrain(): boolean {
+ const entity = this.connectorEntity();
+ if (!entity || this.entitySaving()) {
+ return false;
+ }
+ return canOperateConnector(entity) && isConnectorActionAllowed(entity,
'CANCEL_DRAIN_FLOWFILES');
+ }
+
+ showOperateButtons(): boolean {
+ const entity = this.connectorEntity();
+ return !!entity && canOperateConnector(entity);
+ }
+
+ canStart(): boolean {
+ const entity = this.connectorEntity();
+ if (!entity || this.entitySaving()) {
+ return false;
+ }
+ return canOperateConnector(entity) && isConnectorActionAllowed(entity,
'START');
+ }
+
+ getStartDisabledReason(): string {
+ const entity = this.connectorEntity();
+ if (!entity) {
+ return '';
+ }
+ return getConnectorActionDisabledReason(entity, 'START');
+ }
+
+ canStop(): boolean {
+ const entity = this.connectorEntity();
+ if (!entity || this.entitySaving()) {
+ return false;
+ }
+ return canOperateConnector(entity) && isConnectorActionAllowed(entity,
'STOP');
+ }
+
+ getStopDisabledReason(): string {
+ const entity = this.connectorEntity();
+ if (!entity) {
+ return '';
+ }
+ return getConnectorActionDisabledReason(entity, 'STOP');
+ }
+
+ viewDetails(): void {
+ const entity = this.connectorEntity();
+ if (entity) {
+ this.store.dispatch(navigateToViewConnectorDetails({ id: entity.id
}));
+ }
+ }
+
+ configureConnector(): void {
+ const entity = this.connectorEntity();
+ if (entity) {
+ this.store.dispatch(navigateToConfigureConnector({ request: { id:
entity.id, connector: entity } }));
+ }
+ }
+
+ drainConnector(): void {
+ const entity = this.connectorEntity();
+ if (entity) {
+
this.store.dispatch(ConnectorCanvasEntityActions.promptDrainConnector({
connector: entity }));
+ }
+ }
+
+ cancelDrain(): void {
+ const entity = this.connectorEntity();
+ if (entity) {
+
this.store.dispatch(ConnectorCanvasEntityActions.cancelConnectorDrain({
connector: entity }));
+ }
+ }
+
+ startConnector(): void {
+ const entity = this.connectorEntity();
+ if (entity) {
+ this.store.dispatch(ConnectorCanvasEntityActions.startConnector({
connector: entity }));
+ }
+ }
+
+ stopConnector(): void {
+ const entity = this.connectorEntity();
+ if (entity) {
+ this.store.dispatch(ConnectorCanvasEntityActions.stopConnector({
connector: entity }));
+ }
+ }
+}
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/error/index.ts
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/error/index.ts
index 6083af53f0b..3a236560ffb 100644
--- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/error/index.ts
+++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/error/index.ts
@@ -51,6 +51,7 @@ export enum ErrorContextKey {
LINEAGE = 'lineage',
FLOW_ANALYSIS_RULES = 'flow-analysis-rules',
CONNECTORS = 'connectors',
+ CONNECTOR_CANVAS = 'connector-canvas',
CONNECTOR_RENAME_DIALOG = 'connector-rename-dialog'
}
diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/styles.scss
b/nifi-frontend/src/main/frontend/apps/nifi/src/styles.scss
index 45641f82aa7..204e8af0bd5 100644
--- a/nifi-frontend/src/main/frontend/apps/nifi/src/styles.scss
+++ b/nifi-frontend/src/main/frontend/apps/nifi/src/styles.scss
@@ -57,6 +57,7 @@
@use
'libs/shared/src/components/map-table/editors/text-editor/text-editor.component-theme'
as text-editor;
@use
'app/ui/common/overlapping-connections-banner/overlapping-connections-banner.component-theme'
as
overlapping-connections-banner;
+@use
'app/pages/connectors/ui/connector-canvas/connector-canvas.component-theme' as
connector-canvas;
// Plus imports for other components in your app.
@use 'libs/shared/src/assets/fonts/flowfont/flowfont.css';
@@ -104,6 +105,7 @@ html {
@include text-editor.generate-theme();
@include resizable.generate-theme();
@include overlapping-connections-banner.generate-theme();
+ @include connector-canvas.generate-theme();
.darkMode {
@include app.generate-material-theme();
@@ -137,5 +139,6 @@ html {
@include text-editor.generate-theme();
@include resizable.generate-theme();
@include overlapping-connections-banner.generate-theme();
+ @include connector-canvas.generate-theme();
}
}
diff --git
a/nifi-frontend/src/main/frontend/libs/shared/src/components/connector-detail-header/connector-detail-header.component.html
b/nifi-frontend/src/main/frontend/libs/shared/src/components/connector-detail-header/connector-detail-header.component.html
new file mode 100644
index 00000000000..7ecf984d0a3
--- /dev/null
+++
b/nifi-frontend/src/main/frontend/libs/shared/src/components/connector-detail-header/connector-detail-header.component.html
@@ -0,0 +1,55 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<ng-template #badges>
+ <span
+ class="connector-state-badge text-xs font-semibold uppercase"
+ [class]="getStateColorClass(connector().component.state)"
+ data-qa="connector-state">
+ {{ connector().component.state }}
+ </span>
+ @if (hasUnappliedEdits()) {
+ <span class="caution-color text-xs font-semibold uppercase"
data-qa="edits-not-applied-badge">
+ Edits not applied
+ </span>
+ }
+</ng-template>
+
+<div
+ class="flex flex-col"
+ [class.connector-detail]="!condensed()"
+ [class.gap-y-1]="!condensed()"
+ [class.gap-y-2]="condensed()">
+ @if (condensed()) {
+ <span class="text-base font-semibold" data-qa="connector-name">
+ {{ connector().component.name }}
+ </span>
+ <div class="flex items-center gap-x-2 flex-wrap"
data-qa="connector-badges">
+ <ng-container *ngTemplateOutlet="badges"></ng-container>
+ </div>
+ } @else {
+ <div class="flex items-center flex-wrap gap-x-3">
+ <h3 class="detail-title" data-qa="connector-name">
+ {{ connector().component.name }}
+ </h3>
+ <ng-container *ngTemplateOutlet="badges"></ng-container>
+ </div>
+ }
+ <div class="tertiary-color" [class.text-sm]="condensed()"
data-qa="connector-type">
+ {{ simpleType() }}
+ </div>
+</div>
diff --git
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
b/nifi-frontend/src/main/frontend/libs/shared/src/components/connector-detail-header/connector-detail-header.component.scss
similarity index 55%
copy from
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
copy to
nifi-frontend/src/main/frontend/libs/shared/src/components/connector-detail-header/connector-detail-header.component.scss
index 7a083b21f75..80a222ec026 100644
---
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connector-canvas-entity/connector-canvas-entity.actions.ts
+++
b/nifi-frontend/src/main/frontend/libs/shared/src/components/connector-detail-header/connector-detail-header.component.scss
@@ -15,21 +15,8 @@
* limitations under the License.
*/
-import { createAction, props } from '@ngrx/store';
-import { ConnectorEntity } from '@nifi/shared';
-
-const PREFIX = '[Connector Canvas Entity]';
-
-export const loadConnectorEntity = createAction(`${PREFIX} Load Connector
Entity`, props<{ connectorId: string }>());
-
-export const loadConnectorEntitySuccess = createAction(
- `${PREFIX} Load Connector Entity Success`,
- props<{ connectorEntity: ConnectorEntity }>()
-);
-
-export const loadConnectorEntityFailure = createAction(
- `${PREFIX} Load Connector Entity Failure`,
- props<{ error: string }>()
-);
-
-export const resetConnectorCanvasEntityState = createAction(`${PREFIX} Reset
State`);
+.connector-detail {
+ .detail-title {
+ margin: 0;
+ }
+}
diff --git
a/nifi-frontend/src/main/frontend/libs/shared/src/components/connector-detail-header/connector-detail-header.component.spec.ts
b/nifi-frontend/src/main/frontend/libs/shared/src/components/connector-detail-header/connector-detail-header.component.spec.ts
new file mode 100644
index 00000000000..65321dd24b3
--- /dev/null
+++
b/nifi-frontend/src/main/frontend/libs/shared/src/components/connector-detail-header/connector-detail-header.component.spec.ts
@@ -0,0 +1,313 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { ConnectorDetailHeader } from './connector-detail-header.component';
+import { ConnectorEntity, ConnectorState, ConnectorStatus } from '../../types';
+
+interface SetupOptions {
+ connector?: ConnectorEntity;
+ condensed?: boolean;
+}
+
+function createMockConnector(overrides: Partial<ConnectorEntity> = {}):
ConnectorEntity {
+ return {
+ id: 'test-connector-id',
+ uri: 'http://localhost:4200/nifi-api/connectors/test-connector-id',
+ permissions: {
+ canRead: true,
+ canWrite: true
+ },
+ status: {
+ runStatus: 'RUNNING',
+ validationStatus: 'VALID'
+ } as ConnectorStatus,
+ component: {
+ id: 'test-connector-id',
+ name: 'Test Connector',
+ type: 'org.apache.nifi.connector.TestConnector',
+ state: ConnectorState.RUNNING,
+ bundle: {
+ group: 'org.apache.nifi',
+ artifact: 'nifi-test-connector',
+ version: '1.0.0'
+ },
+ managedProcessGroupId: 'test-pg-id',
+ availableActions: [
+ { name: 'START', description: 'Start action', allowed: true },
+ { name: 'STOP', description: 'Stop action', allowed: true }
+ ]
+ },
+ bulletins: [],
+ revision: {
+ version: 1
+ },
+ ...overrides
+ };
+}
+
+async function setup(options: SetupOptions = {}) {
+ const connector = options.connector ?? createMockConnector();
+
+ await TestBed.configureTestingModule({
+ imports: [ConnectorDetailHeader]
+ }).compileComponents();
+
+ const fixture: ComponentFixture<ConnectorDetailHeader> =
TestBed.createComponent(ConnectorDetailHeader);
+ const component = fixture.componentInstance;
+
+ fixture.componentRef.setInput('connector', connector);
+ if (options.condensed !== undefined) {
+ fixture.componentRef.setInput('condensed', options.condensed);
+ }
+ fixture.detectChanges();
+
+ return { fixture, component, connector };
+}
+
+describe('ConnectorDetailHeader', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it('should create', async () => {
+ const { component } = await setup();
+ expect(component).toBeTruthy();
+ });
+
+ it('should display the connector name', async () => {
+ const { fixture } = await setup();
+ const nameEl =
fixture.nativeElement.querySelector('[data-qa="connector-name"]');
+ expect(nameEl.textContent.trim()).toBe('Test Connector');
+ });
+
+ it('should display the simple connector type', async () => {
+ const { fixture } = await setup();
+ const typeEl =
fixture.nativeElement.querySelector('[data-qa="connector-type"]');
+ expect(typeEl.textContent.trim()).toBe('TestConnector');
+ });
+
+ it('should display the connector state badge with the state value', async
() => {
+ const { fixture } = await setup();
+ const stateBadge =
fixture.nativeElement.querySelector('[data-qa="connector-state"]');
+ expect(stateBadge).toBeTruthy();
+ expect(stateBadge.textContent.trim()).toBe('RUNNING');
+ });
+
+ describe('getStateVariant', () => {
+ it('should return success for RUNNING', async () => {
+ const { component } = await setup();
+
expect(component.getStateVariant(ConnectorState.RUNNING)).toBe('success');
+ });
+
+ it('should return neutral for STOPPED', async () => {
+ const { component } = await setup();
+
expect(component.getStateVariant(ConnectorState.STOPPED)).toBe('neutral');
+ });
+
+ it('should return neutral for DISABLED', async () => {
+ const { component } = await setup();
+
expect(component.getStateVariant(ConnectorState.DISABLED)).toBe('neutral');
+ });
+
+ it('should return info for STARTING', async () => {
+ const { component } = await setup();
+
expect(component.getStateVariant(ConnectorState.STARTING)).toBe('info');
+ });
+
+ it('should return info for UPDATING', async () => {
+ const { component } = await setup();
+
expect(component.getStateVariant(ConnectorState.UPDATING)).toBe('info');
+ });
+
+ it('should return info for STOPPING', async () => {
+ const { component } = await setup();
+
expect(component.getStateVariant(ConnectorState.STOPPING)).toBe('info');
+ });
+
+ it('should return info for DRAINING', async () => {
+ const { component } = await setup();
+
expect(component.getStateVariant(ConnectorState.DRAINING)).toBe('info');
+ });
+
+ it('should return info for PREPARING_FOR_UPDATE', async () => {
+ const { component } = await setup();
+
expect(component.getStateVariant(ConnectorState.PREPARING_FOR_UPDATE)).toBe('info');
+ });
+
+ it('should return critical for UPDATE_FAILED', async () => {
+ const { component } = await setup();
+
expect(component.getStateVariant(ConnectorState.UPDATE_FAILED)).toBe('critical');
+ });
+
+ it('should return neutral for unknown state', async () => {
+ const { component } = await setup();
+ expect(component.getStateVariant('UNKNOWN')).toBe('neutral');
+ });
+ });
+
+ describe('getStateColorClass', () => {
+ it('should map success variant to success-color-default', async () => {
+ const { component } = await setup();
+
expect(component.getStateColorClass(ConnectorState.RUNNING)).toBe('success-color-default');
+ });
+
+ it('should map neutral variant to neutral-color', async () => {
+ const { component } = await setup();
+
expect(component.getStateColorClass(ConnectorState.STOPPED)).toBe('neutral-color');
+ });
+
+ it('should map info variant to primary-color', async () => {
+ const { component } = await setup();
+
expect(component.getStateColorClass(ConnectorState.STARTING)).toBe('primary-color');
+ });
+
+ it('should map critical variant to error-color', async () => {
+ const { component } = await setup();
+
expect(component.getStateColorClass(ConnectorState.UPDATE_FAILED)).toBe('error-color');
+ });
+ });
+
+ describe('hasUnappliedEdits', () => {
+ it('should return false when no DISCARD_WORKING_CONFIGURATION action
exists', async () => {
+ const { component } = await setup();
+ expect(component.hasUnappliedEdits()).toBe(false);
+ });
+
+ it('should return true when DISCARD_WORKING_CONFIGURATION action is
allowed', async () => {
+ const connector = createMockConnector({
+ component: {
+ ...createMockConnector().component,
+ availableActions: [{ name:
'DISCARD_WORKING_CONFIGURATION', description: 'Discard', allowed: true }]
+ }
+ });
+ const { component } = await setup({ connector });
+ expect(component.hasUnappliedEdits()).toBe(true);
+ });
+
+ it('should return false when DISCARD_WORKING_CONFIGURATION action is
not allowed', async () => {
+ const connector = createMockConnector({
+ component: {
+ ...createMockConnector().component,
+ availableActions: [
+ { name: 'DISCARD_WORKING_CONFIGURATION', description:
'Discard', allowed: false }
+ ]
+ }
+ });
+ const { component } = await setup({ connector });
+ expect(component.hasUnappliedEdits()).toBe(false);
+ });
+ });
+
+ it('should show unapplied edits badge when edits are not applied', async
() => {
+ const connector = createMockConnector({
+ component: {
+ ...createMockConnector().component,
+ availableActions: [{ name: 'DISCARD_WORKING_CONFIGURATION',
description: 'Discard', allowed: true }]
+ }
+ });
+ const { fixture } = await setup({ connector });
+ const badge =
fixture.nativeElement.querySelector('[data-qa="edits-not-applied-badge"]');
+ expect(badge).toBeTruthy();
+ });
+
+ it('should not show unapplied edits badge when no unapplied edits', async
() => {
+ const { fixture } = await setup();
+ const badge =
fixture.nativeElement.querySelector('[data-qa="edits-not-applied-badge"]');
+ expect(badge).toBeNull();
+ });
+
+ describe('simpleType', () => {
+ it('should extract simple class name from fully qualified type', async
() => {
+ const { component } = await setup();
+ expect(component.simpleType()).toBe('TestConnector');
+ });
+
+ it('should handle type without package prefix', async () => {
+ const connector = createMockConnector({
+ component: {
+ ...createMockConnector().component,
+ type: 'SimpleType'
+ }
+ });
+ const { component } = await setup({ connector });
+ expect(component.simpleType()).toBe('SimpleType');
+ });
+
+ it('should handle empty type', async () => {
+ const connector = createMockConnector({
+ component: {
+ ...createMockConnector().component,
+ type: ''
+ }
+ });
+ const { component } = await setup({ connector });
+ expect(component.simpleType()).toBe('');
+ });
+ });
+
+ describe('condensed mode', () => {
+ it('should render h3 in default mode', async () => {
+ const { fixture } = await setup();
+ const h3 =
fixture.nativeElement.querySelector('h3[data-qa="connector-name"]');
+ expect(h3).toBeTruthy();
+ });
+
+ it('should render span instead of h3 in condensed mode', async () => {
+ const { fixture } = await setup({ condensed: true });
+ const h3 =
fixture.nativeElement.querySelector('h3[data-qa="connector-name"]');
+ const span =
fixture.nativeElement.querySelector('span[data-qa="connector-name"]');
+ expect(h3).toBeNull();
+ expect(span).toBeTruthy();
+ });
+
+ it('should apply text-sm to type in condensed mode', async () => {
+ const { fixture } = await setup({ condensed: true });
+ const typeEl =
fixture.nativeElement.querySelector('[data-qa="connector-type"]');
+ expect(typeEl.classList.contains('text-sm')).toBe(true);
+ });
+
+ it('should render badges on a separate line in condensed mode', async
() => {
+ const { fixture } = await setup({ condensed: true });
+ const badgesRow =
fixture.nativeElement.querySelector('[data-qa="connector-badges"]');
+ expect(badgesRow).toBeTruthy();
+
+ const stateBadge =
badgesRow.querySelector('[data-qa="connector-state"]');
+ expect(stateBadge).toBeTruthy();
+ });
+
+ it('should not have a separate badges row in default mode', async ()
=> {
+ const { fixture } = await setup();
+ const badgesRow =
fixture.nativeElement.querySelector('[data-qa="connector-badges"]');
+ expect(badgesRow).toBeNull();
+ });
+
+ it('should show edits-not-applied badge in badges row in condensed
mode', async () => {
+ const connector = createMockConnector({
+ component: {
+ ...createMockConnector().component,
+ availableActions: [{ name:
'DISCARD_WORKING_CONFIGURATION', description: 'Discard', allowed: true }]
+ }
+ });
+ const { fixture } = await setup({ connector, condensed: true });
+
+ const badgesRow =
fixture.nativeElement.querySelector('[data-qa="connector-badges"]');
+ const editsBadge =
badgesRow.querySelector('[data-qa="edits-not-applied-badge"]');
+ expect(editsBadge).toBeTruthy();
+ });
+ });
+});
diff --git
a/nifi-frontend/src/main/frontend/libs/shared/src/components/connector-detail-header/connector-detail-header.component.ts
b/nifi-frontend/src/main/frontend/libs/shared/src/components/connector-detail-header/connector-detail-header.component.ts
new file mode 100644
index 00000000000..6c55abceace
--- /dev/null
+++
b/nifi-frontend/src/main/frontend/libs/shared/src/components/connector-detail-header/connector-detail-header.component.ts
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Component, computed, input } from '@angular/core';
+import { NgTemplateOutlet } from '@angular/common';
+import { ConnectorEntity, ConnectorState } from '../../types';
+
+export type ConnectorStateVariant = 'neutral' | 'critical' | 'caution' |
'success' | 'info';
+
+@Component({
+ selector: 'connector-detail-header',
+ standalone: true,
+ imports: [NgTemplateOutlet],
+ templateUrl: './connector-detail-header.component.html',
+ styleUrls: ['./connector-detail-header.component.scss']
+})
+export class ConnectorDetailHeader {
+ connector = input.required<ConnectorEntity>();
+ condensed = input<boolean>(false);
+
+ simpleType = computed(() => {
+ const type = this.connector().component.type || '';
+ const parts = type.split('.');
+ return parts[parts.length - 1];
+ });
+
+ /**
+ * Computed signal that checks if the connector has unapplied edits.
+ */
+ hasUnappliedEdits = computed(() => {
+ const action = this.connector().component.availableActions?.find(
+ (a) => a.name === 'DISCARD_WORKING_CONFIGURATION'
+ );
+ return action?.allowed ?? false;
+ });
+
+ getStateVariant(state: string): ConnectorStateVariant {
+ switch (state) {
+ case ConnectorState.RUNNING:
+ return 'success';
+ case ConnectorState.STOPPED:
+ case ConnectorState.DISABLED:
+ return 'neutral';
+ case ConnectorState.STARTING:
+ case ConnectorState.UPDATING:
+ case ConnectorState.STOPPING:
+ case ConnectorState.DRAINING:
+ case ConnectorState.PREPARING_FOR_UPDATE:
+ return 'info';
+ case ConnectorState.UPDATE_FAILED:
+ return 'critical';
+ default:
+ return 'neutral';
+ }
+ }
+
+ getStateColorClass(state: string): string {
+ switch (this.getStateVariant(state)) {
+ case 'success':
+ return 'success-color-default';
+ case 'critical':
+ return 'error-color';
+ case 'caution':
+ return 'caution-color';
+ case 'info':
+ return 'primary-color';
+ case 'neutral':
+ default:
+ return 'neutral-color';
+ }
+ }
+}
diff --git
a/nifi-frontend/src/main/frontend/libs/shared/src/components/index.ts
b/nifi-frontend/src/main/frontend/libs/shared/src/components/index.ts
index 999c051f553..8bb146d7f58 100644
--- a/nifi-frontend/src/main/frontend/libs/shared/src/components/index.ts
+++ b/nifi-frontend/src/main/frontend/libs/shared/src/components/index.ts
@@ -44,3 +44,4 @@ export * from
'./connector-step-actions/connector-step-actions.component';
export * from './property-group-card/property-group-card.component';
export * from './side-panel-container/side-panel-container.component';
export * from './connector-property-input/connector-property-input.component';
+export * from './connector-detail-header/connector-detail-header.component';