PromucFlow_constructor/app/client/src/sagas/OneClickBindingSaga.ts

335 lines
10 KiB
TypeScript
Raw Normal View History

import type { ReduxAction } from "@appsmith/constants/ReduxActionConstants";
feat: Table one click binding for MongoDB and Postgres (#23629) > Pull Request Template > > Use this template to quickly create a well written pull request. Delete all quotes before creating the pull request. > ## Description > Add a TL;DR when description is extra long (helps content team) > > Please include a summary of the changes and which issue has been fixed. Please also include relevant motivation > and context. List any dependencies that are required for this change > > Links to Notion, Figma or any other documents that might be relevant to the PR > > #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan > One Click Binding - https://github.com/appsmithorg/TestSmith/issues/2390 > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: Vemparala Surya Vamsi <vamsi@appsmith.com>
2023-06-01 17:26:05 +00:00
import { ReduxActionErrorTypes } from "@appsmith/constants/ReduxActionConstants";
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
import type { Plugin } from "api/PluginApi";
import type { Action, QueryActionConfig } from "entities/Action";
import type { Datasource } from "entities/Datasource";
import { invert, merge, omit, partition } from "lodash";
import { all, call, put, select, takeLatest, take } from "redux-saga/effects";
import {
getCurrentApplicationId,
getCurrentPageId,
} from "selectors/editorSelectors";
import {
getActions,
getCurrentPageNameByActionId,
getDatasource,
getPlugin,
} from "selectors/entitiesSelector";
import { createNewQueryName } from "utils/AppsmithUtils";
import WidgetQueryGeneratorRegistry from "utils/WidgetQueryGeneratorRegistry";
import {
createDefaultActionPayload,
getPulginActionDefaultValues,
} from "./ActionSagas";
import "../WidgetQueryGenerators";
import type { ActionDataState } from "reducers/entityReducers/actionsReducer";
import "WidgetQueryGenerators";
import { getWidgetByID } from "./selectors";
import type { WidgetQueryGenerationFormConfig } from "WidgetQueryGenerators/types";
import { QUERY_TYPE } from "WidgetQueryGenerators/types";
import WidgetFactory from "utils/WidgetFactory";
import type { WidgetProps } from "widgets/BaseWidget";
import type { ApiResponse } from "api/ApiResponses";
import type { ActionCreateUpdateResponse } from "api/ActionAPI";
import ActionAPI from "api/ActionAPI";
import { validateResponse } from "./ErrorSagas";
import AnalyticsUtil from "utils/AnalyticsUtil";
import AppsmithConsole from "utils/AppsmithConsole";
import { ENTITY_TYPE } from "entities/AppsmithConsole";
import { fetchActions, runAction } from "actions/pluginActionActions";
import { Toaster, Variant } from "design-system-old";
export function* createActionsForOneClickBindingSaga(
payload: Partial<Action> & { eventData: unknown; pluginId: string },
) {
try {
const response: ApiResponse<ActionCreateUpdateResponse> | undefined =
yield ActionAPI.createAction(payload);
if (!response) {
return false;
}
const isValidResponse: boolean = yield validateResponse(response);
if (isValidResponse) {
const pageName: string = yield select(
getCurrentPageNameByActionId,
response.data.id,
);
AnalyticsUtil.logEvent("CREATE_ACTION", {
id: response.data.id,
// @ts-expect-error: name does not exists on type ActionCreateUpdateResponse
actionName: response.data.name,
pageName: pageName,
...payload.eventData,
});
AppsmithConsole.info({
text: `Action created from one click binding`,
source: {
type: ENTITY_TYPE.ACTION,
id: response.data.id,
// @ts-expect-error: name does not exists on type ActionCreateUpdateResponse
name: response.data.name,
},
});
return response.data;
}
} catch (e) {
return false;
}
}
function* BindWidgetToDatasource(
action: ReduxAction<WidgetQueryGenerationFormConfig>,
) {
const { datasourceId, widgetId } = action.payload;
const pageId: string = yield select(getCurrentPageId);
const actions: ActionDataState = yield select(getActions);
const datasource: Datasource = yield select(getDatasource, datasourceId);
const plugin: Plugin = yield select(getPlugin, datasource?.pluginId);
const widget: WidgetProps = yield select(getWidgetByID(widgetId));
const applicationId: string = yield select(getCurrentApplicationId);
const newActions: string[] = [];
try {
const defaultValues: object | undefined = yield call(
getPulginActionDefaultValues,
datasource?.pluginId,
);
const { getQueryGenerationConfig } = WidgetFactory.getWidgetMethods(
widget.type,
);
const widgetQueryGenerationConfig = getQueryGenerationConfig(widget);
const widgetQueryGenerator = WidgetQueryGeneratorRegistry.get(
plugin.packageName,
);
const actionConfigurationList = widgetQueryGenerator.build(
widgetQueryGenerationConfig,
action.payload,
defaultValues,
);
const commonActionPayload: Partial<Action> = yield call(
createDefaultActionPayload,
pageId,
datasourceId,
"ONE_CLICK_BINDING",
);
const queryNameMap: Record<string, string> = {};
const actionRequestPayloadList: Partial<Action> &
{ eventData: unknown; pluginId: string; type: QUERY_TYPE }[] =
actionConfigurationList.map(
(action: {
payload: QueryActionConfig;
dynamicBindingPathList: unknown;
name: string;
type: QUERY_TYPE;
}) => {
const { dynamicBindingPathList, name, payload, type } = action;
queryNameMap[type] = createNewQueryName(actions, pageId || "", name);
return merge({}, commonActionPayload, {
actionConfiguration: payload,
name: queryNameMap[type],
dynamicBindingPathList,
type,
});
},
);
/*
* Select query is created and bound first so table widget can
* create columns
*/
const groupedPayloadList = partition(actionRequestPayloadList, (d) =>
[QUERY_TYPE.SELECT, QUERY_TYPE.TOTAL_RECORD].includes(d.type),
);
for (const payloadList of groupedPayloadList) {
const createdActions: Action[] = yield all(
payloadList.map((payload) =>
call(createActionsForOneClickBindingSaga, omit(payload, "type")),
),
);
if (createdActions.some((action) => !action)) {
throw new Error("Unable to create Actions");
}
yield put(fetchActions({ applicationId }, []));
const fetchAction: ReduxAction<unknown> = yield take([
ReduxActionTypes.FETCH_ACTIONS_SUCCESS,
ReduxActionErrorTypes.FETCH_ACTIONS_ERROR,
]);
if (fetchAction.type === ReduxActionErrorTypes.FETCH_ACTIONS_ERROR) {
throw new Error("Unable to fetch newly created actions");
}
const actionsToRun = createdActions.filter(
(action) =>
action.name === queryNameMap[QUERY_TYPE.SELECT] ||
action.name === queryNameMap[QUERY_TYPE.TOTAL_RECORD],
);
//TODO(Balaji): Need to make changes to plugin saga to execute the actions in parallel
fix: one click binding postgress sorting issue when primary key is no… (#24090) …t available ## Description When the primary key is not present in a postgres table, we should update generated query to not have its reference. #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/24079 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [x] Jest > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [x] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-06-08 11:28:48 +00:00
for (const actionToRun of actionsToRun) {
yield put(runAction(actionToRun.id, undefined, true));
feat: Table one click binding for MongoDB and Postgres (#23629) > Pull Request Template > > Use this template to quickly create a well written pull request. Delete all quotes before creating the pull request. > ## Description > Add a TL;DR when description is extra long (helps content team) > > Please include a summary of the changes and which issue has been fixed. Please also include relevant motivation > and context. List any dependencies that are required for this change > > Links to Notion, Figma or any other documents that might be relevant to the PR > > #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan > One Click Binding - https://github.com/appsmithorg/TestSmith/issues/2390 > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: Vemparala Surya Vamsi <vamsi@appsmith.com>
2023-06-01 17:26:05 +00:00
const runResponse: ReduxAction<unknown> = yield take([
fix: one click binding postgress sorting issue when primary key is no… (#24090) …t available ## Description When the primary key is not present in a postgres table, we should update generated query to not have its reference. #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/24079 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [x] Jest > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [x] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-06-08 11:28:48 +00:00
ReduxActionTypes.RUN_ACTION_SUCCESS,
feat: Table one click binding for MongoDB and Postgres (#23629) > Pull Request Template > > Use this template to quickly create a well written pull request. Delete all quotes before creating the pull request. > ## Description > Add a TL;DR when description is extra long (helps content team) > > Please include a summary of the changes and which issue has been fixed. Please also include relevant motivation > and context. List any dependencies that are required for this change > > Links to Notion, Figma or any other documents that might be relevant to the PR > > #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan > One Click Binding - https://github.com/appsmithorg/TestSmith/issues/2390 > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: Vemparala Surya Vamsi <vamsi@appsmith.com>
2023-06-01 17:26:05 +00:00
ReduxActionErrorTypes.EXECUTE_PLUGIN_ACTION_ERROR,
]);
if (
runResponse.type === ReduxActionErrorTypes.EXECUTE_PLUGIN_ACTION_ERROR
) {
fix: one click binding postgress sorting issue when primary key is no… (#24090) …t available ## Description When the primary key is not present in a postgres table, we should update generated query to not have its reference. #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/24079 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [x] Jest > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [x] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-06-08 11:28:48 +00:00
throw new Error(`Unable to run action: ${actionToRun.name}`);
feat: Table one click binding for MongoDB and Postgres (#23629) > Pull Request Template > > Use this template to quickly create a well written pull request. Delete all quotes before creating the pull request. > ## Description > Add a TL;DR when description is extra long (helps content team) > > Please include a summary of the changes and which issue has been fixed. Please also include relevant motivation > and context. List any dependencies that are required for this change > > Links to Notion, Figma or any other documents that might be relevant to the PR > > #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan > One Click Binding - https://github.com/appsmithorg/TestSmith/issues/2390 > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: Vemparala Surya Vamsi <vamsi@appsmith.com>
2023-06-01 17:26:05 +00:00
}
}
const { getPropertyUpdatesForQueryBinding } =
WidgetFactory.getWidgetMethods(widget.type);
const createdQueryNames = createdActions.map((d) => d.name);
const queryBindingConfig: Record<string, unknown> = {};
if (createdQueryNames.includes(queryNameMap[QUERY_TYPE.SELECT])) {
queryBindingConfig[QUERY_TYPE.SELECT] = {
data: `{{${queryNameMap[QUERY_TYPE.SELECT]}.data}}`,
fix: one click binding postgress sorting issue when primary key is no… (#24090) …t available ## Description When the primary key is not present in a postgres table, we should update generated query to not have its reference. #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/24079 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [x] Jest > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [x] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-06-08 11:28:48 +00:00
run: `{{
${queryNameMap[QUERY_TYPE.SELECT]}.run();
${queryNameMap[QUERY_TYPE.TOTAL_RECORD]}.run();
}}`,
feat: Table one click binding for MongoDB and Postgres (#23629) > Pull Request Template > > Use this template to quickly create a well written pull request. Delete all quotes before creating the pull request. > ## Description > Add a TL;DR when description is extra long (helps content team) > > Please include a summary of the changes and which issue has been fixed. Please also include relevant motivation > and context. List any dependencies that are required for this change > > Links to Notion, Figma or any other documents that might be relevant to the PR > > #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan > One Click Binding - https://github.com/appsmithorg/TestSmith/issues/2390 > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: Vemparala Surya Vamsi <vamsi@appsmith.com>
2023-06-01 17:26:05 +00:00
};
}
if (createdQueryNames.includes(queryNameMap[QUERY_TYPE.UPDATE])) {
queryBindingConfig[QUERY_TYPE.UPDATE] = {
data: `{{${queryNameMap[QUERY_TYPE.UPDATE]}.data}}`,
run: `{{${queryNameMap[QUERY_TYPE.UPDATE]}.run(() => {
showAlert("Successfully saved!");
${queryNameMap[QUERY_TYPE.SELECT]}.run();
}, () => {
showAlert("Unable to save!");
})}}`,
};
}
if (createdQueryNames.includes(queryNameMap[QUERY_TYPE.CREATE])) {
queryBindingConfig[QUERY_TYPE.CREATE] = {
data: `{{${queryNameMap[QUERY_TYPE.CREATE]}.data}}`,
run: `{{${queryNameMap[QUERY_TYPE.CREATE]}.run(() => {
showAlert("Successfully created!");
${queryNameMap[QUERY_TYPE.SELECT]}.run()
}, () => {
showAlert("Unable to create!");
})}}`,
};
}
if (createdQueryNames.includes(queryNameMap[QUERY_TYPE.TOTAL_RECORD])) {
queryBindingConfig[QUERY_TYPE.TOTAL_RECORD] = {
data: `{{${widgetQueryGenerator.getTotalRecordExpression(
`${queryNameMap[QUERY_TYPE.TOTAL_RECORD]}.data`,
)}}}`,
run: `{{${queryNameMap[QUERY_TYPE.TOTAL_RECORD]}.run()}}`,
};
}
const updatedWidget: WidgetProps = yield select(getWidgetByID(widgetId));
const updates = getPropertyUpdatesForQueryBinding(
queryBindingConfig,
updatedWidget,
action.payload,
);
yield put({
type: ReduxActionTypes.BATCH_UPDATE_WIDGET_PROPERTY,
payload: {
widgetId,
updates: {
modify: updates,
},
},
});
yield take(ReduxActionTypes.SET_EVALUATED_TREE);
newActions.push(...createdQueryNames);
for (const action of createdActions) {
AnalyticsUtil.logEvent("QUERY_GENERATION_BINDING_SUCCESS", {
widgetName: widget.widgetName,
widgetType: widget.type,
QueryName: action.name,
QueryType: invert(queryNameMap)[action.name],
pluginType: plugin.type,
pluginName: plugin.name,
});
}
}
yield put({
type: ReduxActionTypes.BIND_WIDGET_TO_DATASOURCE_SUCCESS,
});
AnalyticsUtil.logEvent("1_CLICK_BINDING_SUCCESS", {
widgetName: widget.widgetName,
widgetType: widget.type,
pluginType: plugin.type,
pluginName: plugin.name,
isMock: datasource.isMock,
});
} catch (e: any) {
Toaster.show({
text: e.message,
hideProgressBar: false,
variant: Variant.danger,
});
yield put({
type: ReduxActionTypes.BIND_WIDGET_TO_DATASOURCE_ERROR,
});
}
feat: Table one click binding for MongoDB and Postgres (#23629) > Pull Request Template > > Use this template to quickly create a well written pull request. Delete all quotes before creating the pull request. > ## Description > Add a TL;DR when description is extra long (helps content team) > > Please include a summary of the changes and which issue has been fixed. Please also include relevant motivation > and context. List any dependencies that are required for this change > > Links to Notion, Figma or any other documents that might be relevant to the PR > > #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan > One Click Binding - https://github.com/appsmithorg/TestSmith/issues/2390 > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: Vemparala Surya Vamsi <vamsi@appsmith.com>
2023-06-01 17:26:05 +00:00
Toaster.show({
text: `Successfully created action${
newActions.length > 1 ? "s" : ""
}: ${newActions.join(", ")}`,
hideProgressBar: true,
variant: Variant.success,
duration: 3000,
});
}
export default function* oneClickBindingSaga() {
yield all([
takeLatest(
ReduxActionTypes.BIND_WIDGET_TO_DATASOURCE,
BindWidgetToDatasource,
),
]);
}