* temp commit
* using onsubmit to continue using action on form
* added recaptcha site key to env example file
* moved the recaptcha lib loading logic to signup page
* removed unnecessary edit
* handle the case where the recaptcha token is not provided as env var
* added proper env var config for client
* recaptcha config for ansible
* recaptcha config for heroku
* recaptcha config for k8s
* updated app.json
* fixed the typos
* added more description for env vars
* removed api key
* minor typo fix
* added new integration button
* updated the add int default link
* added active and create new tabs
* added the empty components to tabs. will control the section manually.
* added proper grid for integrations page
* added vertical tabs
* Added secondary tabs to integrations page
* added separate page for new apis
* classname changes
* added new components for active queries, new queries etc.
* added a separate component for data source list
* adding screen component conditionally, to be showing upon user's choice
* 1. Added grid styling to datasource home
2. Added connect buttons to em
* fixed data source security banner
* updated the styling for new api page
* added tertiary menu for active integrations
* updated styling for active connections
* updated collapse component to work properly
* added show more option to active data sources
* Slash commands feature init commit
* Added more commands
* Introduced JSX to render custom commands
* Merge conflict fix
* Spacing changes
* removed apis/db tabs and replaced em with integrations tab
* removed the unnecessary + integrations btn
* Added slash commands button
* Adjust styles for better ui
* Ordered the action entries under integrations
* Added new datasource command
* updated the getURL with proper params
* updated the link of create datasource btn
* updated the back btn link from data source editor
* Show connect data cta in property pane
* Styling fixes
* Fix margin
* added scrollable content to create new
* added on click scroll to create new page
* fixed a bug, creating new datasource twice
* added new action creator for integrations.
* Minor changes to add new bindings command.
Changed ui behaviour of / button
* UI style change
* updated the query editor to match the over all theme
* updated the query editor tabs
* Added the run btn to empty response screens
* minor fix
* updated the bg color of api type drop down
* updated the url being visited after delete api/query
* removed log
* Insert binding command UI change
* More UI changes
* removed unnecessary junk from integrations editor index
* clean up, removed unnecessary files
* removed useless routes
* for debugger only checking if integrations editor
* Removed all the links for api/query home pages
* Move command actions to a saga
Added support to binding the data back to the widget when are new API is created from widget
* Added reverse binding for DB queries
* Show / button only on hover
* not routing to integrations on create query/api
* Hide actions from suggestions in action pages
* removed the query/datasource/api home pages
* Changes widget.data to widget in slash commands
* Show dependencies in property pane
* Fix warning
* fixed scrolling issue
* will show a list of queries and apis for action picker
* showing icons for each action under integrations
* Fix dropdown not showing up
* Minor refactoring.
Changed commands
* added a way to list data sources in action creators
* Update query page url
* cam show icons for datasources
* Removed unused code
* Feature/slash commands (#5002)
* Slash commands feature init commit
* Added more commands
* Introduced JSX to render custom commands
* Merge conflict fix
* Spacing changes
* Added slash commands button
* Adjust styles for better ui
* Added new datasource command
* Minor changes to add new bindings command.
Changed ui behaviour of / button
* UI style change
* Insert binding command UI change
* More UI changes
* Move command actions to a saga
Added support to binding the data back to the widget when are new API is created from widget
* Added reverse binding for DB queries
* Show / button only on hover
* Hide actions from suggestions in action pages
* Changes widget.data to widget in slash commands
* Minor refactoring.
Changed commands
* Removed unused code
* remove more unusued code
* Added support to generate new api from a datasource in quick commands
* Code correction to use types
* Refactored commands code
* Minor bug fixes
* Remove new integrations command for actions.
Fixed autocomplete not showing up
* Changes to prevent autocomplete trigger for navigation commands
* Prevent hinter execution when show hint is open already.
* Show hinter on focus
* Update text to be called in the omnibar
* updated the copy for empty active datasources
* Update url
* Fix text decoration
* updated the redirection for back btns
* Use themes
* Add cypress test
* fixed back btn nav
* fetching form configs for datasources
* a callback fixed
* Fix slash command not executed on click (#5540)
* Replace the value if not a string else append
* Log commands menu events
* updated mock data base navigation
* updated mock data base navigation
* updated the close editors and back buttons
* All back btns from editors will go back to data sources and back from data source will go back to canvas
* fixed bg colors
* minor styled updates
* removed margin from header of generic datasource
* warnings fixes
* If user is already on the location not redirecting em
* when editing, will check if the coming from data source and redirect accordingly
* updated redirection for newly created api/queries
* updated back btn for newly created datasources
* back for new curl goes to data sources
* Revert "[Fix] revert new nav (#5533)"
This reverts commit 1647815d
* remaining original reverted chagnes
* fixed the width of incoming/outgoing entity bar in property pane
* removing residue from resolved merge conflicts
* Fix widget icons not visible in dropdown menu
* minor fix to use proper integration URL
* updated the URLs for unified datasources
* converted back and close to btns from banners
* on accessing data source from sidebar, it'll always go to view mode
* updated the edit path for saas editors
* Added saved state for google sheet
* on google sheet delete redirecting to create new
* minor fix
* fixed the redirection call on saving a datasource
* removed save and test cmd as it wasn't needed
* Removing test cases to be fixed by Arun
* commenting more tests to be fixed by Arun
* updated call api cy command
* Fix extra margin issue
* fixed the update datasource saga
* fixed video spec
* Revert "commenting more tests to be fixed by Arun"
This reverts commit 42087a95ad77107401a1619e4c2d4c541a81d6c3.
* Revert "Removing test cases to be fixed by Arun"
This reverts commit f6fad67e558d22045114a90409428ef9b737478f.
* fixed the entity explorer query datasource spec
* cautious fix
* update widget locators
* fixed leave org test
* fixes for FormWidgets
* updated the image spec
* Use memo
* Fix debugger url checks
* for copy and delete widget pointing directly to svgs
* Fix entity text
* Fix styling and show tooltip for property pane dependencies
* removed the unnecessary callback
* added a separate saga to to redirect to new integrations using onSuccess
* Bug Fixes - New nav (#5629)
* will show scrollbar only on hover
* made mock data cards clickable
* fixed the grid view
* fixed the cursor position when clicking on / btn
* updated the hint for `/` command
* binding prompt will close on focus change
* hiding / command for api body
* hiding / command for query pane
* Added 2 new icons
* Fix cursor position on selecting a binding and clicking on the slash menu button
* trying out fix to copyWidget cy command
* removing zero width space characters from the property pane text
Co-authored-by: arunvjn <arun@appsmith.com>
Co-authored-by: Akash N <akash@codemonk.in>
Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
Co-authored-by: Rishabh Saxena <rishabh.robben@gmail.com>
592 lines
17 KiB
TypeScript
592 lines
17 KiB
TypeScript
/**
|
|
* Handles the Api pane ui state. It looks into the routing based on actions too
|
|
* */
|
|
import get from "lodash/get";
|
|
import omit from "lodash/omit";
|
|
import cloneDeep from "lodash/cloneDeep";
|
|
import { all, select, put, takeEvery, call, take } from "redux-saga/effects";
|
|
import * as Sentry from "@sentry/react";
|
|
import {
|
|
ReduxAction,
|
|
ReduxActionErrorTypes,
|
|
ReduxActionTypes,
|
|
ReduxActionWithMeta,
|
|
ReduxFormActionTypes,
|
|
} from "constants/ReduxActionConstants";
|
|
import { getFormData } from "selectors/formSelectors";
|
|
import { API_EDITOR_FORM_NAME, SAAS_EDITOR_FORM } from "constants/forms";
|
|
import {
|
|
DEFAULT_API_ACTION_CONFIG,
|
|
POST_BODY_FORMAT_OPTIONS,
|
|
REST_PLUGIN_PACKAGE_NAME,
|
|
POST_BODY_FORMATS,
|
|
CONTENT_TYPE_HEADER_KEY,
|
|
ApiContentTypes,
|
|
EMPTY_KEY_VALUE_PAIRS,
|
|
} from "constants/ApiEditorConstants";
|
|
import history from "utils/history";
|
|
import {
|
|
API_EDITOR_ID_URL,
|
|
DATA_SOURCES_EDITOR_ID_URL,
|
|
INTEGRATION_EDITOR_MODES,
|
|
INTEGRATION_EDITOR_URL,
|
|
INTEGRATION_TABS,
|
|
} from "constants/routes";
|
|
import {
|
|
getCurrentApplicationId,
|
|
getCurrentPageId,
|
|
} from "selectors/editorSelectors";
|
|
import { initialize, autofill, change } from "redux-form";
|
|
import { Property } from "api/ActionAPI";
|
|
import {
|
|
createNewApiName,
|
|
getNextEntityName,
|
|
getQueryParams,
|
|
} from "utils/AppsmithUtils";
|
|
import { getPluginIdOfPackageName } from "sagas/selectors";
|
|
import {
|
|
getAction,
|
|
getActions,
|
|
getPlugins,
|
|
getDatasources,
|
|
getPlugin,
|
|
} from "selectors/entitiesSelector";
|
|
import { ActionData } from "reducers/entityReducers/actionsReducer";
|
|
import { createActionRequest, setActionProperty } from "actions/actionActions";
|
|
import { Datasource } from "entities/Datasource";
|
|
import { Plugin } from "api/PluginApi";
|
|
import { PLUGIN_PACKAGE_DBS } from "constants/QueryEditorConstants";
|
|
import { Action, ApiAction, PluginType } from "entities/Action";
|
|
import { getCurrentOrgId } from "selectors/organizationSelectors";
|
|
import log from "loglevel";
|
|
import PerformanceTracker, {
|
|
PerformanceTransactionName,
|
|
} from "utils/PerformanceTracker";
|
|
import { EventLocation } from "utils/AnalyticsUtil";
|
|
import { Variant } from "components/ads/common";
|
|
import { Toaster } from "components/ads/Toast";
|
|
import { createMessage, ERROR_ACTION_RENAME_FAIL } from "constants/messages";
|
|
import { checkCurrentStep } from "./OnboardingSagas";
|
|
import { OnboardingStep } from "constants/OnboardingConstants";
|
|
import {
|
|
getIndextoUpdate,
|
|
parseUrlForQueryParams,
|
|
queryParamsRegEx,
|
|
} from "utils/ApiPaneUtils";
|
|
|
|
function* syncApiParamsSaga(
|
|
actionPayload: ReduxActionWithMeta<string, { field: string }>,
|
|
actionId: string,
|
|
) {
|
|
const field = actionPayload.meta.field;
|
|
//Payload here contains the path and query params of a typical url like https://{domain}/{path}?{query_params}
|
|
const value = actionPayload.payload;
|
|
// Regular expression to find the query params group
|
|
PerformanceTracker.startTracking(PerformanceTransactionName.SYNC_PARAMS_SAGA);
|
|
if (field === "actionConfiguration.path") {
|
|
const params = parseUrlForQueryParams(value);
|
|
yield put(
|
|
autofill(
|
|
API_EDITOR_FORM_NAME,
|
|
"actionConfiguration.queryParameters",
|
|
params,
|
|
),
|
|
);
|
|
yield put(
|
|
setActionProperty({
|
|
actionId: actionId,
|
|
propertyName: "actionConfiguration.queryParameters",
|
|
value: params,
|
|
}),
|
|
);
|
|
} else if (field.includes("actionConfiguration.queryParameters")) {
|
|
const { values } = yield select(getFormData, API_EDITOR_FORM_NAME);
|
|
const path = values.actionConfiguration.path || "";
|
|
const matchGroups = path.match(queryParamsRegEx) || [];
|
|
const currentPath = matchGroups[1] || "";
|
|
const paramsString = values.actionConfiguration.queryParameters
|
|
.filter((p: Property) => p.key)
|
|
.map(
|
|
(p: Property, i: number) => `${i === 0 ? "?" : "&"}${p.key}=${p.value}`,
|
|
)
|
|
.join("");
|
|
yield put(
|
|
autofill(
|
|
API_EDITOR_FORM_NAME,
|
|
"actionConfiguration.path",
|
|
`${currentPath}${paramsString}`,
|
|
),
|
|
);
|
|
}
|
|
PerformanceTracker.stopTracking();
|
|
}
|
|
|
|
function* redirectToNewIntegrations(
|
|
action: ReduxAction<{ applicationId: string; pageId: string }>,
|
|
) {
|
|
history.push(
|
|
INTEGRATION_EDITOR_URL(
|
|
action.payload.applicationId,
|
|
action.payload.pageId,
|
|
INTEGRATION_TABS.ACTIVE,
|
|
INTEGRATION_EDITOR_MODES.AUTO,
|
|
),
|
|
);
|
|
}
|
|
|
|
function* handleUpdateBodyContentType(
|
|
action: ReduxAction<{ title: ApiContentTypes; apiId: string }>,
|
|
) {
|
|
const { apiId, title } = action.payload;
|
|
const { values } = yield select(getFormData, API_EDITOR_FORM_NAME);
|
|
const displayFormatObject = POST_BODY_FORMAT_OPTIONS.find(
|
|
(el) => el.label === title,
|
|
);
|
|
if (!displayFormatObject) {
|
|
log.error("Display format not supported", title);
|
|
return;
|
|
}
|
|
if (displayFormatObject.value === POST_BODY_FORMATS[3]) {
|
|
// Dont update the content type header if raw has been selected
|
|
yield put({
|
|
type: ReduxActionTypes.SET_EXTRA_FORMDATA,
|
|
payload: {
|
|
id: apiId,
|
|
values: {
|
|
displayFormat: POST_BODY_FORMAT_OPTIONS[3],
|
|
},
|
|
},
|
|
});
|
|
return;
|
|
}
|
|
|
|
const headers = cloneDeep(values.actionConfiguration.headers);
|
|
const bodyFormData = cloneDeep(values.actionConfiguration.bodyFormData);
|
|
|
|
const contentTypeHeaderIndex = headers.findIndex(
|
|
(element: { key: string; value: string }) =>
|
|
element &&
|
|
element.key &&
|
|
element.key.trim().toLowerCase() === CONTENT_TYPE_HEADER_KEY,
|
|
);
|
|
const indexToUpdate = getIndextoUpdate(headers, contentTypeHeaderIndex);
|
|
|
|
headers[indexToUpdate] = {
|
|
key: CONTENT_TYPE_HEADER_KEY,
|
|
value: displayFormatObject.value,
|
|
};
|
|
|
|
yield put(
|
|
change(API_EDITOR_FORM_NAME, "actionConfiguration.headers", headers),
|
|
);
|
|
|
|
if (displayFormatObject.value === POST_BODY_FORMATS[1]) {
|
|
if (!bodyFormData || bodyFormData.length === 0) {
|
|
yield put(
|
|
change(
|
|
API_EDITOR_FORM_NAME,
|
|
"actionConfiguration.bodyFormData",
|
|
EMPTY_KEY_VALUE_PAIRS.slice(),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
function* initializeExtraFormDataSaga() {
|
|
const state = yield select();
|
|
const { extraformData } = state.ui.apiPane;
|
|
const formData = yield select(getFormData, API_EDITOR_FORM_NAME);
|
|
const { values } = formData;
|
|
const headers = get(values, "actionConfiguration.headers");
|
|
|
|
if (!extraformData[values.id]) {
|
|
yield call(setHeaderFormat, values.id, headers);
|
|
}
|
|
}
|
|
|
|
function* changeApiSaga(
|
|
actionPayload: ReduxAction<{ id: string; isSaas: boolean }>,
|
|
) {
|
|
// // Typescript says Element does not have blur function but it does;
|
|
// document.activeElement &&
|
|
// "blur" in document.activeElement &&
|
|
// // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// // @ts-ignore: No types available
|
|
// document.activeElement.blur();
|
|
PerformanceTracker.startTracking(PerformanceTransactionName.CHANGE_API_SAGA);
|
|
const { id, isSaas } = actionPayload.payload;
|
|
const action = yield select(getAction, id);
|
|
if (!action) return;
|
|
if (isSaas) {
|
|
yield put(initialize(SAAS_EDITOR_FORM, action));
|
|
} else {
|
|
yield put(initialize(API_EDITOR_FORM_NAME, action));
|
|
|
|
yield call(initializeExtraFormDataSaga);
|
|
|
|
if (
|
|
action.actionConfiguration &&
|
|
action.actionConfiguration.queryParameters?.length
|
|
) {
|
|
// Sync the api params my mocking a change action
|
|
yield call(
|
|
syncApiParamsSaga,
|
|
{
|
|
type: ReduxFormActionTypes.ARRAY_REMOVE,
|
|
payload: action.actionConfiguration.queryParameters,
|
|
meta: {
|
|
field: "actionConfiguration.queryParameters",
|
|
},
|
|
},
|
|
id,
|
|
);
|
|
}
|
|
}
|
|
|
|
PerformanceTracker.stopTracking();
|
|
}
|
|
|
|
function* setHeaderFormat(apiId: string, headers?: Property[]) {
|
|
let displayFormat;
|
|
|
|
if (headers) {
|
|
const contentType = headers.find(
|
|
(header: any) =>
|
|
header &&
|
|
header.key &&
|
|
header.key.toLowerCase() === CONTENT_TYPE_HEADER_KEY,
|
|
);
|
|
|
|
if (
|
|
contentType &&
|
|
contentType.value &&
|
|
POST_BODY_FORMATS.includes(contentType.value)
|
|
) {
|
|
displayFormat = {
|
|
label: contentType.value,
|
|
value: contentType.value,
|
|
};
|
|
} else {
|
|
displayFormat = POST_BODY_FORMAT_OPTIONS[3];
|
|
}
|
|
}
|
|
|
|
yield put({
|
|
type: ReduxActionTypes.SET_EXTRA_FORMDATA,
|
|
payload: {
|
|
id: apiId,
|
|
values: {
|
|
displayFormat,
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
function* updateFormFields(
|
|
actionPayload: ReduxActionWithMeta<string, { field: string }>,
|
|
) {
|
|
const field = actionPayload.meta.field;
|
|
const value = actionPayload.payload;
|
|
const { values } = yield select(getFormData, API_EDITOR_FORM_NAME);
|
|
|
|
if (field === "actionConfiguration.httpMethod") {
|
|
const { actionConfiguration } = values;
|
|
const actionConfigurationHeaders = cloneDeep(actionConfiguration.headers);
|
|
if (actionConfigurationHeaders) {
|
|
const contentTypeHeaderIndex = actionConfigurationHeaders.findIndex(
|
|
(header: { key: string; value: string }) =>
|
|
header &&
|
|
header.key &&
|
|
header.key.trim().toLowerCase() === CONTENT_TYPE_HEADER_KEY,
|
|
);
|
|
if (value !== "GET") {
|
|
const indexToUpdate = getIndextoUpdate(
|
|
actionConfigurationHeaders,
|
|
contentTypeHeaderIndex,
|
|
);
|
|
actionConfigurationHeaders[indexToUpdate] = {
|
|
key: CONTENT_TYPE_HEADER_KEY,
|
|
value: POST_BODY_FORMAT_OPTIONS[0].value,
|
|
};
|
|
} else {
|
|
if (contentTypeHeaderIndex > -1) {
|
|
actionConfigurationHeaders[contentTypeHeaderIndex] = {
|
|
key: "",
|
|
value: "",
|
|
};
|
|
}
|
|
}
|
|
yield put(
|
|
change(
|
|
API_EDITOR_FORM_NAME,
|
|
"actionConfiguration.headers",
|
|
actionConfigurationHeaders,
|
|
),
|
|
);
|
|
}
|
|
} else if (field.includes("actionConfiguration.headers")) {
|
|
const actionConfigurationHeaders = get(
|
|
values,
|
|
"actionConfiguration.headers",
|
|
);
|
|
const apiId = get(values, "id");
|
|
yield call(setHeaderFormat, apiId, actionConfigurationHeaders);
|
|
}
|
|
}
|
|
|
|
function* formValueChangeSaga(
|
|
actionPayload: ReduxActionWithMeta<string, { field: string; form: string }>,
|
|
) {
|
|
const { field, form } = actionPayload.meta;
|
|
if (form !== API_EDITOR_FORM_NAME) return;
|
|
if (field === "dynamicBindingPathList" || field === "name") return;
|
|
const { values } = yield select(getFormData, API_EDITOR_FORM_NAME);
|
|
if (!values.id) return;
|
|
if (
|
|
actionPayload.type === ReduxFormActionTypes.ARRAY_REMOVE ||
|
|
actionPayload.type === ReduxFormActionTypes.ARRAY_PUSH
|
|
) {
|
|
const value = get(values, field);
|
|
yield put(
|
|
setActionProperty({
|
|
actionId: values.id,
|
|
propertyName: field,
|
|
value,
|
|
}),
|
|
);
|
|
} else {
|
|
yield put(
|
|
setActionProperty({
|
|
actionId: values.id,
|
|
propertyName: field,
|
|
value: actionPayload.payload,
|
|
}),
|
|
);
|
|
}
|
|
|
|
yield all([
|
|
call(syncApiParamsSaga, actionPayload, values.id),
|
|
call(updateFormFields, actionPayload),
|
|
]);
|
|
}
|
|
|
|
function* handleActionCreatedSaga(actionPayload: ReduxAction<Action>) {
|
|
const { id, pluginType } = actionPayload.payload;
|
|
const action = yield select(getAction, id);
|
|
const data = { ...action };
|
|
|
|
if (pluginType === PluginType.API) {
|
|
yield put(initialize(API_EDITOR_FORM_NAME, omit(data, "name")));
|
|
const applicationId = yield select(getCurrentApplicationId);
|
|
const pageId = yield select(getCurrentPageId);
|
|
history.push(
|
|
API_EDITOR_ID_URL(applicationId, pageId, id, {
|
|
editName: "true",
|
|
from: "datasources",
|
|
}),
|
|
);
|
|
}
|
|
}
|
|
|
|
function* handleDatasourceCreatedSaga(actionPayload: ReduxAction<Datasource>) {
|
|
const plugin = yield select(getPlugin, actionPayload.payload.pluginId);
|
|
// Only look at API plugins
|
|
if (plugin.type !== PluginType.API) return;
|
|
|
|
const applicationId = yield select(getCurrentApplicationId);
|
|
const pageId = yield select(getCurrentPageId);
|
|
|
|
history.push(
|
|
DATA_SOURCES_EDITOR_ID_URL(
|
|
applicationId,
|
|
pageId,
|
|
actionPayload.payload.id,
|
|
{
|
|
from: "datasources",
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
function* handleCreateNewApiActionSaga(
|
|
action: ReduxAction<{ pageId: string; from: EventLocation }>,
|
|
) {
|
|
const organizationId = yield select(getCurrentOrgId);
|
|
const pluginId = yield select(
|
|
getPluginIdOfPackageName,
|
|
REST_PLUGIN_PACKAGE_NAME,
|
|
);
|
|
const { pageId } = action.payload;
|
|
if (pageId && pluginId) {
|
|
const actions = yield select(getActions);
|
|
const pageActions = actions.filter(
|
|
(a: ActionData) => a.config.pageId === pageId,
|
|
);
|
|
const newActionName = createNewApiName(pageActions, pageId);
|
|
// Note: Do NOT send pluginId on top level here.
|
|
// It breaks embedded rest datasource flow.
|
|
yield put(
|
|
createActionRequest({
|
|
actionConfiguration: DEFAULT_API_ACTION_CONFIG,
|
|
name: newActionName,
|
|
datasource: {
|
|
name: "DEFAULT_REST_DATASOURCE",
|
|
pluginId,
|
|
organizationId,
|
|
},
|
|
eventData: {
|
|
actionType: "API",
|
|
from: action.payload.from,
|
|
},
|
|
pageId,
|
|
} as ApiAction), // We don't have recursive partial in typescript for now.
|
|
);
|
|
}
|
|
}
|
|
|
|
function* handleCreateNewQueryActionSaga(
|
|
action: ReduxAction<{ pageId: string; from: EventLocation }>,
|
|
) {
|
|
const { pageId } = action.payload;
|
|
const applicationId = yield select(getCurrentApplicationId);
|
|
const actions = yield select(getActions);
|
|
const dataSources = yield select(getDatasources);
|
|
const plugins = yield select(getPlugins);
|
|
const pluginIds = plugins
|
|
.filter((plugin: Plugin) => PLUGIN_PACKAGE_DBS.includes(plugin.packageName))
|
|
.map((plugin: Plugin) => plugin.id);
|
|
const validDataSources: Array<Datasource> = [];
|
|
dataSources.forEach((dataSource: Datasource) => {
|
|
if (pluginIds?.includes(dataSource.pluginId)) {
|
|
validDataSources.push(dataSource);
|
|
}
|
|
});
|
|
if (validDataSources.length) {
|
|
const pageApiNames = actions
|
|
.filter((a: ActionData) => a.config.pageId === pageId)
|
|
.map((a: ActionData) => a.config.name);
|
|
const newQueryName = getNextEntityName("Query", pageApiNames);
|
|
const dataSourceId = validDataSources[0].id;
|
|
let createActionPayload = {
|
|
name: newQueryName,
|
|
pageId,
|
|
datasource: {
|
|
id: dataSourceId,
|
|
},
|
|
eventData: {
|
|
actionType: "Query",
|
|
from: action.payload.from,
|
|
dataSource: validDataSources[0].name,
|
|
},
|
|
actionConfiguration: {},
|
|
};
|
|
|
|
//For onboarding
|
|
const updateActionPayload = yield select(
|
|
checkCurrentStep,
|
|
OnboardingStep.ADD_INPUT_WIDGET,
|
|
);
|
|
if (updateActionPayload) {
|
|
createActionPayload = {
|
|
...createActionPayload,
|
|
name: "add_standup_updates",
|
|
actionConfiguration: {
|
|
body: `Insert into standup_updates("name", "notes") values ('{{appsmith.user.email}}', '{{ Standup_Input.text }}')`,
|
|
},
|
|
};
|
|
}
|
|
|
|
yield put(createActionRequest(createActionPayload));
|
|
} else {
|
|
history.push(
|
|
INTEGRATION_EDITOR_URL(applicationId, pageId, INTEGRATION_TABS.ACTIVE),
|
|
);
|
|
}
|
|
}
|
|
|
|
function* handleApiNameChangeSaga(
|
|
action: ReduxAction<{ id: string; name: string }>,
|
|
) {
|
|
yield put(change(API_EDITOR_FORM_NAME, "name", action.payload.name));
|
|
}
|
|
function* handleApiNameChangeSuccessSaga(
|
|
action: ReduxAction<{ actionId: string }>,
|
|
) {
|
|
const { actionId } = action.payload;
|
|
const actionObj = yield select(getAction, actionId);
|
|
yield take(ReduxActionTypes.FETCH_ACTIONS_FOR_PAGE_SUCCESS);
|
|
if (!actionObj) {
|
|
// Error case, log to sentry
|
|
Toaster.show({
|
|
text: createMessage(ERROR_ACTION_RENAME_FAIL, ""),
|
|
variant: Variant.danger,
|
|
});
|
|
|
|
Sentry.captureException(
|
|
new Error(createMessage(ERROR_ACTION_RENAME_FAIL, "")),
|
|
{
|
|
extra: {
|
|
actionId: actionId,
|
|
},
|
|
},
|
|
);
|
|
return;
|
|
}
|
|
if (actionObj.pluginType === PluginType.API) {
|
|
const params = getQueryParams();
|
|
if (params.editName) {
|
|
params.editName = "false";
|
|
}
|
|
const applicationId = yield select(getCurrentApplicationId);
|
|
const pageId = yield select(getCurrentPageId);
|
|
history.push(API_EDITOR_ID_URL(applicationId, pageId, actionId, params));
|
|
}
|
|
}
|
|
|
|
function* handleApiNameChangeFailureSaga(
|
|
action: ReduxAction<{ oldName: string }>,
|
|
) {
|
|
yield put(change(API_EDITOR_FORM_NAME, "name", action.payload.oldName));
|
|
}
|
|
|
|
export default function* root() {
|
|
yield all([
|
|
takeEvery(ReduxActionTypes.API_PANE_CHANGE_API, changeApiSaga),
|
|
takeEvery(ReduxActionTypes.CREATE_ACTION_SUCCESS, handleActionCreatedSaga),
|
|
takeEvery(
|
|
ReduxActionTypes.CREATE_DATASOURCE_SUCCESS,
|
|
handleDatasourceCreatedSaga,
|
|
),
|
|
takeEvery(ReduxActionTypes.SAVE_ACTION_NAME_INIT, handleApiNameChangeSaga),
|
|
takeEvery(
|
|
ReduxActionTypes.SAVE_ACTION_NAME_SUCCESS,
|
|
handleApiNameChangeSuccessSaga,
|
|
),
|
|
takeEvery(
|
|
ReduxActionErrorTypes.SAVE_ACTION_NAME_ERROR,
|
|
handleApiNameChangeFailureSaga,
|
|
),
|
|
takeEvery(
|
|
ReduxActionTypes.CREATE_NEW_API_ACTION,
|
|
handleCreateNewApiActionSaga,
|
|
),
|
|
takeEvery(
|
|
ReduxActionTypes.CREATE_NEW_QUERY_ACTION,
|
|
handleCreateNewQueryActionSaga,
|
|
),
|
|
takeEvery(
|
|
ReduxActionTypes.UPDATE_API_ACTION_BODY_CONTENT_TYPE,
|
|
handleUpdateBodyContentType,
|
|
),
|
|
takeEvery(
|
|
ReduxActionTypes.REDIRECT_TO_NEW_INTEGRATIONS,
|
|
redirectToNewIntegrations,
|
|
),
|
|
// Intercepting the redux-form change actionType
|
|
takeEvery(ReduxFormActionTypes.VALUE_CHANGE, formValueChangeSaga),
|
|
takeEvery(ReduxFormActionTypes.ARRAY_REMOVE, formValueChangeSaga),
|
|
takeEvery(ReduxFormActionTypes.ARRAY_PUSH, formValueChangeSaga),
|
|
]);
|
|
}
|