Merge branch 'feature/lightning-menu' of gitlab.com:theappsmith/internal-tools-client into feature/lightning-menu

This commit is contained in:
Abhinav Jha 2020-05-22 15:50:10 +05:30
commit 3ef6edf282
2 changed files with 17 additions and 16 deletions

View File

@ -532,10 +532,12 @@ class DynamicAutocompleteInput extends Component<Props, State> {
}
};
updatePropertyValue(value: string, cursor: number) {
updatePropertyValue(value: string, cursor?: number) {
this.editor.setValue(value);
this.editor.focus();
console.log(value, cursor);
if (cursor === undefined) {
cursor = value.length - 2;
}
this.editor.setCursor({
line: 0,
ch: cursor,

View File

@ -13,7 +13,7 @@ import { mergeWith } from "lodash";
const getApiOptions = (
themeType: string,
apis: RestAction[],
updatePropertyValue: (value: string, cursor: number) => void,
updatePropertyValue: (value: string, cursor?: number) => void,
) => ({
sections: [
{
@ -26,6 +26,7 @@ const getApiOptions = (
icon="plus"
iconAlignment="left"
themeType={themeType}
type="button"
/>
),
},
@ -35,8 +36,7 @@ const getApiOptions = (
options: apis.map(api => ({
content: api.name,
onSelect: () => {
const value = `{{${api.name}.data}}`;
updatePropertyValue(value, value.length + 1);
updatePropertyValue(`{{${api.name}.data}}`);
},
})),
},
@ -52,7 +52,7 @@ const getApiOptions = (
const getQueryOptions = (
themeType: string,
queries: RestAction[],
updatePropertyValue: (value: string, cursor: number) => void,
updatePropertyValue: (value: string, cursor?: number) => void,
) => ({
sections: [
{
@ -65,6 +65,7 @@ const getQueryOptions = (
icon="plus"
iconAlignment="left"
themeType={themeType}
type="button"
/>
),
},
@ -74,8 +75,7 @@ const getQueryOptions = (
options: queries.map(query => ({
content: query.name,
onSelect: () => {
const value = `{{${query.name}.data}}`;
updatePropertyValue(value, value.length + 1);
updatePropertyValue(`{{${query.name}.data}}`);
},
})),
},
@ -91,7 +91,7 @@ const getQueryOptions = (
const getWidgetOptions = (
themeType: string,
widgets: WidgetProps[],
updatePropertyValue: (value: string, cursor: number) => void,
updatePropertyValue: (value: string, cursor?: number) => void,
) => ({
sections: [
{
@ -117,15 +117,14 @@ const getWidgetOptions = (
const getWidgetData = (
themeType: string,
widget: WidgetProps,
updatePropertyValue: (value: string, cursor: number) => void,
updatePropertyValue: (value: string, cursor?: number) => void,
) => ({
sections: [
{
options: Object.keys(widget).map(widgetProp => ({
content: widgetProp,
onSelect: () => {
const value = `{{${widget.widgetName}.${widgetProp}}}`;
updatePropertyValue(value, value.length);
updatePropertyValue(`{{${widget.widgetName}.${widgetProp}}}`);
},
})),
},
@ -143,7 +142,7 @@ const lightningMenuOptions = (
apis: RestAction[],
queries: RestAction[],
widgets: WidgetProps[],
updatePropertyValue: (value: string, cursor: number) => void,
updatePropertyValue: (value: string, cursor?: number) => void,
): CustomizedDropdownProps => ({
sections: [
{
@ -153,7 +152,7 @@ const lightningMenuOptions = (
disabled: false,
shouldCloseDropdown: true,
onSelect: () => {
updatePropertyValue("", 0);
updatePropertyValue("");
},
},
{
@ -188,7 +187,7 @@ const lightningMenuOptions = (
disabled: false,
shouldCloseDropdown: true,
onSelect: () => {
updatePropertyValue("{{}}", 2);
updatePropertyValue("{{}}");
},
},
{
@ -212,7 +211,7 @@ const lightningMenuOptions = (
type LightningMenuProps = {
onSelect?: (value: string) => void;
updatePropertyValue: (value: string, cursor: number) => void;
updatePropertyValue: (value: string, cursor?: number) => void;
themeType: string;
};