rfellows commented on code in PR #10683:
URL: https://github.com/apache/nifi/pull/10683#discussion_r2643279696


##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/connector-definition/connector-definition.component.ts:
##########
@@ -0,0 +1,198 @@
+/*
+ * 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, ViewChild, inject } from '@angular/core';
+import { Store } from '@ngrx/store';
+import { NiFiState } from '../../../../state';
+import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
+import { ComponentType, isDefinedAndNotNull, NiFiCommon } from '@nifi/shared';
+import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
+import { selectDefinitionCoordinatesFromRouteForComponentType } from 
'../../state/documentation/documentation.selectors';
+import { distinctUntilChanged } from 'rxjs';
+import {
+    ConnectorDefinitionState,
+    ConfigurationStep,
+    ConnectorPropertyGroup,
+    ConnectorPropertyDescriptor,
+    ConnectorDefinition
+} from '../../state/connector-definition';
+import {
+    loadConnectorDefinition,
+    resetConnectorDefinitionState
+} from '../../state/connector-definition/connector-definition.actions';
+import { selectConnectorDefinitionState } from 
'../../state/connector-definition/connector-definition.selectors';
+import { MatAccordion, MatExpansionModule } from '@angular/material/expansion';
+import { MatButtonModule } from '@angular/material/button';
+import { SeeAlsoComponent } from '../common/see-also/see-also.component';
+import { DocumentationService } from '../../service/documentation.service';
+import { MarkdownComponent } from 'ngx-markdown';
+import { ConnectorPropertyDefinitionComponent } from 
'../common/connector-property-definition/connector-property-definition.component';
+
+@Component({
+    selector: 'connector-definition',
+    imports: [
+        NgxSkeletonLoaderModule,
+        MatExpansionModule,
+        MatButtonModule,
+        SeeAlsoComponent,
+        MarkdownComponent,
+        ConnectorPropertyDefinitionComponent
+    ],
+    templateUrl: './connector-definition.component.html',
+    styleUrl: './connector-definition.component.scss'
+})
+export class ConnectorDefinitionComponent implements OnDestroy {
+    private store = inject<Store<NiFiState>>(Store);
+    private nifiCommon = inject(NiFiCommon);
+    private documentationService = inject(DocumentationService);
+
+    @ViewChild('stepsAccordion') stepsAccordion!: MatAccordion;
+
+    connectorDefinitionState: ConnectorDefinitionState | null = null;
+
+    stepDocumentation: Map<string, string> = new Map();
+    stepDocumentationLoading: Map<string, boolean> = new Map();
+    stepDocumentationError: Map<string, string> = new Map();
+
+    constructor() {
+        this.store
+            
.select(selectDefinitionCoordinatesFromRouteForComponentType(ComponentType.Connector))
+            .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.stepDocumentation.clear();
+                this.stepDocumentationLoading.clear();
+                this.stepDocumentationError.clear();
+
+                this.store.dispatch(
+                    loadConnectorDefinition({
+                        coordinates
+                    })
+                );
+            });
+
+        this.store
+            .select(selectConnectorDefinitionState)
+            .pipe(takeUntilDestroyed())
+            .subscribe((connectorDefinitionState) => {
+                this.connectorDefinitionState = connectorDefinitionState;
+
+                if (connectorDefinitionState.status === 'loading') {
+                    window.scrollTo({ top: 0, left: 0 });
+                }
+            });
+    }
+
+    isInitialLoading(state: ConnectorDefinitionState): boolean {
+        return state.connectorDefinition === null && state.error === null;
+    }
+
+    formatExtensionName(type: string): string {
+        return this.nifiCommon.getComponentTypeLabel(type);
+    }
+
+    hasConfigurationSteps(steps: ConfigurationStep[] | undefined): boolean {
+        return steps !== undefined && steps.length > 0;
+    }
+
+    hasPropertyGroups(groups: ConnectorPropertyGroup[] | undefined): boolean {
+        return groups !== undefined && groups.length > 0;
+    }
+
+    hasProperties(properties: ConnectorPropertyDescriptor[] | undefined): 
boolean {
+        return properties !== undefined && properties.length > 0;
+    }
+
+    formatPropertyTitle(descriptor: ConnectorPropertyDescriptor): string {
+        if (descriptor.required) {
+            return `${descriptor.name}*`;
+        }
+        return descriptor.name;
+    }
+
+    lookupProperty(
+        properties: ConnectorPropertyDescriptor[]
+    ): (name: string) => ConnectorPropertyDescriptor | undefined {
+        return (name: string) => properties.find((prop) => prop.name === name);
+    }
+
+    expandAllSteps(): void {
+        this.stepsAccordion.openAll();
+    }
+
+    collapseAllSteps(): void {
+        this.stepsAccordion.closeAll();
+    }
+
+    expandAllProperties(accordion: MatAccordion): void {
+        accordion.openAll();
+    }
+
+    collapseAllProperties(accordion: MatAccordion): void {
+        accordion.closeAll();
+    }
+
+    loadStepDocumentation(connectorDefinition: ConnectorDefinition, stepName: 
string): void {
+        if (this.stepDocumentation.has(stepName) || 
this.stepDocumentationLoading.get(stepName)) {
+            return;
+        }
+
+        this.stepDocumentationLoading.set(stepName, true);
+        this.documentationService
+            .getStepDocumentation(
+                {
+                    group: connectorDefinition.group,
+                    artifact: connectorDefinition.artifact,
+                    version: connectorDefinition.version,
+                    type: connectorDefinition.type
+                },
+                stepName
+            )
+            .subscribe({
+                next: (response) => {
+                    this.stepDocumentation.set(stepName, 
response.stepDocumentation);
+                    this.stepDocumentationLoading.set(stepName, false);
+                },
+                error: () => {
+                    this.stepDocumentationError.set(stepName, 'Unable to load 
step documentation');
+                    this.stepDocumentationLoading.set(stepName, false);
+                }
+            });
+    }

Review Comment:
   Was this intentionally designed to directly call the service to load the 
step markdown here rather than through NgRx due to needing to load 
(potentially) multiple steps docs for this connector? The most similar use case 
within docs is the additional details loading async, but that is managed 
through ngrx. However, that only needs to manage a single value.
   
   I can see the value in managing it internal to the component as it is a 
short-lived thing and managing these in ngrx would add overhead and complexity. 
Just wanted to make sure it was a conscious decision to stray from the 
established ngrx pattern.



##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/connector-definition/connector-definition.component.html:
##########
@@ -0,0 +1,204 @@
+<!--
+  ~ 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.
+  -->
+
+@if (connectorDefinitionState) {
+    @if (isInitialLoading(connectorDefinitionState)) {
+        <ngx-skeleton-loader count="3"></ngx-skeleton-loader>
+    } @else {
+        @if (connectorDefinitionState.connectorDefinition; as 
connectorDefinition) {
+            <div class="flex flex-col gap-y-4 p-4">
+                <h3 class="primary-color">
+                    {{ formatExtensionName(connectorDefinition.type) }} {{ 
connectorDefinition.version }}
+                </h3>
+                <div class="flex flex-col gap-y-4">
+                    @if (connectorDefinition.deprecated) {
+                        <div class="caution-color-background p-4 flex flex-col 
gap-y-2">
+                            @if (connectorDefinition.deprecationReason) {
+                                <div>{{ connectorDefinition.deprecationReason 
}}</div>
+                            } @else {
+                                <div>
+                                    Please be aware this connector is 
deprecated and may be removed in the near future.
+                                </div>
+                            }
+                            @if (connectorDefinition.deprecationAlternatives) {
+                                <div>
+                                    <div>See Alternatives</div>
+                                    <see-also 
[extensionTypes]="connectorDefinition.deprecationAlternatives"></see-also>
+                                </div>
+                            }
+                        </div>
+                    }
+                    <div>
+                        <div>Bundle</div>
+                        <div class="tertiary-color font-medium">
+                            {{ connectorDefinition.group }} | {{ 
connectorDefinition.artifact }}
+                        </div>
+                    </div>
+                    @if (connectorDefinition.typeDescription) {
+                        <div>
+                            <div>Description</div>
+                            <div class="tertiary-color font-medium">{{ 
connectorDefinition.typeDescription }}</div>
+                        </div>
+                    }
+                    @if (connectorDefinition.tags) {
+                        <div>
+                            <div>Tags</div>
+                            <div class="tertiary-color font-medium">
+                                {{ connectorDefinition.tags.join(', ') }}
+                            </div>
+                        </div>
+                    }
+                    @if 
(hasConfigurationSteps(connectorDefinition.configurationSteps)) {
+                        <div>
+                            <div class="flex justify-between items-center">
+                                <h2>Configuration Steps</h2>
+                                <div>
+                                    <button
+                                        type="button"
+                                        mat-icon-button
+                                        class="primary-icon-button"
+                                        title="Expand All"
+                                        (click)="expandAllSteps()">
+                                        <i class="fa fa-expand 
fa-rotate-45"></i>
+                                    </button>
+                                    <button
+                                        type="button"
+                                        mat-icon-button
+                                        class="primary-icon-button"
+                                        title="Collapse All"
+                                        (click)="collapseAllSteps()">
+                                        <i class="fa fa-compress 
fa-rotate-45"></i>
+                                    </button>
+                                </div>
+                            </div>
+                            <mat-accordion multi 
#stepsAccordion="matAccordion">
+                                @for (step of 
connectorDefinition.configurationSteps; track step.name) {
+                                    <mat-expansion-panel [expanded]="true">
+                                        <mat-expansion-panel-header>
+                                            <mat-panel-title>{{ step.name 
}}</mat-panel-title>
+                                        </mat-expansion-panel-header>
+                                        <div class="flex flex-col gap-y-4">
+                                            @if (step.description) {
+                                                <div class="tertiary-color">{{ 
step.description }}</div>
+                                            }
+                                            @if (step.documented) {
+                                                <mat-expansion-panel
+                                                    
(opened)="loadStepDocumentation(connectorDefinition, step.name)">
+                                                    
<mat-expansion-panel-header>
+                                                        <mat-panel-title>Step 
Documentation</mat-panel-title>
+                                                    
</mat-expansion-panel-header>
+                                                    <div 
class="step-documentation">
+                                                        @if 
(isStepDocumentationLoading(step.name)) {
+                                                            
<ngx-skeleton-loader count="3"></ngx-skeleton-loader>
+                                                        } @else if 
(getStepDocumentationError(step.name); as error) {
+                                                            <div 
class="error-color">{{ error }}</div>
+                                                        } @else if 
(getStepDocumentation(step.name); as documentation) {
+                                                            <markdown 
[data]="documentation"></markdown>
+                                                        }
+                                                    </div>
+                                                </mat-expansion-panel>
+                                            }
+                                            @if 
(hasPropertyGroups(step.propertyGroups)) {
+                                                @for (group of 
step.propertyGroups; track group.name) {
+                                                    <div class="property-group 
flex flex-col gap-y-2">

Review Comment:
   Manage the bottom margin here with tailwind rather than in the scss file in 
the `.property-group` class
   
   ```suggestion
                                                       <div 
class="property-group flex flex-col gap-y-2 mb-4">
   ```



##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/connector-definition/connector-definition.component.html:
##########
@@ -0,0 +1,204 @@
+<!--
+  ~ 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.
+  -->
+
+@if (connectorDefinitionState) {
+    @if (isInitialLoading(connectorDefinitionState)) {
+        <ngx-skeleton-loader count="3"></ngx-skeleton-loader>
+    } @else {
+        @if (connectorDefinitionState.connectorDefinition; as 
connectorDefinition) {
+            <div class="flex flex-col gap-y-4 p-4">
+                <h3 class="primary-color">
+                    {{ formatExtensionName(connectorDefinition.type) }} {{ 
connectorDefinition.version }}
+                </h3>
+                <div class="flex flex-col gap-y-4">
+                    @if (connectorDefinition.deprecated) {
+                        <div class="caution-color-background p-4 flex flex-col 
gap-y-2">
+                            @if (connectorDefinition.deprecationReason) {
+                                <div>{{ connectorDefinition.deprecationReason 
}}</div>
+                            } @else {
+                                <div>
+                                    Please be aware this connector is 
deprecated and may be removed in the near future.
+                                </div>
+                            }
+                            @if (connectorDefinition.deprecationAlternatives) {
+                                <div>
+                                    <div>See Alternatives</div>
+                                    <see-also 
[extensionTypes]="connectorDefinition.deprecationAlternatives"></see-also>
+                                </div>
+                            }
+                        </div>
+                    }
+                    <div>
+                        <div>Bundle</div>
+                        <div class="tertiary-color font-medium">
+                            {{ connectorDefinition.group }} | {{ 
connectorDefinition.artifact }}
+                        </div>
+                    </div>
+                    @if (connectorDefinition.typeDescription) {
+                        <div>
+                            <div>Description</div>
+                            <div class="tertiary-color font-medium">{{ 
connectorDefinition.typeDescription }}</div>
+                        </div>
+                    }
+                    @if (connectorDefinition.tags) {
+                        <div>
+                            <div>Tags</div>
+                            <div class="tertiary-color font-medium">
+                                {{ connectorDefinition.tags.join(', ') }}
+                            </div>
+                        </div>
+                    }
+                    @if 
(hasConfigurationSteps(connectorDefinition.configurationSteps)) {
+                        <div>
+                            <div class="flex justify-between items-center">
+                                <h2>Configuration Steps</h2>
+                                <div>
+                                    <button
+                                        type="button"
+                                        mat-icon-button
+                                        class="primary-icon-button"
+                                        title="Expand All"
+                                        (click)="expandAllSteps()">
+                                        <i class="fa fa-expand 
fa-rotate-45"></i>
+                                    </button>
+                                    <button
+                                        type="button"
+                                        mat-icon-button
+                                        class="primary-icon-button"
+                                        title="Collapse All"
+                                        (click)="collapseAllSteps()">
+                                        <i class="fa fa-compress 
fa-rotate-45"></i>
+                                    </button>
+                                </div>
+                            </div>
+                            <mat-accordion multi 
#stepsAccordion="matAccordion">
+                                @for (step of 
connectorDefinition.configurationSteps; track step.name) {
+                                    <mat-expansion-panel [expanded]="true">
+                                        <mat-expansion-panel-header>
+                                            <mat-panel-title>{{ step.name 
}}</mat-panel-title>
+                                        </mat-expansion-panel-header>
+                                        <div class="flex flex-col gap-y-4">
+                                            @if (step.description) {
+                                                <div class="tertiary-color">{{ 
step.description }}</div>
+                                            }
+                                            @if (step.documented) {
+                                                <mat-expansion-panel
+                                                    
(opened)="loadStepDocumentation(connectorDefinition, step.name)">
+                                                    
<mat-expansion-panel-header>
+                                                        <mat-panel-title>Step 
Documentation</mat-panel-title>

Review Comment:
   It feels a bit odd to need to click the header "Step Documentation" to see 
the documentation while on the documentation page. It seems this is primarily 
the information the user wants to see. making them click again to see it feels 
redundant. I understand it is an additional async call, but maybe we can load 
this when the step panel is loaded? If we don't want to get all of the steps 
and docs initially, i'd consider even keeping the other steps collapsed until 
the user decides they want to see the info about that step.
   
   Thoughts? Any alternate approaches considered?



##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/ui/connector-definition/connector-definition.component.scss:
##########
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+:host {
+    display: block;
+}
+
+.property-group {
+    margin-bottom: 16px;
+}

Review Comment:
   This can be removed if we define the margin in the DOM layout with tailwind 
`mb-4`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to