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

chore: Extracting out common logic between two ADS components to move it to one #38885

Merged
merged 8 commits into from
Jan 31, 2025

Conversation

ankitakinger
Copy link
Contributor

@ankitakinger ankitakinger commented Jan 29, 2025

Description

Extracting out common logic between two ADS components to move it to one.

Fixes #38853

Automation

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

🔍 Cypress test results

Tip

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


Fri, 31 Jan 2025 08:26:34 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced EditableEntityName component with new properties:
      • Added canEdit to control editability
      • Added isFixedWidth for width behavior
      • Added size option for component sizing
    • Introduced canEdit property in EditableDismissibleTab for better editing control
    • Simplified icon rendering logic across components
  • Bug Fixes

    • Updated name validation to require a minimum of 1 character
    • Improved scrolling behavior in DataSidePane
  • Style

    • Refined layout and styling for editable components
    • Updated component alignment and spacing
    • Removed unnecessary styled components for cleaner design

Copy link
Contributor

coderabbitai bot commented Jan 29, 2025

Walkthrough

The pull request introduces significant refactoring to the EditableEntityName and related components in the design system. The changes focus on simplifying component logic, enhancing flexibility through new props like canEdit, isFixedWidth, and size, and streamlining the icon and validation handling. The modifications aim to create a more modular and configurable component structure, particularly for editable entity interactions.

Changes

File Change Summary
...EditableDismissibleTab.stories.tsx Removed styled-components import, simplified JSIcon, updated icon to startIcon, modified validateName validation, added canEdit prop.
...EditableEntityName.stories.tsx Removed EntityIcon, simplified JSIcon, added canEdit prop, removed onExitEditing, updated validation.
...EditableEntityName.styles.ts Updated Root and IconContainer styling, added conditional gap and data attributes.
...EditableEntityName.tsx Refactored component props handling, introduced inEditMode, updated rendering logic.
...EditableEntityName.types.ts Added canEdit, isFixedWidth, and size optional props.
...EntityItem.tsx Replaced EntityEditableName with EditableEntityName, simplified editing logic.
...DataSidePane.tsx Changed overflow-y from scroll to auto.

Assessment against linked issues

Objective Addressed Explanation
Create a common component out of Entity Item and Editable Entity Name

Possibly related PRs

  • chore: Editable name refactor #37069: The EditableEntityName component has been refactored to improve its props handling and internal logic, which aligns with the changes made in the EditableDismissibleTab component that also involves editing functionality.
  • chore: Adding Group component in ADS Templates #38512: The introduction of the Group component in ADS Templates enhances the organization of entity items, which relates to the EntityItem component that is part of the same design system.
  • feat: editable dismissible tab component #38788: The EditableDismissibleTab component integrates an editable entity name feature, which is directly related to the changes in the EditableEntityName component.

Suggested labels

Enhancement

Suggested reviewers

  • albinAppsmith

Poem

Code refactored, components align,
Flexibility now starts to shine ✨
Props dance, styles rearrange,
In design system's elegant range 🎨
Simplicity wins the coding game! 🚀


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a154b1 and dd17cf1.

📒 Files selected for processing (2)
  • app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.types.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.types.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.types.ts
  • app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.types.ts
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@ankitakinger ankitakinger added the ok-to-test Required label for CI label Jan 29, 2025
@github-actions github-actions bot added IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Task A simple Todo skip-changelog Adding this label to a PR prevents it from being listed in the changelog labels Jan 29, 2025
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

🧹 Nitpick comments (2)
app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.tsx (1)

60-60: Consider type safety for rest props.

While spreading rest props is clean, consider explicitly typing which props are allowed to be spread to ListItem.

app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.types.ts (1)

13-16: Enhanced flexibility with optional props
The new optional props (canEdit, isFixedWidth, textKind, gap) provide finer control over behavior and appearance. Adding brief documentation could further clarify usage.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b62c875 and 7cdfe79.

📒 Files selected for processing (8)
  • app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.stories.tsx (2 hunks)
  • app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.tsx (2 hunks)
  • app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.types.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.stories.tsx (2 hunks)
  • app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.styles.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.types.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
🔇 Additional comments (18)
app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.stories.tsx (2)

25-33: LGTM! Props updated to match new component API.

The story configuration properly demonstrates the new component API with appropriate test values for all props.


9-9: Verify icon size change impact on visual consistency.

The icon size has been changed from "md" to "sm". Please ensure this change maintains visual consistency with other components using this icon.

✅ Verification successful

Icon size change is consistent with other story components

The "sm" size is consistently used across story components, while "md" size is used in the main application - this appears to be an intentional design pattern.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances of js-yellow icon to verify size consistency
rg -l 'name="js-yellow"' | xargs rg 'size="[^"]+"' -A 1 -B 1

Length of output: 3767

app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.tsx (3)

5-5: LGTM: Clean import restructuring and prop destructuring.

The changes simplify the component's interface by:

  • Importing the new consolidated EditableEntityName component
  • Using a more semantic startIcon prop name

Also applies to: 17-17


38-47: LGTM: Comprehensive dependency array.

All props used within the memoized component are correctly included in the dependencies array.


24-36: Verify prop types alignment with EditableEntityName component.

The implementation looks clean, but we should ensure all required props are properly typed in the imported component.

✅ Verification successful

Props are correctly typed and implemented

All required and optional props in the EntityItem component match the EditableEntityName interface definition. No type misalignment found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for EditableEntityName prop types definition
ast-grep --pattern 'interface $name {
  $$$
}' app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.types.ts

Length of output: 147


Script:

#!/bin/bash
# Find EditableEntityName related files
fd EditableEntityName

Length of output: 490


Script:

#!/bin/bash
# Examine the prop types and component implementation
echo "=== EditableEntityName.types.ts ==="
cat app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.types.ts

echo -e "\n=== EditableEntityName.tsx ==="
cat app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.tsx

Length of output: 2683

app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.tsx (5)

10-23: Use consistent prop defaults and ensure type safety
A default gap value is provided, which helps maintain consistent spacing without requiring additional checks. Also, destructuring props at the top keeps the component clean and readable.


25-25: Confirm behavior when edit is disallowed
inEditMode is forced to false if canEdit is unset, even if isEditing is true. This might be intentional; verify this logic aligns with your UX requirements.


33-39: Good use of the useEditableText hook
The hook usage is clean and properly passes necessary parameters. Keep an eye on future validations or edge cases (e.g., empty names).


41-48: Spinner usage improves clarity
Leveraging a loading spinner in place of startIcon when isLoading is true is straightforward and keeps the UI consistent.


61-75: Clean layout with appropriate data attributes
The final rendering with tooltip for errors is neatly structured. The use of data- attributes for isEditing and isFixedWidth is a good practice for style or testing hooks.

app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.types.ts (1)

5-5: Property rename maintains clarity
Changing from icon to startIcon clarifies intent and aligns with updates in related components.

app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.types.ts (3)

2-2: Centralized TextKind import is consistent
Importing the TextKind type ensures consistency across components using text variations.


5-5: Renaming prop to startIcon
This renaming matches the new component approach for specifying icons on the left side.


10-10: Improved event naming with onEditComplete
The new callback name is more descriptive and avoids confusion about exit conditions.

app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.stories.tsx (1)

14-14: LGTM! Icon size and prop name changes look good.

The changes align well with the component refactoring:

  • Simplified icon size to "sm"
  • Updated to use the new startIcon prop

Also applies to: 25-25

app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.styles.ts (2)

4-12: LGTM! Root component improvements enhance flexibility.

The changes to Root component improve layout control:

  • Dynamic gap through props
  • Better flex behavior
  • Proper width constraints

25-34: LGTM! Well-handled text overflow states.

Good implementation of text overflow handling:

  • Fixed width mode with ellipsis
  • Proper overflow behavior during editing
app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.tsx (1)

20-20: LGTM! Prop updates improve API clarity.

The changes maintain functionality while improving the API:

  • Consistent use of startIcon
  • More descriptive onEditComplete callback name

Also applies to: 44-44, 46-46

@ankitakinger
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/13030702276.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 38885.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-38885.dp.appsmith.com

hetunandu
hetunandu previously approved these changes Jan 30, 2025
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: 0

🧹 Nitpick comments (1)
app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.tsx (1)

57-60: Consider moving styles to styled-components

Inline styles could be moved to styled-components for consistency.

- style: {
-   backgroundColor: "var(--ads-v2-color-bg)",
-   paddingTop: "4px",
-   paddingBottom: "4px",
-   top: "-5px",
- },

Consider adding these styles to Styled.Text component.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1537874 and 3a154b1.

📒 Files selected for processing (6)
  • app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.stories.tsx (2 hunks)
  • app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.tsx (2 hunks)
  • app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.types.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.styles.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.tsx (2 hunks)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.styles.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.styles.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.styles.ts
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
🔇 Additional comments (7)
app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.tsx (2)

Line range hint 12-21: Clarify the relationship between canEdit and isEditable props

The component has two props controlling edit functionality: isEditable affects double-click behavior while canEdit is passed to child component. This could lead to inconsistent states.

Consider consolidating these props or documenting their distinct purposes.


Line range hint 41-50: LGTM!

Props are correctly passed to EditableEntityName component.

app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.stories.tsx (2)

13-15: LGTM!

Icon size change to "sm" aligns with the design system's tab specifications.


26-32: Verify edit mode functionality and validation requirements

Two concerns:

  1. Previous review noted edit mode stopped working with canEdit
  2. Validation requirement reduced from 3 to 1 characters

Please confirm:

  1. Edit mode works with double-click
  2. 1-character minimum aligns with business requirements
app/client/packages/design-system/ads/src/Templates/EditableEntityName/EditableEntityName.tsx (2)

25-25: LGTM!

Clean implementation of edit mode logic using canEdit prop.


41-48: LGTM!

Well-structured loading state handling with proper spinner size alignment.

app/client/packages/design-system/ads/src/Templates/EditableDismissibleTab/EditableDismissibleTab.types.ts (1)

14-14: Clarify the distinction between canEdit and isEditable props.

The interface now has two seemingly similar boolean flags for editing: isEditable and canEdit. This could lead to confusion for component consumers.

Could you clarify:

  1. The difference between these props
  2. Whether they could be consolidated into a single prop
  3. The scenarios where both props might be needed

@ankitakinger ankitakinger merged commit 3559589 into release Jan 31, 2025
93 checks passed
@ankitakinger ankitakinger deleted the chore/common-editable-entity-name branch January 31, 2025 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Create a common component out of Entity Item and Editable Entity Name components in ADS
3 participants