Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added warning message in response pane while prepared statement is on #36407

Merged
merged 6 commits into from
Sep 23, 2024

Conversation

albinAppsmith
Copy link
Collaborator

@albinAppsmith albinAppsmith commented Sep 19, 2024

Description

Added warning message in response pane to show that use prepared statement is turned on. This will be showing up only if there is an error.

Fixes #36326

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10987691166
Commit: debc9f3
Cypress dashboard.
Tags: @tag.Sanity, @tag.Datasource
Spec:


Mon, 23 Sep 2024 05:25:23 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a warning message for users regarding prepared statements that may cause query errors.
    • Added a mechanism to navigate users to the settings page for resolving issues related to prepared statements.
    • Enhanced the Query Response Tab with contextual warnings and improved user guidance.
  • Bug Fixes

    • Improved error handling related to prepared statements in the query response.
  • Tests

    • Added comprehensive unit tests for the Query Response Tab to ensure correct behavior of the prepared statement warning under various conditions.

@github-actions github-actions bot added IDE Navigation Issues/feature requests related to IDE navigation, and context switching IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Task A simple Todo labels Sep 19, 2024
@albinAppsmith
Copy link
Collaborator Author

/build-deploy-preview skip-test=true

Copy link
Contributor

coderabbitai bot commented Sep 19, 2024

Walkthrough

The pull request introduces a new warning mechanism in the application related to prepared statements. It adds a constant for the warning message and modifies the QueryResponseTab to conditionally display this warning based on specific error conditions. Additionally, a function is implemented to navigate users to the settings tab for further action, enhancing user guidance during query errors.

Changes

File Change Summary
app/client/src/ce/constants/messages.ts Added a new constant PREPARED_STATEMENT_WARNING with functions for a warning message and link.
app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx Introduced a state variable for warning display, a function for navigation, and a conditional UI for the warning message.
app/client/src/pages/Editor/QueryEditor/QueryResponseTab.test.tsx Added unit tests for the QueryResponseTab component to verify the display of the prepared statement warning under various conditions.

Assessment against linked issues

Objective Addressed Explanation
Add "use prepared statement" warning message in response pane (#36326)

Possibly related PRs

Suggested labels

Test

Suggested reviewers

  • AmanAgarwal041
  • hetunandu
  • ApekshaBhosale

In the realm of code, a warning takes flight,
Prepared statements, now brought to light.
With messages clear, and links to explore,
User guidance shines, like never before! 🌟
Navigate with ease, through queries that flow,
A better experience, for all to bestow!


Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9d451ab and debc9f3.

Files selected for processing (1)
  • app/client/src/ce/constants/messages.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/src/ce/constants/messages.ts

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 the Enhancement New feature or request label Sep 19, 2024
Copy link

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

@albinAppsmith albinAppsmith added the ok-to-test Required label for CI label Sep 19, 2024
@albinAppsmith
Copy link
Collaborator Author

/build-deploy-preview skip-test=true

Copy link

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

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: 2

Outside diff range and nitpick comments (3)
app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx (1)

213-215: Include dependencies in your useCallback hook

To ensure that navigateToSettings updates correctly when dependencies change, it's advisable to include dispatch in the dependency array of your useCallback hook. This practice aligns with React's guidelines for hooks and prevents potential stale closures.

You can modify your code as follows:

      const navigateToSettings = useCallback(() => {
        dispatch(setQueryPaneConfigSelectedTabIndex(EDITOR_TABS.SETTINGS));
-      }, []);
+      }, [dispatch]);
app/client/src/ce/constants/messages.ts (2)

2508-2508: Remember to maintain consistent punctuation in messages

In the MESSAGE string, consider adding a period at the end for consistency with other messages that use complete sentences.

Apply this change:

-"Prepared Statements are currently enabled, which may be causing the query error. Turn them off and try running the query again"
+"Prepared Statements are currently enabled, which may be causing the query error. Turn them off and try running the query again."

Consistency in punctuation enhances readability and maintains a professional tone throughout the application.


2506-2510: Consider internationalization support for the new messages

To support localization, ensure that the new messages are compatible with the application's internationalization framework.

If the application uses a localization library, consider adding these messages to the appropriate locale files. This will make it easier to support multiple languages and reach a broader audience.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 006dbfd and 5ed0dfa.

Files selected for processing (2)
  • app/client/src/ce/constants/messages.ts (1 hunks)
  • app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx (6 hunks)
Additional comments not posted (7)
app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx (6)

1-1: Excellent use of React hooks

