From 40464569c052ee1a28d22b5fabfd5d6480793879 Mon Sep 17 00:00:00 2001 From: Matt Burgess Date: Tue, 19 Nov 2024 11:41:12 -0500 Subject: [PATCH] WIP --- .../feature/documentation-routing.module.ts | 5 ++ .../feature/documentation.component.html | 13 +++ .../feature/documentation.component.ts | 5 ++ .../service/documentation.service.ts | 7 ++ ...flow-registry-client-definition.actions.ts | 41 ++++++++++ ...flow-registry-client-definition.effects.ts | 57 +++++++++++++ ...flow-registry-client-definition.reducer.ts | 54 ++++++++++++ ...ow-registry-client-definition.selectors.ts | 25 ++++++ .../flow-registry-client-definition/index.ts | 28 +++++++ .../app/pages/documentation/state/index.ts | 4 + ...-registry-client-definition.component.html | 33 ++++++++ ...-registry-client-definition.component.scss | 16 ++++ ...gistry-client-definition.component.spec.ts | 52 ++++++++++++ ...ow-registry-client-definition.component.ts | 82 +++++++++++++++++++ .../extension-types.effects.ts | 18 ++-- .../extension-types.reducer.ts | 2 + .../extension-types.selectors.ts | 6 +- .../src/app/state/extension-types/index.ts | 2 + ...ntroller-service-references.component.html | 2 +- 19 files changed, 444 insertions(+), 8 deletions(-) create mode 100644 nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.actions.ts create mode 100644 nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.effects.ts create mode 100644 nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.reducer.ts create mode 100644 nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.selectors.ts create mode 100644 nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/index.ts create mode 100644 nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.html create mode 100644 nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.scss create mode 100644 nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.spec.ts create mode 100644 nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.ts diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/feature/documentation-routing.module.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/feature/documentation-routing.module.ts index bb4dda1228f0..4ff349f46a05 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/feature/documentation-routing.module.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/feature/documentation-routing.module.ts @@ -24,6 +24,7 @@ import { ControllerServiceDefinition } from '../ui/controller-service-definition import { ReportingTaskDefinition } from '../ui/reporting-task-definition/reporting-task-definition.component'; import { ParameterProviderDefinition } from '../ui/parameter-provider-definition/parameter-provider-definition.component'; import { FlowAnalysisRuleDefinition } from '../ui/flow-analysis-rule-definition/flow-analysis-rule-definition.component'; +import { FlowRegistryClientDefinition } from '../ui/flow-registry-client-definition/flow-registry-client-definition.component'; import { Overview } from '../ui/overview/overview.component'; const routes: Routes = [ @@ -52,6 +53,10 @@ const routes: Routes = [ path: `${ComponentType.FlowAnalysisRule}/:group/:artifact/:version/:type`, component: FlowAnalysisRuleDefinition }, + { + path: `${ComponentType.FlowRegistryClient}/:group/:artifact/:version/:type`, + component: FlowRegistryClientDefinition + }, { path: 'overview', component: Overview diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/feature/documentation.component.html b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/feature/documentation.component.html index ab48c6f93086..2768fc6b643b 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/feature/documentation.component.html +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/feature/documentation.component.html @@ -112,6 +112,19 @@ } "> + + + Flow Registry Clients + + + @if (extensionTypes.length === 0) { diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/feature/documentation.component.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/feature/documentation.component.ts index 291dd8781ecf..3bcd5df4da26 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/feature/documentation.component.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/feature/documentation.component.ts @@ -33,6 +33,7 @@ import { selectFlowAnalysisRuleTypes, selectParameterProviderTypes, selectProcessorTypes, + selectRegistryClientTypes, selectReportingTaskTypes } from '../../../state/extension-types/extension-types.selectors'; import { ComponentType, isDefinedAndNotNull, NiFiCommon, selectCurrentRoute } from '@nifi/shared'; @@ -71,6 +72,10 @@ export class Documentation implements OnInit, AfterViewInit { flowAnalysisRuleTypes$ = this.store .select(selectFlowAnalysisRuleTypes) .pipe(map((extensionTypes) => this.sortExtensions(extensionTypes))); + registryClientTypes$ = this.store + .select(selectRegistryClientTypes) + .pipe(map((extensionTypes) => this.sortExtensions(extensionTypes))); + accordion = viewChild.required(MatAccordion); diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/service/documentation.service.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/service/documentation.service.ts index 343211ed2e88..5fabf330ebe1 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/service/documentation.service.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/service/documentation.service.ts @@ -25,6 +25,7 @@ import { AdditionalDetailsEntity } from '../state/additional-details'; import { ReportingTaskDefinition } from '../state/reporting-task-definition'; import { ParameterProviderDefinition } from '../state/parameter-provider-definition'; import { FlowAnalysisRuleDefinition } from '../state/flow-analysis-rule-definition'; +import { FlowRegistryClientDefinition } from "../state/flow-registry-client-definition"; @Injectable({ providedIn: 'root' }) export class DocumentationService { @@ -62,6 +63,12 @@ export class DocumentationService { ); } + getFlowRegistryClientDefinition(coordinates: DefinitionCoordinates): Observable { + return this.httpClient.get( + `${DocumentationService.API}/flow/flow-registry-client-definition/${coordinates.group}/${coordinates.artifact}/${coordinates.version}/${coordinates.type}` + ); + } + getAdditionalDetails(coordinates: DefinitionCoordinates): Observable { return this.httpClient.get( `${DocumentationService.API}/flow/additional-details/${coordinates.group}/${coordinates.artifact}/${coordinates.version}/${coordinates.type}` diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.actions.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.actions.ts new file mode 100644 index 000000000000..4f973090583e --- /dev/null +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.actions.ts @@ -0,0 +1,41 @@ +/* + * 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 { createAction, props } from '@ngrx/store'; +import { FlowRegistryClientDefinition } from './index'; +import { DefinitionCoordinates } from '../index'; + +const FLOW_REGISTRY_CLIENT_DEFINITION_PREFIX = '[Flow Registry Client Definition]'; + +export const loadFlowRegistryClientDefinition = createAction( + `${FLOW_REGISTRY_CLIENT_DEFINITION_PREFIX} Load Flow Registry Client Definition`, + props<{ coordinates: DefinitionCoordinates }>() +); + +export const loadFlowRegistryClientDefinitionSuccess = createAction( + `${FLOW_REGISTRY_CLIENT_DEFINITION_PREFIX} Load Flow Registry Client Definition Success`, + props<{ flowRegistryClientDefinition: FlowRegistryClientDefinition }>() +); + +export const flowRegistryClientDefinitionApiError = createAction( + `${FLOW_REGISTRY_CLIENT_DEFINITION_PREFIX} Load Flow Registry Client Definition Error`, + props<{ error: string }>() +); + +export const resetFlowRegistryClientDefinitionState = createAction( + `${FLOW_REGISTRY_CLIENT_DEFINITION_PREFIX} Reset Flow Registry Client Definition State` +); diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.effects.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.effects.ts new file mode 100644 index 000000000000..91b29936d68e --- /dev/null +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.effects.ts @@ -0,0 +1,57 @@ +/* + * 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 } from '@angular/core'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; +import * as FlowRegistryClientDefinitionActions from './flow-registry-client-definition.actions'; +import { catchError, from, map, of, switchMap } from 'rxjs'; +import { ErrorHelper } from '../../../../service/error-helper.service'; +import { HttpErrorResponse } from '@angular/common/http'; +import { DocumentationService } from '../../service/documentation.service'; +import { FlowRegistryClientDefinition } from './index'; + +@Injectable() +export class FlowRegistryClientDefinitionEffects { + constructor( + private actions$: Actions, + private documentationService: DocumentationService, + private errorHelper: ErrorHelper + ) {} + + loadFlowRegistryClientDefinition$ = createEffect(() => + this.actions$.pipe( + ofType(FlowRegistryClientDefinitionActions.loadFlowRegistryClientDefinition), + map((action) => action.coordinates), + switchMap((coordinates) => + from(this.documentationService.getFlowRegistryClientDefinition(coordinates)).pipe( + map((flowRegistryClientDefinition: FlowRegistryClientDefinition) => + FlowRegistryClientDefinitionActions.loadFlowRegistryClientDefinitionSuccess({ + flowRegistryClientDefinition + }) + ), + catchError((errorResponse: HttpErrorResponse) => + of( + FlowRegistryClientDefinitionActions.flowRegistryClientDefinitionApiError({ + error: this.errorHelper.getErrorString(errorResponse) + }) + ) + ) + ) + ) + ) + ); +} diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.reducer.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.reducer.ts new file mode 100644 index 000000000000..fe66044bb051 --- /dev/null +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.reducer.ts @@ -0,0 +1,54 @@ +/* + * 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 { FlowRegistryClientDefinitionState } from './index'; +import { createReducer, on } from '@ngrx/store'; +import { + loadFlowRegistryClientDefinition, + loadFlowRegistryClientDefinitionSuccess, + flowRegistryClientDefinitionApiError, + resetFlowRegistryClientDefinitionState +} from './flow-registry-client-definition.actions'; + +export const initialState: FlowRegistryClientDefinitionState = { + flowRegistryClientDefinition: null, + error: null, + status: 'pending' +}; + +export const flowRegistryClientDefinitionReducer = createReducer( + initialState, + on(loadFlowRegistryClientDefinition, (state) => ({ + ...state, + status: 'loading' as const + })), + on(loadFlowRegistryClientDefinitionSuccess, (state, { flowRegistryClientDefinition }) => ({ + ...state, + flowRegistryClientDefinition, + error: null, + status: 'success' as const + })), + on(flowRegistryClientDefinitionApiError, (state, { error }) => ({ + ...state, + flowRegistryClientDefinition: null, + error, + status: 'error' as const + })), + on(resetFlowRegistryClientDefinitionState, () => ({ + ...initialState + })) +); diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.selectors.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.selectors.ts new file mode 100644 index 000000000000..c89a5dcf4083 --- /dev/null +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/flow-registry-client-definition.selectors.ts @@ -0,0 +1,25 @@ +/* + * 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 { createSelector } from '@ngrx/store'; +import { DocumentationState, selectDocumentationState } from '../index'; +import { flowRegistryClientDefinitionFeatureKey } from './index'; + +export const selectFlowRegistryClientDefinitionState = createSelector( + selectDocumentationState, + (state: DocumentationState) => state[flowRegistryClientDefinitionFeatureKey] +); diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/index.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/index.ts new file mode 100644 index 000000000000..12a84a57a6e7 --- /dev/null +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/flow-registry-client-definition/index.ts @@ -0,0 +1,28 @@ +/* + * 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 { ConfigurableExtensionDefinition } from '../index'; + +export const flowRegistryClientDefinitionFeatureKey = 'flowRegistryClientDefinition'; + +export interface FlowRegistryClientDefinition extends ConfigurableExtensionDefinition {} + +export interface FlowRegistryClientDefinitionState { + flowRegistryClientDefinition: FlowRegistryClientDefinition | null; + error: string | null; + status: 'pending' | 'loading' | 'success' | 'error'; +} diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/index.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/index.ts index 5478a66d6145..e6297e88d97b 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/index.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/state/index.ts @@ -36,6 +36,8 @@ import { import { parameterProviderDefinitionReducer } from './parameter-provider-definition/parameter-provider-definition.reducer'; import { flowAnalysisRuleDefinitionFeatureKey, FlowAnalysisRuleDefinitionState } from './flow-analysis-rule-definition'; import { flowAnalysisRuleDefinitionReducer } from './flow-analysis-rule-definition/flow-analysis-rule-definition.reducer'; +import { flowRegistryClientDefinitionFeatureKey, FlowRegistryClientDefinitionState } from './flow-registry-client-definition'; +import { flowRegistryClientDefinitionReducer } from './flow-registry-client-definition/flow-registry-client-definition.reducer'; import { ComponentType } from '@nifi/shared'; import { DocumentedType } from '../../../state/shared'; @@ -190,6 +192,7 @@ export interface DocumentationState { [reportingTaskDefinitionFeatureKey]: ReportingTaskDefinitionState; [parameterProviderDefinitionFeatureKey]: ParameterProviderDefinitionState; [flowAnalysisRuleDefinitionFeatureKey]: FlowAnalysisRuleDefinitionState; + [flowRegistryClientDefinitionFeatureKey]: FlowRegistryClientDefinitionState; [additionalDetailsFeatureKey]: AdditionalDetailsState; [externalDocumentationFeatureKey]: ExternalDocumentationState; } @@ -201,6 +204,7 @@ export function reducers(state: DocumentationState | undefined, action: Action) [reportingTaskDefinitionFeatureKey]: reportingTaskDefinitionReducer, [parameterProviderDefinitionFeatureKey]: parameterProviderDefinitionReducer, [flowAnalysisRuleDefinitionFeatureKey]: flowAnalysisRuleDefinitionReducer, + [flowRegistryClientDefinitionFeatureKey]: flowRegistryClientDefinitionReducer, [additionalDetailsFeatureKey]: additionalDetailsReducer, [externalDocumentationFeatureKey]: externalDocumentationReducer })(state, action); diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.html b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.html new file mode 100644 index 000000000000..3bc32df12d41 --- /dev/null +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.html @@ -0,0 +1,33 @@ + + +@if (flowRegistryClientDefinitionState) { + @if (isInitialLoading(flowRegistryClientDefinitionState)) { + + } @else { + @if (flowRegistryClientDefinitionState.flowRegistryClientDefinition; as flowRegistryClientDefinition) { +
+ +
+ } @else if (flowRegistryClientDefinitionState.error) { +
+ {{ flowRegistryClientDefinitionState.error }} +
+ } + } +} diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.scss b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.scss new file mode 100644 index 000000000000..b33f7cac34e6 --- /dev/null +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.scss @@ -0,0 +1,16 @@ +/*! + * 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. + */ diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.spec.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.spec.ts new file mode 100644 index 000000000000..491c498d77e3 --- /dev/null +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.spec.ts @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FlowRegistryClientDefinition } from './flow-registry-client-definition.component'; +import { provideMockStore } from '@ngrx/store/testing'; +import { documentationFeatureKey } from '../../state'; +import { flowRegistryClientDefinitionFeatureKey } from '../../state/flow-registry-client-definition'; +import { initialState } from '../../state/flow-registry-client-definition/flow-registry-client-definition.reducer'; + +describe('FlowRegistryClientDefinition', () => { + let component: FlowRegistryClientDefinition; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [FlowRegistryClientDefinition], + providers: [ + provideMockStore({ + initialState: { + [documentationFeatureKey]: { + [flowRegistryClientDefinitionFeatureKey]: initialState + } + } + }) + ] + }).compileComponents(); + + fixture = TestBed.createComponent(FlowRegistryClientDefinition); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.ts new file mode 100644 index 000000000000..d7d34baa1c26 --- /dev/null +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/flow-registry-client-definition/flow-registry-client-definition.component.ts @@ -0,0 +1,82 @@ +/* + * 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, OnDestroy } from '@angular/core'; +import { Store } from '@ngrx/store'; +import { NiFiState } from '../../../../state'; +import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; +import { ComponentType, isDefinedAndNotNull } from '@nifi/shared'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { ConfigurableExtensionDefinitionComponent } from '../common/configurable-extension-definition/configurable-extension-definition.component'; +import { selectDefinitionCoordinatesFromRouteForComponentType } from '../../state/documentation/documentation.selectors'; +import { distinctUntilChanged } from 'rxjs'; +import { FlowRegistryClientDefinitionState } from '../../state/flow-registry-client-definition'; +import { + loadFlowRegistryClientDefinition, + resetFlowRegistryClientDefinitionState +} from '../../state/flow-registry-client-definition/flow-registry-client-definition.actions'; +import { selectFlowRegistryClientDefinitionState } from '../../state/flow-registry-client-definition/flow-registry-client-definition.selectors'; + +@Component({ + selector: 'flow-registry-client-definition', + standalone: true, + imports: [NgxSkeletonLoaderModule, ConfigurableExtensionDefinitionComponent], + templateUrl: './flow-registry-client-definition.component.html', + styleUrl: './flow-registry-client-definition.component.scss' +}) +export class FlowRegistryClientDefinition implements OnDestroy { + flowRegistryClientDefinitionState: FlowRegistryClientDefinitionState | null = null; + + constructor(private store: Store) { + this.store + .select(selectDefinitionCoordinatesFromRouteForComponentType(ComponentType.FlowRegistryClient)) + .pipe( + isDefinedAndNotNull(), + distinctUntilChanged( + (a, b) => + a.group === b.group && a.artifact === b.artifact && a.version === b.version && a.type === b.type + ), + takeUntilDestroyed() + ) + .subscribe((coordinates) => { + this.store.dispatch( + loadFlowRegistryClientDefinition({ + coordinates + }) + ); + }); + + this.store + .select(selectFlowRegistryClientDefinitionState) + .pipe(takeUntilDestroyed()) + .subscribe((flowRegistryClientDefinitionState) => { + this.flowRegistryClientDefinitionState = flowRegistryClientDefinitionState; + + if (flowRegistryClientDefinitionState.status === 'loading') { + window.scrollTo({ top: 0, left: 0 }); + } + }); + } + + isInitialLoading(state: FlowRegistryClientDefinitionState): boolean { + return state.flowRegistryClientDefinition === null && state.error === null; + } + + ngOnDestroy(): void { + this.store.dispatch(resetFlowRegistryClientDefinitionState()); + } +} diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/extension-types.effects.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/extension-types.effects.ts index 48f034b6b367..aac0a53c424c 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/extension-types.effects.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/extension-types.effects.ts @@ -100,7 +100,8 @@ export class ExtensionTypesEffects { this.extensionTypesService.getControllerServiceTypes(), this.extensionTypesService.getReportingTaskTypes(), this.extensionTypesService.getParameterProviderTypes(), - this.extensionTypesService.getFlowAnalysisRuleTypes() + this.extensionTypesService.getFlowAnalysisRuleTypes(), + this.extensionTypesService.getRegistryClientTypes() ]).pipe( map( ([ @@ -108,7 +109,8 @@ export class ExtensionTypesEffects { controllerServiceTypes, reportingTaskTypes, parameterProviderTypes, - flowAnalysisRuleTypes + flowAnalysisRuleTypes, + registryClientTypes ]) => ExtensionTypesActions.loadExtensionTypesForPoliciesSuccess({ response: { @@ -116,7 +118,8 @@ export class ExtensionTypesEffects { controllerServiceTypes: controllerServiceTypes.controllerServiceTypes, reportingTaskTypes: reportingTaskTypes.reportingTaskTypes, parameterProviderTypes: parameterProviderTypes.parameterProviderTypes, - flowAnalysisRuleTypes: flowAnalysisRuleTypes.flowAnalysisRuleTypes + flowAnalysisRuleTypes: flowAnalysisRuleTypes.flowAnalysisRuleTypes, + registryClientTypes: registryClientTypes.registryClientTypes } }) ), @@ -137,7 +140,8 @@ export class ExtensionTypesEffects { this.extensionTypesService.getControllerServiceTypes(), this.extensionTypesService.getReportingTaskTypes(), this.extensionTypesService.getParameterProviderTypes(), - this.extensionTypesService.getFlowAnalysisRuleTypes() + this.extensionTypesService.getFlowAnalysisRuleTypes(), + this.extensionTypesService.getRegistryClientTypes() ]).pipe( map( ([ @@ -145,7 +149,8 @@ export class ExtensionTypesEffects { controllerServiceTypes, reportingTaskTypes, parameterProviderTypes, - flowAnalysisRuleTypes + flowAnalysisRuleTypes, + registryClientTypes ]) => ExtensionTypesActions.loadExtensionTypesForDocumentationSuccess({ response: { @@ -153,7 +158,8 @@ export class ExtensionTypesEffects { controllerServiceTypes: controllerServiceTypes.controllerServiceTypes, reportingTaskTypes: reportingTaskTypes.reportingTaskTypes, parameterProviderTypes: parameterProviderTypes.parameterProviderTypes, - flowAnalysisRuleTypes: flowAnalysisRuleTypes.flowAnalysisRuleTypes + flowAnalysisRuleTypes: flowAnalysisRuleTypes.flowAnalysisRuleTypes, + registryClientTypes: registryClientTypes.flowRegistryClientTypes } }) ), diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/extension-types.reducer.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/extension-types.reducer.ts index 2aafec37bf4a..a302f0a600b0 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/extension-types.reducer.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/extension-types.reducer.ts @@ -65,6 +65,7 @@ export const extensionTypesReducer = createReducer( reportingTaskTypes: response.reportingTaskTypes, parameterProviderTypes: response.parameterProviderTypes, flowAnalysisRuleTypes: response.flowAnalysisRuleTypes, + registryClientTypes: response.registryClientTypes, status: 'success' as const })), on(loadExtensionTypesForDocumentationSuccess, (state, { response }) => ({ @@ -74,6 +75,7 @@ export const extensionTypesReducer = createReducer( reportingTaskTypes: response.reportingTaskTypes, parameterProviderTypes: response.parameterProviderTypes, flowAnalysisRuleTypes: response.flowAnalysisRuleTypes, + registryClientTypes: response.registryClientTypes, status: 'success' as const })) ); diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/extension-types.selectors.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/extension-types.selectors.ts index 37b6f10a4788..ebaba0450438 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/extension-types.selectors.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/extension-types.selectors.ts @@ -76,6 +76,9 @@ export const selectTypesToIdentifyComponentRestrictions = createSelector( if (state.flowAnalysisRuleTypes) { types.push(...state.flowAnalysisRuleTypes); } + if (state.registryClientTypes) { + types.push(...state.registryClientTypes); + } return types; } @@ -130,6 +133,7 @@ export const selectExtensionFromTypes = (extensionTypes: string[]) => controllerServiceTypes: state.controllerServiceTypes.filter(typeFilter), reportingTaskTypes: state.reportingTaskTypes.filter(typeFilter), parameterProviderTypes: state.parameterProviderTypes.filter(typeFilter), - flowAnalysisRuleTypes: state.flowAnalysisRuleTypes.filter(typeFilter) + flowAnalysisRuleTypes: state.flowAnalysisRuleTypes.filter(typeFilter), + registryClientTypes: state.registryClientTypes.filter(typeFilter) } as LoadExtensionTypesForDocumentationResponse; }); diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/index.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/index.ts index 468a6c2f9b7c..a79b3ac1ef9f 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/index.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/state/extension-types/index.ts @@ -39,6 +39,7 @@ export interface LoadExtensionTypesForPoliciesResponse { reportingTaskTypes: DocumentedType[]; flowAnalysisRuleTypes: DocumentedType[]; parameterProviderTypes: DocumentedType[]; + registryClientTypes: DocumentedType[]; } export interface LoadExtensionTypesForDocumentationResponse { @@ -47,6 +48,7 @@ export interface LoadExtensionTypesForDocumentationResponse { reportingTaskTypes: DocumentedType[]; flowAnalysisRuleTypes: DocumentedType[]; parameterProviderTypes: DocumentedType[]; + registryClientTypes: DocumentedType[]; } export interface ExtensionTypesState { diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/ui/common/controller-service/controller-service-references/controller-service-references.component.html b/nifi-frontend/src/main/frontend/apps/nifi/src/app/ui/common/controller-service/controller-service-references/controller-service-references.component.html index dbe6edbc2845..1ada14c25e06 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/ui/common/controller-service/controller-service-references/controller-service-references.component.html +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/ui/common/controller-service/controller-service-references/controller-service-references.component.html @@ -68,7 +68,7 @@ nonService; context: { $implicit: getReferencesByType(references, 'FlowRegistryClient'), - referenceTypeLabel: 'Registry Clients' + referenceTypeLabel: 'Flow Registry Clients' } ">