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: Add redesign for JS Editor Form #36948

Merged
merged 1 commit into from
Oct 18, 2024
Merged

Conversation

hetunandu
Copy link
Member

@hetunandu hetunandu commented Oct 17, 2024

Description

Adds the new JS Editor Form behind feature flags. It ensures the old flow is still easy to recover and change by keeping most items the same.

Fixes #36943

Automation

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

🔍 Cypress test results

Tip

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


Thu, 17 Oct 2024 17:51:50 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new BlockCompletion interface for enhanced type safety.
    • Replaced the TabbedViewContainer with a consolidated EditorForm component for a streamlined editing experience.
    • Added a new JSEditorForm component for JavaScript code editing, with a fallback to an older version if needed.
  • Bug Fixes

    • Improved handling of configuration tab selection in the new editor interface.
  • Documentation

    • Updated export statements to ensure accessibility of the new components.

Copy link
Contributor

coderabbitai bot commented Oct 17, 2024

Walkthrough

The pull request introduces significant changes to the JavaScript editor components. A new interface BlockCompletion is created for improved type safety, replacing inline type definitions in existing interfaces. The JSEditorForm component is introduced, consolidating functionality previously spread across multiple tabs into a single component. The OldJSEditorForm is retained for backward compatibility, with exports updated accordingly.

Changes

File Change Summary
app/client/src/components/editorComponents/CodeEditor/EditorConfig.ts Added BlockCompletion interface; updated blockCompletions in FieldEntityInformation and EditorStyleProps to use this new type.
app/client/src/pages/Editor/JSEditor/Form.tsx Replaced TabbedViewContainer with EditorForm, integrating code editor and settings into one component. Updated handling of selectedConfigTab.
app/client/src/pages/Editor/JSEditor/JSEditorForm/JSEditorForm.tsx Introduced JSEditorForm component with various props; includes feature flag for rendering logic.
app/client/src/pages/Editor/JSEditor/JSEditorForm/index.ts Added export for JSEditorForm component to make it accessible from the index file.
app/client/src/pages/Editor/JSEditor/JSEditorForm/old/JSEditorForm.tsx Introduced OldJSEditorForm component, maintaining tabbed view for backward compatibility.

Assessment against linked issues

Objective Addressed Explanation
Update the JS Editor form to remove tabs and just show the code editor (#[36943])

Possibly related PRs

Suggested labels

Enhancement, Task, IDE Product, IDE Pod, ok-to-test, skip-changelog

Suggested reviewers

  • albinAppsmith

🎉 In the editor's realm, changes take flight,
A new form emerges, shining so bright.
Tabs fade away, simplicity reigns,
With BlockCompletion, clarity gains.
Code flows smoother, in harmony's tune,
A joyful update, like a bright afternoon! 🌟


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 Navigation Issues/feature requests related to IDE navigation, and context switching 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 Oct 17, 2024
@hetunandu hetunandu added the ok-to-test Required label for CI label Oct 17, 2024
Copy link

⚠️ Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 6, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

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 (4)
app/client/src/pages/Editor/JSEditor/JSEditorForm/old/JSEditorForm.tsx (1)

37-105: Component implementation looks solid.

The OldJSEditorForm component is well-structured and implements the required functionality as per the PR objectives. Good use of conditional rendering and proper configuration of child components.

Consider extracting the LazyCodeEditor configuration into a separate constant or useMemo hook to improve readability and potentially optimize performance.

Example refactor:

const codeEditorConfig = useMemo(() => ({
  AIAssisted: true,
  blockCompletions: props.blockCompletions,
  border: CodeEditorBorder.NONE,
  borderLess: true,
  // ... other props
}), [props.blockCompletions, props.currentJSCollection.name, props.changePermitted, props.onChange, props.theme]);

// In JSX
<LazyCodeEditor {...codeEditorConfig} />
app/client/src/components/editorComponents/CodeEditor/index.tsx (2)

Line range hint 50-203: Improved type safety for block completions.

The introduction of the BlockCompletion type and its usage in EditorStyleProps enhances type safety. Good job on this improvement.

Consider using readonly for the blockCompletions array to prevent accidental modifications:

- blockCompletions?: Array<BlockCompletion>;
+ blockCompletions?: readonly BlockCompletion[];

Remove Unused blockCompletions Property

The blockCompletions property is destructured from props but not utilized within the CodeEditor component. Consider removing it if it's unnecessary to eliminate redundant code.

🔗 Analysis chain

Line range hint 204-1400: Verify usage of blockCompletions property.

The blockCompletions property has been added to EditorStyleProps, but it's not utilized in the component logic. Is this intentional, or is there a plan to implement its usage in the future?

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of blockCompletions in the component
rg "blockCompletions" app/client/src/components/editorComponents/CodeEditor/index.tsx

Length of output: 280

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

64-65: Remove redundant 'borderLess' prop

Since border is set to CodeEditorBorder.NONE, the borderLess prop is redundant. Consider removing it to simplify the code.

Apply this diff:

         border={CodeEditorBorder.NONE}
-        borderLess
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ff00216 and c32b614.

📒 Files selected for processing (6)
  • app/client/src/components/editorComponents/CodeEditor/EditorConfig.ts (1 hunks)
  • app/client/src/components/editorComponents/CodeEditor/index.tsx (2 hunks)
  • app/client/src/pages/Editor/JSEditor/Form.tsx (4 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorForm/JSEditorForm.tsx (1 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorForm/index.ts (1 hunks)
  • app/client/src/pages/Editor/JSEditor/JSEditorForm/old/JSEditorForm.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/client/src/pages/Editor/JSEditor/JSEditorForm/index.ts
🧰 Additional context used
🔇 Additional comments (8)
app/client/src/pages/Editor/JSEditor/JSEditorForm/old/JSEditorForm.tsx (3)

1-20: Imports look good.

The necessary components and types are imported correctly.


22-35: Props interface is well-defined.

The Props interface provides good type safety for the component. All necessary properties are included with appropriate types.


1-105: Implementation aligns well with PR objectives.

The OldJSEditorForm component successfully implements the redesigned JS Editor Form as outlined in the PR objectives. It consolidates the functionality into a single component while maintaining backward compatibility. The tabbed interface and conditional rendering of settings allow for easy recovery and modifications.

Good job on meeting the requirements and maintaining a clean, well-structured implementation.

app/client/src/components/editorComponents/CodeEditor/EditorConfig.ts (2)

57-60: LGTM: New BlockCompletion interface.

The new BlockCompletion interface is well-defined and follows TypeScript best practices.


69-69: LGTM: Updated FieldEntityInformation interface.

The change to use Array<BlockCompletion> improves type safety and readability.

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

5-5: Import statement added correctly.

EditorTheme is correctly imported from EditorConfig.


55-55: Type imported appropriately.

JSEditorTab type is correctly imported for type annotations.


65-65: Component imported with alias.

JSEditorForm is imported and aliased as EditorForm appropriately.

currentJSCollection: JSCollection;
changePermitted: boolean;
onChange: (valueOrEvent: React.ChangeEvent | string) => void;
theme: EditorTheme.LIGHT;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct the 'theme' prop type in 'Props' interface

The theme property in the Props interface is assigned a value EditorTheme.LIGHT instead of specifying its type. It should be typed as EditorTheme.

Apply this diff to fix the issue:

-  theme: EditorTheme.LIGHT;
+  theme: EditorTheme;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
theme: EditorTheme.LIGHT;
theme: EditorTheme;

Comment on lines +387 to +389
onValueChange={(string) =>
setSelectedConfigTab(string as JSEditorTab)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor onValueChange to improve clarity and type safety.

Avoid using string as a parameter name and unnecessary type assertions.

Consider updating the function as follows:

-onValueChange={(string) =>
-  setSelectedConfigTab(string as JSEditorTab)
-}
+onValueChange={(tab: JSEditorTab) =>
+  setSelectedConfigTab(tab)
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onValueChange={(string) =>
setSelectedConfigTab(string as JSEditorTab)
}
onValueChange={(tab: JSEditorTab) =>
setSelectedConfigTab(tab)
}

Copy link
Contributor

@ankitakinger ankitakinger left a comment

Choose a reason for hiding this comment

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

LGTM

@hetunandu hetunandu merged commit 5801f49 into release Oct 18, 2024
47 checks passed
@hetunandu hetunandu deleted the chore/js-editor-form branch October 18, 2024 04:35
@coderabbitai coderabbitai bot mentioned this pull request Oct 25, 2024
2 tasks
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
## Description

Adds the new JS Editor Form behind feature flags. It ensures the old
flow is still easy to recover and change by keeping most items the same.


Fixes appsmithorg#36943

## Automation

/ok-to-test tags="@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/11384887879>
> Commit: c32b614
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11384887879&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.JS`
> Spec:
> <hr>Thu, 17 Oct 2024 17:51:50 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 `BlockCompletion` interface for enhanced type safety.
- Replaced the `TabbedViewContainer` with a consolidated `EditorForm`
component for a streamlined editing experience.
- Added a new `JSEditorForm` component for JavaScript code editing, with
a fallback to an older version if needed.

- **Bug Fixes**
- Improved handling of configuration tab selection in the new editor
interface.

- **Documentation**
- Updated export statements to ensure accessibility of the new
components.

<!-- 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 Navigation Issues/feature requests related to IDE navigation, and context switching 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]: JS Editor Form Redesign
2 participants