dididy commented on code in PR #5064: URL: https://github.com/apache/zeppelin/pull/5064#discussion_r2325341631
########## zeppelin-web-angular/src/app/pages/workspace/notebook/paragraph/paragraph.component.ts: ########## @@ -382,6 +388,41 @@ export class NotebookParagraphComponent extends ParagraphBase implements OnInit, this.messageService.moveParagraph(this.paragraph.id, newIndex); } + moveParagraphUp() { + let newIndex = -1; + for (let i = 0; i < this.note.paragraphs.length; i++) { + if (this.note.paragraphs[i].id === this.paragraph.id) { + newIndex = i - 1; + break; + } + } + if (newIndex < 0 || newIndex >= this.note.paragraphs.length) { + return; + } + this.messageService.moveParagraph(this.paragraph.id, newIndex); + } + + moveParagraphDown() { + let newIndex = -1; + for (let i = 0; i < this.note.paragraphs.length; i++) { + if (this.note.paragraphs[i].id === this.paragraph.id) { + newIndex = i + 1; + break; + } + } + + if (newIndex < 0 || newIndex >= this.note.paragraphs.length) { + return; + } + this.messageService.moveParagraph(this.paragraph.id, newIndex); + } Review Comment: 3759b33 I’ve updated all four functions to use a declarative approach. The logic in `moveParagraphUp()` and `moveParagraphDown()` was previously imperative because that’s how it was implemented in the Classic UI. [moveParagraphUp > zeppelin-web/src/app/notebook/notebook.controller.js#L1438-L1447](https://github.com/dididy/zeppelin/blob/fix/ZEPPELIN-6197/6229/zeppelin-web/src/app/notebook/notebook.controller.js#L1438-L1447 ) [moveParagraphDown > zeppelin-web/src/app/notebook/notebook.controller.js#L1462-L1472 ](https://github.com/dididy/zeppelin/blob/fix/ZEPPELIN-6197/6229/zeppelin-web/src/app/notebook/notebook.controller.js#L1462-L1472) I’ve confirmed that both functions work correctly after converting them to a declarative approach. -- 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: reviews-unsubscr...@zeppelin.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org