mcgilman commented on code in PR #9536:
URL: https://github.com/apache/nifi/pull/9536#discussion_r1852304114


##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts:
##########
@@ -2245,51 +2279,64 @@ export class FlowEffects {
             ofType(FlowActions.paste),
             map((action) => action.request),
             concatLatestFrom(() => [
-                
this.store.select(selectCopiedSnippet).pipe(isDefinedAndNotNull()),
                 this.store.select(selectCurrentProcessGroupId),
-                this.store.select(selectTransform)
+                this.store.select(selectCurrentProcessGroupRevision),
+                this.store.select(selectCopiedContent)
             ]),
-            switchMap(([request, copiedSnippet, processGroupId, transform]) =>
-                
from(this.snippetService.createSnippet(copiedSnippet.snippet)).pipe(
-                    switchMap((response) => {
-                        let pasteLocation = request.pasteLocation;
-                        const snippetOrigin = copiedSnippet.origin;
-                        const dimensions = copiedSnippet.dimensions;
-
-                        if (!pasteLocation) {
-                            // if the copied snippet is from a different group 
or the original items are not in the viewport, center the pasted snippet
-                            if (
-                                copiedSnippet.snippet.parentGroupId != 
processGroupId ||
-                                
!this.canvasView.isBoundingBoxInViewport(dimensions, false)
-                            ) {
-                                const center = 
this.canvasView.getCenterForBoundingBox(dimensions);
-                                pasteLocation = {
-                                    x: center[0] - transform.translate.x / 
transform.scale,
-                                    y: center[1] - transform.translate.y / 
transform.scale
-                                };
-                            } else {
-                                pasteLocation = {
-                                    x: snippetOrigin.x + 25,
-                                    y: snippetOrigin.y + 25
-                                };
-                            }
+            switchMap(([request, processGroupId, revision, copiedContent]) => {
+                let pasteRequest: PasteRequest | null = null;
+
+                // Determine if the paste should be positioned based off of 
previously copied items or centered.
+                //   * The current process group is the same as the content 
that was last copied
+                //   * And, the last copied content is the same as the content 
being pasted
+                //   * And, the original content is still in the canvas view
+                if (copiedContent && processGroupId === 
copiedContent.processGroupId) {
+                    if (copiedContent.copyResponse.id === request.id) {
+                        const isInView = 
this.copyPasteService.isCopiedContentInView(copiedContent.copyResponse);
+                        if (isInView) {
+                            pasteRequest = 
this.copyPasteService.toOffsetPasteRequest(
+                                request,
+                                copiedContent.pasteCount
+                            );
                         }
+                    }
+                }
+
+                // If no paste request was created before, create one that is 
centered in the current canvas view
+                if (!pasteRequest) {
+                    pasteRequest = 
this.copyPasteService.toCenteredPasteRequest(request);
+                }
 
-                        return from(
-                            
this.snippetService.copySnippet(response.snippet.id, pasteLocation, 
processGroupId)

Review Comment:
   `SnippetService.copySnippet` is no longer user and can be deleted.



##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/service/canvas-utils.service.ts:
##########
@@ -135,12 +134,12 @@ export class CanvasUtils {
                 this.breadcrumbs = breadcrumbs;
             });
 
-        this.store
-            .select(selectCopiedSnippet)
-            .pipe(takeUntilDestroyed(this.destroyRef))
-            .subscribe((copiedSnippet) => {
-                this.copiedSnippet = copiedSnippet;
-            });
+        // this.store
+        //     .select(selectCopiedSnippet)
+        //     .pipe(takeUntilDestroyed(this.destroyRef))
+        //     .subscribe((copiedSnippet) => {
+        //         this.copiedSnippet = copiedSnippet;
+        //     });

Review Comment:
   Should this have been removed?



##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/state/copy/copy.effects.ts:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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 } from '@ngrx/effects';
+
+@Injectable()
+export class CopyEffects {
+    constructor(private actions$: Actions) {}

Review Comment:
   `actions$` is unused and can be removed.



-- 
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