Skip to content
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

feat: Add auto-teleport to Delete Collection #11459

Merged
merged 3 commits into from
Mar 10, 2025

Conversation

hassnian
Copy link
Contributor

@hassnian hassnian commented Mar 7, 2025

PR Type

  • Bugfix
  • Feature
  • Refactoring

Context

Needs QA check

Screenshot 📸

  • My fix has changed something on UI;

Summary by CodeRabbit

  • New Features

    • Introduced a unified modal component for handling actions, including deletion confirmations and transaction notifications.
    • Added an updated deletion confirmation dialog with a checkbox for acknowledgment and dynamic prompts.
  • Refactor

    • Simplified deletion flows across collection and user cart components for a more streamlined experience.
    • Updated user-facing messaging to clearly emphasize the permanence of deletion actions.
    • Enhanced modal structure and content for improved user interaction.

Copy link

coderabbitai bot commented Mar 7, 2025

Walkthrough

The changes update multiple components handling collection deletion. The deletion process now uses a new modal component, ActionModal, replacing legacy modals. Key modifications include adjustments to prop definitions and event handling, a shift to a checkbox-based acknowledgment instead of buttons, and a streamlined deletion workflow. Additional updates include minor interface changes in auxiliary components and a wording update in internationalization messages.

Changes

File(s) Change Summary
components/collection/ConfirmDeleteCollectionModal.vue, .../HeroButtonDeleteCollection.vue, .../HeroButtons.vue Refactored deletion modal components by replacing NeoModal with ActionModal, updating prop bindings (e.g., adding getAction and collection), removing deprecated deletion functions, and introducing an acknowledgment checkbox.
components/common/ActionModal.vue, .../userCart/UserCartModal.vue Introduced the new ActionModal component to consolidate modal functionality. Updated the user cart modal to use this component, simplifying modal state handling and removing legacy components like SigningModal and NeoModal.
components/common/autoTeleport/AutoTeleportActionButton.vue Changed the amount prop from required to optional.
i18n/locales/en.json Modified the confirmation message wording for collection deletion to emphasize user acknowledgment and finality.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant HB as HeroButtonDeleteCollection
    participant CTM as ConfirmDeleteCollectionModal
    participant AM as ActionModal
    participant S as CollectionService

    U->>HB: Click "Delete Collection"
    HB->>CTM: Open deletion modal (passes getAction & collection)
    CTM->>AM: Render modal with updated props & acknowledgment checkbox
    U->>AM: Toggle acknowledgment checkbox
    U->>AM: Confirm deletion action
    AM->>S: Invoke getAction() to perform deletion
    S-->>AM: Return deletion confirmation
    AM-->>CTM: Close modal and notify completion
Loading

Poem

I'm a happy rabbit, skipping by code,
Nibbled away the clutter on this modal road.
Checkboxes and props now lead the way,
Deletion flows clearer every day.
With a hop and a twitch, my code garden grows—
Celebrating changes in delightful rows!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between c6135c1 and 626e72c.

📒 Files selected for processing (7)
  • components/collection/ConfirmDeleteCollectionModal.vue (1 hunks)
  • components/collection/HeroButtonDeleteCollection.vue (1 hunks)
  • components/collection/HeroButtons.vue (1 hunks)
  • components/common/ActionModal.vue (1 hunks)
  • components/common/autoTeleport/AutoTeleportActionButton.vue (1 hunks)
  • components/common/userCart/UserCartModal.vue (2 hunks)
  • i18n/locales/en.json (1 hunks)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Mar 7, 2025

Deploy Preview for koda-canary ready!

Name Link
🔨 Latest commit 626e72c
🔍 Latest deploy log https://app.netlify.com/sites/koda-canary/deploys/67cac555185d1200091e073a
😎 Deploy Preview https://deploy-preview-11459--koda-canary.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@hassnian hassnian changed the title fix: Balance low error when deleting collection feat: Add auoto-teleport to Delete Collection Mar 7, 2025
@hassnian hassnian changed the title feat: Add auoto-teleport to Delete Collection feat: Add auto-teleport to Delete Collection Mar 7, 2025
@hassnian
Copy link
Contributor Author

hassnian commented Mar 7, 2025

@coderabbitai review

Copy link

coderabbitai bot commented Mar 7, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (8)
components/common/autoTeleport/AutoTeleportActionButton.vue (1)

126-126: Consider verifying default value for optional amount prop.

Changing amount to an optional prop while also assigning a default of 0 in the defaults block (line 144) might cause confusion if other parts of the code rely on this prop being set. Ensure consumers of AutoTeleportActionButton handle the case when amount is undefined, and confirm that default usage is consistent.

components/common/ActionModal.vue (2)

13-60: Ensure consistent close logic in <NeoModal>.

The close-at-signed prop in the signing modal and the @close="onClose" in <NeoModal> may result in multiple routes for dismissal. Verify that dismissal events from both modal instances do not conflict or leave the component in an inconsistent state. For clarity, unify or document the desired close behavior.


64-218: Transactional flow and error handling.

  1. The submit function (lines 133–148) calls execTransaction only when autoteleport is false. Ensure there's no edge case where skipping execTransaction inadvertently omits required steps.
  2. onBeforeMount(closeModal) (line 216) can prematurely close the modal when the component is mounted. Verify this behavior if the modal should be visible upon initial render.
  3. The useTransactionNotification block (lines 150–185) effectively handles success and error states. However, ensure large or delicate transactions properly surface partial failures or edge cases, especially if further user intervention is required.
components/collection/HeroButtonDeleteCollection.vue (2)

20-22: Provide a narrower type for collection

Using unknown may reduce clarity and type safety. For improved maintainability, consider supplying a more explicit type definition if known.


42-57: Refine subscription usage to avoid duplicates

Current logic overwrites the unsubscribeSubscription.value on each call. If a user attempts repeated openings, ensure the old subscription is unsubscribed first or that it is not triggered multiple times to prevent potential memory leaks.

components/collection/ConfirmDeleteCollectionModal.vue (1)

41-45: Improve type definitions for collection

Using any can mask type issues. If possible, define a custom interface or type that accurately represents the collection to increase reliability and clarity.

components/common/userCart/UserCartModal.vue (2)

82-82: Double-check concurrency on closing the modal

onClose sets userCartModal to undefined and clears items. If multiple modal closures occur in quick succession, ensure the store updates and emits remain consistent without race conditions.


90-90: Consider deep clone if needed

items.value = [...listingCartStore.itemsInChain] copies the array but not nested objects. If items are deeply nested, changes to store data might reflect unexpectedly. Evaluate if a deep clone can improve isolation.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c6135c1 and ac96eef.

📒 Files selected for processing (7)
  • components/collection/ConfirmDeleteCollectionModal.vue (1 hunks)
  • components/collection/HeroButtonDeleteCollection.vue (1 hunks)
  • components/collection/HeroButtons.vue (1 hunks)
  • components/common/ActionModal.vue (1 hunks)
  • components/common/autoTeleport/AutoTeleportActionButton.vue (1 hunks)
  • components/common/userCart/UserCartModal.vue (2 hunks)
  • i18n/locales/en.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: Redirect rules
  • GitHub Check: Header rules
  • GitHub Check: Pages changed
  • GitHub Check: shard (10, 10)
  • GitHub Check: runner / eslint
  • GitHub Check: build-cf
  • GitHub Check: build
  • GitHub Check: shard (9, 10)
  • GitHub Check: shard (7, 10)
  • GitHub Check: shard (8, 10)
  • GitHub Check: shard (2, 10)
  • GitHub Check: shard (4, 10)
  • GitHub Check: shard (6, 10)
  • GitHub Check: shard (3, 10)
  • GitHub Check: shard (5, 10)
  • GitHub Check: shard (1, 10)
🔇 Additional comments (16)
i18n/locales/en.json (1)

270-270: Wording adjustment for clarity.

The updated message "I understand collection will be permanently destroyed. Your deposit will be refunded." is concise and emphasizes finality. This also helps ensure user acknowledgment before a destructive action. Looks good.

components/collection/HeroButtons.vue (1)

99-101: Prop binding for CollectionHeroButtonDeleteCollection.

Passing :collection="collection" ensures the child component can access and handle the collection’s data directly. Verify that this prop is optional or required in the child component and handle any potential null or undefined values if it’s required.

components/common/ActionModal.vue (1)

1-11: Modal stacking logic with SigningModal.

The template conditionally renders the <SigningModal> only when autoTeleport is false. Confirm that there are no scenarios where both modals need to be visible simultaneously. Otherwise, consider a separate approach to handle parallel states (e.g., queueing or layering).

components/collection/HeroButtonDeleteCollection.vue (4)

8-10: Validate usage of modal props and events

Using getAction and collection as props works well with @success. However, consider verifying that collection is fully loaded before opening the modal, to avoid potential undefined references or incomplete data.


18-19: Typed import looks good

Importing Actions from the transaction types is clear and descriptive. No concerns here.


32-32: Check for valid route param

When computing collectionId, ensure route.params.id actually exists and is convertible to a string. If it might be undefined, add a safe fallback or explicit error handling.


34-40: Consider graceful handling for invalid IDs

getAction returns an action with collectionId. If route.params.id is missing or invalid, a deletion request could fail. Validate collectionId.value before returning the action object to reduce the chance of runtime errors.

components/collection/ConfirmDeleteCollectionModal.vue (6)

2-10: Refactor to ActionModal is coherent

Switching from NeoModal to ActionModal aligns with the updated workflow. Passing @success="$emit('success')" centralizes success handling and simplifies code.


12-21: Verify collection.meta availability

When displaying collection.meta.image, confirm meta is defined to prevent runtime errors if the collection lacks metadata or an image. A fallback image or error check could improve robustness.


23-32: Acknowledgment checkbox enhances clarity

Using a checkbox to ensure the user acknowledges the deletion is a good UX improvement. This approach discourages accidental clicks and clarifies the irreversible action.


37-39: Sanitize IPFS URLs carefully

sanitizeIpfsUrl is helpful. Ensure that edge cases (e.g., invalid strings) are handled gracefully so that the UI does not break or display invalid URLs.


50-57: Dynamic label is user-friendly

The computed label that instructs users to acknowledge before continuing provides clarity. This straightforward approach improves usability.


59-63: Resetting acknowledgment ensures repeat confirmations

Clearing the checkbox state whenever the modal closes is a robust approach and prevents accidental re-use of previous acknowledgments.

components/common/userCart/UserCartModal.vue (3)

2-40: ActionModal integration looks consistent

Replacing NeoModal and SigningModal with ActionModal unifies the modal pattern. The new approach is cleaner and easier to maintain. Confirm that no references to old modals remain in surrounding code.


50-50: Exposed type is clear

Defining UserCartModalExpose clarifies what this component exposes. This helps other components or tests rely on a stable interface.


80-80: Verify loading fallback

const loading = computed(() => (props.loading || loadingAbi.value)) merges prop-based loading with ABI loading checks. Ensure the props.loading default covers all usage scenarios.

Copy link

sonarqubecloud bot commented Mar 7, 2025

@hassnian hassnian marked this pull request as ready for review March 10, 2025 03:12
@hassnian hassnian requested a review from a team as a code owner March 10, 2025 03:12
@hassnian hassnian requested review from preschian and Jarsen136 and removed request for a team March 10, 2025 03:12
@vikiival vikiival added this pull request to the merge queue Mar 10, 2025
Merged via the queue into kodadot:main with commit c9f1724 Mar 10, 2025
25 of 26 checks passed
@hassnian hassnian deleted the issue-11458 branch March 10, 2025 11:43
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.

Balance low error when deleting collection
4 participants