2023-04-13 11:09:24 +00:00
|
|
|
import type { ReduxAction } from "@appsmith/constants/ReduxActionConstants";
|
2023-10-03 08:10:51 +00:00
|
|
|
import {
|
|
|
|
|
ReduxActionErrorTypes,
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
2023-06-01 17:26:05 +00:00
|
|
|
import type { Plugin } from "api/PluginApi";
|
2023-10-27 06:36:57 +00:00
|
|
|
import {
|
2024-03-11 04:52:24 +00:00
|
|
|
ActionCreationSourceTypeEnum,
|
2023-10-27 06:36:57 +00:00
|
|
|
PluginType,
|
|
|
|
|
type Action,
|
|
|
|
|
type QueryActionConfig,
|
|
|
|
|
} from "entities/Action";
|
2023-06-01 17:26:05 +00:00
|
|
|
import type { Datasource } from "entities/Datasource";
|
|
|
|
|
import { invert, merge, omit, partition } from "lodash";
|
2023-10-03 08:10:51 +00:00
|
|
|
import { all, call, put, select, take, takeLatest } from "redux-saga/effects";
|
2023-06-01 17:26:05 +00:00
|
|
|
import {
|
|
|
|
|
getCurrentApplicationId,
|
|
|
|
|
getCurrentPageId,
|
|
|
|
|
} from "selectors/editorSelectors";
|
|
|
|
|
import {
|
|
|
|
|
getActions,
|
|
|
|
|
getCurrentPageNameByActionId,
|
|
|
|
|
getDatasource,
|
|
|
|
|
getPlugin,
|
2023-09-12 11:51:39 +00:00
|
|
|
} from "@appsmith/selectors/entitiesSelector";
|
2023-10-27 06:36:57 +00:00
|
|
|
import { createNewApiName, createNewQueryName } from "utils/AppsmithUtils";
|
2023-06-01 17:26:05 +00:00
|
|
|
import WidgetQueryGeneratorRegistry from "utils/WidgetQueryGeneratorRegistry";
|
|
|
|
|
import {
|
2023-10-27 06:36:57 +00:00
|
|
|
createDefaultActionPayloadWithPluginDefaults,
|
|
|
|
|
getPluginActionDefaultValues,
|
2023-06-01 17:26:05 +00:00
|
|
|
} from "./ActionSagas";
|
|
|
|
|
import "../WidgetQueryGenerators";
|
2023-09-22 12:42:20 +00:00
|
|
|
import type { ActionDataState } from "@appsmith/reducers/entityReducers/actionsReducer";
|
2023-06-01 17:26:05 +00:00
|
|
|
import "WidgetQueryGenerators";
|
|
|
|
|
import { getWidgetByID } from "./selectors";
|
2023-09-06 12:15:04 +00:00
|
|
|
import type {
|
|
|
|
|
WidgetQueryConfig,
|
|
|
|
|
WidgetQueryGenerationFormConfig,
|
|
|
|
|
} from "WidgetQueryGenerators/types";
|
2023-06-01 17:26:05 +00:00
|
|
|
import { QUERY_TYPE } from "WidgetQueryGenerators/types";
|
|
|
|
|
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";
|
chore: Import debugger fixes (#31080)
## Description
To add debugger error for import path for module instance on EE, this PR
enables code to be extended on EE
#### 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
- [ ] Manual
- [ ] JUnit
- [ ] Jest
- [ ] Cypress
>
>
#### 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
- [ ] My code follows the style guidelines of this project
- [ ] 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
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] 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/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#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
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **Refactor**
- Updated import paths and references for `ENTITY_TYPE` to
`EntityTypeValue` across various components and utilities for improved
code consistency.
- Reorganized import statements related to `AppsmithConsole` utilities
and constants to enhance code maintainability.
- Adjusted usage of enums and types, specifically for entity and
platform error handling, to align with updated import paths.
- **New Features**
- Introduced utility functions for handling entity types and platform
errors in AppsmithConsole, including new constants and error retrieval
functions.
- Added a new enum value `MISSING_MODULE` to better categorize log types
in debugging scenarios.
- **Bug Fixes**
- Implemented changes to error logging and handling mechanisms,
including the addition of new case handling for
`LOG_TYPE.MISSING_MODULE` in debugger logs, to improve the debugging
experience.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-02-14 06:30:18 +00:00
|
|
|
import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils";
|
2023-06-01 17:26:05 +00:00
|
|
|
import { fetchActions, runAction } from "actions/pluginActionActions";
|
|
|
|
|
import { Toaster, Variant } from "design-system-old";
|
2023-09-06 12:15:04 +00:00
|
|
|
import WidgetFactory from "WidgetProvider/factory";
|
2023-06-01 17:26:05 +00:00
|
|
|
|
|
|
|
|
export function* createActionsForOneClickBindingSaga(
|
|
|
|
|
payload: Partial<Action> & { eventData: unknown; pluginId: string },
|
|
|
|
|
) {
|
|
|
|
|
try {
|
2024-03-11 04:52:24 +00:00
|
|
|
// Indicates that source of action creation is one click binding
|
|
|
|
|
payload.source = ActionCreationSourceTypeEnum.ONE_CLICK_BINDING;
|
|
|
|
|
|
2023-06-01 17:26:05 +00:00
|
|
|
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(
|
2023-10-27 06:36:57 +00:00
|
|
|
getPluginActionDefaultValues,
|
2023-06-01 17:26:05 +00:00
|
|
|
datasource?.pluginId,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const { getQueryGenerationConfig } = WidgetFactory.getWidgetMethods(
|
|
|
|
|
widget.type,
|
|
|
|
|
);
|
|
|
|
|
|
2023-10-03 08:10:51 +00:00
|
|
|
const widgetQueryGenerationConfig = getQueryGenerationConfig?.(
|
|
|
|
|
widget,
|
|
|
|
|
action.payload,
|
|
|
|
|
);
|
2023-06-01 17:26:05 +00:00
|
|
|
|
|
|
|
|
const widgetQueryGenerator = WidgetQueryGeneratorRegistry.get(
|
|
|
|
|
plugin.packageName,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const actionConfigurationList = widgetQueryGenerator.build(
|
|
|
|
|
widgetQueryGenerationConfig,
|
|
|
|
|
action.payload,
|
|
|
|
|
defaultValues,
|
|
|
|
|
);
|
|
|
|
|
|
2023-10-27 06:36:57 +00:00
|
|
|
const newActionName =
|
|
|
|
|
plugin.type === PluginType.DB
|
|
|
|
|
? createNewQueryName(actions, pageId || "")
|
|
|
|
|
: createNewApiName(actions, pageId || "");
|
|
|
|
|
|
2023-06-01 17:26:05 +00:00
|
|
|
const commonActionPayload: Partial<Action> = yield call(
|
2023-10-27 06:36:57 +00:00
|
|
|
createDefaultActionPayloadWithPluginDefaults,
|
|
|
|
|
{
|
|
|
|
|
datasourceId,
|
|
|
|
|
from: "ONE_CLICK_BINDING",
|
|
|
|
|
newActionName,
|
|
|
|
|
},
|
2023-06-01 17:26:05 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2023-10-27 06:36:57 +00:00
|
|
|
return merge(
|
|
|
|
|
{},
|
|
|
|
|
{
|
|
|
|
|
...commonActionPayload,
|
|
|
|
|
pageId,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
actionConfiguration: payload,
|
|
|
|
|
name: queryNameMap[type],
|
|
|
|
|
dynamicBindingPathList,
|
|
|
|
|
type,
|
|
|
|
|
},
|
|
|
|
|
);
|
2023-06-01 17:26:05 +00:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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
|
2023-06-08 11:28:48 +00:00
|
|
|
for (const actionToRun of actionsToRun) {
|
|
|
|
|
yield put(runAction(actionToRun.id, undefined, true));
|
2023-06-01 17:26:05 +00:00
|
|
|
|
|
|
|
|
const runResponse: ReduxAction<unknown> = yield take([
|
2023-06-08 11:28:48 +00:00
|
|
|
ReduxActionTypes.RUN_ACTION_SUCCESS,
|
2023-06-01 17:26:05 +00:00
|
|
|
ReduxActionErrorTypes.EXECUTE_PLUGIN_ACTION_ERROR,
|
2023-08-17 07:08:06 +00:00
|
|
|
ReduxActionErrorTypes.RUN_ACTION_ERROR,
|
2023-06-01 17:26:05 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
if (
|
2023-08-17 07:08:06 +00:00
|
|
|
[
|
|
|
|
|
ReduxActionErrorTypes.EXECUTE_PLUGIN_ACTION_ERROR,
|
|
|
|
|
ReduxActionErrorTypes.RUN_ACTION_ERROR,
|
|
|
|
|
].includes(runResponse.type)
|
2023-06-01 17:26:05 +00:00
|
|
|
) {
|
2023-06-08 11:28:48 +00:00
|
|
|
throw new Error(`Unable to run action: ${actionToRun.name}`);
|
2023-06-01 17:26:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { getPropertyUpdatesForQueryBinding } =
|
|
|
|
|
WidgetFactory.getWidgetMethods(widget.type);
|
|
|
|
|
|
|
|
|
|
const createdQueryNames = createdActions.map((d) => d.name);
|
|
|
|
|
|
2023-09-06 12:15:04 +00:00
|
|
|
const queryBindingConfig: WidgetQueryConfig = {};
|
2023-06-01 17:26:05 +00:00
|
|
|
|
2023-10-03 08:10:51 +00:00
|
|
|
const { alertMessage } = action.payload;
|
|
|
|
|
|
2023-06-01 17:26:05 +00:00
|
|
|
if (createdQueryNames.includes(queryNameMap[QUERY_TYPE.SELECT])) {
|
|
|
|
|
queryBindingConfig[QUERY_TYPE.SELECT] = {
|
|
|
|
|
data: `{{${queryNameMap[QUERY_TYPE.SELECT]}.data}}`,
|
2023-06-08 11:28:48 +00:00
|
|
|
run: `{{
|
|
|
|
|
${queryNameMap[QUERY_TYPE.SELECT]}.run();
|
2023-08-10 05:21:19 +00:00
|
|
|
${
|
|
|
|
|
createdQueryNames.includes(queryNameMap[QUERY_TYPE.TOTAL_RECORD])
|
|
|
|
|
? queryNameMap[QUERY_TYPE.TOTAL_RECORD] + ".run()"
|
|
|
|
|
: ""
|
|
|
|
|
}
|
2023-06-08 11:28:48 +00:00
|
|
|
}}`,
|
2023-06-01 17:26:05 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (createdQueryNames.includes(queryNameMap[QUERY_TYPE.UPDATE])) {
|
2023-10-03 08:10:51 +00:00
|
|
|
const selectQuery = queryNameMap[QUERY_TYPE.SELECT]
|
|
|
|
|
? `${queryNameMap[QUERY_TYPE.SELECT]}.run()`
|
|
|
|
|
: "";
|
|
|
|
|
|
|
|
|
|
const successMessage = `${
|
|
|
|
|
alertMessage?.success
|
|
|
|
|
? alertMessage.success?.update
|
|
|
|
|
: "Successfully saved!"
|
|
|
|
|
}`;
|
|
|
|
|
|
2023-06-01 17:26:05 +00:00
|
|
|
queryBindingConfig[QUERY_TYPE.UPDATE] = {
|
|
|
|
|
data: `{{${queryNameMap[QUERY_TYPE.UPDATE]}.data}}`,
|
|
|
|
|
run: `{{${queryNameMap[QUERY_TYPE.UPDATE]}.run(() => {
|
2023-10-03 08:10:51 +00:00
|
|
|
showAlert("${successMessage}");
|
|
|
|
|
${selectQuery.toString()}
|
2023-06-01 17:26:05 +00:00
|
|
|
}, () => {
|
|
|
|
|
showAlert("Unable to save!");
|
|
|
|
|
})}}`,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (createdQueryNames.includes(queryNameMap[QUERY_TYPE.CREATE])) {
|
2023-10-03 08:10:51 +00:00
|
|
|
const selectQuery = queryNameMap[QUERY_TYPE.SELECT]
|
|
|
|
|
? `${queryNameMap[QUERY_TYPE.SELECT]}.run()`
|
|
|
|
|
: "";
|
|
|
|
|
|
|
|
|
|
const successMessage = `${
|
|
|
|
|
alertMessage?.success
|
|
|
|
|
? alertMessage.success?.create
|
|
|
|
|
: "Successfully created!"
|
|
|
|
|
}`;
|
|
|
|
|
|
2023-06-01 17:26:05 +00:00
|
|
|
queryBindingConfig[QUERY_TYPE.CREATE] = {
|
|
|
|
|
data: `{{${queryNameMap[QUERY_TYPE.CREATE]}.data}}`,
|
|
|
|
|
run: `{{${queryNameMap[QUERY_TYPE.CREATE]}.run(() => {
|
2023-10-03 08:10:51 +00:00
|
|
|
showAlert("${successMessage}");
|
|
|
|
|
${selectQuery.toString()}
|
2023-06-01 17:26:05 +00:00
|
|
|
}, () => {
|
|
|
|
|
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));
|
|
|
|
|
|
2023-09-06 12:15:04 +00:00
|
|
|
const { dynamicUpdates, modify } =
|
|
|
|
|
getPropertyUpdatesForQueryBinding?.(
|
|
|
|
|
queryBindingConfig,
|
|
|
|
|
updatedWidget,
|
|
|
|
|
action.payload,
|
|
|
|
|
) || {};
|
2023-06-01 17:26:05 +00:00
|
|
|
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.BATCH_UPDATE_WIDGET_PROPERTY,
|
|
|
|
|
payload: {
|
|
|
|
|
widgetId,
|
|
|
|
|
updates: {
|
2023-07-20 06:22:20 +00:00
|
|
|
modify,
|
2023-06-01 17:26:05 +00:00
|
|
|
},
|
2023-07-20 06:22:20 +00:00
|
|
|
dynamicUpdates,
|
2023-06-01 17:26:05 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
});
|
2023-10-03 08:10:51 +00:00
|
|
|
const { otherFields } = action.payload;
|
2023-06-01 17:26:05 +00:00
|
|
|
AnalyticsUtil.logEvent("1_CLICK_BINDING_SUCCESS", {
|
|
|
|
|
widgetName: widget.widgetName,
|
|
|
|
|
widgetType: widget.type,
|
|
|
|
|
pluginType: plugin.type,
|
|
|
|
|
pluginName: plugin.name,
|
|
|
|
|
isMock: datasource.isMock,
|
2023-10-03 08:10:51 +00:00
|
|
|
formType: otherFields?.formType,
|
2023-06-01 17:26:05 +00:00
|
|
|
});
|
|
|
|
|
} catch (e: any) {
|
|
|
|
|
Toaster.show({
|
|
|
|
|
text: e.message,
|
|
|
|
|
hideProgressBar: false,
|
|
|
|
|
variant: Variant.danger,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.BIND_WIDGET_TO_DATASOURCE_ERROR,
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-04-13 11:09:24 +00:00
|
|
|
|
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,
|
|
|
|
|
});
|
2023-04-13 11:09:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function* oneClickBindingSaga() {
|
|
|
|
|
yield all([
|
|
|
|
|
takeLatest(
|
|
|
|
|
ReduxActionTypes.BIND_WIDGET_TO_DATASOURCE,
|
|
|
|
|
BindWidgetToDatasource,
|
|
|
|
|
),
|
|
|
|
|
]);
|
|
|
|
|
}
|