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,
|
2022-04-12 10:50:01 +00:00
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
2020-04-14 12:34:14 +00:00
|
|
|
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";
|
2022-06-15 15:37:41 +00:00
|
|
|
import { getCurrentWorkspaceId } from "@appsmith/selectors/workspaceSelectors";
|
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 history from "utils/history";
|
2021-03-30 05:29:03 +00:00
|
|
|
import { CURL } from "constants/AppsmithActionConstants/ActionConstants";
|
2022-03-25 10:43:26 +00:00
|
|
|
import { apiEditorIdURL } from "RouteBuilder";
|
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);
|
2022-06-15 15:37:41 +00:00
|
|
|
const workspaceId: string = yield select(getCurrentWorkspaceId);
|
2020-06-17 10:19:56 +00:00
|
|
|
const request: CurlImportRequest = {
|
|
|
|
|
type,
|
|
|
|
|
pageId,
|
|
|
|
|
name,
|
|
|
|
|
curl,
|
2022-06-15 15:37:41 +00:00
|
|
|
workspaceId,
|
2020-06-17 10:19:56 +00:00
|
|
|
};
|
2020-04-14 12:34:14 +00:00
|
|
|
|
|
|
|
|
const response: ApiResponse = yield CurlImportApi.curlImport(request);
|
2022-03-25 10:43:26 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2020-04-14 12:34:14 +00:00
|
|
|
|
|
|
|
|
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-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
|
|
|
|
2022-06-21 13:57:34 +00:00
|
|
|
// @ts-expect-error: response.data is of type unknown
|
2022-03-25 10:43:26 +00:00
|
|
|
history.push(apiEditorIdURL({ pageId, apiId: 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),
|
|
|
|
|
]);
|
|
|
|
|
}
|