You've correctly imported useCallback and useState from React. This will help manage your component's state and memoize functions efficiently.


16-21: Components imported successfully from "@appsmith/ads"

It's great to see that you've imported Callout, Flex, SegmentedControl, and CalloutLinkProps properly. These components will enhance your UI and provide better user interaction.


40-45: Necessary imports for action dispatching and messages

Well done importing setQueryPaneConfigSelectedTabIndex, EDITOR_TABS, createMessage, and PREPARED_STATEMENT_WARNING. These imports are essential for navigation and displaying messages to the user.


165-165: Initializing showPreparedStatementWarning correctly

Good job initializing showPreparedStatementWarning to false. This sets the default state appropriately before any conditions are applied.


217-223: Configuring preparedStatementCalloutLinks appropriately

You've set up preparedStatementCalloutLinks correctly with the necessary onClick handler and link text. This will provide users with a helpful navigation option directly from the warning message.


235-239: Conditional rendering of the warning message

Excellent implementation of the conditional rendering for the Callout component. Displaying the warning only when showPreparedStatementWarning is true ensures users are informed at the appropriate times without cluttering the UI.

app/client/src/ce/constants/messages.ts (1)

2506-2510: Verify the usage of PREPARED_STATEMENT_WARNING in the codebase

Please ensure that the new constant PREPARED_STATEMENT_WARNING is correctly utilized wherever necessary in the application, and that any components or views that display this message handle it appropriately.

Run the following script to check where PREPARED_STATEMENT_WARNING is used:

This will help verify that the constant is being used as intended and highlight any places where it might be missing.

Verification successful

Class, let's take a closer look at how our new constant is being used in the QueryResponseTab component. We'll use a special tool to peek into the file and see the surrounding code. Here's what we're going to do:

Now, let's run this script and see what we can learn from it!


Alright, class! We've done our homework and examined how our new PREPARED_STATEMENT_WARNING constant is being used. I'm pleased to report that everything looks ship-shape! Let's review our findings:

PREPARED_STATEMENT_WARNING is correctly implemented and used

Great job, developers! The new constant is being used exactly as intended in the QueryResponseTab component. Here's what we observed:

  • The constant is properly imported and utilized.
  • Both the MESSAGE and LINK properties are being accessed correctly.
  • The warning is displayed in a Callout component, which is perfect for this type of alert.
  • There's a condition in place to show the warning only when necessary.

Keep up the good work! This implementation shows attention to detail and follows best practices. No further changes are needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for usages of PREPARED_STATEMENT_WARNING in the codebase

# Test: Find all occurrences of PREPARED_STATEMENT_WARNING
# Expect: Usages in the relevant components or views
rg --type ts --no-heading "PREPARED_STATEMENT_WARNING"

Length of output: 477


Script:

#!/bin/bash
# Description: View the context of PREPARED_STATEMENT_WARNING usage in QueryResponseTab.tsx

# Test: Show the lines where PREPARED_STATEMENT_WARNING is used, with 5 lines of context before and after
# Expect: To see how the constant is being implemented in the component
rg --type ts -C 5 "PREPARED_STATEMENT_WARNING" app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx

Length of output: 1075

Comment on lines 205 to 210
const { pluginSpecifiedTemplates } =
currentActionConfig.actionConfiguration;

if (error && pluginSpecifiedTemplates[0].value === true) {
showPreparedStatementWarning = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure pluginSpecifiedTemplates is defined before accessing

To prevent potential runtime errors, it's important to check if pluginSpecifiedTemplates is defined and has elements before accessing pluginSpecifiedTemplates[0].value. This validation will make your code more robust and error-resistant.

Consider applying this change:

        const { pluginSpecifiedTemplates } =
          currentActionConfig.actionConfiguration;

-        if (error && pluginSpecifiedTemplates[0].value === true) {
+        if (
+          error &&
+          pluginSpecifiedTemplates &&
+          pluginSpecifiedTemplates.length > 0 &&
+          pluginSpecifiedTemplates[0].value === true
+        ) {
          showPreparedStatementWarning = true;
        }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { pluginSpecifiedTemplates } =
currentActionConfig.actionConfiguration;
if (error && pluginSpecifiedTemplates[0].value === true) {
showPreparedStatementWarning = true;
}
const { pluginSpecifiedTemplates } =
currentActionConfig.actionConfiguration;
if (
error &&
pluginSpecifiedTemplates &&
pluginSpecifiedTemplates.length > 0 &&
pluginSpecifiedTemplates[0].value === true
) {
showPreparedStatementWarning = true;
}

Comment on lines +2506 to +2510
export const PREPARED_STATEMENT_WARNING = {
MESSAGE: () =>
"Prepared Statements are currently enabled, which may be causing the query error. Turn them off and try running the query again",
LINK: () => "Open settings",
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Well done on introducing the PREPARED_STATEMENT_WARNING constant

You've defined a new constant to display a warning message when prepared statements are enabled and an error occurs. This aligns perfectly with the PR objectives and enhances user awareness during error scenarios.

However, let's consider a small improvement to keep our code consistent and maintainable.

To maintain consistency with other message constants in this file, it would be better to define MESSAGE and LINK as constant strings rather than arrow functions, unless dynamic computation is required. Many existing constants use direct string assignments.

Here's how you might refactor the code:

-export const PREPARED_STATEMENT_WARNING = {
-  MESSAGE: () =>
-      "Prepared Statements are currently enabled, which may be causing the query error. Turn them off and try running the query again",
-  LINK: () => "Open settings",
+export const PREPARED_STATEMENT_WARNING_MESSAGE =
+  "Prepared Statements are currently enabled, which may be causing the query error. Turn them off and try running the query again.";
+export const PREPARED_STATEMENT_WARNING_LINK = "Open settings";

This change makes the constants consistent with the rest of the file and simplifies their usage.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const PREPARED_STATEMENT_WARNING = {
MESSAGE: () =>
"Prepared Statements are currently enabled, which may be causing the query error. Turn them off and try running the query again",
LINK: () => "Open settings",
};
export const PREPARED_STATEMENT_WARNING_MESSAGE =
"Prepared Statements are currently enabled, which may be causing the query error. Turn them off and try running the query again.";
export const PREPARED_STATEMENT_WARNING_LINK = "Open settings";

Copy link

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

1 similar comment
Copy link

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

@albinAppsmith
Copy link
Collaborator Author

/build-deploy-preview skip-test=true

Copy link

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

Copy link

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

@albinAppsmith
Copy link
Collaborator Author

EE DP: https://ee-5186.dp.appsmith.com/

@albinAppsmith albinAppsmith merged commit 12986df into release Sep 23, 2024
42 checks passed
@albinAppsmith albinAppsmith deleted the action-redesign/prepared-statement-warning branch September 23, 2024 13:57
albinAppsmith added a commit that referenced this pull request Sep 24, 2024
…36493)

## Description

Query instance was breaking because of missing prepared statement obj in
the action configuration.

PR caused this issue: #36407

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.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/11007670447>
> Commit: 420801e
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11007670447&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Tue, 24 Sep 2024 07:04:23 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

## Summary by CodeRabbit

- **New Features**
- Enhanced logic for displaying warnings related to prepared statements,
improving user experience by streamlining checks.

- **Bug Fixes**
- Resolved issues with warning display for prepared statements, ensuring
accurate notifications based on user actions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Sep 26, 2024
… is on (appsmithorg#36407)

## Description

Added warning message in response pane to show that use prepared
statement is turned on. This will be showing up only if there is an
error.

Fixes appsmithorg#36326 

## Automation

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

### 🔍 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/10987691166>
> Commit: debc9f3
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10987691166&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity, @tag.Datasource`
> Spec:
> <hr>Mon, 23 Sep 2024 05:25:23 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

- **New Features**
- Introduced a warning message for users regarding prepared statements
that may cause query errors.
- Added a mechanism to navigate users to the settings page for resolving
issues related to prepared statements.
- Enhanced the Query Response Tab with contextual warnings and improved
user guidance.

- **Bug Fixes**
- Improved error handling related to prepared statements in the query
response.

- **Tests**
- Added comprehensive unit tests for the Query Response Tab to ensure
correct behavior of the prepared statement warning under various
conditions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Sep 26, 2024
…ppsmithorg#36493)

## Description

Query instance was breaking because of missing prepared statement obj in
the action configuration.

PR caused this issue: appsmithorg#36407

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.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/11007670447>
> Commit: 420801e
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11007670447&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Tue, 24 Sep 2024 07:04:23 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

## Summary by CodeRabbit

- **New Features**
- Enhanced logic for displaying warnings related to prepared statements,
improving user experience by streamlining checks.

- **Bug Fixes**
- Resolved issues with warning display for prepared statements, ensuring
accurate notifications based on user actions.
<!-- 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
Enhancement New feature or request IDE Navigation Issues/feature requests related to IDE navigation, and context switching IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product ok-to-test Required label for CI Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Add "use prepared statement" warning message in response pane
2 participants