This is an automated email from the ASF dual-hosted git repository.

scottyaslan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 72a3529718 NIFI-13083: (#8684)
72a3529718 is described below

commit 72a3529718118d0a90070b53250d8bfae76598d8
Author: Matt Gilman <matt.c.gil...@gmail.com>
AuthorDate: Mon Apr 22 15:39:02 2024 -0400

    NIFI-13083: (#8684)
    
    - Fixing import preventing the dialog from warning the user that they must 
apply changes before deleting/adding the same parameter with different 
sensitivities.
    - Allowing the sensitivity to change when deleting/adding the same 
parameter as long as it hasn't been saved yet.
    - Adding the Parameters context menu item for Process Groups.
---
 .../service/canvas-context-menu.service.ts         | 28 +++++++++++----
 .../flow-designer/service/canvas-utils.service.ts  | 41 +++++++++++++++++++++-
 .../pages/flow-designer/state/flow/flow.actions.ts |  6 ++++
 .../pages/flow-designer/state/flow/flow.effects.ts | 12 +++++++
 .../app/pages/flow-designer/state/flow/index.ts    |  4 +++
 .../parameter-table/parameter-table.component.ts   |  7 ++--
 6 files changed, 89 insertions(+), 9 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/canvas-context-menu.service.ts
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/canvas-context-menu.service.ts
index 9685477e21..418f9ae54f 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/canvas-context-menu.service.ts
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/canvas-context-menu.service.ts
@@ -57,7 +57,8 @@ import {
     stopVersionControlRequest,
     copy,
     paste,
-    terminateThreads
+    terminateThreads,
+    navigateToParameterContext
 } from '../state/flow/flow.actions';
 import { ComponentType } from '../../../state/shared';
 import {
@@ -504,14 +505,29 @@ export class CanvasContextMenu implements 
ContextMenuDefinitionProvider {
                 }
             },
             {
-                condition: (selection: any) => {
-                    // TODO - hasParameterContext
-                    return false;
+                condition: (selection: d3.Selection<any, any, any, any>) => {
+                    return this.canvasUtils.hasParameterContext(selection);
                 },
                 clazz: 'fa',
                 text: 'Parameters',
-                action: () => {
-                    // TODO - open parameter context
+                action: (selection: d3.Selection<any, any, any, any>) => {
+                    let id;
+                    if (selection.empty()) {
+                        id = this.canvasUtils.getParameterContextId();
+                    } else {
+                        const selectionData = selection.datum();
+                        id = selectionData.parameterContext.id;
+                    }
+
+                    if (id) {
+                        this.store.dispatch(
+                            navigateToParameterContext({
+                                request: {
+                                    id
+                                }
+                            })
+                        );
+                    }
                 }
             },
             {
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/canvas-utils.service.ts
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/canvas-utils.service.ts
index afbc4d2940..d8d2320f51 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/canvas-utils.service.ts
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/canvas-utils.service.ts
@@ -25,6 +25,7 @@ import {
     selectCanvasPermissions,
     selectConnections,
     selectCopiedSnippet,
+    selectCurrentParameterContext,
     selectCurrentProcessGroupId,
     selectParentProcessGroupId
 } from '../state/flow/flow.selectors';
@@ -32,7 +33,7 @@ import { initialState as initialFlowState } from 
'../state/flow/flow.reducer';
 import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
 import { BulletinsTip } from 
'../../../ui/common/tooltips/bulletins-tip/bulletins-tip.component';
 import { BreadcrumbEntity, Position } from '../state/shared';
-import { ComponentType, Permissions } from '../../../state/shared';
+import { ComponentType, ParameterContextReferenceEntity, Permissions } from 
'../../../state/shared';
 import { NiFiCommon } from '../../../service/nifi-common.service';
 import { CurrentUser } from '../../../state/current-user';
 import { initialState as initialUserState } from 
'../../../state/current-user/current-user.reducer';
@@ -57,6 +58,8 @@ export class CanvasUtils {
     private parentProcessGroupId: string | null = 
initialFlowState.flow.processGroupFlow.parentGroupId;
     private canvasPermissions: Permissions = initialFlowState.flow.permissions;
     private currentUser: CurrentUser = initialUserState.user;
+    private currentParameterContext: ParameterContextReferenceEntity | null =
+        initialFlowState.flow.processGroupFlow.parameterContext;
     private flowConfiguration: FlowConfiguration | null = 
initialFlowConfigurationState.flowConfiguration;
     private connections: any[] = [];
     private breadcrumbs: BreadcrumbEntity | null = null;
@@ -107,6 +110,13 @@ export class CanvasUtils {
                 this.currentUser = user;
             });
 
+        this.store
+            .select(selectCurrentParameterContext)
+            .pipe(takeUntilDestroyed(this.destroyRef))
+            .subscribe((currentParameterContext) => {
+                this.currentParameterContext = currentParameterContext;
+            });
+
         this.store
             .select(selectFlowConfiguration)
             .pipe(takeUntilDestroyed(this.destroyRef))
@@ -205,6 +215,13 @@ export class CanvasUtils {
         return this.parentProcessGroupId;
     }
 
+    /**
+     * Returns the current parameter context id or null if there is no bound 
parameter context.
+     */
+    public getParameterContextId(): string | null {
+        return this.currentParameterContext ? this.currentParameterContext.id 
: null;
+    }
+
     /**
      * Returns whether the current group is not the root group and the current 
selection is empty.
      *
@@ -600,6 +617,28 @@ export class CanvasUtils {
         return this.isProcessor(selection) && this.canAccessProvenance();
     }
 
+    /**
+     * Determines if there is a Parameter Context bound.
+     *
+     * @param selection
+     */
+    public hasParameterContext(selection: d3.Selection<any, any, any, any>): 
boolean {
+        let parameterContext;
+
+        if (selection.empty()) {
+            parameterContext = this.currentParameterContext;
+        } else if (this.isProcessGroup(selection)) {
+            const pg = selection.datum();
+            parameterContext = pg.parameterContext;
+        }
+
+        if (parameterContext) {
+            return parameterContext.permissions.canRead;
+        }
+
+        return false;
+    }
+
     /**
      * Determines whether the current user can view the status history for the 
selected component.
      *
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.actions.ts
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.actions.ts
index 67deb5e17b..5f2c30ae9f 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.actions.ts
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.actions.ts
@@ -59,6 +59,7 @@ import {
     NavigateToComponentRequest,
     NavigateToControllerServicesRequest,
     NavigateToManageComponentPoliciesRequest,
+    NavigateToParameterContext,
     NavigateToQueueListing,
     OpenChangeVersionDialogRequest,
     OpenComponentDialogRequest,
@@ -388,6 +389,11 @@ export const navigateToQueueListing = createAction(
     props<{ request: NavigateToQueueListing }>()
 );
 
+export const navigateToParameterContext = createAction(
+    `${CANVAS_PREFIX} Navigate To Parameter Context`,
+    props<{ request: NavigateToParameterContext }>()
+);
+
 export const editCurrentProcessGroup = createAction(
     `${CANVAS_PREFIX} Edit Current Process Group`,
     props<{
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts
index 0ca8744b6b..eb92454cd2 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts
@@ -933,6 +933,18 @@ export class FlowEffects {
         { dispatch: false }
     );
 
+    navigateToParameterContext$ = createEffect(
+        () =>
+            this.actions$.pipe(
+                ofType(FlowActions.navigateToParameterContext),
+                map((action) => action.request),
+                tap((request) => {
+                    this.router.navigate(['/parameter-contexts', request.id]);
+                })
+            ),
+        { dispatch: false }
+    );
+
     navigateToEditCurrentProcessGroup$ = createEffect(
         () =>
             this.actions$.pipe(
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/index.ts
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/index.ts
index c0ce2dd56d..09083969bb 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/index.ts
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/index.ts
@@ -367,6 +367,10 @@ export interface NavigateToQueueListing {
     connectionId: string;
 }
 
+export interface NavigateToParameterContext {
+    id: string;
+}
+
 export interface EditCurrentProcessGroupRequest {
     id: string;
 }
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.ts
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.ts
index 2604ea0a9a..b3f84250c1 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.ts
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/parameter-contexts/ui/parameter-context-listing/parameter-table/parameter-table.component.ts
@@ -31,7 +31,7 @@ import { Observable, take } from 'rxjs';
 import { ParameterReferences } from 
'../../../../../ui/common/parameter-references/parameter-references.component';
 import { Store } from '@ngrx/store';
 import { ParameterContextListingState } from 
'../../../state/parameter-context-listing';
-import { showOkDialog } from 
'../../../../flow-designer/state/flow/flow.actions';
+import { showOkDialog } from 
'../../../state/parameter-context-listing/parameter-context-listing.actions';
 
 export interface ParameterItem {
     deleted: boolean;
@@ -157,7 +157,10 @@ export class ParameterTable implements AfterViewInit, 
ControlValueAccessor {
                 );
 
                 if (item) {
-                    if (item.entity.parameter.sensitive !== 
parameter.sensitive) {
+                    // if the item is added that means it hasn't been saved 
yet. in this case, we
+                    // can simply update the existing parameter. if the item 
has been saved, and the
+                    // sensitivity has changed, the user must apply the 
changes first.
+                    if (!item.added && item.entity.parameter.sensitive !== 
parameter.sensitive) {
                         this.store.dispatch(
                             showOkDialog({
                                 title: 'Parameter Exists',

Reply via email to