diff --git a/app/client/src/ce/PluginActionEditor/components/PluginActionResponse/hooks/usePluginActionResponseTabs.tsx b/app/client/src/ce/PluginActionEditor/components/PluginActionResponse/hooks/usePluginActionResponseTabs.tsx index 4b8f04d18a50..5f6c1748462f 100644 --- a/app/client/src/ce/PluginActionEditor/components/PluginActionResponse/hooks/usePluginActionResponseTabs.tsx +++ b/app/client/src/ce/PluginActionEditor/components/PluginActionResponse/hooks/usePluginActionResponseTabs.tsx @@ -149,6 +149,7 @@ function usePluginActionResponseTabs() { actionName={action.name} actionSource={actionSource} currentActionConfig={action} + isRunDisabled={blockExecution} isRunning={isRunning} onRunClick={onRunClick} runErrorMessage={""} // TODO diff --git a/app/client/src/components/editorComponents/ApiResponseView.test.tsx b/app/client/src/components/editorComponents/ApiResponseView.test.tsx index b440e9a409c2..189f6beaa306 100644 --- a/app/client/src/components/editorComponents/ApiResponseView.test.tsx +++ b/app/client/src/components/editorComponents/ApiResponseView.test.tsx @@ -81,7 +81,7 @@ describe("ApiResponseView", () => { diff --git a/app/client/src/components/editorComponents/ApiResponseView.tsx b/app/client/src/components/editorComponents/ApiResponseView.tsx index e459b509c033..8bf6a400adb4 100644 --- a/app/client/src/components/editorComponents/ApiResponseView.tsx +++ b/app/client/src/components/editorComponents/ApiResponseView.tsx @@ -33,7 +33,7 @@ import { ApiResponseHeaders } from "PluginActionEditor/components/PluginActionRe interface Props { currentActionConfig: Action; theme?: EditorTheme; - disabled: boolean; + isRunDisabled: boolean; onRunClick: () => void; actionResponse?: ActionResponse; isRunning: boolean; @@ -43,7 +43,7 @@ function ApiResponseView(props: Props) { const { actionResponse = EMPTY_RESPONSE, currentActionConfig, - disabled, + isRunDisabled = false, isRunning, theme = EditorTheme.LIGHT, } = props; @@ -99,7 +99,7 @@ function ApiResponseView(props: Props) { + getPluginNameFromId(state, currentActionConfig?.pluginId || ""), + ); + + let actionBody = ""; + + if (!!currentActionConfig?.actionConfiguration) { + if ("formData" in currentActionConfig?.actionConfiguration) { + // if the action has a formData (the action is postUQI e.g. Oracle) + actionBody = + currentActionConfig.actionConfiguration.formData?.body?.data || ""; + } else { + // if the action is pre UQI, the path is different e.g. mySQL + actionBody = currentActionConfig.actionConfiguration?.body || ""; + } + } + + // if (the body is empty and the action is an sql datasource) or the user does not have permission, block action execution. + const blockExecution = + (!actionBody && SQL_DATASOURCES.includes(currentActionPluginName)) || + !isExecutePermitted; + // when switching between different redux forms, make sure this redux form has been initialized before rendering anything. // the initialized prop below comes from redux-form. if (!props.initialized) { @@ -252,6 +285,7 @@ export function EditorJSONtoForm(props: Props) { void; + isRunDisabled?: boolean; isRunning: boolean; onRunClick: () => void; } @@ -59,6 +52,7 @@ const QueryEditorHeader = (props: Props) => { const { dataSources, formName, + isRunDisabled = false, isRunning, onCreateDatasourceClick, onRunClick, @@ -78,11 +72,6 @@ const QueryEditorHeader = (props: Props) => { currentActionConfig?.userPermissions, ); - const isExecutePermitted = getHasExecuteActionPermission( - isFeatureEnabled, - currentActionConfig?.userPermissions, - ); - const currentPlugin = useSelector((state: AppState) => getPlugin(state, currentActionConfig?.pluginId || ""), ); @@ -95,29 +84,6 @@ const QueryEditorHeader = (props: Props) => { const icon = ActionUrlIcon(iconUrl); - // get the current action's plugin name - const currentActionPluginName = useSelector((state: AppState) => - getPluginNameFromId(state, currentActionConfig?.pluginId || ""), - ); - - let actionBody = ""; - - if (!!currentActionConfig?.actionConfiguration) { - if ("formData" in currentActionConfig?.actionConfiguration) { - // if the action has a formData (the action is postUQI e.g. Oracle) - actionBody = - currentActionConfig.actionConfiguration.formData?.body?.data || ""; - } else { - // if the action is pre UQI, the path is different e.g. mySQL - actionBody = currentActionConfig.actionConfiguration?.body || ""; - } - } - - // if (the body is empty and the action is an sql datasource) or the user does not have permission, block action execution. - const blockExecution = - (!actionBody && SQL_DATASOURCES.includes(currentActionPluginName)) || - !isExecutePermitted; - return ( @@ -141,7 +107,7 @@ const QueryEditorHeader = (props: Props) => {