-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Resolve the functionality to duplicate a page that has been already duplicated #1776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ Changes requested. Reviewed everything up to ec33733 in 2 minutes and 1 seconds
More details
- Looked at
19
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. apps/studio/src/routes/editor/LayersPanel/Tree/PageTreeNode.tsx:78
- Draft comment:
New path generation always appends '1'. This may cause duplicate naming issues when duplicating a page multiple times. Consider incrementing the suffix (e.g., '2', '3', etc.) to ensure uniqueness. - Reason this comment was not posted:
Marked as duplicate.
2. apps/studio/src/routes/editor/LayersPanel/Tree/PageTreeNode.tsx:78
- Draft comment:
Consider checking if the generated newPath already exists to avoid collisions, especially when duplications occur repeatedly. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
The comment raises a valid concern about potential path collisions. However, I don't see evidence that pathExists() is a real method on editorEngine.pages. The suggestion assumes implementation details we can't verify. The current code likely relies on the backend to handle collisions appropriately.
I might be wrong about the backend handling - what if it just overwrites existing files silently? Also, the UI could benefit from preventing collisions early.
While collision prevention would be nice, we can't assume the suggested API exists. If there were serious collision issues, they would likely be handled at a more central level.
Delete the comment since it makes assumptions about available APIs and the current error handling approach without strong evidence.
Workflow ID: wflow_JrL0ZaOgjvlIFoTs
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
const basePath = node.data.path; | ||
const newPath = basePath.replace(/(\/[^/]+)$/, (match) => { | ||
const baseName = getBaseName(match); | ||
const newName = `${baseName}1`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider the duplication naming logic: appending '1' may lead to unexpected names on multiple duplications (e.g., 'Home' → 'Home1' then 'Home1' → 'Home11').
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome thanks @SoloDevAbu!
* 'main' of https://github.com/onlook-dev/onlook: Resolve the functionality to duplicate a page that has been already duplicated (onlook-dev#1776) fix text color changes inconsistently when entering edit mode (onlook-dev#1780)
…uplicated (#1776) * Resolve the functionality to duplicate a page that has been already duplicated
…uplicated (onlook-dev#1776) * Resolve the functionality to duplicate a page that has been already duplicated
…uplicated (onlook-dev#1776) * Resolve the functionality to duplicate a page that has been already duplicated
Description
fixed when a page duplicated for the first time, then again the page can't be duplicated.
Related Issues
Solved issue #1770
Important
Fixes page duplication issue by modifying
handleDuplicate
inPageTreeNode.tsx
to generate unique paths.PageTreeNode.tsx
.handleDuplicate
to generate a unique path by appending '1' to the base name of the page.handleDuplicate
inPageTreeNode.tsx
to usegetBaseName
for path generation.This description was created by
for ec33733. It will automatically update as commits are pushed.