Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ function usePluginActionResponseTabs() {
actionName={action.name}
actionSource={actionSource}
currentActionConfig={action}
isRunDisabled={blockExecution}
isRunning={isRunning}
onRunClick={onRunClick}
runErrorMessage={""} // TODO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe("ApiResponseView", () => {
<Router>
<ApiResponseView
currentActionConfig={Api1}
disabled={false}
isRunDisabled={false}
isRunning={false}
onRunClick={noop}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,7 +43,7 @@ function ApiResponseView(props: Props) {
const {
actionResponse = EMPTY_RESPONSE,
currentActionConfig,
disabled,
isRunDisabled = false,
isRunning,
theme = EditorTheme.LIGHT,
} = props;
Expand Down Expand Up @@ -99,7 +99,7 @@ function ApiResponseView(props: Props) {
<ApiResponse
action={currentActionConfig}
actionResponse={actionResponse}
isRunDisabled={disabled}
isRunDisabled={isRunDisabled}
isRunning={isRunning}
onRunClick={onRunClick}
responseTabHeight={responseTabHeight}
Expand All @@ -113,7 +113,7 @@ function ApiResponseView(props: Props) {
panelComponent: (
<ApiResponseHeaders
actionResponse={actionResponse}
isRunDisabled={disabled}
isRunDisabled={isRunDisabled}
isRunning={isRunning}
onDebugClick={onDebugClick}
onRunClick={onRunClick}
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/pages/Editor/APIEditor/CommonEditorForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ function CommonEditorForm(props: CommonFormPropsWithExtraParams) {
<ApiResponseView
actionResponse={actionResponse}
currentActionConfig={currentActionConfig}
disabled={!isExecutePermitted}
isRunDisabled={blockExecution}
isRunning={isRunning}
onRunClick={onRunClick}
theme={theme}
Expand Down
37 changes: 36 additions & 1 deletion app/client/src/pages/Editor/QueryEditor/EditorJSONtoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import ActionRightPane from "components/editorComponents/ActionRightPane";
import type { ActionResponse } from "api/ActionAPI";
import type { Plugin } from "api/PluginApi";
import type { UIComponentTypes } from "api/PluginApi";
import { EDITOR_TABS } from "constants/QueryEditorConstants";
import { EDITOR_TABS, SQL_DATASOURCES } from "constants/QueryEditorConstants";
import type { FormEvalOutput } from "reducers/evaluationReducers/formEvaluationReducer";
import {
getPluginActionConfigSelectedTab,
Expand All @@ -37,6 +37,10 @@ import { doesPluginRequireDatasource } from "ee/entities/Engine/actionHelpers";
import FormRender from "./FormRender";
import QueryEditorHeader from "./QueryEditorHeader";
import RunHistory from "ee/components/RunHistory";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import { getHasExecuteActionPermission } from "ee/utils/BusinessFeatures/permissionPageHelpers";
import { getPluginNameFromId } from "ee/selectors/entitiesSelector";

const QueryFormContainer = styled.form`
flex: 1;
Expand Down Expand Up @@ -241,6 +245,35 @@ export function EditorJSONtoForm(props: Props) {
[dispatch],
);

const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
const isExecutePermitted = getHasExecuteActionPermission(
isFeatureEnabled,
currentActionConfig?.userPermissions,
);

// 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;

// 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) {
Expand All @@ -252,6 +285,7 @@ export function EditorJSONtoForm(props: Props) {
<QueryEditorHeader
dataSources={dataSources}
formName={formName}
isRunDisabled={blockExecution}
isRunning={isRunning}
onCreateDatasourceClick={onCreateDatasourceClick}
onRunClick={onRunClick}
Expand Down Expand Up @@ -334,6 +368,7 @@ export function EditorJSONtoForm(props: Props) {
actionResponse={actionResponse}
actionSource={actionSource}
currentActionConfig={currentActionConfig}
isRunDisabled={blockExecution}
isRunning={isRunning}
onRunClick={onRunClick}
runErrorMessage={runErrorMessage}
Expand Down
3 changes: 3 additions & 0 deletions app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const ResultsCount = styled.div`
interface QueryDebuggerTabsProps {
actionSource: SourceEntity;
currentActionConfig?: Action;
isRunDisabled?: boolean;
isRunning: boolean;
actionName: string; // Check what and how to get
runErrorMessage?: string;
Expand All @@ -59,6 +60,7 @@ function QueryDebuggerTabs({
actionResponse,
actionSource,
currentActionConfig,
isRunDisabled = false,
isRunning,
onRunClick,
runErrorMessage,
Expand Down Expand Up @@ -233,6 +235,7 @@ function QueryDebuggerTabs({
actionName={actionName}
actionSource={actionSource}
currentActionConfig={currentActionConfig}
isRunDisabled={isRunDisabled}
isRunning={isRunning}
onRunClick={onRunClick}
runErrorMessage={runErrorMessage}
Expand Down
44 changes: 5 additions & 39 deletions app/client/src/pages/Editor/QueryEditor/QueryEditorHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,14 @@ import { StyledFormRow } from "./EditorJSONtoForm";
import styled from "styled-components";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import {
getHasExecuteActionPermission,
getHasManageActionPermission,
} from "ee/utils/BusinessFeatures/permissionPageHelpers";
import { getHasManageActionPermission } from "ee/utils/BusinessFeatures/permissionPageHelpers";
import { useActiveActionBaseId } from "ee/pages/Editor/Explorer/hooks";
import { useSelector } from "react-redux";
import {
getActionByBaseId,
getPlugin,
getPluginNameFromId,
} from "ee/selectors/entitiesSelector";
import { getActionByBaseId, getPlugin } from "ee/selectors/entitiesSelector";
import { QueryEditorContext } from "./QueryEditorContext";
import type { Plugin } from "api/PluginApi";
import type { Datasource } from "entities/Datasource";
import type { AppState } from "ee/reducers";
import { SQL_DATASOURCES } from "constants/QueryEditorConstants";
import DatasourceSelector from "./DatasourceSelector";
import { getSavingStatusForActionName } from "selectors/actionSelectors";
import { getAssetUrl } from "ee/utils/airgapHelpers";
Expand Down Expand Up @@ -51,6 +43,7 @@ interface Props {
formName: string;
dataSources: Datasource[];
onCreateDatasourceClick: () => void;
isRunDisabled?: boolean;
isRunning: boolean;
onRunClick: () => void;
}
Expand All @@ -59,6 +52,7 @@ const QueryEditorHeader = (props: Props) => {
const {
dataSources,
formName,
isRunDisabled = false,
isRunning,
onCreateDatasourceClick,
onRunClick,
Expand All @@ -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 || ""),
);
Expand All @@ -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 (
<StyledFormRow>
<NameWrapper>
Expand All @@ -141,7 +107,7 @@ const QueryEditorHeader = (props: Props) => {
<Button
className="t--run-query"
data-guided-tour-iid="run-query"
isDisabled={blockExecution}
isDisabled={isRunDisabled}
isLoading={isRunning}
onClick={onRunClick}
size="md"
Expand Down
14 changes: 3 additions & 11 deletions app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ import type { SourceEntity } from "entities/AppsmithConsole";
import type { Action } from "entities/Action";
import { getActionData } from "ee/selectors/entitiesSelector";
import { actionResponseDisplayDataFormats } from "../utils";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import { getHasExecuteActionPermission } from "ee/utils/BusinessFeatures/permissionPageHelpers";
import { getErrorAsString } from "sagas/ActionExecution/errorUtils";
import { isString } from "lodash";
import ActionExecutionInProgressView from "components/editorComponents/ActionExecutionInProgressView";
Expand Down Expand Up @@ -72,6 +69,7 @@ const ResponseContentWrapper = styled.div<{ isError: boolean }>`

interface Props {
actionSource: SourceEntity;
isRunDisabled?: boolean;
isRunning: boolean;
onRunClick: () => void;
currentActionConfig: Action;
Expand All @@ -84,19 +82,13 @@ const QueryResponseTab = (props: Props) => {
actionName,
actionSource,
currentActionConfig,
isRunDisabled = false,
isRunning,
onRunClick,
runErrorMessage,
} = props;
const dispatch = useDispatch();

const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);

const isExecutePermitted = getHasExecuteActionPermission(
isFeatureEnabled,
currentActionConfig?.userPermissions,
);

const actionResponse = useSelector((state) =>
getActionData(state, currentActionConfig.id),
);
Expand Down Expand Up @@ -345,7 +337,7 @@ const QueryResponseTab = (props: Props) => {
)}
{!output && !error && (
<NoResponse
isRunDisabled={!isExecutePermitted}
isRunDisabled={isRunDisabled}
isRunning={isRunning}
onRunClick={responseTabOnRunClick}
/>
Expand Down