Skip to content

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

Merged
merged 2 commits into from
Apr 15, 2025

Conversation

SoloDevAbu
Copy link
Contributor

@SoloDevAbu SoloDevAbu commented Apr 13, 2025

Description

fixed when a page duplicated for the first time, then again the page can't be duplicated.

Related Issues

Solved issue #1770

Screenshot from 2025-04-13 15-27-36


Important

Fixes page duplication issue by modifying handleDuplicate in PageTreeNode.tsx to generate unique paths.

  • Behavior:
    • Fixes issue where a page could not be duplicated more than once in PageTreeNode.tsx.
    • Modifies handleDuplicate to generate a unique path by appending '1' to the base name of the page.
  • Functions:
    • Updates handleDuplicate in PageTreeNode.tsx to use getBaseName for path generation.

This description was created by Ellipsis for ec33733. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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 in 1 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`;
Copy link
Contributor

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').

Copy link
Contributor

@Kitenite Kitenite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thanks @SoloDevAbu!

@Kitenite Kitenite merged commit 0224afb into onlook-dev:main Apr 15, 2025
zongkelong pushed a commit to zongkelong/coolook that referenced this pull request Apr 15, 2025
* '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)
Kitenite pushed a commit that referenced this pull request Apr 15, 2025
…uplicated (#1776)

* Resolve the functionality to duplicate a page that has been already duplicated
ml-delaurier pushed a commit to ml-delaurier/nolook that referenced this pull request Apr 23, 2025
…uplicated (onlook-dev#1776)

* Resolve the functionality to duplicate a page that has been already duplicated
t1c1 pushed a commit to t1c1/onlookbotcodes that referenced this pull request Jun 5, 2025
…uplicated (onlook-dev#1776)

* Resolve the functionality to duplicate a page that has been already duplicated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants