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: Adding new name editor for JS object in toolbar #37056

Merged
merged 2 commits into from
Oct 24, 2024

Conversation

ankitakinger
Copy link
Contributor

@ankitakinger ankitakinger commented Oct 24, 2024

Description

Adding new name editor for JS object in toolbar under modularised flow.

Fixes #36964

Automation

/ok-to-test tags="@tag.Sanity, @tag.JS"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11496788011
Commit: 7ae7ec7
Cypress dashboard.
Tags: @tag.Sanity, @tag.JS
Spec:


Thu, 24 Oct 2024 10:42:17 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new optional name editor in the JSEditor, allowing users to edit JavaScript object names dynamically.
    • Enhanced the JSEditorToolbar to conditionally render the name editor based on user permissions.
  • Bug Fixes

    • Simplified the props for the JSObjectNameEditor component by removing unnecessary properties.
  • Documentation

    • Updated export statements to ensure accessibility of the new JSObjectNameEditor component across modules.

Copy link
Contributor

coderabbitai bot commented Oct 24, 2024

Walkthrough

The changes introduce a new optional property showNameEditor to the JSFormProps and Props interfaces, enabling conditional rendering of a name editor in the JSEditorForm and JSEditorToolbar components. The JSObjectNameEditor component is created to facilitate editing JavaScript object names, integrating with Redux for state management. Additionally, the import statement for JSObjectNameEditor in JSHeader.tsx is modified from a default to a named import, and an old version of the JSObjectNameEditor has a property removed from its interface.

Changes

File Change Summary
app/client/src/pages/Editor/JSEditor/Form.tsx Added showNameEditor?: boolean to JSFormProps, default value set to false, passed to JSEditorToolbar.
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx Added showNameEditor?: boolean to Props, enables conditional rendering of JSObjectNameEditor.
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSHeader.tsx Modified import statement for JSObjectNameEditor from default to named import.
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSObjectNameEditor/JSObjectNameEditor.tsx Introduced JSObjectNameEditor component with state management and editing functionality.
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSObjectNameEditor/index.tsx Added export for JSObjectNameEditor and JSObjectNameEditorProps.
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSObjectNameEditor/old/JSObjectNameEditor.tsx Removed page?: string; from JSObjectNameEditorProps interface.

Assessment against linked issues

Objective Addressed Explanation
Add new editable text component for JS modules (#36964)

Possibly related PRs

Suggested labels

Enhancement

Suggested reviewers

  • albinAppsmith
  • hetunandu

"In the editor's realm, a name takes flight,
With props that shimmer, and features so bright.
A toolbar now dances, with options galore,
Editing names, oh what fun to explore!
With hooks and Redux, the state's in control,
A new component shines, making editing whole!" 🌟


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.

@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 labels Oct 24, 2024
@ankitakinger ankitakinger added the ok-to-test Required label for CI label Oct 24, 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 24, 2024
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: 3

🧹 Outside diff range and nitpick comments (1)
app/client/src/pages/Editor/JSEditor/JSObjectNameEditor/JSObjectNameEditor.tsx (1)

27-32: Avoid redundant 'JSObjectNameEditorProps' interface

Check if you can reuse an existing props interface to prevent duplication.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 23a5772 and 1ead9ae.

📒 Files selected for processing (6)
  • app/client/src/pages/Editor/JSEditor/Form.tsx (3 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx (3 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSHeader.tsx (1 hunks)
  • app/client/src/pages/Editor/JSEditor/JSObjectNameEditor/JSObjectNameEditor.tsx (1 hunks)
  • app/client/src/pages/Editor/JSEditor/JSObjectNameEditor/index.tsx (1 hunks)
  • app/client/src/pages/Editor/JSEditor/JSObjectNameEditor/old/JSObjectNameEditor.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/pages/Editor/JSEditor/JSObjectNameEditor/old/JSObjectNameEditor.tsx
✅ Files skipped from review due to trivial changes (1)
  • app/client/src/pages/Editor/JSEditor/JSObjectNameEditor/index.tsx
🧰 Additional context used
📓 Learnings (1)
app/client/src/pages/Editor/JSEditor/JSObjectNameEditor/JSObjectNameEditor.tsx (2)
Learnt from: ankitakinger
PR: appsmithorg/appsmith#36560
File: app/client/src/pages/Editor/JSEditor/JSObjectNameEditor.tsx:28-28
Timestamp: 2024-09-26T06:52:44.158Z
Learning: When type definitions like `SaveActionNameParams` are declared in multiple places, consolidating them by removing duplicates and reusing a single definition maintains consistency in the codebase.
Learnt from: ankitakinger
PR: appsmithorg/appsmith#36560
File: app/client/src/pages/Editor/JSEditor/JSObjectNameEditor.tsx:28-28
Timestamp: 2024-10-08T15:32:34.115Z
Learning: When type definitions like `SaveActionNameParams` are declared in multiple places, consolidating them by removing duplicates and reusing a single definition maintains consistency in the codebase.
🔇 Additional comments (8)
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSHeader.tsx (2)

Line range hint 13-28: Verify Props interface alignment with parent components.

The Props interface doesn't include the showNameEditor property mentioned in the AI summary, but it's used in parent components. Please verify if this property should be added to maintain consistency with the parent component chain.

#!/bin/bash
# Search for showNameEditor prop usage in parent components
ast-grep --pattern 'interface $_ {
  $$$
  showNameEditor?: boolean;
  $$$
}'

9-9: Verify all JSObjectNameEditor imports across the codebase.

The change from default to named import suggests a breaking change in the JSObjectNameEditor module.

app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx (2)

16-16: LGTM: Clean import statement

The import follows proper TypeScript conventions and maintains good module organization.


37-37: LGTM: Well-typed optional prop addition

The new prop follows TypeScript best practices and maintains interface consistency.

app/client/src/pages/Editor/JSEditor/Form.tsx (3)

71-71: LGTM: Clean interface addition

The optional boolean prop follows TypeScript conventions and maintains consistency with the interface structure.


112-112: LGTM: Proper default value initialization

The default value of false ensures backward compatibility and maintains the existing behavior by default.


358-358: Verify JSEditorToolbar implementation

The prop passing looks correct. Let's verify the JSEditorToolbar implementation to ensure proper handling of this prop.

✅ Verification successful

Let me gather more information about how the showNameEditor prop is actually used in the component implementation.


JSEditorToolbar properly implements showNameEditor prop

The prop is correctly defined in the interface and properly used for conditional rendering of the JSObjectNameEditor component. Implementation follows React best practices.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify JSEditorToolbar implementation for showNameEditor prop

# Check JSEditorToolbar component implementation
ast-grep --pattern 'interface JSEditorToolbarProps {
  $$$
  showNameEditor?: boolean
  $$$
}'

# Check usage of showNameEditor in JSEditorToolbar
rg -A 5 'showNameEditor.*\?' app/client/src/pages/Editor/JSEditor/JSEditorToolbar

Length of output: 708


Script:

#!/bin/bash
# Check the actual usage of showNameEditor prop in JSEditorToolbar component
ast-grep --pattern 'const JSEditorToolbar = ({ $$$, showNameEditor, $$$ }: JSEditorToolbarProps) => {
  $$$
}'

# Also check for any conditional rendering or logic using this prop
rg -A 10 'showNameEditor' app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx

Length of output: 901

app/client/src/pages/Editor/JSEditor/JSObjectNameEditor/JSObjectNameEditor.tsx (1)

155-171: Verify the use of 'focusout' event

Ensure that using the 'focusout' event with useEventListener behaves as intended. In React, 'blur' might be more appropriate.

Run the following script to check the usage of 'focusout' across the codebase:

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: 2

🧹 Outside diff range and nitpick comments (1)
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSObjectNameEditor/JSObjectNameEditor.tsx (1)

65-68: Remove Unused Parameter baseQueryId

The baseQueryId parameter is not utilized in the code. Removing it will clean up the codebase.

Apply this diff to eliminate the unused parameter:

 const params = useParams<{
     baseCollectionId?: string;
-    baseQueryId?: string;
 }>();
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1ead9ae and 7ae7ec7.

📒 Files selected for processing (6)
  • app/client/src/pages/Editor/JSEditor/Form.tsx (4 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx (3 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSHeader.tsx (1 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSObjectNameEditor/JSObjectNameEditor.tsx (1 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSObjectNameEditor/index.tsx (1 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSObjectNameEditor/old/JSObjectNameEditor.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSObjectNameEditor/old/JSObjectNameEditor.tsx
✅ Files skipped from review due to trivial changes (1)
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSObjectNameEditor/index.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/client/src/pages/Editor/JSEditor/Form.tsx
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSEditorToolbar.tsx
  • app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSHeader.tsx
🧰 Additional context used
📓 Learnings (1)
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/JSObjectNameEditor/JSObjectNameEditor.tsx (3)
Learnt from: ankitakinger
PR: appsmithorg/appsmith#36560
File: app/client/src/pages/Editor/JSEditor/JSObjectNameEditor.tsx:28-28
Timestamp: 2024-09-26T06:52:44.158Z
Learning: When type definitions like `SaveActionNameParams` are declared in multiple places, consolidating them by removing duplicates and reusing a single definition maintains consistency in the codebase.
Learnt from: ankitakinger
PR: appsmithorg/appsmith#36560
File: app/client/src/pages/Editor/JSEditor/JSObjectNameEditor.tsx:28-28
Timestamp: 2024-10-08T15:32:34.115Z
Learning: When type definitions like `SaveActionNameParams` are declared in multiple places, consolidating them by removing duplicates and reusing a single definition maintains consistency in the codebase.
Learnt from: ankitakinger
PR: appsmithorg/appsmith#37056
File: app/client/src/pages/Editor/JSEditor/JSObjectNameEditor/JSObjectNameEditor.tsx:22-25
Timestamp: 2024-10-24T08:38:20.429Z
Learning: "constants/AppConstants" does not export "SaveActionNameParams".

@hetunandu hetunandu self-requested a review October 24, 2024 11:33
@ankitakinger ankitakinger merged commit 3d9d08a into release Oct 24, 2024
45 checks passed
@ankitakinger ankitakinger deleted the chore/add-ads-text-input-js-module branch October 24, 2024 11:34
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
…7056)

## Description

Adding new name editor for JS object in toolbar under modularised flow.

Fixes [appsmithorg#36964](appsmithorg#36964)

## Automation

/ok-to-test tags="@tag.Sanity, @tag.JS"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11496788011>
> Commit: 7ae7ec7
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11496788011&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity, @tag.JS`
> Spec:
> <hr>Thu, 24 Oct 2024 10:42:17 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


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

- **New Features**
- Introduced a new optional name editor in the JSEditor, allowing users
to edit JavaScript object names dynamically.
- Enhanced the JSEditorToolbar to conditionally render the name editor
based on user permissions.

- **Bug Fixes**
- Simplified the props for the JSObjectNameEditor component by removing
unnecessary properties.

- **Documentation**
- Updated export statements to ensure accessibility of the new
JSObjectNameEditor component across modules.
<!-- 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
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]: Add new editable text component for JS modules
2 participants