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: Updated GraphQL form UI #36728

Merged
merged 7 commits into from
Oct 10, 2024

Conversation

albinAppsmith
Copy link
Collaborator

@albinAppsmith albinAppsmith commented Oct 7, 2024

Description

This PR has following new features and fixes

  1. Feat: Update GraphQL to use form control dynamic text field instead of custom implementation.
  2. Feat: Added full width support for section component in action form.
  3. Fix: Rest API headers not scrollable if there are more number of items.

EE PR: https://github.com/appsmithorg/appsmith-ee/pull/5297

Fixes #35494
Fixes #36410
Fixes #36499

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/11240771681
Commit: 14b3e00
Cypress dashboard.
Tags: @tag.All
Spec:


Wed, 09 Oct 2024 05:42:42 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a streamlined form-based design for the PostBodyData component, enhancing user interaction with dynamic text fields for GraphQL queries and variables.
    • Added a new styled component, MainContainer, to improve layout responsiveness in the CommonEditorForm.
    • Enhanced the Section component with an optional isFullWidth property for greater configurability.
  • Bug Fixes

    • Adjusted the LoadingContainer height dynamically to enhance UI responsiveness.
  • Style

    • Updated styles for the Section component to support full-width expansion when applicable.
  • Removed Features

    • Deprecated the QueryEditor and VariableEditor components, simplifying the editor interface.

Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

Walkthrough

The pull request introduces significant changes to various components within the application, particularly focusing on the PostBodyData, CommonEditorForm, and Section components. Key modifications include the removal of outdated imports, the introduction of new styled components, and enhancements to the layout and functionality of forms. Notably, the PostBodyData component transitions to a streamlined design using DynamicTextField components, while the Section component gains a new property for full-width rendering. These alterations aim to improve the modularity and responsiveness of the UI.

Changes

File Path Change Summary
app/client/src/PluginActionEditor/components/PluginActionForm/components/GraphQLEditor/PostBodyData.tsx Removed imports related to resizing and variable editing, added DynamicTextField components for queries and variables, introduced EXPECTED_VARIABLE constant, modified PostBodyContainer height to a minimum of 250 pixels, removed ResizableDiv and ResizerHandler.
app/client/src/pages/Editor/APIEditor/CommonEditorForm.tsx Added MainContainer styled component for layout, introduced CommonFormPropsWithExtraParams type for modularity, updated props destructuring in CommonEditorForm, retained existing logic for permissions and execution checks.
app/client/src/pages/Editor/APIEditor/Editor.tsx Added EDITOR_TABS_HEIGHT constant for dynamic height adjustment of LoadingContainer, modified its height calculation to improve responsiveness.
app/client/src/pages/Editor/APIEditor/GraphQL/QueryEditor.tsx Removed QueryEditor component and its associated props and logic.
app/client/src/pages/Editor/APIEditor/GraphQL/VariableEditor.tsx Removed VariableEditor component and its associated props and logic.
app/client/src/pages/Editor/ActionForm/Section/index.tsx Introduced optional isFullWidth property to SectionProps interface, added data-fullwidth attribute to <div> element, default value set to false.
app/client/src/pages/Editor/ActionForm/Section/styles.module.css Added new style rule for elements with data-fullwidth="true" to set max-width to none, allowing full-width expansion.

Assessment against linked issues

