From a0b536ecedabb999daa7a1463525ce97d131c8aa Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Fri, 25 Oct 2019 05:35:20 +0000 Subject: [PATCH] Fixes for the API Editor #109 #112 #111 #116 --- app/client/package.json | 2 +- app/client/src/actions/actionActions.ts | 51 ++++++--- app/client/src/assets/icons/form/add-new.svg | 3 + .../components/canvas/CreatableDropdown.tsx | 1 - app/client/src/components/canvas/Dropdown.tsx | 6 +- .../src/components/canvas/TabbedView.tsx | 43 +++---- .../components/canvas/TextInputComponent.tsx | 2 +- .../src/components/editor/ApiResponseView.tsx | 106 ++++++++++++++++++ .../src/components/editor/JSONEditor.tsx | 3 +- .../src/components/editor/JSONViewer.tsx | 8 +- app/client/src/components/editor/Sidebar.tsx | 2 +- .../src/components/fields/DropdownField.tsx | 2 + .../src/components/fields/ResourcesField.tsx | 1 + .../src/components/forms/ApiEditorForm.tsx | 82 +++++--------- .../src/constants/ApiEditorConstants.ts | 9 +- app/client/src/constants/DefaultTheme.tsx | 2 +- .../src/constants/ReduxActionConstants.tsx | 11 +- app/client/src/icons/FormIcons.tsx | 6 + app/client/src/index.tsx | 7 +- .../src/normalizers/ApiFormNormalizer.ts | 15 +++ app/client/src/pages/Editor/ApiEditor.tsx | 21 ++-- app/client/src/pages/Editor/ApiSidebar.tsx | 88 ++++++++++++--- .../entityReducers/actionsReducer.tsx | 73 ++++++++---- app/client/src/sagas/ActionSagas.ts | 37 ++++-- app/client/src/sagas/ResourcesSagas.ts | 3 +- app/client/src/utils/history.ts | 2 + app/client/yarn.lock | 2 +- 27 files changed, 410 insertions(+), 178 deletions(-) create mode 100644 app/client/src/assets/icons/form/add-new.svg create mode 100644 app/client/src/components/editor/ApiResponseView.tsx create mode 100644 app/client/src/normalizers/ApiFormNormalizer.ts create mode 100644 app/client/src/utils/history.ts diff --git a/app/client/package.json b/app/client/package.json index 095aaed2be..3206ad5a25 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -28,6 +28,7 @@ "eslint": "^6.4.0", "flow-bin": "^0.91.0", "fontfaceobserver": "^2.1.0", + "history": "^4.10.1", "husky": "^3.0.5", "jsonpath-plus": "^1.0.0", "lint-staged": "^9.2.5", @@ -53,7 +54,6 @@ "react-router-dom": "^5.0.1", "react-scripts": "^3.1.1", "react-select": "^3.0.8", - "react-tabs": "^3.0.0", "redux": "^4.0.1", "redux-form": "^8.2.6", "redux-saga": "^1.0.0", diff --git a/app/client/src/actions/actionActions.ts b/app/client/src/actions/actionActions.ts index f4f553b97c..a59a73d6d6 100644 --- a/app/client/src/actions/actionActions.ts +++ b/app/client/src/actions/actionActions.ts @@ -3,7 +3,14 @@ import { RestAction } from "../api/ActionAPI"; export const createAction = (payload: RestAction) => { return { - type: ReduxActionTypes.CREATE_ACTION, + type: ReduxActionTypes.CREATE_ACTION_INIT, + payload, + }; +}; + +export const createActionSuccess = (payload: RestAction) => { + return { + type: ReduxActionTypes.CREATE_ACTION_SUCCESS, payload, }; }; @@ -14,13 +21,6 @@ export const fetchActions = () => { }; }; -export const selectAction = (payload: { id: string }) => { - return { - type: ReduxActionTypes.SELECT_ACTION, - payload, - }; -}; - export const fetchApiConfig = (payload: { id: string }) => { return { type: ReduxActionTypes.FETCH_ACTION, @@ -30,21 +30,35 @@ export const fetchApiConfig = (payload: { id: string }) => { export const runAction = (payload: { id: string }) => { return { - type: ReduxActionTypes.RUN_ACTION, - payload, - }; -}; - -export const deleteAction = (payload: { id: string }) => { - return { - type: ReduxActionTypes.DELETE_ACTION, + type: ReduxActionTypes.RUN_ACTION_INIT, payload, }; }; export const updateAction = (payload: { data: RestAction }) => { return { - type: ReduxActionTypes.UPDATE_ACTION, + type: ReduxActionTypes.UPDATE_ACTION_INIT, + payload, + }; +}; + +export const updateActionSuccess = (payload: { data: RestAction }) => { + return { + type: ReduxActionTypes.UPDATE_ACTION_SUCCESS, + payload, + }; +}; + +export const deleteAction = (payload: { id: string }) => { + return { + type: ReduxActionTypes.DELETE_ACTION_INIT, + payload, + }; +}; + +export const deleteActionSuccess = (payload: { id: string }) => { + return { + type: ReduxActionTypes.DELETE_ACTION_SUCCESS, payload, }; }; @@ -55,4 +69,7 @@ export default { fetchApiConfig, runAction, deleteAction, + deleteActionSuccess, + updateAction, + updateActionSuccess, }; diff --git a/app/client/src/assets/icons/form/add-new.svg b/app/client/src/assets/icons/form/add-new.svg new file mode 100644 index 0000000000..6edbd99663 --- /dev/null +++ b/app/client/src/assets/icons/form/add-new.svg @@ -0,0 +1,3 @@ + + + diff --git a/app/client/src/components/canvas/CreatableDropdown.tsx b/app/client/src/components/canvas/CreatableDropdown.tsx index 59349221e0..98a698fb7b 100644 --- a/app/client/src/components/canvas/CreatableDropdown.tsx +++ b/app/client/src/components/canvas/CreatableDropdown.tsx @@ -38,7 +38,6 @@ class CreatableDropdown extends React.Component { onCreateOption={onCreateOption} {...input} onChange={value => input.onChange(value)} - onBlur={() => input.onBlur(input.value)} /> ); } diff --git a/app/client/src/components/canvas/Dropdown.tsx b/app/client/src/components/canvas/Dropdown.tsx index 5deeb69785..245825f15c 100644 --- a/app/client/src/components/canvas/Dropdown.tsx +++ b/app/client/src/components/canvas/Dropdown.tsx @@ -8,12 +8,13 @@ type DropdownProps = { label: string; }>; input: WrappedFieldInputProps; + placeholder: string; }; const selectStyles = { control: (styles: any) => ({ ...styles, - width: 100, + width: 120, }), }; @@ -21,12 +22,11 @@ export const BaseDropdown = (props: DropdownProps) => { const { input, options } = props; return (