You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "rfellows (via GitHub)" <gi...@apache.org> on 2026/04/07 15:37:20 UTC
[PR] NIFI-15793 - Connector listing [nifi]
rfellows opened a new pull request, #11112:
URL: https://github.com/apache/nifi/pull/11112
# NIFI-15793 - Connector listing
## Summary
This change adds a **Connectors** listing experience to the NiFi frontend: a lazy-loaded feature with NgRx-backed state, REST integration for connector lifecycle operations, and a Material table UI with sorting, selection, validation feedback, and contextual actions. The feature is **gated at build time** via `environment.enableConnectors` so it can be compiled in for development while remaining off in production until the project is ready to expose it broadly.
## In scope
- **Listing page**: Toolbar (refresh, add connector), sortable table (name, type, bundle, state, validation errors, "edits not applied" indicator), row selection, action menu.
- **Create**: New connectors through the existing extension-creation flow wrapped in a dedicated dialog.
- **Lifecycle actions**: Start, Stop, Delete (with confirmations where appropriate).
- **Rename**: Dedicated dialog with form validation.
- **Drain / cancel drain**: With confirmation dialogs.
- **Discard working configuration**: With confirmation.
- **Purge**: End-to-end flow -- confirmation, submit, **polling** for status, completion/results presentation (dedicated NgRx slice).
- **Navigation & integration**: Global nav entry as a sibling to **Canvas**, shown only when the feature flag allows and `connectorsPermissions.canRead` is satisfied; links for **Manage Access Policies** and **View Documentation** where applicable.
- **Extension types**: Loading connector extension types to support creation and related UI.
- **Shared model & permissions**: New connector-related types and permission helpers in `libs/shared/` with unit tests.
- **Quality**: Broad unit coverage for components, effects, and utilities; **`data-qa`** attributes on connector templates for stable test targeting (scoped to this feature).
- **Errors**: New error context keys for connectors and the rename dialog.
## Not in scope
The following are intentionally **not** implemented in this PR. Placeholders (e.g. TODOs surfaced via alert dialogs) exist where a future screen would plug in:
- Connector **configuration wizard / editor**
- Connector **details** view
- **Per-connector canvas** (or equivalent deep design surface)
These are expected in **follow-up work** under separate changes.
## What changed (high level)
| Area | Notes |
|------|--------|
| **`libs/shared/`** | Types (`ConnectorEntity`, components, actions, state, bundle, etc.); helpers (`canReadConnector`, `canModifyConnector`, `canOperateConnector`, `getConnectorAction`, `isConnectorActionAllowed`, `getConnectorActionDisabledReason`); unit tests for permission utilities. |
| **`apps/nifi` -- connectors feature** | Lazy route + `CanMatchFn` guard (`connectorsFeatureGuard`) tied to `enableConnectors`; `ConnectorService` (CRUD, run status, rename, drain, cancel drain, discard working config, purge); NgRx slices `connectors-listing` and `purge-connector`; UI: `ConnectorsListing`, `ConnectorTable`, `CreateConnector`, `RenameConnectorDialog`; eight spec files; `data-qa` hooks. |
| **Environment** | `enableConnectors: true` in development, `false` in production. |
| **NgRx / infra** | `loadExtensionTypesForConnectors` and related wiring; error context keys `CONNECTORS`, `CONNECTOR_RENAME_DIALOG`. |
## Design notes
- **Feature flag**: The connectors area is hidden behind `environment.enableConnectors` so shipping the code does not imply enabling the UI in all environments.
- **Create dialog state**: `CreateConnector` consumes NgRx selectors instead of `MAT_DIALOG_DATA` so dialog behavior stays aligned with global store state.
- **Shared permissions**: Permission checks live in the shared library for reuse as the rest of the connectors UX grows.
- **Purge**: Uses a polling pattern to track purge request status through completion.
## Testing
- Unit tests cover permission utilities, listing/purge effects and reducers where applicable, and UI components (per the added spec files).
- `data-qa` attributes support automated or manual targeting of key connector UI elements.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15793 - Connector listing [nifi]
Posted by "mcgilman (via GitHub)" <gi...@apache.org>.
mcgilman commented on code in PR #11112:
URL: https://github.com/apache/nifi/pull/11112#discussion_r3047045589
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connectors-listing/connectors-listing.reducer.ts:
##########
@@ -0,0 +1,168 @@
+/*
+ * 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 { createReducer, on } from '@ngrx/store';
+import { ConnectorsListingState } from '../index';
+import {
+ cancelConnectorDrain,
+ cancelConnectorDrainSuccess,
+ connectorsListingBannerApiError,
+ createConnector,
+ createConnectorSuccess,
+ deleteConnector,
+ deleteConnectorSuccess,
+ discardConnectorConfig,
+ discardConnectorConfigSuccess,
+ drainConnector,
+ drainConnectorSuccess,
+ loadConnectorsListing,
+ loadConnectorsListingSuccess,
+ renameConnector,
+ renameConnectorApiError,
+ renameConnectorSuccess,
+ resetConnectorsListingState,
+ startConnector,
+ startConnectorSuccess,
+ stopConnector,
+ stopConnectorSuccess
+} from './connectors-listing.actions';
+
+export const initialState: ConnectorsListingState = {
+ connectors: [],
+ saving: false,
+ loadedTimestamp: '',
+ status: 'pending'
+};
+
+export const connectorsListingReducer = createReducer(
+ initialState,
+
+ on(resetConnectorsListingState, () => ({
+ ...initialState
+ })),
+
+ on(loadConnectorsListing, (state) => ({
+ ...state,
+ status: 'loading' as const
+ })),
+
+ on(loadConnectorsListingSuccess, (state, { response }) => ({
+ ...state,
+ connectors: response.connectors,
+ loadedTimestamp: response.loadedTimestamp,
+ status: 'success' as const
+ })),
+
+ on(createConnector, (state) => ({
+ ...state,
+ saving: true
+ })),
+
+ on(createConnectorSuccess, (state, { response }) => ({
+ ...state,
+ connectors: [...state.connectors, response.connector],
+ saving: false
+ })),
+
+ on(deleteConnector, (state) => ({
+ ...state,
+ saving: true
+ })),
+
+ on(deleteConnectorSuccess, (state, { response }) => ({
+ ...state,
+ connectors: state.connectors.filter((c) => c.id !== response.connector.id),
+ saving: false
+ })),
+
+ on(startConnector, (state) => ({
+ ...state,
+ saving: true
+ })),
+
+ on(startConnectorSuccess, (state, { response }) => ({
+ ...state,
+ connectors: state.connectors.map((c) => (c.id === response.connector.id ? response.connector : c)),
+ saving: false
+ })),
+
+ on(stopConnector, (state) => ({
+ ...state,
+ saving: true
+ })),
+
+ on(stopConnectorSuccess, (state, { response }) => ({
+ ...state,
+ connectors: state.connectors.map((c) => (c.id === response.connector.id ? response.connector : c)),
+ saving: false
+ })),
+
+ on(renameConnector, (state) => ({
+ ...state,
+ saving: true
+ })),
+
+ on(renameConnectorSuccess, (state, { response }) => ({
+ ...state,
+ connectors: state.connectors.map((c) => (c.id === response.connector.id ? response.connector : c)),
+ saving: false
+ })),
+
+ on(renameConnectorApiError, (state) => ({
+ ...state,
+ saving: false
+ })),
+
+ on(connectorsListingBannerApiError, (state) => ({
+ ...state,
+ saving: false,
+ status: 'success' as const
Review Comment:
This should be covered with the fix to my previous comment but this doesn't seem right.
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connectors-listing/connectors-listing.effects.ts:
##########
@@ -0,0 +1,553 @@
+/*
+ * 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 { Injectable, inject } from '@angular/core';
+import { Actions, createEffect, ofType } from '@ngrx/effects';
+import { Store } from '@ngrx/store';
+import { MatDialog } from '@angular/material/dialog';
+import { Router } from '@angular/router';
+import { catchError, from, map, of, switchMap, take, tap } from 'rxjs';
+import { HttpErrorResponse } from '@angular/common/http';
+import { LARGE_DIALOG, MEDIUM_DIALOG, SMALL_DIALOG, YesNoDialog } from '@nifi/shared';
+import { NiFiState } from '../../../../state';
+import { ConnectorService } from '../../service/connector.service';
+import { ErrorHelper } from '../../../../service/error-helper.service';
+import { Client } from '../../../../service/client.service';
+import { CreateConnector } from '../../ui/create-connector/create-connector.component';
+import { RenameConnectorDialog } from '../../ui/rename-connector-dialog/rename-connector-dialog.component';
+import { selectSaving } from './connectors-listing.selectors';
+import { DocumentedType } from '../../../../state/shared';
+import * as ErrorActions from '../../../../state/error/error.actions';
+import { ErrorContextKey } from '../../../../state/error';
+import {
+ cancelConnectorDrain,
+ cancelConnectorDrainSuccess,
+ connectorsListingBannerApiError,
+ createConnector,
+ createConnectorSuccess,
+ deleteConnector,
+ deleteConnectorSuccess,
+ discardConnectorConfig,
+ discardConnectorConfigSuccess,
+ drainConnector,
+ drainConnectorSuccess,
+ loadConnectorsListing,
+ loadConnectorsListingSuccess,
+ navigateToConfigureConnector,
+ navigateToManageAccessPolicies,
+ navigateToViewConnector,
+ navigateToViewConnectorDetails,
+ openNewConnectorDialog,
+ openRenameConnectorDialog,
+ promptConnectorDeletion,
+ promptDiscardConnectorConfig,
+ promptDrainConnector,
+ renameConnector,
+ renameConnectorApiError,
+ renameConnectorSuccess,
+ selectConnector,
+ startConnector,
+ startConnectorSuccess,
+ stopConnector,
+ stopConnectorSuccess
+} from './connectors-listing.actions';
+import { RenameConnectorRequest } from '../index';
+import { BackNavigation } from '../../../../state/navigation';
+
+@Injectable()
+export class ConnectorsListingEffects {
+ private actions$ = inject(Actions);
+ private store = inject<Store<NiFiState>>(Store);
+ private connectorService = inject(ConnectorService);
+ private errorHelper = inject(ErrorHelper);
+ private client = inject(Client);
+ private dialog = inject(MatDialog);
+ private router = inject(Router);
+
+ loadConnectorsListing$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(loadConnectorsListing),
+ switchMap(() =>
+ from(this.connectorService.getConnectors()).pipe(
+ map((response) =>
+ loadConnectorsListingSuccess({
+ response: {
+ connectors: response.connectors || [],
+ loadedTimestamp: response.currentTime
+ }
+ })
+ ),
+ catchError((errorResponse: HttpErrorResponse) =>
+ of(
+ connectorsListingBannerApiError({
+ error: this.errorHelper.getErrorString(errorResponse)
+ })
Review Comment:
In other listings, we capture the correct `status` to set. With the connectors listings if the initial load fails the skeleton will be stuck because the `status` is explicitly set to `success` and the `loadedTimestamp` is never populated. For instance in the Counter Listing
```
of(
CounterListingActions.loadCountersError({
errorResponse,
loadedTimestamp,
status: loadedTimestamp !== initialState.loadedTimestamp ? 'success' : 'pending'
})
)
```
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/service/connector.service.ts:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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 { Injectable, inject } from '@angular/core';
+import { Observable } from 'rxjs';
+import { HttpClient } from '@angular/common/http';
+import { Client } from '../../../service/client.service';
+import { ClusterConnectionService } from '../../../service/cluster-connection.service';
+import { CreateConnectorRequest } from '../state';
+import { ConnectorEntity } from '@nifi/shared';
+import { DropRequestEntity } from '../../flow-designer/state/queue';
+
+@Injectable({ providedIn: 'root' })
+export class ConnectorService {
+ private httpClient = inject(HttpClient);
+ private client = inject(Client);
+ private clusterConnectionService = inject(ClusterConnectionService);
+
+ private static readonly API: string = '../nifi-api';
+
+ getConnectors(): Observable<any> {
Review Comment:
Can we be more specific with the type?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/service/connector.service.ts:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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 { Injectable, inject } from '@angular/core';
+import { Observable } from 'rxjs';
+import { HttpClient } from '@angular/common/http';
+import { Client } from '../../../service/client.service';
+import { ClusterConnectionService } from '../../../service/cluster-connection.service';
+import { CreateConnectorRequest } from '../state';
+import { ConnectorEntity } from '@nifi/shared';
+import { DropRequestEntity } from '../../flow-designer/state/queue';
+
+@Injectable({ providedIn: 'root' })
+export class ConnectorService {
+ private httpClient = inject(HttpClient);
+ private client = inject(Client);
+ private clusterConnectionService = inject(ClusterConnectionService);
+
+ private static readonly API: string = '../nifi-api';
+
+ getConnectors(): Observable<any> {
+ return this.httpClient.get(`${ConnectorService.API}/flow/connectors`);
+ }
+
+ createConnector(createConnectorRequest: CreateConnectorRequest): Observable<any> {
Review Comment:
Can we be more specific with the type?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/purge-connector/purge-connector.effects.spec.ts:
##########
@@ -0,0 +1,423 @@
+/*
+ * 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 { TestBed } from '@angular/core/testing';
+import { provideMockActions } from '@ngrx/effects/testing';
+import { Observable, of, throwError, Subject } from 'rxjs';
+import { PurgeConnectorEffects } from './purge-connector.effects';
+import { ConnectorService } from '../../service/connector.service';
+import { ErrorHelper } from '../../../../service/error-helper.service';
+import { MatDialog } from '@angular/material/dialog';
+import { provideMockStore, MockStore } from '@ngrx/store/testing';
+import { HttpErrorResponse } from '@angular/common/http';
+import { ConnectorAction, ConnectorActionName, ConnectorEntity } from '@nifi/shared';
+import * as ErrorActions from '../../../../state/error/error.actions';
+import { ErrorContextKey } from '../../../../state/error';
+import { selectPurgeConnectorId, selectPurgeDropRequestEntity } from './purge-connector.selectors';
+import { loadConnectorsListing } from '../connectors-listing/connectors-listing.actions';
+import {
+ deletePurgeRequest,
+ pollPurgeConnector,
+ pollPurgeConnectorSuccess,
+ promptPurgeConnector,
+ purgeConnectorApiError,
+ showPurgeConnectorResults,
+ startPollingPurgeConnector,
+ stopPollingPurgeConnector,
+ submitPurgeConnector,
+ submitPurgeConnectorSuccess
+} from './purge-connector.actions';
+import { DropRequestEntity } from '../../../flow-designer/state/queue';
+import type { Mock } from 'vitest';
+
+describe('PurgeConnectorEffects', () => {
+ function createMockAction(name: ConnectorActionName, allowed = true, reasonNotAllowed?: string): ConnectorAction {
+ const action: ConnectorAction = { name, description: `${name} action`, allowed };
+ if (reasonNotAllowed !== undefined) {
+ action.reasonNotAllowed = reasonNotAllowed;
+ }
+ return action;
+ }
+
+ function createMockConnector(
+ options: {
+ id?: string;
+ name?: string;
+ availableActions?: ConnectorAction[];
+ } = {}
+ ): ConnectorEntity {
+ const defaultActions: ConnectorAction[] = options.availableActions ?? [
+ createMockAction('START', true),
+ createMockAction('STOP', true),
+ createMockAction('CONFIGURE', true),
+ createMockAction('DELETE', true)
+ ];
+
+ return {
+ id: options.id || 'connector-123',
+ uri: `http://localhost/nifi-api/connectors/${options.id || 'connector-123'}`,
+ permissions: { canRead: true, canWrite: true },
+ revision: { version: 1, clientId: 'client-1' },
+ bulletins: [],
+ component: {
+ id: options.id || 'connector-123',
+ type: 'org.apache.nifi.connector.TestConnector',
+ bundle: { group: 'org.apache.nifi', artifact: 'nifi-test-nar', version: '1.0.0' },
+ name: options.name || 'Test Connector',
+ state: 'STOPPED',
+ managedProcessGroupId: 'pg-root-default',
+ availableActions: defaultActions
+ },
+ status: { runStatus: 'STOPPED' }
+ };
+ }
+
+ function createMockDropRequestEntity(
+ options: {
+ id?: string;
+ finished?: boolean;
+ percentCompleted?: number;
+ dropped?: string;
+ original?: string;
+ failureReason?: string;
+ } = {}
+ ): DropRequestEntity {
+ return {
+ dropRequest: {
+ id: options.id || 'purge-req-1',
+ uri: `/connectors/connector-123/purge-requests/${options.id || 'purge-req-1'}`,
+ submissionTime: '2025-01-01T00:00:00.000Z',
+ lastUpdated: '2025-01-01T00:00:01.000Z',
+ percentCompleted: options.percentCompleted ?? 100,
+ finished: options.finished ?? true,
+ failureReason: options.failureReason || '',
+ currentCount: 0,
+ currentSize: 0,
+ current: '0 / 0 bytes',
+ originalCount: 10,
+ originalSize: 1024,
+ original: options.original || '10 / 1 KB',
+ droppedCount: 10,
+ droppedSize: 1024,
+ dropped: options.dropped || '10 / 1 KB',
+ state: 'Completed'
+ }
+ };
+ }
+
+ async function setup(
+ options: {
+ purgeConnectorId?: string | null;
+ purgeDropEntity?: DropRequestEntity | null;
+ } = {}
+ ) {
+ let actions$: Observable<any>;
+
+ const mockConnectorService = {
+ createPurgeRequest: vi.fn(),
+ getPurgeRequest: vi.fn(),
+ deletePurgeRequest: vi.fn()
+ };
+
+ const mockErrorHelper = {
+ getErrorString: vi.fn().mockReturnValue('Error message')
+ };
+
+ const mockDialog = {
+ open: vi.fn(),
+ closeAll: vi.fn()
+ };
+
+ await TestBed.configureTestingModule({
+ providers: [
+ PurgeConnectorEffects,
+ provideMockActions(() => actions$),
+ provideMockStore({
+ initialState: {},
+ selectors: [
+ { selector: selectPurgeConnectorId, value: options.purgeConnectorId ?? null },
+ { selector: selectPurgeDropRequestEntity, value: options.purgeDropEntity ?? null }
+ ]
+ }),
+ { provide: ConnectorService, useValue: mockConnectorService },
+ { provide: ErrorHelper, useValue: mockErrorHelper },
+ { provide: MatDialog, useValue: mockDialog }
+ ]
+ }).compileComponents();
+
+ const effects = TestBed.inject(PurgeConnectorEffects);
+ const store = TestBed.inject(MockStore);
+
+ return {
+ effects,
+ store,
+ actions$: (action: any) => {
Review Comment:
Can we be more specific with the type?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/service/connector.service.ts:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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 { Injectable, inject } from '@angular/core';
+import { Observable } from 'rxjs';
+import { HttpClient } from '@angular/common/http';
+import { Client } from '../../../service/client.service';
+import { ClusterConnectionService } from '../../../service/cluster-connection.service';
+import { CreateConnectorRequest } from '../state';
+import { ConnectorEntity } from '@nifi/shared';
+import { DropRequestEntity } from '../../flow-designer/state/queue';
+
+@Injectable({ providedIn: 'root' })
+export class ConnectorService {
+ private httpClient = inject(HttpClient);
+ private client = inject(Client);
+ private clusterConnectionService = inject(ClusterConnectionService);
+
+ private static readonly API: string = '../nifi-api';
+
+ getConnectors(): Observable<any> {
+ return this.httpClient.get(`${ConnectorService.API}/flow/connectors`);
+ }
+
+ createConnector(createConnectorRequest: CreateConnectorRequest): Observable<any> {
+ return this.httpClient.post(`${ConnectorService.API}/connectors`, {
+ revision: createConnectorRequest.revision,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(),
+ component: {
+ bundle: createConnectorRequest.connectorBundle,
+ type: createConnectorRequest.connectorType
+ }
+ });
+ }
+
+ updateConnector(connector: ConnectorEntity): Observable<any> {
+ return this.httpClient.put(`${ConnectorService.API}/connectors/${connector.id}`, {
+ revision: this.client.getRevision(connector),
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(),
+ component: connector.component,
+ id: connector.id
+ });
+ }
+
+ deleteConnector(connector: ConnectorEntity): Observable<any> {
Review Comment:
Can we be more specific with the type?
##########
nifi-frontend/src/main/frontend/libs/shared/src/types/index.ts:
##########
@@ -218,3 +218,63 @@ export function isDefinedAndNotNull<T>() {
})
);
}
+
+export interface Bundle {
Review Comment:
`Bundle` should already be defined.
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connectors-listing/connectors-listing.effects.spec.ts:
##########
@@ -0,0 +1,746 @@
+/*
+ * 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 { TestBed } from '@angular/core/testing';
+import { provideMockActions } from '@ngrx/effects/testing';
+import { Observable, of, throwError } from 'rxjs';
+import { ConnectorsListingEffects } from './connectors-listing.effects';
+import { ConnectorService } from '../../service/connector.service';
+import { ErrorHelper } from '../../../../service/error-helper.service';
+import { Client } from '../../../../service/client.service';
+import { MatDialog } from '@angular/material/dialog';
+import { Router } from '@angular/router';
+import { provideMockStore, MockStore } from '@ngrx/store/testing';
+import { HttpErrorResponse } from '@angular/common/http';
+import { CreateConnector } from '../../ui/create-connector/create-connector.component';
+import { ConnectorAction, ConnectorActionName, ConnectorEntity, YesNoDialog } from '@nifi/shared';
+import * as ErrorActions from '../../../../state/error/error.actions';
+import { ErrorContextKey } from '../../../../state/error';
+import { selectSaving } from './connectors-listing.selectors';
+import {
+ cancelConnectorDrain,
+ cancelConnectorDrainSuccess,
+ connectorsListingBannerApiError,
+ createConnector,
+ createConnectorSuccess,
+ deleteConnector,
+ deleteConnectorSuccess,
+ discardConnectorConfig,
+ discardConnectorConfigSuccess,
+ drainConnector,
+ drainConnectorSuccess,
+ loadConnectorsListing,
+ loadConnectorsListingSuccess,
+ openNewConnectorDialog,
+ promptConnectorDeletion,
+ promptDiscardConnectorConfig,
+ promptDrainConnector,
+ renameConnector,
+ renameConnectorApiError,
+ renameConnectorSuccess,
+ selectConnector,
+ startConnector,
+ startConnectorSuccess,
+ stopConnector,
+ stopConnectorSuccess
+} from './connectors-listing.actions';
+import type { Mock } from 'vitest';
+
+describe('ConnectorsListingEffects', () => {
+ function createMockAction(name: ConnectorActionName, allowed = true, reasonNotAllowed?: string): ConnectorAction {
+ const action: ConnectorAction = { name, description: `${name} action`, allowed };
+ if (reasonNotAllowed !== undefined) {
+ action.reasonNotAllowed = reasonNotAllowed;
+ }
+ return action;
+ }
+
+ function createMockConnector(
+ options: {
+ id?: string;
+ name?: string;
+ type?: string;
+ availableActions?: ConnectorAction[];
+ } = {}
+ ): ConnectorEntity {
+ const defaultActions: ConnectorAction[] = options.availableActions ?? [
+ createMockAction('START', true),
+ createMockAction('STOP', true),
+ createMockAction('CONFIGURE', true),
+ createMockAction('DELETE', true)
+ ];
+
+ return {
+ id: options.id || 'connector-123',
+ uri: `http://localhost/nifi-api/connectors/${options.id || 'connector-123'}`,
+ permissions: { canRead: true, canWrite: true },
+ revision: { version: 1, clientId: 'client-1' },
+ bulletins: [],
+ component: {
+ id: options.id || 'connector-123',
+ type: options.type || 'org.apache.nifi.connector.TestConnector',
+ bundle: {
+ group: 'org.apache.nifi',
+ artifact: 'nifi-test-nar',
+ version: '1.0.0'
+ },
+ name: options.name || 'Test Connector',
+ state: 'STOPPED',
+ managedProcessGroupId: 'pg-root-default',
+ availableActions: defaultActions
+ },
+ status: { runStatus: 'STOPPED' }
+ };
+ }
+
+ function createMockDialogRef(data: any = {}) {
Review Comment:
Can we be more specific with the type?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-table/connector-table.component.ts:
##########
@@ -0,0 +1,268 @@
+/*
+ * 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, EventEmitter, Input, Output, inject } from '@angular/core';
+import { MatButtonModule } from '@angular/material/button';
+import { MatTableDataSource, MatTableModule } from '@angular/material/table';
+import { MatSortModule, Sort } from '@angular/material/sort';
+import { MatMenuModule } from '@angular/material/menu';
+import { MatTooltipModule } from '@angular/material/tooltip';
+import {
+ ConnectorEntity,
+ ConnectorActionName,
+ NifiTooltipDirective,
+ NiFiCommon,
+ canReadConnector,
+ canModifyConnector,
+ canOperateConnector,
+ isConnectorActionAllowed,
+ getConnectorActionDisabledReason
+} from '@nifi/shared';
+import { ValidationErrorsTipInput } from '../../../../state/shared';
+import { FlowConfiguration } from '../../../../state/flow-configuration';
+import { CurrentUser } from '../../../../state/current-user';
+import { ValidationErrorsTip } from '../../../../ui/common/tooltips/validation-errors-tip/validation-errors-tip.component';
+
+@Component({
+ selector: 'connector-table',
+ standalone: true,
+ templateUrl: './connector-table.component.html',
+ imports: [MatButtonModule, MatTableModule, MatSortModule, MatMenuModule, MatTooltipModule, NifiTooltipDirective],
+ styleUrls: ['./connector-table.component.scss']
+})
+export class ConnectorTable {
+ private nifiCommon = inject(NiFiCommon);
+
+ protected readonly ValidationErrorsTip = ValidationErrorsTip;
+
+ @Input() initialSortColumn: 'name' | 'type' | 'bundle' | 'state' = 'name';
+ @Input() initialSortDirection: 'asc' | 'desc' = 'asc';
+ activeSort: Sort = {
+ active: this.initialSortColumn,
+ direction: this.initialSortDirection
+ };
+
+ @Input() set connectors(connectorEntities: ConnectorEntity[]) {
+ this.dataSource.data = this.sortEntities(connectorEntities, this.activeSort);
+ }
+
+ @Input() selectedConnectorId!: string;
+ @Input() flowConfiguration!: FlowConfiguration;
+ @Input() currentUser!: CurrentUser;
+
+ @Output() selectConnector = new EventEmitter<ConnectorEntity>();
+ @Output() viewConnector = new EventEmitter<ConnectorEntity>();
+ @Output() viewDetails = new EventEmitter<ConnectorEntity>();
+ @Output() configureConnector = new EventEmitter<ConnectorEntity>();
+ @Output() renameConnector = new EventEmitter<ConnectorEntity>();
+ @Output() startConnector = new EventEmitter<ConnectorEntity>();
+ @Output() stopConnector = new EventEmitter<ConnectorEntity>();
+ @Output() deleteConnector = new EventEmitter<ConnectorEntity>();
+ @Output() manageAccessPolicies = new EventEmitter<ConnectorEntity>();
+ @Output() viewDocumentation = new EventEmitter<ConnectorEntity>();
+ @Output() discardConnectorConfig = new EventEmitter<ConnectorEntity>();
+ @Output() drainConnector = new EventEmitter<ConnectorEntity>();
+ @Output() cancelDrainConnector = new EventEmitter<ConnectorEntity>();
+ @Output() purgeConnector = new EventEmitter<ConnectorEntity>();
+
+ displayedColumns: string[] = ['moreDetails', 'name', 'type', 'bundle', 'state', 'actions'];
+ dataSource: MatTableDataSource<ConnectorEntity> = new MatTableDataSource<ConnectorEntity>();
+
+ canRead(entity: ConnectorEntity): boolean {
+ return canReadConnector(entity);
+ }
+
+ hasErrors(entity: ConnectorEntity): boolean {
+ return !this.nifiCommon.isEmpty(entity.component.validationErrors);
+ }
+
+ getValidationErrorsTipData(entity: ConnectorEntity): ValidationErrorsTipInput {
+ return {
+ isValidating: entity.component.validationStatus === 'VALIDATING',
+ validationErrors: entity.component.validationErrors || []
+ };
+ }
+
+ canModify(entity: ConnectorEntity): boolean {
+ return canModifyConnector(entity);
+ }
+
+ canOperate(entity: ConnectorEntity): boolean {
+ return canOperateConnector(entity);
+ }
+
+ isActionAllowed(entity: ConnectorEntity, actionName: ConnectorActionName): boolean {
+ return isConnectorActionAllowed(entity, actionName);
+ }
+
+ getActionDisabledReason(entity: ConnectorEntity, actionName: ConnectorActionName): string {
+ return getConnectorActionDisabledReason(entity, actionName);
+ }
+
+ canConfigure(entity: ConnectorEntity): boolean {
+ return isConnectorActionAllowed(entity, 'CONFIGURE');
+ }
+
+ canDelete(entity: ConnectorEntity): boolean {
+ return isConnectorActionAllowed(entity, 'DELETE');
+ }
+
+ canStart(entity: ConnectorEntity): boolean {
+ return isConnectorActionAllowed(entity, 'START');
+ }
+
+ canStop(entity: ConnectorEntity): boolean {
+ return isConnectorActionAllowed(entity, 'STOP');
+ }
+
+ canDiscardConfig(entity: ConnectorEntity): boolean {
+ return isConnectorActionAllowed(entity, 'DISCARD_WORKING_CONFIGURATION');
+ }
+
+ canDrain(entity: ConnectorEntity): boolean {
+ return isConnectorActionAllowed(entity, 'DRAIN_FLOWFILES');
+ }
+
+ canCancelDrain(entity: ConnectorEntity): boolean {
+ return isConnectorActionAllowed(entity, 'CANCEL_DRAIN_FLOWFILES');
+ }
+
+ canPurge(entity: ConnectorEntity): boolean {
+ return isConnectorActionAllowed(entity, 'PURGE_FLOWFILES');
+ }
+
+ formatName(entity: ConnectorEntity): string {
+ return this.canRead(entity) ? entity.component.name : entity.id;
+ }
+
+ formatType(entity: ConnectorEntity): string {
+ return this.canRead(entity) ? this.nifiCommon.formatType(entity.component) : '';
+ }
+
+ formatBundle(entity: ConnectorEntity): string {
+ return this.canRead(entity) ? this.nifiCommon.formatBundle(entity.component.bundle) : '';
+ }
+
+ formatState(entity: ConnectorEntity): string {
+ if (!this.canRead(entity)) {
+ return '';
+ }
+ return entity.component.state || 'STOPPED';
Review Comment:
Is this fallback needed?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/service/connector.service.ts:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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 { Injectable, inject } from '@angular/core';
+import { Observable } from 'rxjs';
+import { HttpClient } from '@angular/common/http';
+import { Client } from '../../../service/client.service';
+import { ClusterConnectionService } from '../../../service/cluster-connection.service';
+import { CreateConnectorRequest } from '../state';
+import { ConnectorEntity } from '@nifi/shared';
+import { DropRequestEntity } from '../../flow-designer/state/queue';
+
+@Injectable({ providedIn: 'root' })
+export class ConnectorService {
+ private httpClient = inject(HttpClient);
+ private client = inject(Client);
+ private clusterConnectionService = inject(ClusterConnectionService);
+
+ private static readonly API: string = '../nifi-api';
+
+ getConnectors(): Observable<any> {
+ return this.httpClient.get(`${ConnectorService.API}/flow/connectors`);
+ }
+
+ createConnector(createConnectorRequest: CreateConnectorRequest): Observable<any> {
+ return this.httpClient.post(`${ConnectorService.API}/connectors`, {
+ revision: createConnectorRequest.revision,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(),
+ component: {
+ bundle: createConnectorRequest.connectorBundle,
+ type: createConnectorRequest.connectorType
+ }
+ });
+ }
+
+ updateConnector(connector: ConnectorEntity): Observable<any> {
+ return this.httpClient.put(`${ConnectorService.API}/connectors/${connector.id}`, {
+ revision: this.client.getRevision(connector),
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(),
+ component: connector.component,
+ id: connector.id
+ });
+ }
+
+ deleteConnector(connector: ConnectorEntity): Observable<any> {
+ const revision = this.client.getRevision(connector);
+ const params: any = {
+ ...revision,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged()
+ };
+ return this.httpClient.delete(`${ConnectorService.API}/connectors/${connector.id}`, { params });
+ }
+
+ updateConnectorRunStatus(connector: ConnectorEntity, runStatus: string): Observable<any> {
+ const revision = this.client.getRevision(connector);
+ return this.httpClient.put(`${ConnectorService.API}/connectors/${connector.id}/run-status`, {
+ revision,
+ state: runStatus,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged()
+ });
+ }
+
+ discardConnectorWorkingConfiguration(connector: ConnectorEntity): Observable<any> {
Review Comment:
Can we be more specific with the type?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/service/connector.service.ts:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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 { Injectable, inject } from '@angular/core';
+import { Observable } from 'rxjs';
+import { HttpClient } from '@angular/common/http';
+import { Client } from '../../../service/client.service';
+import { ClusterConnectionService } from '../../../service/cluster-connection.service';
+import { CreateConnectorRequest } from '../state';
+import { ConnectorEntity } from '@nifi/shared';
+import { DropRequestEntity } from '../../flow-designer/state/queue';
+
+@Injectable({ providedIn: 'root' })
+export class ConnectorService {
+ private httpClient = inject(HttpClient);
+ private client = inject(Client);
+ private clusterConnectionService = inject(ClusterConnectionService);
+
+ private static readonly API: string = '../nifi-api';
+
+ getConnectors(): Observable<any> {
+ return this.httpClient.get(`${ConnectorService.API}/flow/connectors`);
+ }
+
+ createConnector(createConnectorRequest: CreateConnectorRequest): Observable<any> {
+ return this.httpClient.post(`${ConnectorService.API}/connectors`, {
+ revision: createConnectorRequest.revision,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(),
+ component: {
+ bundle: createConnectorRequest.connectorBundle,
+ type: createConnectorRequest.connectorType
+ }
+ });
+ }
+
+ updateConnector(connector: ConnectorEntity): Observable<any> {
+ return this.httpClient.put(`${ConnectorService.API}/connectors/${connector.id}`, {
+ revision: this.client.getRevision(connector),
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(),
+ component: connector.component,
+ id: connector.id
+ });
+ }
+
+ deleteConnector(connector: ConnectorEntity): Observable<any> {
+ const revision = this.client.getRevision(connector);
+ const params: any = {
+ ...revision,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged()
+ };
+ return this.httpClient.delete(`${ConnectorService.API}/connectors/${connector.id}`, { params });
+ }
+
+ updateConnectorRunStatus(connector: ConnectorEntity, runStatus: string): Observable<any> {
+ const revision = this.client.getRevision(connector);
+ return this.httpClient.put(`${ConnectorService.API}/connectors/${connector.id}/run-status`, {
+ revision,
+ state: runStatus,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged()
+ });
+ }
+
+ discardConnectorWorkingConfiguration(connector: ConnectorEntity): Observable<any> {
+ const revision = this.client.getRevision(connector);
+ const params: any = {
+ ...revision,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged()
+ };
+ return this.httpClient.delete(`${ConnectorService.API}/connectors/${connector.id}/working-configuration`, {
+ params
+ });
+ }
+
+ drainConnector(connector: ConnectorEntity): Observable<any> {
Review Comment:
Can we be more specific with the type?
##########
nifi-frontend/src/main/frontend/libs/shared/src/types/index.ts:
##########
@@ -218,3 +218,63 @@ export function isDefinedAndNotNull<T>() {
})
);
}
+
+export interface Bundle {
+ artifact: string;
+ group: string;
+ version: string;
+}
+
+export type ConnectorActionName =
+ | 'START'
+ | 'STOP'
+ | 'CONFIGURE'
+ | 'DISCARD_WORKING_CONFIGURATION'
+ | 'PURGE_FLOWFILES'
+ | 'DRAIN_FLOWFILES'
+ | 'CANCEL_DRAIN_FLOWFILES'
+ | 'APPLY_UPDATES'
+ | 'DELETE';
+
+export interface ConnectorAction {
+ name: ConnectorActionName;
+ description: string;
+ allowed: boolean;
+ reasonNotAllowed?: string;
+}
+
+export enum ConnectorState {
+ STARTING = 'STARTING',
+ RUNNING = 'RUNNING',
+ STOPPING = 'STOPPING',
+ STOPPED = 'STOPPED',
+ DRAINING = 'DRAINING',
+ DISABLED = 'DISABLED',
+ PREPARING_FOR_UPDATE = 'PREPARING_FOR_UPDATE',
+ UPDATING = 'UPDATING',
+ UPDATE_FAILED = 'UPDATE_FAILED'
+}
+
+export interface ConnectorComponent {
+ id: string;
+ name: string;
+ type: string;
+ state: string;
+ bundle: Bundle;
+ validationErrors?: string[];
+ validationStatus?: string;
+ multipleVersionsAvailable?: boolean;
+ availableActions: ConnectorAction[];
+ managedProcessGroupId: string;
+}
+
+export interface ConnectorEntity {
+ permissions: Permissions;
+ operatePermissions?: Permissions;
+ revision: Revision;
+ bulletins: BulletinEntity[];
+ id: string;
+ uri: string;
+ status: any;
Review Comment:
Can we be more specific with the type?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/service/connector.service.ts:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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 { Injectable, inject } from '@angular/core';
+import { Observable } from 'rxjs';
+import { HttpClient } from '@angular/common/http';
+import { Client } from '../../../service/client.service';
+import { ClusterConnectionService } from '../../../service/cluster-connection.service';
+import { CreateConnectorRequest } from '../state';
+import { ConnectorEntity } from '@nifi/shared';
+import { DropRequestEntity } from '../../flow-designer/state/queue';
+
+@Injectable({ providedIn: 'root' })
+export class ConnectorService {
+ private httpClient = inject(HttpClient);
+ private client = inject(Client);
+ private clusterConnectionService = inject(ClusterConnectionService);
+
+ private static readonly API: string = '../nifi-api';
+
+ getConnectors(): Observable<any> {
+ return this.httpClient.get(`${ConnectorService.API}/flow/connectors`);
+ }
+
+ createConnector(createConnectorRequest: CreateConnectorRequest): Observable<any> {
+ return this.httpClient.post(`${ConnectorService.API}/connectors`, {
+ revision: createConnectorRequest.revision,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(),
+ component: {
+ bundle: createConnectorRequest.connectorBundle,
+ type: createConnectorRequest.connectorType
+ }
+ });
+ }
+
+ updateConnector(connector: ConnectorEntity): Observable<any> {
+ return this.httpClient.put(`${ConnectorService.API}/connectors/${connector.id}`, {
+ revision: this.client.getRevision(connector),
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(),
+ component: connector.component,
+ id: connector.id
+ });
+ }
+
+ deleteConnector(connector: ConnectorEntity): Observable<any> {
+ const revision = this.client.getRevision(connector);
+ const params: any = {
+ ...revision,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged()
+ };
+ return this.httpClient.delete(`${ConnectorService.API}/connectors/${connector.id}`, { params });
+ }
+
+ updateConnectorRunStatus(connector: ConnectorEntity, runStatus: string): Observable<any> {
Review Comment:
Can we be more specific with the type?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/service/connector.service.ts:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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 { Injectable, inject } from '@angular/core';
+import { Observable } from 'rxjs';
+import { HttpClient } from '@angular/common/http';
+import { Client } from '../../../service/client.service';
+import { ClusterConnectionService } from '../../../service/cluster-connection.service';
+import { CreateConnectorRequest } from '../state';
+import { ConnectorEntity } from '@nifi/shared';
+import { DropRequestEntity } from '../../flow-designer/state/queue';
+
+@Injectable({ providedIn: 'root' })
+export class ConnectorService {
+ private httpClient = inject(HttpClient);
+ private client = inject(Client);
+ private clusterConnectionService = inject(ClusterConnectionService);
+
+ private static readonly API: string = '../nifi-api';
+
+ getConnectors(): Observable<any> {
+ return this.httpClient.get(`${ConnectorService.API}/flow/connectors`);
+ }
+
+ createConnector(createConnectorRequest: CreateConnectorRequest): Observable<any> {
+ return this.httpClient.post(`${ConnectorService.API}/connectors`, {
+ revision: createConnectorRequest.revision,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(),
+ component: {
+ bundle: createConnectorRequest.connectorBundle,
+ type: createConnectorRequest.connectorType
+ }
+ });
+ }
+
+ updateConnector(connector: ConnectorEntity): Observable<any> {
Review Comment:
Can we be more specific with the type?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/service/connector.service.ts:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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 { Injectable, inject } from '@angular/core';
+import { Observable } from 'rxjs';
+import { HttpClient } from '@angular/common/http';
+import { Client } from '../../../service/client.service';
+import { ClusterConnectionService } from '../../../service/cluster-connection.service';
+import { CreateConnectorRequest } from '../state';
+import { ConnectorEntity } from '@nifi/shared';
+import { DropRequestEntity } from '../../flow-designer/state/queue';
+
+@Injectable({ providedIn: 'root' })
+export class ConnectorService {
+ private httpClient = inject(HttpClient);
+ private client = inject(Client);
+ private clusterConnectionService = inject(ClusterConnectionService);
+
+ private static readonly API: string = '../nifi-api';
+
+ getConnectors(): Observable<any> {
+ return this.httpClient.get(`${ConnectorService.API}/flow/connectors`);
+ }
+
+ createConnector(createConnectorRequest: CreateConnectorRequest): Observable<any> {
+ return this.httpClient.post(`${ConnectorService.API}/connectors`, {
+ revision: createConnectorRequest.revision,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(),
+ component: {
+ bundle: createConnectorRequest.connectorBundle,
+ type: createConnectorRequest.connectorType
+ }
+ });
+ }
+
+ updateConnector(connector: ConnectorEntity): Observable<any> {
+ return this.httpClient.put(`${ConnectorService.API}/connectors/${connector.id}`, {
+ revision: this.client.getRevision(connector),
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(),
+ component: connector.component,
+ id: connector.id
+ });
+ }
+
+ deleteConnector(connector: ConnectorEntity): Observable<any> {
+ const revision = this.client.getRevision(connector);
+ const params: any = {
+ ...revision,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged()
+ };
+ return this.httpClient.delete(`${ConnectorService.API}/connectors/${connector.id}`, { params });
+ }
+
+ updateConnectorRunStatus(connector: ConnectorEntity, runStatus: string): Observable<any> {
+ const revision = this.client.getRevision(connector);
+ return this.httpClient.put(`${ConnectorService.API}/connectors/${connector.id}/run-status`, {
+ revision,
+ state: runStatus,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged()
+ });
+ }
+
+ discardConnectorWorkingConfiguration(connector: ConnectorEntity): Observable<any> {
+ const revision = this.client.getRevision(connector);
+ const params: any = {
+ ...revision,
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged()
+ };
+ return this.httpClient.delete(`${ConnectorService.API}/connectors/${connector.id}/working-configuration`, {
+ params
+ });
+ }
+
+ drainConnector(connector: ConnectorEntity): Observable<any> {
+ return this.httpClient.post(`${ConnectorService.API}/connectors/${connector.id}/drain`, {
+ revision: this.client.getRevision(connector),
+ disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged()
+ });
+ }
+
+ cancelConnectorDrain(connector: ConnectorEntity): Observable<any> {
Review Comment:
Can we be more specific with the type?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connectors-listing/connectors-listing.effects.spec.ts:
##########
@@ -0,0 +1,746 @@
+/*
+ * 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 { TestBed } from '@angular/core/testing';
+import { provideMockActions } from '@ngrx/effects/testing';
+import { Observable, of, throwError } from 'rxjs';
+import { ConnectorsListingEffects } from './connectors-listing.effects';
+import { ConnectorService } from '../../service/connector.service';
+import { ErrorHelper } from '../../../../service/error-helper.service';
+import { Client } from '../../../../service/client.service';
+import { MatDialog } from '@angular/material/dialog';
+import { Router } from '@angular/router';
+import { provideMockStore, MockStore } from '@ngrx/store/testing';
+import { HttpErrorResponse } from '@angular/common/http';
+import { CreateConnector } from '../../ui/create-connector/create-connector.component';
+import { ConnectorAction, ConnectorActionName, ConnectorEntity, YesNoDialog } from '@nifi/shared';
+import * as ErrorActions from '../../../../state/error/error.actions';
+import { ErrorContextKey } from '../../../../state/error';
+import { selectSaving } from './connectors-listing.selectors';
+import {
+ cancelConnectorDrain,
+ cancelConnectorDrainSuccess,
+ connectorsListingBannerApiError,
+ createConnector,
+ createConnectorSuccess,
+ deleteConnector,
+ deleteConnectorSuccess,
+ discardConnectorConfig,
+ discardConnectorConfigSuccess,
+ drainConnector,
+ drainConnectorSuccess,
+ loadConnectorsListing,
+ loadConnectorsListingSuccess,
+ openNewConnectorDialog,
+ promptConnectorDeletion,
+ promptDiscardConnectorConfig,
+ promptDrainConnector,
+ renameConnector,
+ renameConnectorApiError,
+ renameConnectorSuccess,
+ selectConnector,
+ startConnector,
+ startConnectorSuccess,
+ stopConnector,
+ stopConnectorSuccess
+} from './connectors-listing.actions';
+import type { Mock } from 'vitest';
+
+describe('ConnectorsListingEffects', () => {
+ function createMockAction(name: ConnectorActionName, allowed = true, reasonNotAllowed?: string): ConnectorAction {
+ const action: ConnectorAction = { name, description: `${name} action`, allowed };
+ if (reasonNotAllowed !== undefined) {
+ action.reasonNotAllowed = reasonNotAllowed;
+ }
+ return action;
+ }
+
+ function createMockConnector(
+ options: {
+ id?: string;
+ name?: string;
+ type?: string;
+ availableActions?: ConnectorAction[];
+ } = {}
+ ): ConnectorEntity {
+ const defaultActions: ConnectorAction[] = options.availableActions ?? [
+ createMockAction('START', true),
+ createMockAction('STOP', true),
+ createMockAction('CONFIGURE', true),
+ createMockAction('DELETE', true)
+ ];
+
+ return {
+ id: options.id || 'connector-123',
+ uri: `http://localhost/nifi-api/connectors/${options.id || 'connector-123'}`,
+ permissions: { canRead: true, canWrite: true },
+ revision: { version: 1, clientId: 'client-1' },
+ bulletins: [],
+ component: {
+ id: options.id || 'connector-123',
+ type: options.type || 'org.apache.nifi.connector.TestConnector',
+ bundle: {
+ group: 'org.apache.nifi',
+ artifact: 'nifi-test-nar',
+ version: '1.0.0'
+ },
+ name: options.name || 'Test Connector',
+ state: 'STOPPED',
+ managedProcessGroupId: 'pg-root-default',
+ availableActions: defaultActions
+ },
+ status: { runStatus: 'STOPPED' }
+ };
+ }
+
+ function createMockDialogRef(data: any = {}) {
+ return { componentInstance: data };
+ }
+
+ async function setup(
+ options: {
+ saving?: boolean;
+ } = {}
+ ) {
+ let actions$: Observable<any>;
+
+ const mockConnectorService = {
+ getConnectors: vi.fn(),
+ createConnector: vi.fn(),
+ deleteConnector: vi.fn(),
+ updateConnector: vi.fn(),
+ updateConnectorRunStatus: vi.fn(),
+ discardConnectorWorkingConfiguration: vi.fn(),
+ drainConnector: vi.fn(),
+ cancelConnectorDrain: vi.fn()
+ };
+
+ const mockErrorHelper = {
+ getErrorString: vi.fn().mockReturnValue('Error message')
+ };
+
+ const mockClient = {
+ getClientId: vi.fn().mockReturnValue('client-1')
+ };
+
+ const mockDialog = {
+ open: vi.fn(),
+ closeAll: vi.fn()
+ };
+
+ const mockRouter = {
+ navigate: vi.fn()
+ };
+
+ await TestBed.configureTestingModule({
+ providers: [
+ ConnectorsListingEffects,
+ provideMockActions(() => actions$),
+ provideMockStore({
+ initialState: {},
+ selectors: [{ selector: selectSaving, value: options.saving ?? false }]
+ }),
+ { provide: ConnectorService, useValue: mockConnectorService },
+ { provide: ErrorHelper, useValue: mockErrorHelper },
+ { provide: Client, useValue: mockClient },
+ { provide: MatDialog, useValue: mockDialog },
+ { provide: Router, useValue: mockRouter }
+ ]
+ }).compileComponents();
+
+ const effects = TestBed.inject(ConnectorsListingEffects);
+ const store = TestBed.inject(MockStore);
+
+ return {
+ effects,
+ store,
+ actions$: (action: any) => {
Review Comment:
Can we be more specific with the type?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/purge-connector/purge-connector.effects.ts:
##########
@@ -0,0 +1,280 @@
+/*
+ * 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 { Injectable, inject } from '@angular/core';
+import { Actions, createEffect, ofType } from '@ngrx/effects';
+import { concatLatestFrom } from '@ngrx/operators';
+import { Store } from '@ngrx/store';
+import { MatDialog } from '@angular/material/dialog';
+import { asyncScheduler, catchError, filter, from, interval, map, of, switchMap, take, takeUntil, tap } from 'rxjs';
+import { HttpErrorResponse } from '@angular/common/http';
+import { isDefinedAndNotNull, SMALL_DIALOG, YesNoDialog } from '@nifi/shared';
+import { NiFiState } from '../../../../state';
+import { ConnectorService } from '../../service/connector.service';
+import { ErrorHelper } from '../../../../service/error-helper.service';
+import { CancelDialog } from '../../../../ui/common/cancel-dialog/cancel-dialog.component';
+import { OkDialog } from '../../../../ui/common/ok-dialog/ok-dialog.component';
+import { DropRequest } from '../../../flow-designer/state/queue';
+import * as ErrorActions from '../../../../state/error/error.actions';
+import { ErrorContextKey } from '../../../../state/error';
+import { selectPurgeConnectorId, selectPurgeDropRequestEntity } from './purge-connector.selectors';
+import { loadConnectorsListing } from '../connectors-listing/connectors-listing.actions';
+import {
+ deletePurgeRequest,
+ pollPurgeConnector,
+ pollPurgeConnectorSuccess,
+ promptPurgeConnector,
+ purgeConnectorApiError,
+ resetPurgeConnectorState,
+ showPurgeConnectorResults,
+ startPollingPurgeConnector,
+ stopPollingPurgeConnector,
+ submitPurgeConnector,
+ submitPurgeConnectorSuccess
+} from './purge-connector.actions';
+
+@Injectable()
+export class PurgeConnectorEffects {
+ private actions$ = inject(Actions);
+ private store = inject<Store<NiFiState>>(Store);
+ private connectorService = inject(ConnectorService);
+ private errorHelper = inject(ErrorHelper);
+ private dialog = inject(MatDialog);
+
+ promptPurgeConnector$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(promptPurgeConnector),
+ map((action) => action.request),
+ tap((request) => {
+ const dialogRef = this.dialog.open<YesNoDialog>(YesNoDialog, {
+ ...SMALL_DIALOG,
+ data: {
+ title: 'Purge Connector',
+ message: `Are you sure you want to purge connector '${request.connector.component.name}'? All FlowFiles waiting at the time of the request will be removed.`
+ }
+ });
+
+ dialogRef.componentInstance!.yes.pipe(take(1)).subscribe(() => {
+ this.store.dispatch(submitPurgeConnector({ request }));
+ });
+ })
+ ),
+ { dispatch: false }
+ );
+
+ submitPurgeConnector$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(submitPurgeConnector),
+ map((action) => action.request),
+ switchMap((request) => {
+ const dialogReference = this.dialog.open(CancelDialog, {
+ data: {
+ title: 'Purge Connector',
+ message: 'Waiting for connector to be purged...'
+ },
+ disableClose: true
+ });
+
+ dialogReference.componentInstance.exit.pipe(take(1)).subscribe(() => {
+ this.store.dispatch(stopPollingPurgeConnector());
+ });
+
+ return from(this.connectorService.createPurgeRequest(request.connector.id)).pipe(
+ map((response) =>
+ submitPurgeConnectorSuccess({
+ response: { dropEntity: response }
+ })
+ ),
+ catchError((errorResponse: HttpErrorResponse) =>
+ of(
+ purgeConnectorApiError({
+ error: this.errorHelper.getErrorString(errorResponse)
+ })
+ )
+ )
+ );
+ })
+ )
+ );
+
+ submitPurgeConnectorSuccess$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(submitPurgeConnectorSuccess),
+ map((action) => action.response),
+ switchMap((response) => {
+ const dropRequest: DropRequest = response.dropEntity.dropRequest;
+ if (dropRequest.finished) {
+ return of(deletePurgeRequest());
+ } else {
+ return of(startPollingPurgeConnector());
+ }
+ })
+ )
+ );
+
+ startPollingPurgeConnector$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(startPollingPurgeConnector),
+ switchMap(() =>
+ interval(2000, asyncScheduler).pipe(takeUntil(this.actions$.pipe(ofType(stopPollingPurgeConnector))))
+ ),
+ switchMap(() => of(pollPurgeConnector()))
+ )
+ );
+
+ pollPurgeConnector$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(pollPurgeConnector),
+ concatLatestFrom(() => [
+ this.store.select(selectPurgeDropRequestEntity).pipe(isDefinedAndNotNull()),
+ this.store.select(selectPurgeConnectorId)
+ ]),
+ switchMap(([, dropEntity, connectorId]) => {
+ if (!connectorId) {
+ return of(purgeConnectorApiError({ error: 'Purge request state is missing' }));
+ }
+
+ return from(this.connectorService.getPurgeRequest(connectorId, dropEntity.dropRequest.id)).pipe(
+ map((response) =>
+ pollPurgeConnectorSuccess({
+ response: { dropEntity: response }
+ })
+ ),
+ catchError((errorResponse: HttpErrorResponse) =>
+ of(
+ purgeConnectorApiError({
+ error: this.errorHelper.getErrorString(errorResponse)
+ })
+ )
+ )
+ );
+ })
+ )
+ );
+
+ pollPurgeConnectorSuccess$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(pollPurgeConnectorSuccess),
+ map((action) => action.response),
+ filter((response) => response.dropEntity.dropRequest.finished),
+ switchMap(() => of(stopPollingPurgeConnector()))
+ )
+ );
+
+ stopPollingPurgeConnector$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(stopPollingPurgeConnector),
+ switchMap(() => of(deletePurgeRequest()))
+ )
+ );
+
+ deletePurgeRequest$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(deletePurgeRequest),
+ concatLatestFrom(() => [
+ this.store.select(selectPurgeDropRequestEntity).pipe(isDefinedAndNotNull()),
+ this.store.select(selectPurgeConnectorId)
+ ]),
+ switchMap(([, dropEntity, connectorId]) => {
+ this.dialog.closeAll();
+
+ if (!connectorId) {
+ return of(loadConnectorsListing());
+ }
+
+ return from(this.connectorService.deletePurgeRequest(connectorId, dropEntity.dropRequest.id)).pipe(
+ map((response) =>
+ showPurgeConnectorResults({
+ request: { dropEntity: response }
+ })
+ ),
+ catchError(() =>
+ of(
+ showPurgeConnectorResults({
+ request: { dropEntity }
+ })
Review Comment:
Looks like the error is being silently swallowed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15793 - Connector listing [nifi]
Posted by "mcgilman (via GitHub)" <gi...@apache.org>.
mcgilman commented on code in PR #11112:
URL: https://github.com/apache/nifi/pull/11112#discussion_r3047599637
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/state/connectors-listing/connectors-listing.effects.ts:
##########
@@ -0,0 +1,553 @@
+/*
+ * 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 { Injectable, inject } from '@angular/core';
+import { Actions, createEffect, ofType } from '@ngrx/effects';
+import { Store } from '@ngrx/store';
+import { MatDialog } from '@angular/material/dialog';
+import { Router } from '@angular/router';
+import { catchError, from, map, of, switchMap, take, tap } from 'rxjs';
+import { HttpErrorResponse } from '@angular/common/http';
+import { LARGE_DIALOG, MEDIUM_DIALOG, SMALL_DIALOG, YesNoDialog } from '@nifi/shared';
+import { NiFiState } from '../../../../state';
+import { ConnectorService } from '../../service/connector.service';
+import { ErrorHelper } from '../../../../service/error-helper.service';
+import { Client } from '../../../../service/client.service';
+import { CreateConnector } from '../../ui/create-connector/create-connector.component';
+import { RenameConnectorDialog } from '../../ui/rename-connector-dialog/rename-connector-dialog.component';
+import { selectSaving } from './connectors-listing.selectors';
+import { DocumentedType } from '../../../../state/shared';
+import * as ErrorActions from '../../../../state/error/error.actions';
+import { ErrorContextKey } from '../../../../state/error';
+import {
+ cancelConnectorDrain,
+ cancelConnectorDrainSuccess,
+ connectorsListingBannerApiError,
+ createConnector,
+ createConnectorSuccess,
+ deleteConnector,
+ deleteConnectorSuccess,
+ discardConnectorConfig,
+ discardConnectorConfigSuccess,
+ drainConnector,
+ drainConnectorSuccess,
+ loadConnectorsListing,
+ loadConnectorsListingSuccess,
+ navigateToConfigureConnector,
+ navigateToManageAccessPolicies,
+ navigateToViewConnector,
+ navigateToViewConnectorDetails,
+ openNewConnectorDialog,
+ openRenameConnectorDialog,
+ promptConnectorDeletion,
+ promptDiscardConnectorConfig,
+ promptDrainConnector,
+ renameConnector,
+ renameConnectorApiError,
+ renameConnectorSuccess,
+ selectConnector,
+ startConnector,
+ startConnectorSuccess,
+ stopConnector,
+ stopConnectorSuccess
+} from './connectors-listing.actions';
+import { RenameConnectorRequest } from '../index';
+import { BackNavigation } from '../../../../state/navigation';
+
+@Injectable()
+export class ConnectorsListingEffects {
+ private actions$ = inject(Actions);
+ private store = inject<Store<NiFiState>>(Store);
+ private connectorService = inject(ConnectorService);
+ private errorHelper = inject(ErrorHelper);
+ private client = inject(Client);
+ private dialog = inject(MatDialog);
+ private router = inject(Router);
+
+ loadConnectorsListing$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(loadConnectorsListing),
+ switchMap(() =>
+ from(this.connectorService.getConnectors()).pipe(
+ map((response) =>
+ loadConnectorsListingSuccess({
+ response: {
+ connectors: response.connectors || [],
+ loadedTimestamp: response.currentTime
+ }
+ })
+ ),
+ catchError((errorResponse: HttpErrorResponse) =>
+ of(
+ connectorsListingBannerApiError({
+ error: this.errorHelper.getErrorString(errorResponse)
+ })
+ )
+ )
+ )
+ )
+ )
+ );
+
+ openNewConnectorDialog$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(openNewConnectorDialog),
+ tap(() => {
+ const dialogRef = this.dialog.open(CreateConnector, {
+ ...LARGE_DIALOG
+ });
+
+ dialogRef
+ .componentInstance!.createConnector.pipe(take(1))
+ .subscribe((connectorType: DocumentedType) => {
+ this.store.dispatch(
+ createConnector({
+ request: {
+ revision: {
+ clientId: this.client.getClientId(),
+ version: 0
+ },
+ connectorType: connectorType.type,
+ connectorBundle: connectorType.bundle
+ }
+ })
+ );
+ });
+ })
+ ),
+ { dispatch: false }
+ );
+
+ createConnector$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(createConnector),
+ map((action) => action.request),
+ switchMap((request) =>
+ from(this.connectorService.createConnector(request)).pipe(
+ map((response) =>
+ createConnectorSuccess({
+ response: {
+ connector: response
+ }
+ })
+ ),
+ catchError((errorResponse: HttpErrorResponse) => {
+ this.dialog.closeAll();
+ return of(
+ connectorsListingBannerApiError({
+ error: this.errorHelper.getErrorString(errorResponse)
+ })
+ );
+ })
+ )
+ )
+ )
+ );
+
+ createConnectorSuccess$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(createConnectorSuccess),
+ map((action) => action.response),
+ tap(() => {
+ this.dialog.closeAll();
+ }),
+ switchMap((response) =>
+ of(
+ selectConnector({
+ request: {
+ id: response.connector.id
+ }
+ })
+ )
+ )
+ )
+ );
+
+ promptConnectorDeletion$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(promptConnectorDeletion),
+ map((action) => action.request),
+ tap((request) => {
+ const dialogRef = this.dialog.open<YesNoDialog>(YesNoDialog, {
+ ...SMALL_DIALOG,
+ data: {
+ title: 'Delete Connector',
+ message: `Are you sure you want to delete connector '${request.connector.component.name}'?`
+ }
+ });
+
+ dialogRef.componentInstance!.yes.pipe(take(1)).subscribe(() => {
+ this.store.dispatch(deleteConnector({ request }));
+ });
+ })
+ ),
+ { dispatch: false }
+ );
+
+ deleteConnector$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(deleteConnector),
+ map((action) => action.request),
+ switchMap((request) =>
+ from(this.connectorService.deleteConnector(request.connector)).pipe(
+ map((response) =>
+ deleteConnectorSuccess({
+ response: {
+ connector: response
+ }
+ })
+ ),
+ catchError((errorResponse: HttpErrorResponse) =>
+ of(
+ connectorsListingBannerApiError({
+ error: this.errorHelper.getErrorString(errorResponse)
+ })
+ )
+ )
+ )
+ )
+ )
+ );
+
+ connectorsListingBannerApiError$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(connectorsListingBannerApiError),
+ map((action) => action.error),
+ switchMap((error) =>
+ of(
+ ErrorActions.addBannerError({
+ errorContext: { errors: [error], context: ErrorContextKey.CONNECTORS }
+ })
+ )
+ )
+ )
+ );
+
+ startConnector$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(startConnector),
+ map((action) => action.request),
+ switchMap((request) =>
+ from(this.connectorService.updateConnectorRunStatus(request.connector, 'RUNNING')).pipe(
+ map((response) =>
+ startConnectorSuccess({
+ response: { connector: response }
+ })
+ ),
+ catchError((errorResponse: HttpErrorResponse) =>
+ of(
+ connectorsListingBannerApiError({
+ error: this.errorHelper.getErrorString(errorResponse)
+ })
+ )
+ )
+ )
+ )
+ )
+ );
+
+ stopConnector$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(stopConnector),
+ map((action) => action.request),
+ switchMap((request) =>
+ from(this.connectorService.updateConnectorRunStatus(request.connector, 'STOPPED')).pipe(
+ map((response) =>
+ stopConnectorSuccess({
+ response: { connector: response }
+ })
+ ),
+ catchError((errorResponse: HttpErrorResponse) =>
+ of(
+ connectorsListingBannerApiError({
+ error: this.errorHelper.getErrorString(errorResponse)
+ })
+ )
+ )
+ )
+ )
+ )
+ );
+
+ selectConnector$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(selectConnector),
+ map((action) => action.request),
+ tap((request) => {
+ this.router.navigate(['/connectors', request.id]);
+ })
+ ),
+ { dispatch: false }
+ );
+
+ navigateToConfigureConnector$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(navigateToConfigureConnector),
+ tap(() => {
+ window.alert(
+ 'TODO: Configure connector is not yet implemented. This feature will be ported in a future iteration.'
+ );
+ })
+ ),
+ { dispatch: false }
+ );
+
+ navigateToManageAccessPolicies$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(navigateToManageAccessPolicies),
+ map((action) => action.id),
+ tap((id) => {
+ const routeBoundary: string[] = ['/access-policies'];
+ this.router.navigate([...routeBoundary, 'read', 'component', 'connectors', id], {
+ state: {
+ backNavigation: {
+ route: ['/connectors', id],
+ routeBoundary,
+ context: 'connector'
+ } as BackNavigation
+ }
+ });
+ })
+ ),
+ { dispatch: false }
+ );
+
+ openRenameConnectorDialog$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(openRenameConnectorDialog),
+ map((action) => action.connector),
+ tap((connector) => {
+ const dialogRef = this.dialog.open(RenameConnectorDialog, {
+ ...MEDIUM_DIALOG,
+ data: { connector }
+ });
+
+ dialogRef.componentInstance.saving$ = this.store.select(selectSaving);
+
+ dialogRef.componentInstance.rename.pipe(take(1)).subscribe((request: RenameConnectorRequest) => {
Review Comment:
If `renameConnector` fails, the `take(1)` prevents a subsequent attempt. We should probably migrate this to take until `dialogRef` is closed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15793 - Connector listing [nifi]
Posted by "mcgilman (via GitHub)" <gi...@apache.org>.
mcgilman commented on code in PR #11112:
URL: https://github.com/apache/nifi/pull/11112#discussion_r3052893510
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/state/shared/index.ts:
##########
@@ -413,11 +414,7 @@ export interface DocumentedType {
deprecationReason?: string;
}
-export interface Bundle {
- artifact: string;
- group: string;
- version: string;
-}
+export type { Bundle } from '@nifi/shared';
Review Comment:
Can we avoid re-exporting this type and update the imports to use `shared`?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-table/connector-table.component.spec.ts:
##########
@@ -0,0 +1,779 @@
+/*
+ * 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 { TestBed } from '@angular/core/testing';
+import { ConnectorTable } from './connector-table.component';
+import { ConnectorAction, ConnectorActionName, ConnectorEntity, NiFiCommon } from '@nifi/shared';
+import { NoopAnimationsModule } from '@angular/platform-browser/animations';
+import { By } from '@angular/platform-browser';
+import { FlowConfiguration } from '../../../../state/flow-configuration';
+import { CurrentUser } from '../../../../state/current-user';
+
+describe('ConnectorTable', () => {
+ function createMockAction(name: ConnectorActionName, allowed = true, reasonNotAllowed?: string): ConnectorAction {
+ const action: ConnectorAction = {
+ name,
+ description: `${name} action`,
+ allowed
+ };
+ if (reasonNotAllowed !== undefined) {
+ action.reasonNotAllowed = reasonNotAllowed;
+ }
+ return action;
+ }
+
+ function createMockConnector(
+ options: {
+ id?: string;
+ name?: string;
+ type?: string;
+ state?: string;
+ canRead?: boolean;
+ canWrite?: boolean;
+ canOperate?: boolean;
+ managedProcessGroupId?: string;
+ validationErrors?: string[];
+ validationStatus?: string;
+ availableActions?: ConnectorAction[];
+ } = {}
+ ): ConnectorEntity {
+ const defaultActions: ConnectorAction[] = options.availableActions ?? [
+ createMockAction('START', true),
+ createMockAction('STOP', true),
+ createMockAction('CONFIGURE', true),
+ createMockAction('DELETE', true)
+ ];
+
+ const connector: ConnectorEntity = {
+ id: options.id || 'connector-123',
+ uri: `http://localhost/nifi-api/connectors/${options.id || 'connector-123'}`,
+ permissions: {
+ canRead: options.canRead ?? true,
+ canWrite: options.canWrite ?? true
+ },
+ revision: { version: 1, clientId: 'client-1' },
+ bulletins: [],
+ component: {
+ id: options.id || 'connector-123',
+ type: options.type || 'org.apache.nifi.connector.TestConnector',
+ name: options.name || 'Test Connector',
+ bundle: {
+ group: 'org.apache.nifi',
+ artifact: 'nifi-test-nar',
+ version: '1.0.0'
+ },
+ state: options.state || 'STOPPED',
+ managedProcessGroupId: options.managedProcessGroupId ?? 'pg-root-default',
+ validationErrors: options.validationErrors,
+ validationStatus: options.validationStatus,
+ availableActions: defaultActions
+ },
+ status: {
+ runStatus: options.state || 'STOPPED'
+ }
+ };
+
+ if (options.canOperate !== undefined) {
+ connector.operatePermissions = {
+ canRead: true,
+ canWrite: options.canOperate
+ };
+ }
+
+ return connector;
+ }
+
+ function createMockConnectors(): ConnectorEntity[] {
+ return [
+ createMockConnector({ id: 'connector-1', name: 'Alpha Connector' }),
+ createMockConnector({ id: 'connector-2', name: 'Beta Connector' }),
+ createMockConnector({ id: 'connector-3', name: 'Charlie Connector' })
+ ];
+ }
+
+ function createMockFlowConfiguration(
+ options: {
+ supportsManagedAuthorizer?: boolean;
+ } = {}
+ ): FlowConfiguration {
+ return {
+ supportsManagedAuthorizer: options.supportsManagedAuthorizer ?? true,
+ supportsConfigurableAuthorizer: true,
+ supportsConfigurableUsersAndGroups: true,
+ currentTime: '2025-01-01T00:00:00.000Z',
+ timeOffset: 0,
+ defaultBackPressureDataSizeThreshold: 1073741824,
+ defaultBackPressureObjectThreshold: 10000
+ };
+ }
+
+ function createMockCurrentUser(
+ options: {
+ canReadTenants?: boolean;
+ } = {}
+ ): CurrentUser {
+ return {
+ identity: 'test-user',
+ anonymous: false,
+ logoutSupported: true,
+ canVersionFlows: false,
+ provenancePermissions: { canRead: true, canWrite: false },
+ countersPermissions: { canRead: true, canWrite: false },
+ tenantsPermissions: { canRead: options.canReadTenants ?? true, canWrite: false },
+ controllerPermissions: { canRead: true, canWrite: false },
+ policiesPermissions: { canRead: true, canWrite: false },
+ systemPermissions: { canRead: true, canWrite: false },
+ parameterContextPermissions: { canRead: true, canWrite: false },
+ restrictedComponentsPermissions: { canRead: true, canWrite: false },
+ connectorsPermissions: { canRead: true, canWrite: true },
+ componentRestrictionPermissions: []
+ };
+ }
+
+ interface SetupOptions {
+ connectors?: ConnectorEntity[];
+ selectedConnectorId?: string;
+ initialSortColumn?: 'name' | 'type' | 'bundle' | 'state';
+ initialSortDirection?: 'asc' | 'desc';
+ flowConfiguration?: FlowConfiguration;
+ currentUser?: CurrentUser;
+ }
+
+ async function setup(options: SetupOptions = {}) {
+ const mockNiFiCommon = {
+ formatType: vi.fn().mockReturnValue('TestConnector'),
+ formatBundle: vi.fn().mockReturnValue('nifi-test-nar - 1.0.0'),
+ compareString: vi.fn((a: string, b: string) => a.localeCompare(b)),
+ isEmpty: vi.fn((arr: unknown) => !arr || (Array.isArray(arr) && arr.length === 0))
+ };
+
+ await TestBed.configureTestingModule({
+ imports: [ConnectorTable, NoopAnimationsModule],
+ providers: [{ provide: NiFiCommon, useValue: mockNiFiCommon }]
+ }).compileComponents();
+
+ const fixture = TestBed.createComponent(ConnectorTable);
+ const component = fixture.componentInstance;
+
+ if (options.initialSortColumn) {
+ component.initialSortColumn = options.initialSortColumn;
+ }
+ if (options.initialSortDirection) {
+ component.initialSortDirection = options.initialSortDirection;
+ }
+ if (options.selectedConnectorId !== undefined) {
+ component.selectedConnectorId = options.selectedConnectorId;
+ }
+ if (options.connectors) {
+ component.connectors = options.connectors;
+ }
+ if (options.flowConfiguration) {
+ component.flowConfiguration = options.flowConfiguration;
+ }
+ if (options.currentUser) {
+ component.currentUser = options.currentUser;
+ }
+
+ fixture.detectChanges();
+
+ return { component, fixture, mockNiFiCommon };
+ }
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ describe('Component initialization', () => {
+ it('should create', async () => {
+ const { component } = await setup();
+ expect(component).toBeTruthy();
+ });
+
+ it('should initialize with default sort column and direction', async () => {
+ const { component } = await setup();
+ expect(component.initialSortColumn).toBe('name');
+ expect(component.initialSortDirection).toBe('asc');
+ });
+
+ it('should have correct displayed columns', async () => {
+ const { component } = await setup();
+ expect(component.displayedColumns).toEqual(['moreDetails', 'name', 'type', 'bundle', 'state', 'actions']);
+ });
+ });
+
+ describe('Validation errors', () => {
+ it('should return true for hasErrors when connector has validation errors', async () => {
+ const { component } = await setup();
+ const connector = createMockConnector({ validationErrors: ['Property X is required'] });
+ expect(component.hasErrors(connector)).toBe(true);
+ });
+
+ it('should return false for hasErrors when connector has no validation errors', async () => {
+ const { component } = await setup();
+ const connector = createMockConnector({ validationErrors: [] });
+ expect(component.hasErrors(connector)).toBe(false);
+ });
+
+ it('should return false for hasErrors when validationErrors is undefined', async () => {
+ const { component } = await setup();
+ const connector = createMockConnector();
+ expect(component.hasErrors(connector)).toBe(false);
+ });
+
+ it('should return isValidating true when status is VALIDATING', async () => {
+ const { component } = await setup();
+ const connector = createMockConnector({
+ validationErrors: ['Error 1'],
+ validationStatus: 'VALIDATING'
+ });
+ const tipData = component.getValidationErrorsTipData(connector);
+ expect(tipData.isValidating).toBe(true);
+ expect(tipData.validationErrors).toEqual(['Error 1']);
+ });
+
+ it('should return isValidating false when status is not VALIDATING', async () => {
+ const { component } = await setup();
+ const connector = createMockConnector({
+ validationErrors: ['Error 1', 'Error 2'],
+ validationStatus: 'INVALID'
+ });
+ const tipData = component.getValidationErrorsTipData(connector);
+ expect(tipData.isValidating).toBe(false);
+ expect(tipData.validationErrors).toEqual(['Error 1', 'Error 2']);
+ });
+
+ it('should return empty array for validationErrors when undefined', async () => {
+ const { component } = await setup();
+ const connector = createMockConnector();
+ const tipData = component.getValidationErrorsTipData(connector);
+ expect(tipData.validationErrors).toEqual([]);
+ });
+ });
+
+ describe('Permission checks', () => {
+ it('should check canRead permission', async () => {
+ const { component } = await setup();
+ expect(component.canRead(createMockConnector({ canRead: true }))).toBe(true);
+ expect(component.canRead(createMockConnector({ canRead: false }))).toBe(false);
+ });
+
+ it('should check canModify permission', async () => {
+ const { component } = await setup();
+ expect(component.canModify(createMockConnector({ canWrite: true }))).toBe(true);
+ expect(component.canModify(createMockConnector({ canWrite: false }))).toBe(false);
+ });
+
+ it('should check canOperate with write permission', async () => {
+ const { component } = await setup();
+ expect(component.canOperate(createMockConnector({ canWrite: true }))).toBe(true);
+ });
+
+ it('should check canOperate with operate permission', async () => {
+ const { component } = await setup();
+ expect(component.canOperate(createMockConnector({ canWrite: false, canOperate: true }))).toBe(true);
+ });
+
+ it('should check canOperate with neither permission', async () => {
+ const { component } = await setup();
+ expect(component.canOperate(createMockConnector({ canWrite: false, canOperate: false }))).toBe(false);
+ });
+
+ it('should check canOperate without operatePermissions', async () => {
+ const { component } = await setup();
+ expect(component.canOperate(createMockConnector({ canWrite: false }))).toBe(false);
+ });
+
+ it('should check canConfigure', async () => {
+ const { component } = await setup();
+ expect(
+ component.canConfigure(createMockConnector({ availableActions: [createMockAction('CONFIGURE', true)] }))
+ ).toBe(true);
+ expect(
+ component.canConfigure(
+ createMockConnector({ availableActions: [createMockAction('CONFIGURE', false)] })
+ )
+ ).toBe(false);
+ expect(
+ component.canConfigure(createMockConnector({ availableActions: [createMockAction('START', true)] }))
+ ).toBe(false);
+ });
+
+ it('should check canDelete', async () => {
+ const { component } = await setup();
+ expect(
+ component.canDelete(createMockConnector({ availableActions: [createMockAction('DELETE', true)] }))
+ ).toBe(true);
+ expect(
+ component.canDelete(createMockConnector({ availableActions: [createMockAction('DELETE', false)] }))
+ ).toBe(false);
+ expect(
+ component.canDelete(createMockConnector({ availableActions: [createMockAction('START', true)] }))
+ ).toBe(false);
+ });
+
+ it('should check canStart', async () => {
+ const { component } = await setup();
+ expect(
+ component.canStart(createMockConnector({ availableActions: [createMockAction('START', true)] }))
+ ).toBe(true);
+ expect(
+ component.canStart(createMockConnector({ availableActions: [createMockAction('START', false)] }))
+ ).toBe(false);
+ });
+
+ it('should check canStop', async () => {
+ const { component } = await setup();
+ expect(component.canStop(createMockConnector({ availableActions: [createMockAction('STOP', true)] }))).toBe(
+ true
+ );
+ expect(
+ component.canStop(createMockConnector({ availableActions: [createMockAction('STOP', false)] }))
+ ).toBe(false);
+ });
+
+ it('should check canDiscardConfig', async () => {
+ const { component } = await setup();
+ expect(
+ component.canDiscardConfig(
+ createMockConnector({
+ availableActions: [createMockAction('DISCARD_WORKING_CONFIGURATION', true)]
+ })
+ )
+ ).toBe(true);
+ expect(
+ component.canDiscardConfig(
+ createMockConnector({
+ availableActions: [createMockAction('DISCARD_WORKING_CONFIGURATION', false)]
+ })
+ )
+ ).toBe(false);
+ });
+
+ it('should check canDrain', async () => {
+ const { component } = await setup();
+ expect(
+ component.canDrain(
+ createMockConnector({ availableActions: [createMockAction('DRAIN_FLOWFILES', true)] })
+ )
+ ).toBe(true);
+ expect(
+ component.canDrain(
+ createMockConnector({ availableActions: [createMockAction('DRAIN_FLOWFILES', false)] })
+ )
+ ).toBe(false);
+ });
+
+ it('should check canCancelDrain', async () => {
+ const { component } = await setup();
+ expect(
+ component.canCancelDrain(
+ createMockConnector({ availableActions: [createMockAction('CANCEL_DRAIN_FLOWFILES', true)] })
+ )
+ ).toBe(true);
+ expect(
+ component.canCancelDrain(
+ createMockConnector({ availableActions: [createMockAction('CANCEL_DRAIN_FLOWFILES', false)] })
+ )
+ ).toBe(false);
+ });
+
+ it('should check canPurge', async () => {
+ const { component } = await setup();
+ expect(
+ component.canPurge(
+ createMockConnector({ availableActions: [createMockAction('PURGE_FLOWFILES', true)] })
+ )
+ ).toBe(true);
+ expect(
+ component.canPurge(
+ createMockConnector({ availableActions: [createMockAction('PURGE_FLOWFILES', false)] })
+ )
+ ).toBe(false);
+ });
+ });
+
+ describe('Data formatting', () => {
+ it('should format name when readable', async () => {
+ const { component } = await setup();
+ expect(component.formatName(createMockConnector({ name: 'My Connector', canRead: true }))).toBe(
+ 'My Connector'
+ );
+ });
+
+ it('should return ID when not readable', async () => {
+ const { component } = await setup();
+ expect(component.formatName(createMockConnector({ id: 'connector-xyz', canRead: false }))).toBe(
+ 'connector-xyz'
+ );
+ });
+
+ it('should format type when readable', async () => {
+ const { component, mockNiFiCommon } = await setup();
+ const connector = createMockConnector({ canRead: true });
+ component.formatType(connector);
+ expect(mockNiFiCommon.formatType).toHaveBeenCalledWith(connector.component);
+ });
+
+ it('should return empty string for type when not readable', async () => {
+ const { component } = await setup();
+ expect(component.formatType(createMockConnector({ canRead: false }))).toBe('');
+ });
+
+ it('should format bundle when readable', async () => {
+ const { component, mockNiFiCommon } = await setup();
+ const connector = createMockConnector({ canRead: true });
+ component.formatBundle(connector);
+ expect(mockNiFiCommon.formatBundle).toHaveBeenCalledWith(connector.component.bundle);
+ });
+
+ it('should format state when readable', async () => {
+ const { component } = await setup();
+ expect(component.formatState(createMockConnector({ state: 'RUNNING', canRead: true }))).toBe('RUNNING');
+ });
+
+ it('should return default STOPPED state', async () => {
+ const { component } = await setup();
+ expect(component.formatState(createMockConnector({ canRead: true }))).toBe('STOPPED');
+ });
Review Comment:
This test appears to be assertig the default STOPPED state but it happens to work because `createMockConnector` falls back to a STOPPED state when not set.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15793 - Connector listing [nifi]
Posted by "mcgilman (via GitHub)" <gi...@apache.org>.
mcgilman commented on code in PR #11112:
URL: https://github.com/apache/nifi/pull/11112#discussion_r3052886130
##########
nifi-frontend/src/main/frontend/libs/shared/src/types/index.ts:
##########
@@ -218,3 +218,63 @@ export function isDefinedAndNotNull<T>() {
})
);
}
+
+export interface Bundle {
+ artifact: string;
+ group: string;
+ version: string;
+}
+
+export type ConnectorActionName =
+ | 'START'
+ | 'STOP'
+ | 'CONFIGURE'
+ | 'DISCARD_WORKING_CONFIGURATION'
+ | 'PURGE_FLOWFILES'
+ | 'DRAIN_FLOWFILES'
+ | 'CANCEL_DRAIN_FLOWFILES'
+ | 'APPLY_UPDATES'
+ | 'DELETE';
+
+export interface ConnectorAction {
+ name: ConnectorActionName;
+ description: string;
+ allowed: boolean;
+ reasonNotAllowed?: string;
+}
+
+export enum ConnectorState {
+ STARTING = 'STARTING',
+ RUNNING = 'RUNNING',
+ STOPPING = 'STOPPING',
+ STOPPED = 'STOPPED',
+ DRAINING = 'DRAINING',
+ DISABLED = 'DISABLED',
+ PREPARING_FOR_UPDATE = 'PREPARING_FOR_UPDATE',
+ UPDATING = 'UPDATING',
+ UPDATE_FAILED = 'UPDATE_FAILED'
+}
+
+export interface ConnectorComponent {
+ id: string;
+ name: string;
+ type: string;
+ state: string;
+ bundle: Bundle;
+ validationErrors?: string[];
+ validationStatus?: string;
+ multipleVersionsAvailable?: boolean;
+ availableActions: ConnectorAction[];
+ managedProcessGroupId: string;
+}
+
+export interface ConnectorEntity {
+ permissions: Permissions;
+ operatePermissions?: Permissions;
+ revision: Revision;
+ bulletins: BulletinEntity[];
+ id: string;
+ uri: string;
+ status: any;
Review Comment:
I don't think this was updated in your latest commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15793 - Connector listing [nifi]
Posted by "rfellows (via GitHub)" <gi...@apache.org>.
rfellows merged PR #11112:
URL: https://github.com/apache/nifi/pull/11112
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org