diff --git a/app/client/src/actions/evaluationActions.ts b/app/client/src/actions/evaluationActions.ts index 65eaef3fd9..8bae2e5a45 100644 --- a/app/client/src/actions/evaluationActions.ts +++ b/app/client/src/actions/evaluationActions.ts @@ -8,6 +8,7 @@ import type { DataTree } from "entities/DataTree/dataTreeFactory"; import type { DependencyMap } from "utils/DynamicBindingUtils"; import type { Diff } from "deep-diff"; import type { QueryActionConfig } from "entities/Action"; +import type { DatasourceConfiguration } from "entities/Datasource"; export const FIRST_EVAL_REDUX_ACTIONS = [ // Pages @@ -183,6 +184,7 @@ export const startFormEvaluations = ( pluginId: string, actionDiffPath?: string, hasRouteChanged?: boolean, + datasourceConfiguration?: DatasourceConfiguration, ) => { return { type: ReduxActionTypes.RUN_FORM_EVALUATION, @@ -193,6 +195,7 @@ export const startFormEvaluations = ( pluginId, actionDiffPath, hasRouteChanged, + datasourceConfiguration, }, }; }; diff --git a/app/client/src/sagas/FormEvaluationSaga.ts b/app/client/src/sagas/FormEvaluationSaga.ts index fbeb672098..f287edf354 100644 --- a/app/client/src/sagas/FormEvaluationSaga.ts +++ b/app/client/src/sagas/FormEvaluationSaga.ts @@ -28,6 +28,7 @@ import { extractQueueOfValuesToBeFetched, } from "./helper"; import type { Action as ReduxActionType } from "redux"; +import type { DatasourceConfiguration } from "entities/Datasource"; export type FormEvalActionPayload = { formId: string; @@ -38,6 +39,7 @@ export type FormEvalActionPayload = { settingConfig?: FormConfigType[]; actionDiffPath?: string; hasRouteChanged?: boolean; + datasourceConfiguration?: DatasourceConfiguration; }; // This value holds an array of values that needs to be dynamically fetched diff --git a/app/client/src/sagas/QueryPaneSagas.ts b/app/client/src/sagas/QueryPaneSagas.ts index f6041a2c12..9fa48daeb0 100644 --- a/app/client/src/sagas/QueryPaneSagas.ts +++ b/app/client/src/sagas/QueryPaneSagas.ts @@ -253,6 +253,15 @@ function* formValueChangeSaga( return; } + // get datasource configuration based on datasource id + // pass it to run form evaluations method + // This is required for google sheets, as we need to modify query + // state based on datasource config + const datasource: Datasource | undefined = yield select( + getDatasource, + values.datasource.id, + ); + // Editing form fields triggers evaluations. // We pass the action to run form evaluations when the dataTree evaluation is complete const postEvalActions = @@ -265,6 +274,7 @@ function* formValueChangeSaga( values.pluginId, field, hasRouteChanged, + datasource?.datasourceConfiguration, ), ] : []; diff --git a/app/client/src/workers/Evaluation/formEval.ts b/app/client/src/workers/Evaluation/formEval.ts index 49a3d927f4..7e9a2d3313 100644 --- a/app/client/src/workers/Evaluation/formEval.ts +++ b/app/client/src/workers/Evaluation/formEval.ts @@ -14,6 +14,7 @@ import { isArray, isEmpty, isString, merge, uniq } from "lodash"; import { extractEvalConfigFromFormConfig } from "components/formControls/utils"; import { isDynamicValue } from "utils/DynamicBindingUtils"; import { isTrueObject } from "@appsmith/workers/Evaluation/evaluationUtils"; +import type { DatasourceConfiguration } from "entities/Datasource"; export enum ConditionType { HIDE = "hide", // When set, the component will be shown until condition is true @@ -290,6 +291,8 @@ function evaluateDynamicValuesConfig( function evaluateFormConfigElements( actionConfiguration: ActionConfig, config: FormConfigEvalObject, + /* eslint-disable @typescript-eslint/no-unused-vars */ + datasourceConfiguration?: DatasourceConfiguration, ) { const paths = Object.keys(config); if (paths.length > 0) { @@ -310,6 +313,7 @@ function evaluate( currentEvalState: FormEvalOutput, actionDiffPath?: string, hasRouteChanged?: boolean, + datasourceConfiguration?: DatasourceConfiguration, ) { Object.keys(currentEvalState).forEach((key: string) => { try { @@ -403,6 +407,7 @@ function evaluate( currentEvalState[key] .evaluateFormConfig as EvaluatedFormConfig ).evaluateFormConfigObject, + datasourceConfiguration, ); } }); @@ -420,6 +425,7 @@ function getFormEvaluation( currentEvalState: FormEvaluationState, actionDiffPath?: string, hasRouteChanged?: boolean, + datasourceConfiguration?: DatasourceConfiguration, ): FormEvaluationState { // Only change the form evaluation state if the form ID is same or the evaluation state is present if (!!currentEvalState && currentEvalState.hasOwnProperty(formId)) { @@ -472,6 +478,7 @@ function getFormEvaluation( currentEvalState[formId], actionDiffPath, hasRouteChanged, + datasourceConfiguration, ); } else { conditionToBeEvaluated = { @@ -483,6 +490,7 @@ function getFormEvaluation( conditionToBeEvaluated, actionDiffPath, hasRouteChanged, + datasourceConfiguration, ); } @@ -534,8 +542,13 @@ export function setFormEvaluationSaga( // This is the initial evaluation state, evaluations can now be run on top of this return { [payload.formId]: finalEvalObj }; } else { - const { actionConfiguration, actionDiffPath, formId, hasRouteChanged } = - payload; + const { + actionConfiguration, + actionDiffPath, + datasourceConfiguration, + formId, + hasRouteChanged, + } = payload; // In case the formData is not ready or the form is not of type UQI, return empty state if (!actionConfiguration || !actionConfiguration.formData) { return currentEvalState; @@ -546,6 +559,7 @@ export function setFormEvaluationSaga( currentEvalState, actionDiffPath, hasRouteChanged, + datasourceConfiguration, ); } } diff --git a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/resources/editor/root.json b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/resources/editor/root.json index 341f88edf7..04c07af9ee 100644 --- a/app/server/appsmith-plugins/googleSheetsPlugin/src/main/resources/editor/root.json +++ b/app/server/appsmith-plugins/googleSheetsPlugin/src/main/resources/editor/root.json @@ -60,7 +60,7 @@ "value": "ROWS" }, { - "disabled": "{{ ['FETCH_MANY', 'FETCH_DETAILS', 'INSERT_ONE', 'DELETE_ONE'].includes(actionConfiguration.formData.command.data) === false }}", + "disabled": "{{ ['FETCH_MANY', 'FETCH_DETAILS', 'INSERT_ONE', 'DELETE_ONE'].includes(actionConfiguration.formData.command.data) === false || (['INSERT_ONE', 'DELETE_ONE'].includes(actionConfiguration.formData.command.data) === true && ['https://www.googleapis.com/auth/drive.file'].includes(datasourceConfiguration.authentication.scopeString) === true)}}", "label": "Spreadsheet", "value": "SPREADSHEET" },