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 the GraphQLEditorForm for the modularised flow #36633

Merged
merged 7 commits into from
Oct 2, 2024

Conversation

ankitakinger
Copy link
Contributor

@ankitakinger ankitakinger commented Oct 1, 2024

Description

Adding the GraphQLEditorForm for the modularised flow

Fixes #36624

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/11138697528
Commit: 3aa280e
Cypress dashboard.
Tags: @tag.All
Spec:


Wed, 02 Oct 2024 07:47:13 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new GraphQLEditorForm component for editing GraphQL actions within the plugin action editor.
    • Added a PostBodyData component for managing the layout and functionality of a GraphQL API editor, featuring a QueryEditor and a VariableEditor.
    • Enhanced the useGetFormActionValues hook to include actionConfigurationBody, ensuring a complete set of action values.
  • Improvements

    • Simplified prop management and conditional rendering in various components, enhancing maintainability.
  • Bug Fixes

    • Removed deprecated closeEditorLink from multiple contexts and components to streamline functionality.

Copy link
Contributor

coderabbitai bot commented Oct 1, 2024

Walkthrough

The pull request introduces significant changes to the plugin action editor, notably by enhancing the useGetFormActionValues hook to include actionConfigurationBody, which improves data consistency. Additionally, a new GraphQLEditorForm component is added to facilitate the GraphQL API editor's layout and functionality, featuring resizable sections for editing queries and variables. These modifications aim to streamline the user experience and enhance the overall structure of the codebase.

Changes

File Path Change Summary
.../hooks/useGetFormActionValues.ts Updated to extract actionConfigurationBody, ensuring a complete return object.
.../PluginActionForm.tsx Enhanced conditional rendering logic to support GraphQLEditorForm alongside APIEditorForm.
.../GraphQLEditor/GraphQLEditorForm.tsx Introduced a new component for editing GraphQL actions, integrating permissions and rendering UI components.
.../GraphQLEditor/PostBodyData.tsx Added a new component for managing layout and functionality of GraphQL API editor with resizable editors.
.../APIEditor/GraphQL/GraphQLEditorForm.tsx Refactored to streamline imports and state management, replacing API_EDITOR_FORM_NAME with FORM_NAME.

Assessment against linked issues

