From 06de06c11fa68f0e4a878f7f04cff6b5027d97fe Mon Sep 17 00:00:00 2001 From: Ayush Pahwa Date: Mon, 12 Jul 2021 13:22:27 +0530 Subject: [PATCH] Improved label, updating navigateTo default prams when action type is changed to navigateTo in JS actions (#5532) * Updating navigateTo default prams when action type is changed to navigateTo * Gave default value to url, made the query params defaault to empty object rather than the empty curly braces with single quotes --- .../editorComponents/ActionCreator/Fields.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/client/src/components/editorComponents/ActionCreator/Fields.tsx b/app/client/src/components/editorComponents/ActionCreator/Fields.tsx index 29884f65fb..7a9d0f8a35 100644 --- a/app/client/src/components/editorComponents/ActionCreator/Fields.tsx +++ b/app/client/src/components/editorComponents/ActionCreator/Fields.tsx @@ -350,14 +350,18 @@ const fieldConfigs: FieldConfigs = { setter: (option: TreeDropdownOption) => { const type: ActionType = option.type || option.value; let value = option.value; + let defaultParams = ""; switch (type) { case ActionType.integration: value = `${value}.run`; break; + case ActionType.navigateTo: + defaultParams = `'#', {}`; + break; default: break; } - return value === "none" ? "" : `{{${value}()}}`; + return value === "none" ? "" : `{{${value}(${defaultParams})}}`; }, view: ViewTypes.SELECTOR_VIEW, }, @@ -456,6 +460,9 @@ const fieldConfigs: FieldConfigs = { return textGetter(value, 1); }, setter: (value: any, currentValue: string) => { + if (value === "") { + value = undefined; + } return textSetter(value, currentValue, 1); }, view: ViewTypes.TEXT_VIEW, @@ -621,7 +628,7 @@ function renderField(props: { if (fieldType === FieldType.NAVIGATION_TARGET_FIELD) { label = "Target"; options = NAVIGATION_TARGET_FIELD_OPTIONS; - defaultText = "Navigation target"; + defaultText = NAVIGATION_TARGET_FIELD_OPTIONS[0].label; } viewElement = (view as (props: SelectorViewProps) => JSX.Element)({ options: options, @@ -667,7 +674,7 @@ function renderField(props: { if (fieldType === FieldType.ALERT_TEXT_FIELD) { fieldLabel = "Message"; } else if (fieldType === FieldType.URL_FIELD) { - fieldLabel = "Page Name"; + fieldLabel = "Page Name or URL"; } else if (fieldType === FieldType.KEY_TEXT_FIELD) { fieldLabel = "Key"; } else if (fieldType === FieldType.VALUE_TEXT_FIELD) {