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
This commit is contained in:
Ayush Pahwa 2021-07-12 13:22:27 +05:30 committed by GitHub
parent 2dba1558e6
commit 06de06c11f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {