Skip to content

chore: update anvil modal size api#37033

Merged
jsartisan merged 1 commit intoreleasefrom
chore/fix-modal-size-api
Oct 23, 2024
Merged

chore: update anvil modal size api#37033
jsartisan merged 1 commit intoreleasefrom
chore/fix-modal-size-api

Conversation

@jsartisan
Copy link
Contributor

@jsartisan jsartisan commented Oct 23, 2024

Fixes the API for modal for setting modal.

/ok-to-test tags="@tag.Anvil"

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11479189189
Commit: 1a07d20
Cypress dashboard.
Tags: @tag.Anvil
Spec:


Wed, 23 Oct 2024 12:09:48 UTC

Summary by CodeRabbit

  • New Features

    • Introduced a new size prop for the Modal component, allowing for flexible sizing options (e.g., small, medium, large).
    • Added overlayProps for enhanced customization of the Modal's overlay properties.
  • Bug Fixes

    • Removed the outdated dataAttributes prop, streamlining the Modal configuration.
  • Documentation

    • Updated examples to reflect the new prop structure for the Modal component.

@jsartisan jsartisan added the ok-to-test Required label for CI label Oct 23, 2024
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Oct 23, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

Walkthrough

The changes in this pull request focus on the Modal component, specifically in the Modal.tsx, types.ts, and related files. The dataAttributes prop has been removed and replaced with overlayProps, while a new size prop has been introduced with a default value of "medium". Updates were made to the ModalProps interface to reflect these changes. The ModalExamples and ComplexForm components have been updated to utilize the new size prop, simplifying modal size specifications. The WDSModalWidget class has also been modified to accommodate these prop changes.

Changes

File Change Summary
app/client/packages/design-system/widgets/src/components/Modal/src/Modal.tsx Removed dataAttributes, added overlayProps, introduced size prop with default "medium", reordered imports.
app/client/packages/design-system/widgets/src/components/Modal/src/types.ts Removed dataAttributes from ModalProps, added size and overlayProps to ModalProps.
app/client/packages/design-system/widgets/src/components/Modal/stories/ModalExamples.tsx Replaced dataAttributes with size prop for modal instances, updated large and small modals accordingly.
app/client/packages/design-system/widgets/src/testing/ComplexForm.tsx Removed dataAttributes, added size="small" to Modal.
app/client/src/modules/ui-builder/ui/wds/WDSModalWidget/widget/index.tsx Removed dataAttributes, added size and overlayProps to Modal, adjusted prop order in getWidgetView.

Possibly related PRs

  • chore: add tests for anvil modal. #34347: The changes in this PR involve adding tests for the Anvil Modal widget, which is directly related to the modifications made to the Modal component in the main PR, particularly regarding the handling of props like size and dataAttributes.

Suggested labels

Task, Anvil Pod

Suggested reviewers

  • KelvinOm
  • marks0351

Poem

In the land of modals, changes unfold,
With sizes and overlays, a story retold.
dataAttributes waved goodbye,
As size takes the stage, oh my!
Flexibility blooms, like flowers in spring,
A modal's new dance, let the joy bells ring! 🌼✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.

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
Contributor

@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: 1

🧹 Outside diff range and nitpick comments (4)
app/client/packages/design-system/widgets/src/components/Modal/src/Modal.tsx (1)

22-23: Component props update looks good

The data-size attribute and overlayProps spread provide a cleaner API for modal customization.

Consider adding a JSDoc comment above the Modal component to document the available size options and usage of overlayProps.

+/**
+ * Modal component with customizable size and overlay properties
+ * @param size - Modal size ("small" | "medium" | "large")
+ * @param overlayProps - Additional props to be spread on the overlay
+ */
 export const Modal = (props: ModalProps) => {
app/client/src/modules/ui-builder/ui/wds/WDSModalWidget/widget/index.tsx (1)

143-153: LGTM! Consider reordering props for better readability.

The Modal API changes look good with the new size prop and overlayProps. For better readability, consider grouping related props together:

  <Modal
    isOpen={this.state.isVisible as boolean}
    onClose={this.onModalClose}
+   size={this.props.size}
    overlayProps={{
      [AnvilDataAttributes.MODAL_SIZE]: this.props.size,
      [AnvilDataAttributes.WIDGET_NAME]: this.props.widgetName,
      [AnvilDataAttributes.IS_SELECTED_WIDGET]: this.props.isWidgetSelected
        ? "true"
        : "false",
    }}
    setOpen={(val) => this.setState({ isVisible: val })}
-   size={this.props.size}
  >
app/client/packages/design-system/widgets/src/components/Modal/stories/ModalExamples.tsx (2)

127-127: LGTM! Consider adding size documentation.

The size prop implementation is consistent. Consider adding a comment or updating component documentation to list available size options for future developers.


Line range hint 119-124: Consider documenting default size behavior.

The medium modal doesn't specify a size prop, relying on the default value. Consider adding a comment to explicitly indicate that medium is the default size for better code clarity.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 371b523 and 1a07d20.

📒 Files selected for processing (5)
  • app/client/packages/design-system/widgets/src/components/Modal/src/Modal.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/Modal/src/types.ts (2 hunks)
  • app/client/packages/design-system/widgets/src/components/Modal/stories/ModalExamples.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/testing/ComplexForm.tsx (1 hunks)
  • app/client/src/modules/ui-builder/ui/wds/WDSModalWidget/widget/index.tsx (1 hunks)
🧰 Additional context used
🔇 Additional comments (6)
app/client/packages/design-system/widgets/src/components/Modal/src/Modal.tsx (2)

1-6: Import reordering looks good


11-13: Props update looks good, verify migration impact

The new props structure with overlayProps and size is well-defined with appropriate defaults.

Let's verify all Modal usages have been updated:

app/client/packages/design-system/widgets/src/components/Modal/src/types.ts (2)

6-6: LGTM: Clean type import


19-22: Verify: Is excluding 'xSmall' size intentional?

The type definition explicitly omits the 'xSmall' size option. Please confirm if this is intentional, as it might affect existing modal implementations.

app/client/packages/design-system/widgets/src/testing/ComplexForm.tsx (1)

208-208: LGTM! Modal size prop update aligns with the new API.

The change from using dataAttributes to the new size prop follows the updated Modal API design.

Let's verify other Modal instances are updated consistently:

✅ Verification successful

Let me try a different approach to verify the Modal component usage.

This should help us:

  1. Find Modal component usage patterns
  2. Check if there are any remaining dataAttributes props
  3. Verify the consistency of size prop usage

The -U flag enables multiline matching, and we're including both .ts and .tsx files in the search.


Let me try one more time with just the file extension without type specification.


Based on the search results, I can see that the Modal component has been updated across the codebase to use a new API design that includes size prop instead of dataAttributes. The search shows no remaining usage of dataAttributes prop with Modal components, which confirms the migration is complete.

The size="small" prop update is correct and consistent with the new Modal API

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining dataAttributes usage in Modal components
rg -l "Modal.*dataAttributes" --type tsx

Length of output: 70


Script:

#!/bin/bash
# Search for Modal components with their props
rg -U "Modal.*?>" --type ts --type tsx -A 2

# Also search for any remaining dataAttributes usage
rg "dataAttributes" --type ts --type tsx

Length of output: 142


Script:

#!/bin/bash
# Find all TypeScript/React files first
fd "\.(tsx|ts)$" 

# Then search for Modal usage in those files
fd "\.(tsx|ts)$" -x rg -l "Modal.*dataAttributes"

# And search for Modal components with their props
fd "\.(tsx|ts)$" -x rg -U "Modal.*?>" -A 2

Length of output: 391747

app/client/packages/design-system/widgets/src/components/Modal/stories/ModalExamples.tsx (1)

57-57: LGTM! Clean API improvement.

The change from data attributes to a dedicated size prop improves the API's clarity and usability.

@jsartisan jsartisan requested a review from KelvinOm October 23, 2024 12:41
/** The children of the component. */
children: ReactNode;
/** Additional props to be passed to the overlay */
overlayProps?: Record<string, string>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Besides the date attributes, there doesn't seem to be any point in pass anything else here, right? Maybe we should keep the prev name?

@jsartisan jsartisan merged commit 62e5f09 into release Oct 23, 2024
@jsartisan jsartisan deleted the chore/fix-modal-size-api branch October 23, 2024 13:00
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
Fixes the API for modal for setting modal.

/ok-to-test tags="@tag.Anvil"

<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11479189189>
> Commit: 1a07d20
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11479189189&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Anvil`
> Spec:
> <hr>Wed, 23 Oct 2024 12:09:48 UTC
<!-- end of auto-generated comment: Cypress test results  -->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced a new `size` prop for the Modal component, allowing for
flexible sizing options (e.g., small, medium, large).
- Added `overlayProps` for enhanced customization of the Modal's overlay
properties.

- **Bug Fixes**
- Removed the outdated `dataAttributes` prop, streamlining the Modal
configuration.

- **Documentation**
- Updated examples to reflect the new prop structure for the Modal
component.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants