diff --git a/app/client/src/api/ApplicationApi.tsx b/app/client/src/api/ApplicationApi.tsx index 143ad094b9..2023d0fdc2 100644 --- a/app/client/src/api/ApplicationApi.tsx +++ b/app/client/src/api/ApplicationApi.tsx @@ -1,7 +1,6 @@ import Api from "./Api"; import { ApiResponse } from "./ApiResponses"; import { AxiosPromise } from "axios"; -import { getUserCurrentOrgId } from "selectors/organizationSelectors"; export interface PublishApplicationRequest { applicationId: string; @@ -24,9 +23,9 @@ export interface ApplicationResponsePayload { pages?: ApplicationPagePayload[]; } -export interface FetchApplicationResponse extends ApiResponse { - data: ApplicationResponsePayload & { pages: ApplicationPagePayload[] }; -} +// export interface FetchApplicationResponse extends ApiResponse { +// data: ApplicationResponsePayload & { pages: ApplicationPagePayload[] }; +// } export interface FetchApplicationsResponse extends ApiResponse { data: Array; diff --git a/app/client/src/components/editorComponents/ApiResponseView.tsx b/app/client/src/components/editorComponents/ApiResponseView.tsx index b5c294d85d..bd6f2b569d 100644 --- a/app/client/src/components/editorComponents/ApiResponseView.tsx +++ b/app/client/src/components/editorComponents/ApiResponseView.tsx @@ -42,50 +42,50 @@ const StatusCodeText = styled(BaseText)<{ code: string }>` props.code.match(/2\d\d/) ? props.theme.colors.primary : Colors.RED}; `; -const TableWrapper = styled.div` - &&& { - table { - table-layout: fixed; - width: 100%; - td { - font-size: 12px; - width: 50%; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - } - } -`; +// const TableWrapper = styled.div` +// &&& { +// table { +// table-layout: fixed; +// width: 100%; +// td { +// font-size: 12px; +// width: 50%; +// white-space: nowrap; +// overflow: hidden; +// text-overflow: ellipsis; +// } +// } +// } +// `; interface ReduxStateProps { responses: Record; isRunning: Record; } -const ResponseHeadersView = (props: { data: Record }) => { - if (!props.data) return
; - return ( - - - - - - - - - - {Object.keys(props.data).map(k => ( - - - - - ))} - -
KeyValue
{k}{props.data[k].join(", ")}
-
- ); -}; +// const ResponseHeadersView = (props: { data: Record }) => { +// if (!props.data) return
; +// return ( +// +// +// +// +// +// +// +// +// +// {Object.keys(props.data).map(k => ( +// +// +// +// +// ))} +// +//
KeyValue
{k}{props.data[k].join(", ")}
+//
+// ); +// }; type Props = ReduxStateProps & RouteComponentProps; diff --git a/app/client/src/components/propertyControls/DatePickerControl.tsx b/app/client/src/components/propertyControls/DatePickerControl.tsx index da96d9abf8..d17df874f0 100644 --- a/app/client/src/components/propertyControls/DatePickerControl.tsx +++ b/app/client/src/components/propertyControls/DatePickerControl.tsx @@ -4,7 +4,7 @@ import { StyledDatePicker } from "./StyledControls"; import moment from "moment-timezone"; import styled from "styled-components"; import { TimePrecision } from "@blueprintjs/datetime"; -import BaseWidget, { WidgetProps } from "widgets/BaseWidget"; +import { WidgetProps } from "widgets/BaseWidget"; const DatePickerControlWrapper = styled.div` display: flex; diff --git a/app/client/src/pages/Applications/CreateApplicationForm.tsx b/app/client/src/pages/Applications/CreateApplicationForm.tsx index aeff2b588e..31e981a03e 100644 --- a/app/client/src/pages/Applications/CreateApplicationForm.tsx +++ b/app/client/src/pages/Applications/CreateApplicationForm.tsx @@ -47,11 +47,8 @@ export const CreateApplicationForm = (props: Props) => { const mapStateToProps = (state: AppState, props: Props): any => { const orgId = props.orgId; - console.log(orgId, " orgId in mapStateToProps"); return { - initialValues: { - orgId: props.orgId, - }, + initialValues: { orgId }, }; }; diff --git a/app/client/src/sagas/ActionSagas.ts b/app/client/src/sagas/ActionSagas.ts index d5d98fc9a6..f859c3c5f0 100644 --- a/app/client/src/sagas/ActionSagas.ts +++ b/app/client/src/sagas/ActionSagas.ts @@ -44,7 +44,6 @@ import { moveActionError, moveActionSuccess, updateActionSuccess, - updateApiNameDraft, fetchActionsForPage, } from "actions/actionActions"; import { @@ -77,8 +76,7 @@ import { ToastType } from "react-toastify"; import AnalyticsUtil from "utils/AnalyticsUtil"; import * as log from "loglevel"; import { QUERY_CONSTANT } from "constants/QueryEditorConstants"; -import { RestAction } from "entities/Action"; -import { validateEntityName } from "components/editorComponents/EntityNameComponent"; +import { Action, RestAction } from "entities/Action"; import { ActionData } from "reducers/entityReducers/actionsReducer"; import { getActions } from "selectors/entitiesSelector"; @@ -549,6 +547,18 @@ export function* deleteActionSaga( } } +export function extractBindingsFromAction(action: Action) { + const bindings: string[] = []; + action.dynamicBindingPathList.forEach(a => { + const value = _.get(action, a.key); + if (isDynamicValue(value)) { + const { jsSnippets } = getDynamicBindings(value); + bindings.push(...jsSnippets.filter(jsSnippet => !!jsSnippet)); + } + }); + return bindings; +} + export function* runApiActionSaga( reduxAction: ReduxAction<{ id: string; @@ -574,15 +584,7 @@ export function* runApiActionSaga( } if (dirty) { action = _.omit(transformRestAction(values), "id") as RestAction; - - const actionString = JSON.stringify(action); - if (isDynamicValue(actionString)) { - const { jsSnippets } = getDynamicBindings(actionString); - // Replace cause the existing keys could have been updated - jsonPathKeys = jsSnippets.filter(jsSnippet => !!jsSnippet); - } else { - jsonPathKeys = []; - } + jsonPathKeys = extractBindingsFromAction(action as RestAction); } const { paginationField } = reduxAction.payload; diff --git a/app/client/src/sagas/CurlImportSagas.ts b/app/client/src/sagas/CurlImportSagas.ts index 1e7090c90d..5d85caeca6 100644 --- a/app/client/src/sagas/CurlImportSagas.ts +++ b/app/client/src/sagas/CurlImportSagas.ts @@ -16,15 +16,13 @@ import { fetchActions } from "actions/actionActions"; import { CURL } from "constants/ApiConstants"; import { changeApi } from "actions/apiPaneActions"; import { getCurrentOrgId } from "selectors/organizationSelectors"; +import transformCurlImport from "transformers/CurlImportTransformer"; export function* curlImportSaga(action: ReduxAction) { const { type, pageId, name } = action.payload; let { curl } = action.payload; try { - // Transform to add quotes if not present - curl = `${curl.charAt(0) !== '"' ? '"' : ""}${curl}${ - curl.charAt(curl.length - 1) !== '"' ? '"' : "" - }`; + curl = transformCurlImport(curl); const organizationId = yield select(getCurrentOrgId); const request: CurlImportRequest = { type, diff --git a/app/client/src/sagas/QueryPaneSagas.ts b/app/client/src/sagas/QueryPaneSagas.ts index 2cec2a5140..a1edcc8503 100644 --- a/app/client/src/sagas/QueryPaneSagas.ts +++ b/app/client/src/sagas/QueryPaneSagas.ts @@ -27,7 +27,12 @@ import { getCurrentPageId, } from "selectors/editorSelectors"; import { change, initialize } from "redux-form"; -import { getAction, getActionParams, getActionTimeout } from "./ActionSagas"; +import { + extractBindingsFromAction, + getAction, + getActionParams, + getActionTimeout, +} from "./ActionSagas"; import { AppState } from "reducers"; import ActionAPI, { PaginationField, @@ -40,12 +45,12 @@ import { changeQuery, deleteQuerySuccess } from "actions/queryPaneActions"; import { AppToaster } from "components/editorComponents/ToastComponent"; import { ToastType } from "react-toastify"; import { PageAction } from "constants/ActionConstants"; -import { isDynamicValue, getDynamicBindings } from "utils/DynamicBindingUtils"; +import { isDynamicValue } from "utils/DynamicBindingUtils"; import AnalyticsUtil from "utils/AnalyticsUtil"; import { GenericApiResponse } from "api/ApiResponses"; import { validateResponse } from "./ErrorSagas"; import { getQueryName } from "selectors/entitiesSelector"; -import { RestAction } from "entities/Action"; +import { QueryAction, RestAction } from "entities/Action"; const getQueryDraft = (state: AppState, id: string) => { const drafts = state.entities.actionDrafts; @@ -146,7 +151,6 @@ function* updateDynamicBindingsSaga( const isDynamic = isDynamicValue(value); let dynamicBindings: Property[] = values.dynamicBindingPathList || []; - console.log({ field, value, isDynamic, dynamicBindings }); const fieldExists = _.some(dynamicBindings, { key: field }); if (!isDynamic && fieldExists) { @@ -214,7 +218,7 @@ function* handleMoveOrCopySaga(actionPayload: ReduxAction<{ id: string }>) { export function* executeQuerySaga( actionPayload: ReduxAction<{ - action: RestAction; + action: QueryAction; actionId: string; paginationField: PaginationField; }>, @@ -224,7 +228,7 @@ export function* executeQuerySaga( values, dirty, }: { - values: RestAction; + values: QueryAction; dirty: boolean; valid: boolean; } = yield select(getFormData, QUERY_EDITOR_FORM_NAME); @@ -233,16 +237,8 @@ export function* executeQuerySaga( let jsonPathKeys = actionObject.jsonPathKeys; if (dirty) { - action = _.omit(values, "id") as RestAction; - - const actionString = JSON.stringify(action); - if (isDynamicValue(actionString)) { - const { jsSnippets } = getDynamicBindings(actionString); - // Replace cause the existing keys could have been updated - jsonPathKeys = jsSnippets.filter(jsSnippet => !!jsSnippet); - } else { - jsonPathKeys = []; - } + action = _.omit(values, "id") as QueryAction; + jsonPathKeys = extractBindingsFromAction(action as QueryAction); } const { paginationField } = actionPayload.payload; diff --git a/app/client/src/selectors/dataTreeSelectors.ts b/app/client/src/selectors/dataTreeSelectors.ts index a3d4450d74..ee05562d9c 100644 --- a/app/client/src/selectors/dataTreeSelectors.ts +++ b/app/client/src/selectors/dataTreeSelectors.ts @@ -7,7 +7,6 @@ import { getWidgets, getWidgetsMeta } from "sagas/selectors"; import * as log from "loglevel"; import "url-search-params-polyfill"; import { getPageList } from "./appViewSelectors"; -import _ from "lodash"; // TODO Commenting out for now as it is causing performance issues // function getQueryParams() { diff --git a/app/client/src/transformers/CurlImportTransformer.test.ts b/app/client/src/transformers/CurlImportTransformer.test.ts new file mode 100644 index 0000000000..294b41fe23 --- /dev/null +++ b/app/client/src/transformers/CurlImportTransformer.test.ts @@ -0,0 +1,22 @@ +import transformCurlImport from "transformers/CurlImportTransformer"; + +describe("CurlImportTransformer", () => { + it("has quotes in start and end and escapes special characters", () => { + const inputs = [ + `curl -X GET`, + `"curl -X GET`, + `curl -X GET"`, + `curl google.com\n`, + ]; + const outputs = [ + `"curl -X GET"`, + `"\\"curl -X GET"`, + `"curl -X GET\\""`, + `"curl google.com\\n"`, + ]; + inputs.forEach((input, index) => { + const result = transformCurlImport(input); + expect(result).toBe(outputs[index]); + }); + }); +}); diff --git a/app/client/src/transformers/CurlImportTransformer.ts b/app/client/src/transformers/CurlImportTransformer.ts new file mode 100644 index 0000000000..10ed0a72b0 --- /dev/null +++ b/app/client/src/transformers/CurlImportTransformer.ts @@ -0,0 +1,3 @@ +export default (curlString: string): string => { + return JSON.stringify(curlString); +}; diff --git a/app/client/src/utils/Validators.ts b/app/client/src/utils/Validators.ts index 943f0aa1b0..3a1568c709 100644 --- a/app/client/src/utils/Validators.ts +++ b/app/client/src/utils/Validators.ts @@ -400,7 +400,7 @@ export const VALIDATORS: Record = { .second(0) .millisecond(0); const dateFormat = props.dateFormat ? props.dateFormat : moment.ISO_8601; - const dateStr = moment().toISOString(); + // const dateStr = moment().toISOString(); const todayDateString = today.format(dateFormat); if (dateString === undefined) { return { diff --git a/app/client/src/widgets/DropdownWidget.tsx b/app/client/src/widgets/DropdownWidget.tsx index 059ff397b8..2bdf96332a 100644 --- a/app/client/src/widgets/DropdownWidget.tsx +++ b/app/client/src/widgets/DropdownWidget.tsx @@ -135,7 +135,6 @@ class DropdownWidget extends BaseWidget { selectedOption.value, ); } else if (this.props.selectionType === "MULTI_SELECT") { - console.log(this.props, selectedOption); const isAlreadySelected = this.props.selectedOptionValueArr.includes( selectedOption.value, ); diff --git a/app/client/yarn.lock b/app/client/yarn.lock index 41caf46f46..515d35d1f2 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -13378,10 +13378,6 @@ schema-utils@^2.0.1, schema-utils@^2.5.0, schema-utils@^2.6.0, schema-utils@^2.6 ajv "^6.10.2" ajv-keywords "^3.4.1" -screenfull@^5.0.2: - version "5.0.2" - resolved "https://registry.yarnpkg.com/screenfull/-/screenfull-5.0.2.tgz#b9acdcf1ec676a948674df5cd0ff66b902b0bed7" - scriptjs@^2.5.8: version "2.5.9" resolved "https://registry.yarnpkg.com/scriptjs/-/scriptjs-2.5.9.tgz#343915cd2ec2ed9bfdde2b9875cd28f59394b35f"