-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Changes from 2 commits
46410cc
5ed0dfa
cc19110
1ad67e1
9d451ab
debc9f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||||||||||||||||||||||||||||||||
import React, { useState } from "react"; | ||||||||||||||||||||||||||||||||||||
import React, { useCallback, useState } from "react"; | ||||||||||||||||||||||||||||||||||||
import { useDispatch, useSelector } from "react-redux"; | ||||||||||||||||||||||||||||||||||||
import ReactJson from "react-json-view"; | ||||||||||||||||||||||||||||||||||||
import { | ||||||||||||||||||||||||||||||||||||
|
@@ -13,7 +13,12 @@ import LogAdditionalInfo from "components/editorComponents/Debugger/ErrorLogs/co | |||||||||||||||||||||||||||||||||||
import LogHelper from "components/editorComponents/Debugger/ErrorLogs/components/LogHelper"; | ||||||||||||||||||||||||||||||||||||
import LOG_TYPE from "entities/AppsmithConsole/logtype"; | ||||||||||||||||||||||||||||||||||||
import { JsonWrapper } from "components/editorComponents/Debugger/ErrorLogs/components/LogCollapseData"; | ||||||||||||||||||||||||||||||||||||
import { Callout, Flex, SegmentedControl } from "@appsmith/ads"; | ||||||||||||||||||||||||||||||||||||
import { | ||||||||||||||||||||||||||||||||||||
Callout, | ||||||||||||||||||||||||||||||||||||
Flex, | ||||||||||||||||||||||||||||||||||||
SegmentedControl, | ||||||||||||||||||||||||||||||||||||
type CalloutLinkProps, | ||||||||||||||||||||||||||||||||||||
} from "@appsmith/ads"; | ||||||||||||||||||||||||||||||||||||
import styled from "styled-components"; | ||||||||||||||||||||||||||||||||||||
import { DEBUGGER_TAB_KEYS } from "components/editorComponents/Debugger/helpers"; | ||||||||||||||||||||||||||||||||||||
import AnalyticsUtil from "ee/utils/AnalyticsUtil"; | ||||||||||||||||||||||||||||||||||||
|
@@ -32,6 +37,12 @@ import ActionExecutionInProgressView from "components/editorComponents/ActionExe | |||||||||||||||||||||||||||||||||||
import { EditorTheme } from "components/editorComponents/CodeEditor/EditorConfig"; | ||||||||||||||||||||||||||||||||||||
import BindDataButton from "./BindDataButton"; | ||||||||||||||||||||||||||||||||||||
import { getQueryPaneDebuggerState } from "selectors/queryPaneSelectors"; | ||||||||||||||||||||||||||||||||||||
import { setQueryPaneConfigSelectedTabIndex } from "actions/queryPaneActions"; | ||||||||||||||||||||||||||||||||||||
import { EDITOR_TABS } from "constants/QueryEditorConstants"; | ||||||||||||||||||||||||||||||||||||
import { | ||||||||||||||||||||||||||||||||||||
createMessage, | ||||||||||||||||||||||||||||||||||||
PREPARED_STATEMENT_WARNING, | ||||||||||||||||||||||||||||||||||||
} from "ee/constants/messages"; | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
const HelpSection = styled.div``; | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
@@ -151,6 +162,7 @@ const QueryResponseTab = (props: Props) => { | |||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
let error = runErrorMessage; | ||||||||||||||||||||||||||||||||||||
let hintMessages: Array<string> = []; | ||||||||||||||||||||||||||||||||||||
let showPreparedStatementWarning = false; | ||||||||||||||||||||||||||||||||||||
// TODO: Fix this the next time the file is edited | ||||||||||||||||||||||||||||||||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||||||||||||||||||||||||||||||||||||
let output: Record<string, any>[] | null = null; | ||||||||||||||||||||||||||||||||||||
|
@@ -189,8 +201,26 @@ const QueryResponseTab = (props: Props) => { | |||||||||||||||||||||||||||||||||||
error = ""; | ||||||||||||||||||||||||||||||||||||
hintMessages = actionResponse.messages; | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
const { pluginSpecifiedTemplates } = | ||||||||||||||||||||||||||||||||||||
currentActionConfig.actionConfiguration; | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
if (error && pluginSpecifiedTemplates[0].value === true) { | ||||||||||||||||||||||||||||||||||||
showPreparedStatementWarning = true; | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure To prevent potential runtime errors, it's important to check if 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
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
const navigateToSettings = useCallback(() => { | ||||||||||||||||||||||||||||||||||||
dispatch(setQueryPaneConfigSelectedTabIndex(EDITOR_TABS.SETTINGS)); | ||||||||||||||||||||||||||||||||||||
}, []); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
const preparedStatementCalloutLinks: CalloutLinkProps[] = [ | ||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
onClick: navigateToSettings, | ||||||||||||||||||||||||||||||||||||
children: createMessage(PREPARED_STATEMENT_WARNING.LINK), | ||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||
]; | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
if (isRunning) { | ||||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||||
<ActionExecutionInProgressView | ||||||||||||||||||||||||||||||||||||
|
@@ -202,6 +232,11 @@ const QueryResponseTab = (props: Props) => { | |||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||||
<ResponseContentWrapper isError={!!error}> | ||||||||||||||||||||||||||||||||||||
{showPreparedStatementWarning && ( | ||||||||||||||||||||||||||||||||||||
<Callout kind="warning" links={preparedStatementCalloutLinks}> | ||||||||||||||||||||||||||||||||||||
{createMessage(PREPARED_STATEMENT_WARNING.MESSAGE)} | ||||||||||||||||||||||||||||||||||||
</Callout> | ||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||
{error && ( | ||||||||||||||||||||||||||||||||||||
<ResponseTabErrorContainer> | ||||||||||||||||||||||||||||||||||||
<ResponseTabErrorContent> | ||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
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
constantYou'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
andLINK
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:
This change makes the constants consistent with the rest of the file and simplifies their usage.
Committable suggestion