2020-08-20 06:23:25 +00:00
|
|
|
import { takeLatest, put, all, select } from "redux-saga/effects";
|
2020-04-14 12:34:14 +00:00
|
|
|
import {
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
ReduxActionErrorTypes,
|
|
|
|
|
ReduxAction,
|
|
|
|
|
} from "constants/ReduxActionConstants";
|
|
|
|
|
import { validateResponse } from "sagas/ErrorSagas";
|
|
|
|
|
import CurlImportApi, { CurlImportRequest } from "api/ImportApi";
|
|
|
|
|
import { ApiResponse } from "api/ApiResponses";
|
2020-05-05 07:50:30 +00:00
|
|
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
2021-03-13 14:24:45 +00:00
|
|
|
import { createMessage, CURL_IMPORT_SUCCESS } from "constants/messages";
|
2020-06-03 05:40:48 +00:00
|
|
|
import { getCurrentApplicationId } from "selectors/editorSelectors";
|
2020-06-17 10:19:56 +00:00
|
|
|
import { getCurrentOrgId } from "selectors/organizationSelectors";
|
2020-06-25 10:04:57 +00:00
|
|
|
import transformCurlImport from "transformers/CurlImportTransformer";
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
import { API_EDITOR_ID_URL } from "constants/routes";
|
|
|
|
|
import history from "utils/history";
|
2020-11-24 07:01:37 +00:00
|
|
|
import { Toaster } from "components/ads/Toast";
|
|
|
|
|
import { Variant } from "components/ads/common";
|
2021-03-30 05:29:03 +00:00
|
|
|
import { CURL } from "constants/AppsmithActionConstants/ActionConstants";
|
2020-04-14 12:34:14 +00:00
|
|
|
|
|
|
|
|
export function* curlImportSaga(action: ReduxAction<CurlImportRequest>) {
|
2021-05-13 08:35:39 +00:00
|
|
|
const { name, pageId, type } = action.payload;
|
2020-04-14 12:34:14 +00:00
|
|
|
let { curl } = action.payload;
|
|
|
|
|
try {
|
2020-06-25 10:04:57 +00:00
|
|
|
curl = transformCurlImport(curl);
|
2020-06-17 10:19:56 +00:00
|
|
|
const organizationId = yield select(getCurrentOrgId);
|
|
|
|
|
const request: CurlImportRequest = {
|
|
|
|
|
type,
|
|
|
|
|
pageId,
|
|
|
|
|
name,
|
|
|
|
|
curl,
|
|
|
|
|
organizationId,
|
|
|
|
|
};
|
2020-04-14 12:34:14 +00:00
|
|
|
|
|
|
|
|
const response: ApiResponse = yield CurlImportApi.curlImport(request);
|
|
|
|
|
const isValidResponse = yield validateResponse(response);
|
|
|
|
|
const applicationId = yield select(getCurrentApplicationId);
|
|
|
|
|
|
|
|
|
|
if (isValidResponse) {
|
2020-05-05 07:50:30 +00:00
|
|
|
AnalyticsUtil.logEvent("IMPORT_API", {
|
|
|
|
|
importSource: CURL,
|
|
|
|
|
});
|
2020-06-03 05:40:48 +00:00
|
|
|
|
2020-11-24 07:01:37 +00:00
|
|
|
Toaster.show({
|
2021-03-13 14:24:45 +00:00
|
|
|
text: createMessage(CURL_IMPORT_SUCCESS),
|
2020-11-24 07:01:37 +00:00
|
|
|
variant: Variant.success,
|
2020-04-14 12:34:14 +00:00
|
|
|
});
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.SUBMIT_CURL_FORM_SUCCESS,
|
|
|
|
|
payload: response.data,
|
|
|
|
|
});
|
2020-06-03 05:40:48 +00:00
|
|
|
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
history.push(API_EDITOR_ID_URL(applicationId, pageId, response.data.id));
|
2020-04-14 12:34:14 +00:00
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.SUBMIT_CURL_FORM_ERROR,
|
|
|
|
|
payload: {
|
|
|
|
|
error,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function* curlImportSagas() {
|
|
|
|
|
yield all([
|
|
|
|
|
takeLatest(ReduxActionTypes.SUBMIT_CURL_FORM_INIT, curlImportSaga),
|
|
|
|
|
]);
|
|
|
|
|
}
|