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: [Plugin Action Editor] Defer plugin config checks #37655

Merged
merged 2 commits into from
Nov 23, 2024

Conversation

hetunandu
Copy link
Member

@hetunandu hetunandu commented Nov 22, 2024

Description

Updates Plugin Action Editor to defer the plugin check till needed. This ensures the usage of Plugin Action Context in scenarios the config is not needed.

Eg: If we want to show Plugin Action Response in App View Mode but not the form, we can still use the Plugin Action Editor with its context.

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/11973235246
Commit: 88d7be1
Cypress dashboard.
Tags: @tag.All
Spec:


Fri, 22 Nov 2024 14:25:16 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced error message presentation with centered layout in various components.
    • Improved rendering logic for form configurations, ensuring clearer separation based on type.
  • Bug Fixes

    • Simplified error handling in the PluginActionEditor component, removing unnecessary error checks.
    • Updated error handling in the ActionSettings component to improve message display.
  • Documentation

    • Updated error handling and rendering logic for better user experience.

@hetunandu hetunandu added the ok-to-test Required label for CI label Nov 22, 2024
Copy link
Contributor

coderabbitai bot commented Nov 22, 2024

Walkthrough

The changes in this pull request involve modifications to the PluginActionContextType interface, specifically making editorConfig and settingsConfig optional. Additionally, the PluginActionEditor component's error handling logic has been simplified by removing checks for these configurations. The FormRender component has been updated to improve error message presentation and rendering logic, while the ActionSettings component now uses a CenteredWrapper for error messages. These alterations enhance flexibility and user interface clarity without altering core functionalities.

Changes

File Change Summary
app/client/src/PluginActionEditor/PluginActionContext.tsx Updated PluginActionContextType interface: editorConfig and settingsConfig are now optional.
app/client/src/PluginActionEditor/PluginActionEditor.tsx Removed error handling for settingsConfig and editorConfig, simplifying control flow.
app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/FormRender.tsx Enhanced error handling UI with CenteredWrapper and Text; refined rendering logic for forms.
app/client/src/pages/Editor/ActionSettings.tsx Added CenteredWrapper for centering error messages when actionSettingsConfig is missing.
app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx Added error handling for missing editorConfig, rendering error messages using CenteredWrapper and Text.

Possibly related PRs

Suggested labels

IDE Product, Task, IDE Pod

Suggested reviewers

  • AmanAgarwal041
  • ayushpahwa
  • albinAppsmith
  • ankitakinger

🎉 In the realm of code where changes flow,
Optional configs now steal the show!
Error checks simplified, a clearer view,
With centered messages, all bright and new.
Forms render better, with logic refined,
In this code journey, progress we find! 🚀


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 skip-changelog Adding this label to a PR prevents it from being listed in the changelog labels Nov 22, 2024
albinAppsmith
albinAppsmith previously approved these changes Nov 22, 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: 0

🧹 Outside diff range and nitpick comments (5)
app/client/src/PluginActionEditor/PluginActionContext.tsx (1)

Line range hint 28-47: Well-structured context implementation.

The context provider maintains proper type safety while supporting the new optional configs. The useMemo optimization ensures efficient re-renders only when dependencies change.

Consider documenting the optional nature of these configs in JSDoc comments to help other developers understand when they can be omitted.

app/client/src/pages/Editor/ActionSettings.tsx (2)

8-8: Consider using path aliases for cleaner imports

The relative import path could be simplified using path aliases to improve maintainability.

-import CenteredWrapper from "../../components/designSystems/appsmith/CenteredWrapper";
+import CenteredWrapper from "@design-system/CenteredWrapper";

Line range hint 11-14: Consider addressing technical debt

The TODO comments and any types should be addressed to improve type safety. Consider defining proper interfaces for actionSettingsConfig.

interface ActionSettingsConfig {
  children: Array<{
    configProperty: string;
    // Add other necessary properties
  } | {
    children: ActionSettingsConfig[];
  }>;
}

interface ActionSettingsProps {
  actionSettingsConfig: ActionSettingsConfig[];
  formName: string;
  theme?: EditorTheme;
}
app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/FormRender.tsx (2)

269-275: Consider preserving the refresh functionality

While the new error UI is cleaner, it removes the refresh capability that was present in the original ErrorComponent. Consider adding a refresh button for better user experience.

 return (
   <CenteredWrapper>
     <Text color="var(--ads-v2-color-fg-error)" kind="heading-m">
       {createMessage(UNEXPECTED_ERROR)}
     </Text>
+    <Button
+      kind="secondary"
+      size="sm"
+      onClick={() => window.location.reload()}
+    >
+      {createMessage(ACTION_EDITOR_REFRESH)}
+    </Button>
   </CenteredWrapper>
 );

Line range hint 29-33: Technical Debt: Address TODOs and type safety

Multiple TODOs and eslint-disable comments indicate areas needing improvement:

  1. Props interface has an any type for editorConfig
  2. Several functions use any type for section parameters
  3. Type assertions could be replaced with proper typing

Consider creating a technical debt ticket to address these issues.

Would you like me to help create proper TypeScript interfaces for these components?

Also applies to: 91-93, 156-158, 184-186, 249-251

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0685d33 and 9107cdb.

📒 Files selected for processing (4)
  • app/client/src/PluginActionEditor/PluginActionContext.tsx (1 hunks)
  • app/client/src/PluginActionEditor/PluginActionEditor.tsx (0 hunks)
  • app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/FormRender.tsx (2 hunks)
  • app/client/src/pages/Editor/ActionSettings.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/PluginActionEditor/PluginActionEditor.tsx
