rfellows commented on code in PR #11160:
URL: https://github.com/apache/nifi/pull/11160#discussion_r3126117350
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.ts:
##########
@@ -64,6 +77,10 @@ export class ConnectorCanvasComponent implements OnInit,
OnDestroy {
private destroyRef = inject(DestroyRef);
private router = inject(Router);
private dialog = inject(MatDialog);
+ private storage = inject(Storage);
+
+ private static readonly CONTROL_VISIBILITY_KEY =
'graph-control-visibility';
+ private static readonly GRAPH_CONTROL_KEY = 'connector-graph-controls';
Review Comment:
This duplicates `GRAPH_CONTROLS_STORAGE_KEY` on line 55 above. We should get
rid of one of them. At this point, `GRAPH_CONTROLS_STORAGE_KEY` is unused and
actually spawns a lint warning.
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/connector-canvas.component.scss:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+context-error-banner.canvas-error-banner {
+ ::ng-deep .banner-container {
+ background-color: var(--mat-sys-surface-container);
+ border: 1px solid var(--mat-sys-outline-variant);
+ border-radius: 4px;
+ box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
+ color: var(--mat-sys-on-surface);
+ margin-bottom: 0;
+ }
+}
Review Comment:
This file isn't leveraged/referenced in the `@Component` ts file and it
duplicates the same styles as in `_connector-canvas.component-theme.scss`...
can we just delete this file since it seems to be unsed?
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/connectors/ui/connector-canvas/graph-controls/connector-info-control/connector-info-control.component.ts:
##########
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Component, inject, input } from '@angular/core';
+import { MatButtonModule } from '@angular/material/button';
+import { MatExpansionPanel, MatExpansionPanelHeader, MatExpansionPanelTitle }
from '@angular/material/expansion';
+import { MatTooltip } from '@angular/material/tooltip';
+import { Store } from '@ngrx/store';
+import {
+ ConnectorDetailHeader,
+ ConnectorEntity,
+ Storage,
+ canReadConnector,
+ canModifyConnector,
+ canOperateConnector,
+ isConnectorActionAllowed,
+ getConnectorActionDisabledReason
+} from '@nifi/shared';
+import * as ConnectorCanvasEntityActions from
'../../../../state/connector-canvas-entity/connector-canvas-entity.actions';
+import {
+ navigateToViewConnectorDetails,
+ navigateToConfigureConnector
+} from '../../../../state/connectors-listing/connectors-listing.actions';
+
+@Component({
+ selector: 'connector-info-control',
+ standalone: true,
+ imports: [
+ ConnectorDetailHeader,
+ MatButtonModule,
+ MatExpansionPanel,
+ MatExpansionPanelHeader,
+ MatExpansionPanelTitle,
+ MatTooltip
+ ],
+ templateUrl: './connector-info-control.component.html',
+ styleUrls: ['./connector-info-control.component.scss']
+})
+export class ConnectorInfoControl {
+ private store = inject(Store);
+ private storage = inject(Storage);
+
+ private static readonly CONTROL_VISIBILITY_KEY =
'graph-control-visibility';
+ private static readonly CONNECTOR_KEY = 'connector-info-control';
+
+ connectorCollapsed = false;
+
+ connectorEntity = input<ConnectorEntity | null>(null);
+ entitySaving = input<boolean>(false);
+
+ constructor() {
+ try {
+ const item: { [key: string]: boolean } | null =
this.storage.getItem(
+ ConnectorInfoControl.CONTROL_VISIBILITY_KEY
+ );
+ if (item) {
+ this.connectorCollapsed =
item[ConnectorInfoControl.CONNECTOR_KEY] === false;
+ }
+ } catch (_e) {
+ // likely could not parse item... ignoring
+ }
+ }
+
+ toggleCollapsed(collapsed: boolean): void {
+ this.connectorCollapsed = collapsed;
+
+ let item: { [key: string]: boolean } | null =
this.storage.getItem(ConnectorInfoControl.CONTROL_VISIBILITY_KEY);
+ if (item == null) {
+ item = {};
+ }
+
+ item[ConnectorInfoControl.CONNECTOR_KEY] = !this.connectorCollapsed;
+ this.storage.setItem(ConnectorInfoControl.CONTROL_VISIBILITY_KEY,
item);
+ }
+
+ canRead(): boolean {
+ const entity = this.connectorEntity();
+ return !!entity && canReadConnector(entity);
+ }
+
+ canConfigure(): boolean {
+ const entity = this.connectorEntity();
+ if (!entity || this.entitySaving()) {
+ return false;
+ }
+ return canReadConnector(entity) && canModifyConnector(entity) &&
isConnectorActionAllowed(entity, 'CONFIGURE');
+ }
+
+ getConfigureDisabledReason(): string {
+ const entity = this.connectorEntity();
+ if (!entity) {
+ return '';
+ }
+ return getConnectorActionDisabledReason(entity, 'CONFIGURE');
+ }
+
+ showConfigureButton(): boolean {
+ const entity = this.connectorEntity();
+ if (!entity) {
+ return false;
+ }
+ return canReadConnector(entity) && canModifyConnector(entity);
+ }
+
+ canDrain(): boolean {
+ const entity = this.connectorEntity();
+ if (!entity) {
+ return false;
+ }
+ return canOperateConnector(entity) && isConnectorActionAllowed(entity,
'DRAIN_FLOWFILES');
+ }
+
+ canCancelDrain(): boolean {
+ const entity = this.connectorEntity();
+ if (!entity) {
+ return false;
+ }
+ return canOperateConnector(entity) && isConnectorActionAllowed(entity,
'CANCEL_DRAIN_FLOWFILES');
+ }
Review Comment:
These 2 `canXXX` methods differ in pattern to the others in this file in
that these don't consider the `this.entitySaving()`. They are more similar to
the `showXXX` methods. I see the `entitySaving` is instead used on the DOM
elements to control disabled state. Maybe tighten up the pattern? I think we
are getting what the desired effect is, but the logic isn't consistent.
--
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]