Objective Addressed Explanation
Render the common editor form (#[36624])
Handle resize of body editors (query variables) (#[36624]) Resizing logic was removed from GraphQLEditorForm.tsx.
Define the Pagination UI Component (#[36624]) Pagination UI component definition is unclear in the changes.

Possibly related PRs

Suggested reviewers

  • ayushpahwa
  • hetunandu
  • albinAppsmith

Poem

In the realm of code where changes gleam,
A hook now holds a new, bright dream.
With GraphQL's queries side by side,
Resizable editors, our joy and pride.
Simplified paths, a clearer view,
In the world of plugins, we bid adieu! 🎉


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.

@ankitakinger ankitakinger added the ok-to-test Required label for CI label Oct 1, 2024
Copy link

github-actions bot commented Oct 1, 2024

⚠️ Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 2, 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: 7

🧹 Outside diff range and nitpick comments (8)
app/client/src/pages/Editor/APIEditor/GraphQL/QueryEditor.tsx (2)

21-24: Well done on simplifying the QueryHeader, class!

I'm pleased to see you've refactored the QueryHeader to use the Text component. This is a step in the right direction for maintaining consistency with our design system. However, let's take this opportunity to make our code even more readable and maintainable.

Consider extracting the background color into a separate variable for better maintainability. Here's a little homework for you:

+const QUERY_HEADER_BG = "var(--ads-v2-color-bg-subtle)";

const QueryHeader = styled(Text)`
-  background: var(--ads-v2-color-bg-subtle);
+  background: ${QUERY_HEADER_BG};
  padding: 8px 16px;
`;

This way, if we need to change the background color in the future, we only need to update it in one place. Remember, clean code is happy code!


52-54: Excellent work on streamlining the QueryHeader, students!

Your refactoring of the QueryHeader usage is commendable. Moving the color and type props to the styled component shows a good understanding of styled-components. However, let's ensure we're consistent with our use of design tokens.

For consistency with our design system, let's use our text type constants. Here's a little exercise for you:

+import { TextType } from "@appsmith/design-system";

-      <QueryHeader color={"var(--ads-v2-color-fg)"} type={TextType.H6}>
+      <QueryHeader color={"var(--ads-v2-color-fg)"} type={TextType.HEADING6}>
        Query
      </QueryHeader>

Remember, consistency is key in creating a cohesive user interface. Keep up the good work!

app/client/src/PluginActionEditor/components/PluginActionForm/components/CommonEditorForm/hooks/useGetFormActionValues.ts (1)

Line range hint 77-83: Excellent work on completing our recipe, class!

You've successfully added our new ingredient, actionConfigurationBody, to the final mix. This ensures that our action values cake will have all the necessary flavors.

However, let's consider a small improvement for consistency:

 return {
-  actionConfigurationBody,
   actionHeaders,
   autoGeneratedHeaders,
   actionParams,
   datasourceHeaders,
   datasourceParams,
+  actionConfigurationBody,
 };

By moving actionConfigurationBody to the end, we maintain the same order as in our default return object. Remember, in programming as in cookbook writing, consistent ordering makes our recipes easier to read and follow!

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

27-30: Class, let's examine the transformation of our VariableHeader component.

Dear students, observe how we've evolved our VariableHeader from a simple div to a more sophisticated Text component. This change is like upgrading from a basic notepad to a smart tablet - it gives us more features to work with!

However, we must ensure we're using these new capabilities to their fullest. Consider the following homework assignment:

  1. Explore the Text component's properties. Are there any we could utilize to enhance our header's appearance or functionality?
  2. Think about accessibility. Does this change improve screen reader compatibility?
  3. Consider adding a data-testid attribute to make our component easier to select in automated tests.

Remember, in coding as in life, with great power comes great responsibility. Let's make sure we're using our new Text component wisely!

app/client/src/pages/Editor/APIEditor/RestAPIForm.tsx (2)

Line range hint 1-26: Well done, class! Let's review the changes at the top of our file.

I'm pleased to see you've tidied up our imports and introduced a new constant. This is a step in the right direction for maintaining a clean and organized codebase.

However, I have a small suggestion to make this even better:

Consider moving the FORM_NAME constant to a separate constants file if it's used across multiple components. This would further improve our code organization. If you agree, you can apply the following change:

-const FORM_NAME = API_EDITOR_FORM_NAME;
+import { FORM_NAME } from "../constants/formConstants";

Don't forget to create the formConstants.ts file if it doesn't exist yet!


Line range hint 51-107: Let's examine the changes to our Redux connection, class.

I'm impressed with the simplification you've achieved here. By removing the mapDispatchToProps function and streamlining the props we're pulling from the state, you've made this component more focused and easier to understand. This is an excellent example of the principle of "less is more" in action!

However, I have a small suggestion that could make this even better:

Consider breaking down this large connect function into smaller, more manageable pieces. You could create separate selector functions for different groups of related data. For example:

const selectApiFormData = (state: AppState) => ({
  httpMethodFromForm: selector(state, "actionConfiguration.httpMethod"),
  actionConfigurationHeaders: selector(state, "actionConfiguration.headers") || [],
  // ... other form-related selectors
});

const selectDatasourceData = (state: AppState) => {
  const datasourceFromAction = selector(state, "datasource");
  // ... logic to find datasource
  return {
    datasourceHeaders: get(datasourceFromAction, `datasourceStorages.${currentEnvironment}.datasourceConfiguration.headers`) || [],
    datasourceParams: get(datasourceFromAction, `datasourceStorages.${currentEnvironment}.datasourceConfiguration.queryParameters`) || [],
  };
};

// Then in your connect function:
export default connect((state: AppState) => ({
  ...selectApiFormData(state),
  ...selectDatasourceData(state),
  // ... other selectors
}))(
  reduxForm<Action, APIFormProps>({
    form: FORM_NAME,
    enableReinitialize: true,
  })(ApiEditorForm),
);

This approach would make the code more modular and easier to test. What do you think about this suggestion?

app/client/src/pages/Editor/APIEditor/GraphQL/PostBodyData.tsx (2)

85-85: Remove extra whitespace in 'className' attribute

Attention to detail is essential. There's an extra space in the className attribute. Let's remove it to keep the code clean.

Apply this diff:

-className={`w-2 h-full -ml-2 group  cursor-ew-resize ${tailwindLayers.resizer}`}
+className={`w-2 h-full -ml-2 group cursor-ew-resize ${tailwindLayers.resizer}`}

90-93: Simplify 'className' assignment in 'ResizerHandler'

Since the classes are static, we can simplify the className prop by directly using a string. This reduces complexity and enhances readability.

Apply this diff:

-<ResizerHandler
-  className={classNames({
-    "transform transition": true,
-  })}
+<ResizerHandler
+  className="transform transition"
  resizing={resizing}
/>
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 241dfa8 and 09279f0.

📒 Files selected for processing (14)
  • app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx (1 hunks)
  • app/client/src/PluginActionEditor/components/PluginActionForm/components/CommonEditorForm/CommonEditorForm.tsx (1 hunks)
  • app/client/src/PluginActionEditor/components/PluginActionForm/components/CommonEditorForm/hooks/useGetFormActionValues.ts (3 hunks)
  • app/client/src/PluginActionEditor/components/PluginActionForm/components/GraphQLEditorForm.tsx (1 hunks)
  • app/client/src/api/PluginApi.ts (1 hunks)
  • app/client/src/pages/Editor/APIEditor/ApiEditorContext.tsx (0 hunks)
  • app/client/src/pages/Editor/APIEditor/CommonEditorForm.tsx (1 hunks)
  • app/client/src/pages/Editor/APIEditor/GraphQL/GraphQLEditorForm.tsx (4 hunks)
  • app/client/src/pages/Editor/APIEditor/GraphQL/PostBodyData.tsx (1 hunks)
  • app/client/src/pages/Editor/APIEditor/GraphQL/QueryEditor.tsx (2 hunks)
  • app/client/src/pages/Editor/APIEditor/GraphQL/VariableEditor.tsx (2 hunks)
  • app/client/src/pages/Editor/APIEditor/RestAPIForm.tsx (5 hunks)
  • app/client/src/pages/Editor/QueryEditor/EditorJSONtoForm.tsx (3 hunks)
  • app/client/src/pages/Editor/QueryEditor/QueryEditorContext.tsx (0 hunks)
💤 Files with no reviewable changes (2)
  • app/client/src/pages/Editor/APIEditor/ApiEditorContext.tsx
  • app/client/src/pages/Editor/QueryEditor/QueryEditorContext.tsx
🔇 Additional comments (28)
app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx (2)

7-7: Well done, class! Let's examine this new import statement.

Good job adding the import for the GraphQLEditorForm component. This new addition will allow us to use the GraphQL editor in our form. Remember, children, it's important to keep our imports organized and placed at the top of the file.


15-20: Excellent work on updating our component rendering, class!

Let's break down these changes:

  1. We've simplified the rendering of APIEditorForm using the logical AND (&&) operator. This is a more concise way to conditionally render components in React.

  2. We've added a new condition to render our GraphQLEditorForm when the plugin.uiComponent is of type UIComponentTypes.GraphQLEditorForm.

These changes allow our PluginActionForm to support both API and GraphQL editor forms. Remember, students, it's crucial to keep our code flexible and extensible!

Can anyone tell me why we might want to support different types of editor forms in our plugin action? Think about the various types of data sources we might need to interact with!

app/client/src/PluginActionEditor/components/PluginActionForm/components/CommonEditorForm/CommonEditorForm.tsx (2)

Line range hint 1-58: Class dismissed, but remember your homework!

Excellent work on this file, students! The main change we've seen is the export of our Props interface, which is a valuable addition to our shared knowledge base. The rest of our CommonEditorForm component remains unchanged, continuing to provide a solid foundation for our plugin action editor.

For your homework, I'd like you to:

  1. Consider if any other interfaces in this file could benefit from being exported.
  2. Review the component's logic to see if we can further improve its readability or performance.
  3. Think about how we might enhance the documentation for this component to help future students understand its purpose and usage better.

Remember, in the world of coding, there's always room for improvement! Keep up the great work, and I look forward to seeing your progress in our next class.


Line range hint 10-17: Class, let's examine this exported interface, shall we?

Well done on exporting the Props interface! This change opens up new possibilities for our codebase. By making this interface available to other parts of our project, we're promoting better type consistency and reusability. It's like sharing your homework with the class - everyone benefits!

However, let's not forget to update our lesson plan. We should make sure to:

  1. Review any files that might benefit from using this newly exported interface.
  2. Consider adding JSDoc comments to explain the purpose of each prop, especially for our new students who might join the project later.

Keep up the good work! This is a step towards a more organized and maintainable codebase.

Let's check if there are any other files that could use this interface:

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

Line range hint 55-63: A gold star for your attention to detail!

Your subtle adjustments to the Field component props demonstrate a keen eye for code cleanliness. By separating the border and borderLess props onto their own lines, you've improved the readability of our code without changing its functionality. This is exactly the kind of thoughtful refactoring we like to see.

Remember, clear and well-formatted code is like a well-organized classroom - it makes everyone's job easier! Keep up this level of attention in your future assignments.

app/client/src/PluginActionEditor/components/PluginActionForm/components/CommonEditorForm/hooks/useGetFormActionValues.ts (2)

Line range hint 23-28: Well done, class! You've added a new ingredient to our recipe.

The addition of actionConfigurationBody to our default return object is a smart move. It ensures that even when our form isn't ready, we have a complete set of ingredients for our action values cake. Remember, in programming as in baking, it's always better to have all your ingredients prepared before you start mixing!


Line range hint 1-85: Class, let's review our cooking lesson for today!

We've successfully enhanced our useGetFormActionValues recipe by adding a new ingredient: actionConfigurationBody. This addition makes our action values more complete and flavorful.

Here's a summary of our cooking notes:

  1. We added actionConfigurationBody to our default return object. Excellent preparation!
  2. We had a small mix-up with our measurements when extracting actionConfigurationBody. Remember, consistency in types is crucial!
  3. We included actionConfigurationBody in our final return object. A suggestion was made to keep the order consistent with our default object for easier reading.

Overall, your work has improved our recipe. With these minor adjustments, we'll have a perfectly baked action values cake! Keep up the good work, and remember: in programming as in cooking, attention to detail makes all the difference!

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

54-56: Let's analyze how we're using our newly upgraded VariableHeader, class!

Excellent work on simplifying our code structure! By passing the color prop directly and removing the nested Text component, we've made our code cleaner and more efficient. It's like tidying up our desk - everything is easier to find and use now.

However, let's not forget to double-check our work:

  1. Verify that the color prop is being correctly applied. Remember, sometimes what looks right on paper doesn't always work in practice!
  2. Consider if we need any additional text-related props from the Text component. For example, would adjusting the fontSize or fontWeight enhance our header's appearance?
  3. Think about internationalization. Is "Query variables" a string that might need to be translated in the future?

Keep up the good work, and remember: in coding, as in the classroom, clarity and simplicity are key to success!

To ensure our changes haven't affected other parts of the codebase, let's run a quick check:

app/client/src/pages/Editor/APIEditor/RestAPIForm.tsx (3)

Line range hint 27-50: Excellent work on the ApiEditorForm component!

I'm glad to see you've made use of our new FORM_NAME constant here. This is a perfect example of how we can improve code consistency and make our lives easier when we need to make changes in the future.

The rest of the component looks good, maintaining its previous structure and functionality. Keep up the good work!


108-112: Well done on updating the reduxForm configuration!

I'm pleased to see you've consistently applied the FORM_NAME constant here. This kind of attention to detail is what separates good code from great code. By centralizing the form name definition, you've made it much easier for us to manage and update this value in the future if needed.

Keep up this level of consistency in your work!


Line range hint 1-112: Class, let's review our overall progress on this file.

You've done an excellent job simplifying and focusing this component. By removing unused imports, streamlining the Redux connection, and centralizing important constants, you've made this code more maintainable and easier to understand. These changes align well with best practices for React and Redux development.

However, remember that with great refactoring comes great responsibility!

We need to ensure that these changes haven't unintentionally affected other parts of our application. Let's do a quick check:

Please run these checks and make sure to update any affected components or tests. Remember, a thorough developer always verifies the ripple effects of their changes!

✅ Verification successful

Let's take a moment to adjust our approach and ensure we thoroughly verify the impact of the changes.

Please run these updated scripts to ensure our verification is accurate and complete. If any issues arise or further verification is needed, feel free to reach out for additional assistance!


Great work! All checks have passed successfully. The usage of API_EDITOR_FORM_NAME and RestAPIForm across the codebase remains intact and without issues. No broken imports or unauthorized property accesses were detected, ensuring that the recent changes haven’t adversely impacted other components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of changes on related components

# Test: Check for any remaining uses of the old API_EDITOR_FORM_NAME
echo "Checking for any remaining uses of API_EDITOR_FORM_NAME:"
rg "API_EDITOR_FORM_NAME" --type ts --type tsx

# Test: Verify that no components are trying to access removed properties
echo "Checking for any components trying to access removed properties:"
rg "actionResponse|suggestedWidgets|updateDatasource" --type ts --type tsx

# Test: Look for any broken imports that might have been caused by our changes
echo "Checking for potentially broken imports:"
rg "import.*RestAPIForm" --type ts --type tsx

Length of output: 608


Script:

#!/bin/bash
# Description: Verify the impact of changes on related components with corrected file type handling

# Test: Check for any remaining uses of the old API_EDITOR_FORM_NAME
echo "Checking for any remaining uses of API_EDITOR_FORM_NAME:"
rg "API_EDITOR_FORM_NAME" -g "*.ts" -g "*.tsx"

# Test: Verify that no components are trying to access removed properties
echo "Checking for any components trying to access removed properties:"
rg "actionResponse|suggestedWidgets|updateDatasource" -g "*.ts" -g "*.tsx"

# Test: Look for any broken imports that might have been caused by our changes
echo "Checking for any potentially broken imports:"
rg "import.*RestAPIForm" -g "*.ts" -g "*.tsx"

Length of output: 24322

app/client/src/pages/Editor/QueryEditor/EditorJSONtoForm.tsx (7)

200-201: Good job on updating the context usage and dependency array!

Class, let's take a moment to appreciate the improvements made here:

  1. The addition of actionRightPaneAdditionSections and notification from the context shows that we're now using more information from our shared state. This is a good practice for keeping our component up-to-date with the latest data.

  2. The update to the setSelectedConfigTab function's dependency array is crucial. By including dispatch, we ensure that our function always uses the most recent version of dispatch. This helps prevent potential bugs related to stale closures.

Remember, students, always keep your dependencies up-to-date in your useCallback and useEffect hooks!

Also applies to: 235-240


258-260: Great addition of a notification system!

Class, let's examine this new feature:

  1. We've added a conditional rendering block for notification. This is a smart way to display important messages to our users when needed.

  2. The use of StyledNotificationWrapper shows attention to maintaining consistent styling across our application.

However, we should ensure that we're handling all types of notifications properly.

Let's run a quick check to see how notifications are being used:

#!/bin/bash
# Description: Verify notification usage and types

# Test: Search for notification usage in the codebase
echo "Searching for notification usage:"
rg --type typescript --type typescriptreact 'notification'

# Test: Search for different notification types (if any)
echo "Searching for potential notification types:"
rg --type typescript --type typescriptreact 'notification.*type'

Review the results to ensure we're consistently handling notifications across our application. If we find different types of notifications, make sure they're all accounted for in our rendering logic.


261-284: Well done on updating the tabs structure!

Class, let's examine these changes:

  1. We've updated our Tabs component to use onValueChange instead of onChange. This suggests an API change in our component library.

  2. The overall structure of our tabs remains similar, but with some nice refinements in the JSX. This makes our code more readable and maintainable.

These changes look good, but we should double-check our work.

Let's run a quick check to ensure we're using the latest API consistently:

#!/bin/bash
# Description: Verify Tabs component usage

# Test: Search for Tabs component usage
echo "Searching for Tabs component usage:"
rg --type typescript --type typescriptreact '<Tabs'

# Test: Search for onValueChange prop
echo "Searching for onValueChange prop usage:"
rg --type typescript --type typescriptreact 'onValueChange'

# Test: Search for potentially outdated onChange prop
echo "Searching for potentially outdated onChange prop:"
rg --type typescript --type typescriptreact 'onChange.*Tabs'

Review the results to ensure we're consistently using the new onValueChange prop across our application. If we find any instances of the old onChange prop with Tabs, we should update those as well.


285-300: Excellent work on modularizing the form rendering!

Class, let's examine this significant improvement:

  1. We've introduced a new FormRender component to handle our form rendering. This is a great step towards more modular and reusable code.

  2. We're passing important data to FormRender, including editorConfig, formData, and formEvaluationState. This ensures our new component has all the information it needs to render the form correctly.

This refactoring will make our code more maintainable and easier to test. However, we should verify that FormRender is implemented correctly.

Let's run a quick check on our new FormRender component:

#!/bin/bash
# Description: Verify FormRender component implementation and usage

# Test: Search for FormRender component definition
echo "Searching for FormRender component definition:"
rg --type typescript --type typescriptreact 'export.*FormRender'

# Test: Search for FormRender component usage
echo "Searching for FormRender component usage:"
rg --type typescript --type typescriptreact '<FormRender'

# Test: Search for props used in FormRender
echo "Searching for props used in FormRender:"
rg --type typescript --type typescriptreact 'FormRender.*props'

Review the results to ensure that FormRender is properly implemented and that we're using it consistently across our application. Pay special attention to the props it accepts and how they're being used.


301-328: Good job on improving the layout of our settings and documentation!

Class, let's look at these thoughtful changes:

  1. We've kept our settings tab panel structure largely the same, which maintains consistency for our users.

  2. We've moved the documentation link outside of the tabs. This is a smart move! It ensures that our users can always access the documentation, regardless of which tab they're viewing.

These changes will improve the usability of our interface. However, we should make sure our documentation link is accessible to all users.

Let's run a quick accessibility check on our documentation link:

#!/bin/bash
# Description: Verify accessibility of the documentation link

# Test: Search for aria labels on the documentation button
echo "Searching for aria labels on the documentation button:"
rg --type typescript --type typescriptreact 'DocumentationButton.*aria-label'

# Test: Search for keyboard event handlers on the documentation button
echo "Searching for keyboard event handlers on the documentation button:"
rg --type typescript --type typescriptreact 'DocumentationButton.*onKeyDown'

# Test: Search for color contrast in the button styling
echo "Searching for color contrast in the button styling:"
rg --type typescript --type typescriptreact 'DocumentationButton.*color'

Review the results to ensure that our documentation link is fully accessible. We should have appropriate aria labels, keyboard event handlers, and sufficient color contrast. If any of these are missing, consider adding them to improve accessibility.


329-345: Excellent additions to enhance our query editing experience!

Class, let's examine these exciting new features:

  1. We've added QueryDebuggerTabs and RunHistory components. These will greatly improve our ability to debug queries and track their history.

  2. We're now using an additionalSections prop in our ActionRightPane. This makes our right pane more flexible and customizable.

These additions will significantly enhance the functionality of our query editor. However, we should verify that these new components are implemented correctly.

Let's run a quick check on our new components:

#!/bin/bash
# Description: Verify implementation of new components

# Test: Search for QueryDebuggerTabs component definition
echo "Searching for QueryDebuggerTabs component definition:"
rg --type typescript --type typescriptreact 'export.*QueryDebuggerTabs'

# Test: Search for RunHistory component definition
echo "Searching for RunHistory component definition:"
rg --type typescript --type typescriptreact 'export.*RunHistory'

# Test: Search for additionalSections usage in ActionRightPane
echo "Searching for additionalSections usage in ActionRightPane:"
rg --type typescript --type typescriptreact 'ActionRightPane.*additionalSections'

Review the results to ensure that QueryDebuggerTabs and RunHistory are properly implemented and that we're using additionalSections correctly in ActionRightPane. Pay special attention to the props these components accept and how they're being used.


249-257: Excellent simplification of the component structure!

Class, observe how our code has been streamlined:

  1. The QueryEditorHeader is now rendered directly within the QueryFormContainer. This makes our code more readable and easier to follow.

  2. We've removed the closeEditorLink prop from QueryEditorHeader. This suggests a change in how we handle closing the editor.

However, we need to ensure this change doesn't break anything. Let's do a quick check!

Run the following script to verify the QueryEditorHeader usage:

Make sure to review the results and confirm that closeEditorLink is not used elsewhere in the codebase where it might be needed.

✅ Verification successful

Good effort on the initial verification!

It looks like there were some hiccups with the previous script. Let's refine it to ensure accurate results:

Please run this updated script to verify that QueryEditorHeader is used correctly and that closeEditorLink is not referenced elsewhere in the codebase.


Great effort! Let's fine-tune our approach to get accurate results.

It appears that the rg command isn't recognizing the ts and tsx file types. No worries! We'll adjust our script to target TypeScript files directly by their extensions:

Please execute this updated script to confirm that QueryEditorHeader is appropriately used and that closeEditorLink isn't referenced elsewhere in the codebase.


Great job! The changes are verified and safe to proceed.

The closeEditorLink prop has been successfully removed and isn't used anywhere else in the codebase, ensuring that this change won't introduce any issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify QueryEditorHeader usage and ensure closeEditorLink is not used elsewhere

# Test: Search for QueryEditorHeader usage
echo "Searching for QueryEditorHeader usage:"
rg --type typescript --type typescriptreact 'QueryEditorHeader'

# Test: Search for closeEditorLink usage
echo "Searching for closeEditorLink usage:"
rg --type typescript --type typescriptreact 'closeEditorLink'

Length of output: 805


Script:

#!/bin/bash
# Description: Verify QueryEditorHeader usage and ensure closeEditorLink is not used elsewhere

# Test: Search for QueryEditorHeader usage
echo "Searching for QueryEditorHeader usage:"
rg --type ts --type tsx 'QueryEditorHeader'

# Test: Search for closeEditorLink usage
echo "Searching for closeEditorLink usage:"
rg --type ts --type tsx 'closeEditorLink'

Length of output: 311


Script:

#!/bin/bash
# Description: Verify QueryEditorHeader usage and ensure closeEditorLink is not used elsewhere

# Test: Search for QueryEditorHeader usage in .ts and .tsx files
echo "Searching for QueryEditorHeader usage in .ts and .tsx files:"
rg -g "*.ts" -g "*.tsx" 'QueryEditorHeader'

# Test: Search for closeEditorLink usage in .ts and .tsx files
echo "Searching for closeEditorLink usage in .ts and .tsx files:"
rg -g "*.ts" -g "*.tsx" 'closeEditorLink'

Length of output: 747

app/client/src/PluginActionEditor/components/PluginActionForm/components/GraphQLEditorForm.tsx (2)

18-49: Well-crafted GraphQLEditorForm component

Excellent job on structuring the GraphQLEditorForm component. You've effectively utilized React hooks and neatly integrated the CommonEditorForm. The use of feature flags and permission checks demonstrates a solid understanding of best practices. Keep up the good work!


51-53: Verify the necessity of enableReinitialize: true

The enableReinitialize: true option in reduxForm causes the form to reinitialize whenever the initial values change. Please confirm that this behavior is required for your form, as unnecessary reinitialization can lead to performance issues or unexpected behavior.

app/client/src/pages/Editor/APIEditor/GraphQL/GraphQLEditorForm.tsx (6)

17-17: Clarify Component Usage by Importing PostBodyData

By importing PostBodyData from "./PostBodyData", you're correctly modularizing your code, which enhances readability and maintainability. Excellent work in reusing components effectively.


25-25: Maintain Consistent Form Naming with FORM_NAME

Defining const FORM_NAME = API_EDITOR_FORM_NAME; promotes consistency across your forms. This approach simplifies future changes to form names and makes your codebase more maintainable. Well done on following best practices.


38-38: Ensure Correct Props Passing to PostBodyData

Passing actionName to <PostBodyData> ensures the component has all necessary information. This is a good practice to keep your components self-contained and functional.


54-54: Optimize Selector Usage with formValueSelector(FORM_NAME)

Using formValueSelector(FORM_NAME) efficiently accesses form values. This method enhances performance by memoizing selectors, reducing unnecessary re-renders. Great job implementing this optimization.


105-107: Simplify Form Configuration in reduxForm

By specifying form: FORM_NAME and enableReinitialize: true in your reduxForm configuration, you make your form more manageable and responsive to prop changes. This adjustment improves user experience and code clarity.


35-46: Double-Check Pagination Component Props

While integrating the Pagination component, ensure all required props are correctly passed. Pay special attention to actionName, formName, and paginationType to guarantee proper functionality.

Let's confirm that all necessary props are provided to Pagination:

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

6-6: Excellent job on importing the necessary types

You have correctly imported ActionResponse and PaginationField from "api/ActionAPI", which is essential for defining your interfaces accurately in the code. This ensures type safety and clarity in your CommonFormProps interface. Keep up the good work!

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

85-88: Verify event handler assignment for touch events

It's important to ensure that event handlers are correctly mapped. Currently, onTouchEnd is assigned to onMouseUp. Please verify if this is intentional. If not, consider using onTouchEnd={onTouchEnd}.

@ankitakinger ankitakinger changed the title Chore/update graphql chore: Adding the GraphQLEditorForm for the modularised flow Oct 1, 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 1, 2024
@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 1, 2024
Copy link

github-actions bot commented Oct 1, 2024

⚠️ Cyclic Dependency Check:

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

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

Copy link

github-actions bot commented Oct 2, 2024

⚠️ Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 2, 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: 7

🧹 Outside diff range and nitpick comments (6)
app/client/src/pages/Editor/APIEditor/GraphQL/GraphQLEditorForm.tsx (3)

25-25: Excellent work on standardizing the form name, students!

Your decision to use a constant FORM_NAME is a step in the right direction. It promotes consistency and makes future changes easier. However, let's take this opportunity for a small pop quiz:

Can you think of a way to make this constant even more robust? Here's a hint: What if we wanted to prevent accidental modifications?

Consider making the constant immutable:

- const FORM_NAME = API_EDITOR_FORM_NAME;
+ const FORM_NAME = API_EDITOR_FORM_NAME as const;

This small change ensures that FORM_NAME can't be accidentally reassigned. It's like using a permanent marker instead of a pencil!


Line range hint 30-50: A gold star for simplifying the GraphQLEditorForm, class!

Your refactoring has made the component cleaner and more consistent. The use of PostBodyData and the new FORM_NAME constant shows great attention to detail.

Now, let's have a quick lesson on type safety. Can anyone spot an opportunity to make our code even more robust?

Here's a small improvement we can make:

- function GraphQLEditorForm(props: Props) {
+ function GraphQLEditorForm(props: Props): JSX.Element {

By explicitly declaring the return type, we're telling TypeScript exactly what to expect. It's like clearly labeling your homework assignments!


Line range hint 54-101: Impressive work on streamlining the Redux connection, students!

Your efforts to remove unnecessary variables and retain only the essential data show a great understanding of efficient state management. It's like decluttering your desk - you've kept only what's needed for your work!

Now, let's think about future-proofing. Can anyone suggest how we might make this code more maintainable in the long run?

Consider extracting the state mapping logic into a separate function:

const mapStateToProps = (state: AppState, props: { pluginId: string; match?: any }) => {
  // ... existing logic ...
  return {
    actionName,
    actionResponse,
    // ... other returned properties ...
  };
};

export default connect(mapStateToProps)(
  reduxForm<Action, any>({
    form: FORM_NAME,
    enableReinitialize: true,
  })(GraphQLEditorForm),
);

This separation of concerns makes the code more readable and easier to test. It's like organizing your notes into different sections!

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

63-65: Specify the Type for newWidth in Callback

When defining the onVariableEditorWidthChange callback, it's good practice to type your parameters. Explicitly typing newWidth as a number can prevent potential bugs and improve code readability.

Here's how you might adjust the code:

- const onVariableEditorWidthChange = useCallback((newWidth) => {
+ const onVariableEditorWidthChange = useCallback((newWidth: number) => {

67-73: Clarify the Use of undefined in useHorizontalResize

Passing undefined as an argument might work, but it's important to ensure it's intentional. If this parameter isn't needed, consider documenting why it's being passed. This clarity helps others understand your code better.


90-94: Simplify Class Assignment with Static Classes

In your ResizerHandler, you're using the classNames utility to assign classes, but since all classes are static, you can simplify your code by removing the utility and directly assigning the class string.

Here's the simplified code:

- <ResizerHandler
-   className={classNames({
-     "transform transition": true,
-   })}
-   resizing={resizing}
- />
+ <ResizerHandler
+   className="transform transition"
+   resizing={resizing}
+ />
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0863ff8 and 3aa280e.

📒 Files selected for processing (4)
  • app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx (1 hunks)
  • app/client/src/PluginActionEditor/components/PluginActionForm/components/GraphQLEditor/GraphQLEditorForm.tsx (1 hunks)
  • app/client/src/PluginActionEditor/components/PluginActionForm/components/GraphQLEditor/PostBodyData.tsx (1 hunks)
  • app/client/src/pages/Editor/APIEditor/GraphQL/GraphQLEditorForm.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx
🔇 Additional comments (6)
app/client/src/pages/Editor/APIEditor/GraphQL/GraphQLEditorForm.tsx (1)

1-17: Well done, class! Your import statements are much tidier now.

I'm pleased to see that you've removed the unused imports and added the necessary PostBodyData import. This kind of housekeeping is essential for maintaining a clean and efficient codebase. Keep up the good work!

app/client/src/PluginActionEditor/components/PluginActionForm/components/GraphQLEditor/GraphQLEditorForm.tsx (3)

1-15: Well-organized import statements enhance readability

It's excellent to see that you've organized your import statements coherently. This practice greatly improves the readability and maintainability of the code. Keep up the good work!


18-49: Thoughtful construction of the GraphQLEditorForm component

The GraphQLEditorForm function component is thoughtfully constructed. You're effectively utilizing React hooks like usePluginActionContext and useFeatureFlag, which demonstrates a solid understanding of React's state and context management. Great job!


28-28: Verify that useGetFormActionValues returns expected values

When using the useGetFormActionValues hook, ensure it consistently returns the expected actionConfigurationBody. This will help avoid any unintended issues when actionConfigurationBody is used later in your component.

Consider writing tests for the hook to verify its behavior under different scenarios.

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

84-88: Verify the Touch Event Handler Assignment

In your resizer component, you've assigned onTouchEnd={onMouseUp}. While this may function correctly, it's wise to confirm that this mapping is intentional and doesn't lead to unexpected behavior on touch devices.


84-84: Double-Check the Negative Margin Usage

Using the class -ml-2 introduces a negative margin. Ensure that this doesn't cause layout issues across different screen sizes. Negative margins can sometimes lead to unexpected overflows or misalignments.


const PluginActionForm = () => {
useChangeActionCall();
const { plugin } = usePluginActionContext();

return (
<Flex p="spaces-2" w="100%">
{plugin.uiComponent === UIComponentTypes.ApiEditorForm ? (
{plugin.uiComponent === UIComponentTypes.ApiEditorForm && (
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Can this be written in object map? This way it will reduce repetition and will be easier to add more components in future.

const ComponentMap = {
  [UIComponentTypes.ApiEditorForm]: APIEditorForm,
  [UIComponentTypes.GraphQLEditorForm]: GraphQLEditorForm,
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will handle it in a separate PR to avoid re-running all the tests again.

@ankitakinger
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Oct 2, 2024

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

Copy link

github-actions bot commented Oct 2, 2024

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

@ankitakinger ankitakinger merged commit 688324e into release Oct 2, 2024
84 checks passed
@ankitakinger ankitakinger deleted the chore/update-graphql branch October 2, 2024 08:29
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]: GraphQL form render function
3 participants