Objective Addressed Explanation
Support scrolling in REST API panel for too many parameters (Issue #36410) No changes related to scrolling functionality were made.
Add property to Section component for full width and height (Issue #36499)

Possibly related PRs

Suggested labels

High, skip-changelog

Suggested reviewers

  • AmanAgarwal041
  • ayushpahwa
  • hetunandu

"In the land of code where changes flow,
Components dance, and new styles grow.
With fields dynamic and layouts bright,
The editor shines, a true delight!
Full width and height, a sight to see,
In the realm of plugins, we code with glee!" 🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ddaf538 and 14b3e00.

📒 Files selected for processing (1)
  • app/client/src/pages/Editor/APIEditor/Editor.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/pages/Editor/APIEditor/Editor.tsx

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 Bug Something isn't working Community Reported issues reported by community members 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 IDE tabs query and js tabs Low An issue that is neither critical nor breaks a user flow Needs Triaging Needs attention from maintainers to triage Production Task A simple Todo labels Oct 7, 2024
@github-actions github-actions bot added Enhancement New feature or request and removed Bug Something isn't working labels Oct 7, 2024
@albinAppsmith albinAppsmith added the ok-to-test Required label for CI label Oct 7, 2024
@github-actions github-actions bot added Bug Something isn't working and removed Bug Something isn't working labels Oct 7, 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 (2)
app/client/src/pages/Editor/ActionForm/Section/styles.module.css (1)

17-19: Well done, class! This addition expands our layout possibilities.

The new style rule for full-width sections is a valuable enhancement to our CSS toolkit. Let's break it down:

  1. We're using a data attribute data-fullwidth="true" to control the width. This is an excellent practice as it separates our styling concerns from our HTML structure.
  2. By setting max-width: none;, we're allowing the section to expand beyond its default 800px limit when needed.

This change aligns perfectly with our lesson objective of creating more flexible and responsive layouts. It's like giving our sections the ability to stretch their arms wide when they need more space!

Remember, class, with great power comes great responsibility. Use this full-width option judiciously to maintain a balanced and harmonious layout in your designs.

app/client/src/PluginActionEditor/components/PluginActionForm/components/GraphQLEditor/PostBodyData.tsx (1)

17-18: Consider Responsive Design for Code Editor Height

Dear students, setting a minimum height for components can enhance the user experience by ensuring sufficient space is available for content. In lines 17-18, you've set height: auto; and min-height: 250px; for the CodeMirror editor. This is a good practice, but let's also consider how this affects smaller screens.

Review the component's behavior on various screen sizes to ensure it's responsive. Adjust the min-height if necessary to accommodate smaller devices.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d15eea3 and c2496b5.

📒 Files selected for processing (5)
  • app/client/src/PluginActionEditor/components/PluginActionForm/components/GraphQLEditor/PostBodyData.tsx (1 hunks)
  • app/client/src/pages/Editor/APIEditor/CommonEditorForm.tsx (1 hunks)
  • app/client/src/pages/Editor/APIEditor/Editor.tsx (2 hunks)
  • app/client/src/pages/Editor/ActionForm/Section/index.tsx (2 hunks)
  • app/client/src/pages/Editor/ActionForm/Section/styles.module.css (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/client/src/pages/Editor/APIEditor/Editor.tsx
🧰 Additional context used
🔇 Additional comments (6)
app/client/src/pages/Editor/ActionForm/Section/index.tsx (4)

8-8: Well done, class! Let's examine this new addition.

The introduction of the isFullWidth prop is a commendable step towards enhancing our component's flexibility. This optional boolean property will allow us to control the width behavior of our Section component, which is crucial for responsive design.

Remember, children, in React, props are the building blocks of component customization. By adding this prop, we're giving future developers more control over the layout of their sections.


14-14: Excellent use of default values, students!

Here, we see a prime example of how to handle new props responsibly. By setting isFullWidth = false as the default, we ensure that our component maintains its current behavior for all existing implementations. This is what we call "backwards compatibility" in the programming world.

Remember, class: when adding new features, always consider how they might affect existing code. Default values are our friends in such situations!


23-23: Attention, class! Let's discuss this clever use of data attributes.

The addition of data-fullwidth={isFullWidth.toString()} is a textbook example of how to expose component state for styling or scripting purposes. By using a data attribute, we're following best practices in separating our concerns.

Note the use of .toString() here. Can anyone tell me why this is necessary? That's right! HTML attributes expect string values, so we need to convert our boolean to a string.

This approach allows us to style our component differently based on its isFullWidth state using CSS attribute selectors. For example:

.section[data-fullwidth="true"] {
  width: 100%;
}

Well done on implementing this feature so thoughtfully!


Line range hint 1-33: Class, let's summarize what we've learned today!

This pull request has successfully enhanced our Section component by introducing the isFullWidth prop. Let's recap the key points:

  1. We added a new optional prop to our interface, expanding the component's API.
  2. We set a sensible default value, ensuring backwards compatibility.
  3. We exposed the prop's value through a data attribute, allowing for flexible styling.

These changes directly address the objectives outlined in issue #36499, providing greater flexibility in layout design. The ability to create full-width sections will undoubtedly improve the responsiveness and visual appeal of our forms.

Remember, students, small changes like these can have a big impact on the overall user experience. Always think about how your code changes can make life easier for both developers and end-users.

Great work on this implementation! Does anyone have any questions before we move on?

app/client/src/PluginActionEditor/components/PluginActionForm/components/GraphQLEditor/PostBodyData.tsx (1)

72-72: Evaluate the Necessity of the height Property

Students, it's prudent to question whether each property we add serves a purpose. The height="100%" attribute on the DynamicTextField might be redundant if the component naturally adapts its height based on content.

Please verify if the height prop is necessary. If it's not influencing the component's display, consider removing it to simplify the code.

app/client/src/pages/Editor/APIEditor/CommonEditorForm.tsx (1)

114-114: Ensure overflow: hidden; Does Not Hide Important Content

Dear student, by adding overflow: hidden; to the Wrapper component, you're controlling the overflow behavior of this element. While this can prevent unwanted scroll bars and hide overflowing content, please double-check to ensure this does not unintentionally conceal any important UI elements or disrupt the user experience, especially on smaller screens or when the content dynamically changes.

height="100%"
mode={EditorModes.JSON_WITH_BINDING}
name="actionConfiguration.pluginSpecifiedTemplates[1].value"
placeholder={`${EXPECTED_VARIABLE.example}\n\n\\\\Take widget inputs using {{ }}`}
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 Escape Characters in the Placeholder String

Attention class, proper string formatting is crucial for accurate rendering. In line 75, the placeholder string includes double backslashes (\\\\), which may not display as intended in the UI. Let's correct this to ensure the placeholder message is clear to the users.

Here's the suggested fix:

- placeholder={`${EXPECTED_VARIABLE.example}\n\n\\\\Take widget inputs using {{ }}`}
+ placeholder={`${EXPECTED_VARIABLE.example}\n\n\\Take widget inputs using {{ }}`}

This change adjusts the escape characters so that a single backslash is rendered, providing the correct guidance to users.

📝 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
placeholder={`${EXPECTED_VARIABLE.example}\n\n\\\\Take widget inputs using {{ }}`}
placeholder={`${EXPECTED_VARIABLE.example}\n\n\\Take widget inputs using {{ }}`}

evaluatedPopUpLabel={"Query"}
mode={EditorModes.GRAPHQL_WITH_BINDING}
name="actionConfiguration.body"
placeholder={`{{\n\t{name: inputName.property, preference: dropdownName.property}\n}}`}
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

Provide an Appropriate Placeholder for the Query Input

Dear students, when guiding users through placeholders, it's essential to offer examples that closely resemble the expected input. The current placeholder for the Query input appears to be an object, which might confuse users expecting to enter a GraphQL query. Let's refine it to present a sample GraphQL query instead.

Consider updating the placeholder as follows:

- placeholder={`{{\n\t{name: inputName.property, preference: dropdownName.property}\n}}`}
+ placeholder={`query {\n  user(id: "{{inputName.property}}") {\n    name\n    email\n  }\n}`}

This change provides a clearer example of a GraphQL query, enhancing user understanding.

📝 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
placeholder={`{{\n\t{name: inputName.property, preference: dropdownName.property}\n}}`}
placeholder={`query {\n user(id: "{{inputName.property}}") {\n name\n email\n }\n}`}

<StyledFormLabel>Query variables</StyledFormLabel>
<DynamicTextField
border={CodeEditorBorder.ALL_SIDE}
dataTreePath={`${props.actionName}.config.pluginSpecifiedTemplates[1].value`}
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

Maintain Consistency in Accessing actionName

Class, consistency is key to writing clean and maintainable code. Throughout your component, you've destructured actionName from props, yet in line 69, you revert to using props.actionName. Let's align this usage for clarity.

Apply the following change:

- dataTreePath={`${props.actionName}.config.pluginSpecifiedTemplates[1].value`}
+ dataTreePath={`${actionName}.config.pluginSpecifiedTemplates[1].value`}

This adjustment ensures uniformity in how actionName is referenced.

📝 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
dataTreePath={`${props.actionName}.config.pluginSpecifiedTemplates[1].value`}
dataTreePath={`${actionName}.config.pluginSpecifiedTemplates[1].value`}

@@ -226,7 +227,7 @@ class ApiEditor extends React.Component<Props> {

const formStyles: CSSProperties = {
position: "relative",
height: "100%",
height: `calc(100% - ${EDITOR_TABS_HEIGHT})`,
Copy link
Member

Choose a reason for hiding this comment

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

Can we do this without depending on the height of the tabs? This makes it quite dependent on tabs. As you know all implementations do not have tabs

Copy link
Member

Choose a reason for hiding this comment

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

Screenshot 2024-10-08 at 9 10 14 AM

This is from modules

@github-actions github-actions bot added the Bug Something isn't working label Oct 8, 2024
@github-actions github-actions bot removed the Bug Something isn't working label Oct 8, 2024
@github-actions github-actions bot added the Bug Something isn't working label Oct 8, 2024
@@ -18,6 +20,7 @@ const Section: React.FC<SectionProps> = ({
return (
<div
className={classNames}
data-fullwidth={isFullWidth.toString()}
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason for not using classes to control css states?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point... This was a practise we used in ADS as well I see in WDS. @KelvinOm Do you see any specific reason we should stick to this? As I can see, class is better performant than data attributes.

@albinAppsmith
Copy link
Collaborator Author

/build-deploy-preview skip-test=true

Copy link

github-actions bot commented Oct 9, 2024

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

Copy link

github-actions bot commented Oct 9, 2024

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

@albinAppsmith albinAppsmith merged commit 579cb7d into release Oct 10, 2024
82 checks passed
@albinAppsmith albinAppsmith deleted the action-redesign/graphql-zone-section branch October 10, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Community Reported issues reported by community members Enhancement New feature or request 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 IDE tabs query and js tabs Low An issue that is neither critical nor breaks a user flow Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Production Task A simple Todo
Projects
None yet
3 participants