🔇 Additional comments (3)
app/client/src/PluginActionEditor/PluginActionContext.tsx (1)

15-16: LGTM! Making configs optional aligns with the PR objective.

The change to make editorConfig and settingsConfig optional matches the goal of deferring plugin config checks.

Let's verify that components using these configs handle the optional case properly:

✅ Verification successful

Let me try another search strategy to verify the usage of these optional configs.


Making configs optional is safe - proper null checks are in place

The codebase properly handles the optional nature of editorConfig and settingsConfig:

  • FormRender.tsx has explicit null check: if (!editorConfig || editorConfig.length < 0)
  • Optional chaining is used in component props: editorConfig={editorConfig}
  • Values are safely merged in hooks with proper type checks
  • Context values are memoized to prevent unnecessary renders
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for direct usage of editorConfig and settingsConfig
ast-grep --pattern 'editorConfig.$$$' 
ast-grep --pattern 'settingsConfig.$$$'

# Search for null checks or optional chaining
rg -A 2 'editorConfig\??\.' 
rg -A 2 'settingsConfig\??\.'

Length of output: 152384


Script:

#!/bin/bash
# Search for direct usage of editorConfig and settingsConfig in the PluginActionEditor directory
rg -A 3 'editorConfig|settingsConfig' app/client/src/PluginActionEditor/

Length of output: 11888

app/client/src/pages/Editor/ActionSettings.tsx (1)

47-51: LGTM! Clean implementation of error state UI

The error handling implementation using CenteredWrapper and Text components follows design system guidelines and improves error visibility.

app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/FormRender.tsx (1)

25-26: LGTM: Clean import additions

The new imports align with the project's design system and are appropriately used for error message presentation.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx (1)

16-24: Consider adding more specific error information

While the error handling is well-implemented, the generic error message might not be helpful for debugging. Consider including more context about the missing editorConfig.

-          {createMessage(UNEXPECTED_ERROR)}
+          {`${createMessage(UNEXPECTED_ERROR)}: Plugin Action Editor configuration is missing`}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9107cdb and 88d7be1.

📒 Files selected for processing (1)
  • app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx (1 hunks)
🔇 Additional comments (2)
app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx (2)

2-2: LGTM: Import statements are properly organized

The new imports are correctly placed and follow the project's conventions.

Also applies to: 9-10


14-14: Verify the optional editorConfig handling across components

The change to make editorConfig optional aligns with the PR objective but requires verification of proper handling in other components.

✅ Verification successful

The previous search revealed usage of editorConfig in multiple components, but we need to:

  1. Check actual usage of editorConfig properties
  2. Verify if the type definition makes it optional
  3. Find any potential null checks for editorConfig

This will help us determine if the optionality is properly handled across the codebase.


The previous results show that editorConfig is marked as optional in the context type and interfaces, but we need to verify:

  1. How the code handles the optional nature through null checks
  2. Which components actually use editorConfig
  3. If there are any conditional renders based on editorConfig presence

This will help us confirm proper handling of the optional editorConfig across the codebase.


Optional editorConfig is properly handled across the codebase

The type definition in PluginActionContext.tsx already marks editorConfig as optional (editorConfig?: unknown[]), and this optionality is consistently reflected in component interfaces where it's used (FormRender.tsx, Editor.tsx). The change aligns with the existing type system and component implementations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other components using editorConfig from the plugin action context
ast-grep --pattern 'const { $$$, editorConfig, $$$ } = usePluginActionContext()'

# Search for direct editorConfig usage
rg "editorConfig\." --type ts --type tsx

Length of output: 2388


Script:

#!/bin/bash
# Search for editorConfig usage with proper file types
rg "editorConfig\." -t typescript -t tsx

# Search for type definition of usePluginActionContext
ast-grep --pattern 'interface $_ {
  $$$
  editorConfig
  $$$
}'

# Search for editorConfig optional marker
ast-grep --pattern 'editorConfig?: $_'

Length of output: 8043


Script:

#!/bin/bash
# Search for editorConfig usage and null checks
rg "editorConfig(\?|\s+&&|\s*\|\|)" -t ts -t tsx

# Search for files that use editorConfig
fd -e ts -e tsx -x grep -l "editorConfig"

# Look for conditional rendering with editorConfig
ast-grep --pattern 'editorConfig ? $_ : $_'

Length of output: 4305

@hetunandu hetunandu merged commit 86d17a6 into release Nov 23, 2024
84 checks passed
@hetunandu hetunandu deleted the chore/move-config-check-plugin-action-editor branch November 23, 2024 03:01
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 27, 2024
…#37655)

## Description

Updates Plugin Action Editor to defer the plugin check till needed. This
ensures the usage of Plugin Action Context in scenarios the config is
not needed.

Eg: If we want to show Plugin Action Response in App View Mode but not
the form, we can still use the Plugin Action Editor with its context.


## Automation

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

### 🔍 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/11973235246>
> Commit: 88d7be1
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11973235246&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Fri, 22 Nov 2024 14:25:16 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

## Release Notes

- **New Features**
- Enhanced error message presentation with centered layout in various
components.
- Improved rendering logic for form configurations, ensuring clearer
separation based on type.

- **Bug Fixes**
- Simplified error handling in the `PluginActionEditor` component,
removing unnecessary error checks.
- Updated error handling in the `ActionSettings` component to improve
message display.

- **Documentation**
- Updated error handling and rendering logic for better user experience.
<!-- 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
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants