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: sniping mode for module to bind to existing and new widgets #35072

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

ashit-rath
Copy link
Contributor

@ashit-rath ashit-rath commented Jul 22, 2024

Description

Fixes sniping for module instances.
For binding to widgets, the module instance id and moduleInstance name was to be passed to the BindDataButton component.

Fixes #31957

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/10056587287
Commit: 74ec4dc
Cypress dashboard.
Tags: @tag.All
Spec:


Tue, 23 Jul 2024 10:37:32 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced new apiName prop in the ApiResponseView component for enhanced flexibility in API response rendering.
    • Added moduleInstanceId to BindDataButtonProps for improved data binding context.
    • Enhanced QueryResponseTab components by adding actionName prop, improving functionality and display.
  • Bug Fixes

    • Updated logic in QueryResponseTab to allow for fallback to actionName when rendering, enhancing adaptability.
  • Tests

    • Added a comprehensive test suite for bindDataToWidgetSaga to ensure expected behavior and integration with Redux state management.
  • Refactor

    • Improved the logic in bindDataToWidgetSaga to utilize actionName, streamlining the data binding process.

@ashit-rath ashit-rath self-assigned this Jul 22, 2024
Copy link
Contributor

coderabbitai bot commented Jul 22, 2024

Walkthrough

The recent updates enhance various components in the application by introducing new props, such as apiName and actionName, which improve flexibility and functionality in handling API responses and data binding. These changes streamline control flows by allowing components to adapt dynamically based on the provided props, ultimately leading to a more robust data-handling mechanism.

Changes

Files Change Summary
app/client/src/components/editorComponents/ApiResponseView.tsx Added apiName prop to ApiResponseView, enabling fallback for actionName in ApiResponseMeta.
app/client/src/pages/Editor/QueryEditor/BindDataButton.tsx Introduced moduleInstanceId to BindDataButtonProps for enhanced data binding context; updated logic for deriving queryId.
app/client/src/pages/Editor/QueryEditor/EditorJSONtoForm.tsx Added actionName prop to QueryResponseTab, enhancing functionality and potential interactions with other components.
app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx Introduced actionName prop to QueryResponseTab, improving its behavior and data presentation.
app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx Enhanced Props interface by adding actionName, allowing more flexible handling of action names; modified logic for utilizing the actionName.
app/client/src/sagas/SnipingModeSaga.test.ts Added comprehensive tests for bindDataToWidgetSaga, ensuring correct behavior and state management during data binding operations.
app/client/src/sagas/SnipingModeSagas.ts Enhanced bindDataToWidgetSaga with new module instance retrieval and updated logic to utilize actionName, improving clarity and robustness.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant QueryEditor
    participant ApiResponseView
    participant BindDataButton
    participant QueryResponseTab

    User->>QueryEditor: Interacts with component
    QueryEditor->>ApiResponseView: Passes apiName
    ApiResponseView->>QueryResponseTab: Passes actionName
    QueryResponseTab->>BindDataButton: Uses actionName for data binding
    BindDataButton->>QueryEditor: Updates binding display
Loading

Assessment against linked issues

Objective Addressed Explanation
Ensure moduleInstanceId enhances data binding functionality and addresses existing issues.
Ensure that toggling JS mode does not expose references after binding. Impact of changes on JS mode behavior unclear.
Ensure that binding to existing widgets works as expected. No specific changes directly address this issue.

Poem

In the land of code where functions play,
New props awaken, brightening the day.
apiName and actionName lead the quest,
Flexibility reigns, and components are blessed.
Binding data with ease, oh what a thrill,
In this wondrous world, our spirits we fill! 🎉


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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 Medium Issues that frustrate users due to poor UX Module consumer Issues related to the module consumer side Needs Triaging Needs attention from maintainers to triage Packages Product Issues related to packages Packages Pod issues that belong to the packages pod Production labels Jul 22, 2024
@ashit-rath ashit-rath changed the title fix sniping mode for module to bind to existing and new widgets fix: sniping mode for module to bind to existing and new widgets Jul 22, 2024
@github-actions github-actions bot removed the Bug Something isn't working label Jul 22, 2024
@ashit-rath ashit-rath added Bug Something isn't working ok-to-test Required label for CI labels Jul 22, 2024
@github-actions github-actions bot added Bug Something isn't working and removed Bug Something isn't working labels Jul 22, 2024
Copy link

⚠️ Cyclic Dependency Check:

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

Outside diff range, codebase verification and nitpick comments (2)
app/client/src/sagas/SnipingModeSaga.test.ts (1)

1-17: Ensure all imports are necessary and correctly used.

The imports seem appropriate for the test file. However, ensure that each imported module is used within the test cases to avoid unnecessary imports.

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

Line range hint 1-24:
Ensure all imports are necessary and correctly used.

The existing imports seem appropriate for the file. However, ensure that each imported module is used within the component to avoid unnecessary imports.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 57decce and 74ec4dc.

Files selected for processing (7)
  • app/client/src/components/editorComponents/ApiResponseView.tsx (2 hunks)
  • app/client/src/pages/Editor/QueryEditor/BindDataButton.tsx (2 hunks)
  • app/client/src/pages/Editor/QueryEditor/EditorJSONtoForm.tsx (1 hunks)
  • app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx (1 hunks)
  • app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx (2 hunks)
  • app/client/src/sagas/SnipingModeSaga.test.ts (1 hunks)
  • app/client/src/sagas/SnipingModeSagas.ts (4 hunks)
Additional comments not posted (20)
app/client/src/sagas/SnipingModeSaga.test.ts (4)

19-22: Good use of describe block and beforeEach setup.

The describe block groups related tests, and the beforeEach setup ensures a clean state for each test.


24-103: Comprehensive test case for binding data to widget.

The test case is well-structured and covers the scenario where the moduleInstance is used when the action is missing. Ensure that all possible edge cases are considered.


65-100: Thorough assertions to verify dispatched actions.

The assertions check the dispatched actions, ensuring the correct behavior of the saga. Consider adding more assertions to cover additional edge cases if necessary.


102-103: Proper cleanup after the test case.

The spy is correctly restored after the test case, ensuring no side effects for subsequent tests.

app/client/src/sagas/SnipingModeSagas.ts (5)

25-26: Ensure new imports are necessary and correctly used.

The new imports for ModuleInstance and getModuleInstanceById are appropriate for the changes made in the file. Verify that these imports are used correctly within the saga.


40-43: Correct integration of module instance retrieval.

The saga correctly retrieves the module instance using getModuleInstanceById. Ensure that the retrieval logic handles cases where the module instance might not be found.


45-46: Correct use of actionName.

The actionName variable is defined using the module instance name or action config name, ensuring flexibility in the saga. Verify that all scenarios where actionName might be undefined are handled.


61-61: Good use of conditional check for actionName.

The conditional check ensures that the saga proceeds only if actionName is defined. This prevents potential errors in the subsequent logic.


Line range hint 68-88:
Consistent and correct usage of actionName.

The actionName is consistently used in constructing queries and logging events, ensuring clarity and correctness in the saga logic.

app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx (4)

Line range hint 31-31:
Correct addition of actionName prop.

The actionName prop has been correctly added to the QueryDebuggerTabs component. Ensure that this prop is passed down and used appropriately within the component.


Line range hint 207-212:
Correct integration of actionName in component logic.

The actionName prop is correctly passed to the QueryResponseTab component, ensuring that it can utilize this prop as needed.


Line range hint 189-195:
Correct use of actionName in response tabs.

The actionName is used in the DebuggerLogs component within the response tabs, enhancing the functionality by allowing the component to utilize this prop.


Line range hint 1-212:
Overall structure and logic of the component are correct.

The overall structure and logic of the QueryDebuggerTabs component remain intact, and the addition of the actionName prop does not introduce any issues.

app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx (2)

65-65: Good job adding the new property!

The addition of the actionName property to the Props interface is clear and well-structured. This will enhance the flexibility of the component.


Line range hint 70-275: Well done on enhancing the component's flexibility!

The usage of the actionName property in the QueryResponseTab component is well-implemented. It provides a fallback mechanism to use currentActionConfig.name if actionName is not provided. This enhances the component's flexibility and reusability.

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

259-259: Great enhancement!

The addition of the actionName prop to the QueryResponseTab component within the EditorJSONtoForm function is well-implemented. This change enhances the functionality of the QueryResponseTab component.

app/client/src/pages/Editor/QueryEditor/BindDataButton.tsx (2)

255-255: Nice addition of the optional property!

The addition of the moduleInstanceId property to the BindDataButtonProps interface is clear and well-structured. This will enhance the flexibility of the component.


342-344: Excellent enhancement for robustness!

The usage of the moduleInstanceId property in the bindDataOnCanvas dispatch call is well-implemented. It provides a fallback mechanism to determine the queryId, enhancing the robustness of the data binding operations.

app/client/src/components/editorComponents/ApiResponseView.tsx (2)

206-206: Good job adding the new prop apiName.

This addition enhances the flexibility of the component by allowing it to use apiName as a fallback for the actionName prop.


339-339: Excellent use of fallback logic for actionName.

Using apiName as a fallback for currentActionConfig?.name ensures that the component can handle scenarios where currentActionConfig is not available.

@ashit-rath ashit-rath added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 23, 2024
@ashit-rath ashit-rath merged commit d39eb58 into release Jul 23, 2024
161 checks passed
@ashit-rath ashit-rath deleted the fix/module-instance-sniping branch July 23, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Medium Issues that frustrate users due to poor UX Module consumer Issues related to the module consumer side Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Packages Pod issues that belong to the packages pod Packages Product Issues related to packages Production
Projects
None yet
2 participants