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

fix: Updating the logic for datasource selector to fox the client build failure on prod #38107

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

ankitakinger
Copy link
Contributor

@ankitakinger ankitakinger commented Dec 11, 2024

Description

Updating the logic for datasource selector to fox the client build failure on prod

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

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

🔍 Cypress test results

Warning

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12277105493
Commit: 507ed6f
Cypress dashboard.
Tags: @tag.Datasource
Spec:
It seems like no tests ran 😔. We are not able to recognize it, please check workflow here.


Wed, 11 Dec 2024 13:32:23 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced Datasource component to support plugin data.
    • DatasourceInfo, DatasourceTables, and DatasourceSelector components now accept a plugin prop, improving their functionality and flexibility.
  • Bug Fixes

    • No functional changes, but improved handling of plugin data integration.
  • Documentation

    • Updated component interfaces to reflect new plugin prop.

Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Walkthrough

The changes introduced in this pull request enhance the Datasource component and its related components by integrating a new plugin prop, which is derived from the Redux state. This new prop is passed down to the DatasourceInfo, DatasourceTables, and DatasourceSelector components, allowing them to utilize plugin-specific data. The modifications maintain existing functionalities while improving the components' flexibility and reusability.

Changes

File Change Summary
app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/Datasource.tsx Added plugin variable from Redux state and passed it as a prop to DatasourceInfo and DatasourceTables.
app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceInfo.tsx Added optional plugin property to Props interface and passed it to DatasourceSelector.
app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceSelector/index.tsx Updated DatasourceProps interface to include plugin. Logic modified to use plugin prop instead of context.
app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceTables.tsx Added plugin property to Props interface and updated method signature to accept plugin.

Possibly related PRs

Suggested labels

Bug, IDE Product, Task, IDE Pod, ok-to-test

Suggested reviewers

  • albinAppsmith
  • ayushpahwa
  • hetunandu

🎉 In the land of code where plugins roam,
A Datasource found a new home!
With props and states, it danced with glee,
Enhancing components, as happy as can be!
So raise a toast to this splendid feat,
For plugins and datasources now meet! 🍾


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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @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 the Bug Something isn't working label Dec 11, 2024
@ankitakinger ankitakinger added the ok-to-test Required label for CI label Dec 11, 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 (3)
app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceSelector/index.tsx (1)

22-28: Consider adding null check for plugin.uiComponent

While the null check for plugin is good, accessing uiComponent should also be null-checked to prevent potential runtime errors.

- return props.plugin ? (
-   API_FORM_COMPONENTS.includes(props.plugin.uiComponent) ? (
+ return props.plugin?.uiComponent ? (
+   API_FORM_COMPONENTS.includes(props.plugin.uiComponent) ? (
app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceInfo.tsx (1)

13-13: Consider enhancing analytics with plugin information

The plugin prop is now available but not utilized in the analytics event. Consider adding the plugin name to the analytics event for better tracking.

  AnalyticsUtil.logEvent("EDIT_DATASOURCE_CLICK", {
    datasourceId: datasourceId,
-   pluginName: "",
+   pluginName: plugin?.name || "",
    entryPoint: entryPoint,
  });

Also applies to: 19-19, 25-25, 56-56

app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/Datasource.tsx (1)

49-50: Clean implementation of plugin integration

The changes follow a good architectural pattern by:

  1. Fetching plugin data at the container level
  2. Passing it down consistently to child components
  3. Maintaining separation of concerns

This approach should effectively resolve the client build failure while maintaining code quality.

Also applies to: 149-149, 177-177

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0a046ed and 507ed6f.

📒 Files selected for processing (4)
  • app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/Datasource.tsx (4 hunks)
  • app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceInfo.tsx (2 hunks)
  • app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceSelector/index.tsx (2 hunks)
  • app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceTables.tsx (3 hunks)
🔇 Additional comments (6)
app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceSelector/index.tsx (1)

2-2: LGTM: Type imports and interface updates are correct

The Plugin type import and interface update properly maintain type safety.

Also applies to: 18-18

app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceTables.tsx (2)

12-12: LGTM: Clean implementation of plugin prop flow

The changes correctly implement the plugin prop flow through the component hierarchy while maintaining type safety.

Also applies to: 19-19, 29-29, 62-62


Line range hint 1-1: Verify plugin prop usage across the codebase

Let's ensure all usages of these components have been updated to provide the plugin prop.

app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/Datasource.tsx (3)

28-28: LGTM: Import follows existing pattern

The new import aligns with other entity selector imports from the same module.


149-149: Verify plugin prop types in child components

The plugin prop is consistently passed to child components, but we should verify the prop types are properly defined.

Let's check the prop types in the child components:

Also applies to: 177-177

✅ Verification successful

Let me search for the component definitions and prop types with a different approach using ripgrep. This should help us verify the plugin prop types in the child components.


The previous searches revealed the Plugin type is used throughout the codebase, but we need to specifically check the component files to verify the prop types in the child components that are receiving the plugin prop.


I can see that both DatasourceInfo and DatasourceTables components have proper type definitions for the plugin prop as Plugin | undefined, but we should verify the DatasourceSelector component as well since it's receiving the plugin prop from DatasourceInfo.


Plugin prop types are properly defined in all components

All components receiving the plugin prop have proper type definitions:

  • DatasourceTables: plugin?: Plugin
  • DatasourceInfo: plugin?: Plugin
  • DatasourceSelector: plugin?: Plugin

The Plugin type is correctly imported from 'api/PluginApi' in all components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for DatasourceInfo and DatasourceTables component definitions
ast-grep --pattern 'interface Props {
  $$$
  plugin: $$$
  $$$
}'

Length of output: 68


Script:

#!/bin/bash
# Search for DatasourceInfo component definition and its props
rg -A 5 "DatasourceInfo.*Props" 

# Search for DatasourceTables component definition and its props
rg -A 5 "DatasourceTables.*Props"

# Search for plugin prop type definitions in these components
rg -B 2 -A 2 "plugin:.*Plugin"

Length of output: 23722


Script:

#!/bin/bash
# Let's check the specific component files for DatasourceInfo and DatasourceTables
fd -e tsx "DatasourceInfo|DatasourceTables" -x cat {}

Length of output: 4619


Script:

#!/bin/bash
# Let's check the DatasourceSelector component since it also receives the plugin prop
fd -e tsx "DatasourceSelector" -x cat {}

Length of output: 8403


49-50: Consider adding error handling for undefined plugin

While the empty string fallback prevents runtime errors, it might mask potential issues. Consider adding explicit error handling or validation.

Let's verify the plugin selector usage pattern across the codebase:

Consider this safer implementation:

-  const plugin = useSelector((state) => getPlugin(state, pluginId || ""));
+  const plugin = useSelector((state) => {
+    if (!pluginId) return undefined;
+    return getPlugin(state, pluginId);
+  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants