From dff9c60f9f75978d407c35cfaaca21b2c3eac7d1 Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Mon, 8 Jun 2020 16:39:13 +0530 Subject: [PATCH 01/13] fixed resize handles size fixed body for url encoded form data added defaults for dropdown and radio widget added multipart type but hid it till we figure out logic allowed number to be added to defaults of widgets --- .../DynamicAutocompleteInput.tsx | 10 +++++ .../ResizeStyledComponents.tsx | 2 +- .../src/constants/ApiEditorConstants.ts | 26 ++++++++---- .../PropertyPaneConfigResponse.tsx | 2 +- .../mockResponses/WidgetConfigResponse.tsx | 11 +++-- .../pages/Editor/APIEditor/PostBodyData.tsx | 41 +++++++++++-------- .../Editor/APIEditor/RapidApiEditorForm.tsx | 2 +- app/client/src/sagas/ApiPaneSagas.ts | 36 +--------------- .../src/transformers/RestActionTransformer.ts | 17 ++++---- app/client/src/widgets/FilepickerWidget.tsx | 6 +-- 10 files changed, 75 insertions(+), 78 deletions(-) diff --git a/app/client/src/components/editorComponents/DynamicAutocompleteInput.tsx b/app/client/src/components/editorComponents/DynamicAutocompleteInput.tsx index dfac98dcef..503c1ce12c 100644 --- a/app/client/src/components/editorComponents/DynamicAutocompleteInput.tsx +++ b/app/client/src/components/editorComponents/DynamicAutocompleteInput.tsx @@ -337,6 +337,11 @@ class DynamicAutocompleteInput extends Component { let inputValue = this.props.input.value || ""; if (typeof inputValue === "object") { inputValue = JSON.stringify(inputValue, null, 2); + } else if ( + typeof inputValue === "number" || + typeof inputValue === "string" + ) { + inputValue += ""; } this.editor.setValue(inputValue); this.startAutocomplete(); @@ -353,6 +358,11 @@ class DynamicAutocompleteInput extends Component { // Safe update of value of the editor when value updated outside the editor if (typeof inputValue === "object") { inputValue = JSON.stringify(inputValue, null, 2); + } else if ( + typeof inputValue === "number" || + typeof inputValue === "string" + ) { + inputValue += ""; } if ((!!inputValue || inputValue === "") && inputValue !== editorValue) { this.editor.setValue(inputValue); diff --git a/app/client/src/components/editorComponents/ResizeStyledComponents.tsx b/app/client/src/components/editorComponents/ResizeStyledComponents.tsx index 32382ca63d..be73e16c29 100644 --- a/app/client/src/components/editorComponents/ResizeStyledComponents.tsx +++ b/app/client/src/components/editorComponents/ResizeStyledComponents.tsx @@ -3,7 +3,7 @@ import { WIDGET_PADDING } from "constants/WidgetConstants"; import styled, { css } from "styled-components"; const EDGE_RESIZE_HANDLE_WIDTH = 10; -const CORNER_RESIZE_HANDLE_WIDTH = 40; +const CORNER_RESIZE_HANDLE_WIDTH = 10; export const VisibilityContainer = styled.div<{ visible: boolean; diff --git a/app/client/src/constants/ApiEditorConstants.ts b/app/client/src/constants/ApiEditorConstants.ts index 81be4b197b..9994706282 100644 --- a/app/client/src/constants/ApiEditorConstants.ts +++ b/app/client/src/constants/ApiEditorConstants.ts @@ -26,13 +26,23 @@ export const DEFAULT_API_ACTION: Partial = { export const API_CONSTANT = "API"; export const DEFAULT_PROVIDER_OPTION = "Business Software"; export const CONTENT_TYPE = "content-type"; -export const POST_BODY_FORMATS = [ - "application/json", - "application/x-www-form-urlencoded", - "raw", + +export const POST_BODY_FORMAT_OPTIONS = [ + { label: "json", value: "application/json" }, + { + label: "x-www-form-urlencoded", + value: "application/x-www-form-urlencoded", + }, + { label: "form-data", value: "multipart/form-data" }, + { label: "raw", value: "raw" }, ]; -export const POST_BODY_FORMAT_OPTIONS = POST_BODY_FORMATS.map(method => ({ - label: method, - value: method, -})); +export const POST_BODY_FORMAT_OPTIONS_NO_MULTI_PART = POST_BODY_FORMAT_OPTIONS.filter( + option => { + return option.value !== "multipart/form-data"; + }, +); + +export const POST_BODY_FORMATS = POST_BODY_FORMAT_OPTIONS.map(option => { + return option.value; +}); diff --git a/app/client/src/mockResponses/PropertyPaneConfigResponse.tsx b/app/client/src/mockResponses/PropertyPaneConfigResponse.tsx index 24d2fc3d3a..87209f2cc4 100644 --- a/app/client/src/mockResponses/PropertyPaneConfigResponse.tsx +++ b/app/client/src/mockResponses/PropertyPaneConfigResponse.tsx @@ -952,7 +952,7 @@ const PropertyPaneConfigResponse = { }, { id: "11.1.7", - propertyName: "uploadedFileUrls", + propertyName: "uploadedFileUrlPaths", helpText: "Stores the url of the uploaded file so that it can be referenced in an action later", label: "Uploaded File URLs", diff --git a/app/client/src/mockResponses/WidgetConfigResponse.tsx b/app/client/src/mockResponses/WidgetConfigResponse.tsx index 69dbfc74f3..df3917c06a 100644 --- a/app/client/src/mockResponses/WidgetConfigResponse.tsx +++ b/app/client/src/mockResponses/WidgetConfigResponse.tsx @@ -131,6 +131,7 @@ const WidgetConfigResponse: WidgetConfigReducerState = { { label: "Vegan", value: "VEGAN" }, ], widgetName: "Dropdown", + defaultOptionValue: "VEG", }, CHECKBOX_WIDGET: { rows: 1, @@ -147,7 +148,7 @@ const WidgetConfigResponse: WidgetConfigReducerState = { { id: "1", label: "Male", value: "M" }, { id: "2", label: "Female", value: "F" }, ], - defaultOptionValue: "1", + defaultOptionValue: "M", widgetName: "RadioGroup", }, ALERT_WIDGET: { @@ -164,6 +165,8 @@ const WidgetConfigResponse: WidgetConfigReducerState = { files: [], label: "Select Files", columns: 4, + maxNumFiles: 1, + maxFileSize: 5, widgetName: "FilePicker", isDefaultClickDisabled: true, }, @@ -233,8 +236,8 @@ const WidgetConfigResponse: WidgetConfigReducerState = { view: [ { type: "ICON_WIDGET", - position: { left: 15, top: 0 }, - size: { rows: 1, cols: 1 }, + position: { left: 14, top: 0 }, + size: { rows: 1, cols: 2 }, props: { iconName: "cross", iconSize: 24, @@ -244,7 +247,7 @@ const WidgetConfigResponse: WidgetConfigReducerState = { { type: "TEXT_WIDGET", position: { left: 0, top: 0 }, - size: { rows: 1, cols: 15 }, + size: { rows: 1, cols: 10 }, props: { text: "Modal Title", textStyle: "HEADING", diff --git a/app/client/src/pages/Editor/APIEditor/PostBodyData.tsx b/app/client/src/pages/Editor/APIEditor/PostBodyData.tsx index 6a5040f255..a00a3aa7bc 100644 --- a/app/client/src/pages/Editor/APIEditor/PostBodyData.tsx +++ b/app/client/src/pages/Editor/APIEditor/PostBodyData.tsx @@ -7,6 +7,7 @@ import { POST_BODY_FORMAT_OPTIONS, POST_BODY_FORMATS, CONTENT_TYPE, + POST_BODY_FORMAT_OPTIONS_NO_MULTI_PART, } from "constants/ApiEditorConstants"; import { API_EDITOR_FORM_NAME } from "constants/forms"; import FormLabel from "components/editorComponents/FormLabel"; @@ -59,7 +60,7 @@ const PostBodyData = (props: Props) => { } = props; return ( - {"Post Body"} + {"Body"}