2020-01-23 07:53:36 +00:00
|
|
|
import React from "react";
|
2022-06-03 05:07:02 +00:00
|
|
|
import BaseControl, { ControlData, ControlProps } from "./BaseControl";
|
2020-04-20 05:42:46 +00:00
|
|
|
// import DynamicActionCreator from "components/editorComponents/DynamicActionCreator";
|
2021-03-15 12:17:56 +00:00
|
|
|
import { ActionCreator } from "components/editorComponents/ActionCreator";
|
2022-07-14 05:00:30 +00:00
|
|
|
import {
|
|
|
|
|
DSEventDetail,
|
|
|
|
|
DSEventTypes,
|
|
|
|
|
DS_EVENT,
|
|
|
|
|
emitInteractionAnalyticsEvent,
|
|
|
|
|
} from "utils/AppsmithUtils";
|
2020-01-23 07:53:36 +00:00
|
|
|
|
2020-02-18 10:41:52 +00:00
|
|
|
class ActionSelectorControl extends BaseControl<ControlProps> {
|
2022-07-14 05:00:30 +00:00
|
|
|
componentRef = React.createRef<HTMLDivElement>();
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
this.componentRef.current?.addEventListener(
|
|
|
|
|
DS_EVENT,
|
|
|
|
|
this.handleAdsEvent as (arg0: Event) => void,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
|
this.componentRef.current?.removeEventListener(
|
|
|
|
|
DS_EVENT,
|
|
|
|
|
this.handleAdsEvent as (arg0: Event) => void,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleAdsEvent = (e: CustomEvent<DSEventDetail>) => {
|
|
|
|
|
if (
|
|
|
|
|
e.detail.component === "TreeDropdown" &&
|
|
|
|
|
e.detail.event === DSEventTypes.KEYPRESS
|
|
|
|
|
) {
|
|
|
|
|
emitInteractionAnalyticsEvent(this.componentRef.current, {
|
|
|
|
|
key: e.detail.meta.key,
|
|
|
|
|
});
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
handleValueUpdate = (newValue: string, isUpdatedViaKeyboard = false) => {
|
2020-02-18 10:41:52 +00:00
|
|
|
const { propertyName } = this.props;
|
2022-07-14 05:00:30 +00:00
|
|
|
this.updateProperty(propertyName, newValue, isUpdatedViaKeyboard);
|
2020-01-23 07:53:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
2020-02-18 10:41:52 +00:00
|
|
|
const { propertyValue } = this.props;
|
2021-02-19 04:49:54 +00:00
|
|
|
|
2020-01-23 07:53:36 +00:00
|
|
|
return (
|
2020-04-20 05:42:46 +00:00
|
|
|
<ActionCreator
|
2021-04-28 10:28:39 +00:00
|
|
|
additionalAutoComplete={this.props.additionalAutoComplete}
|
2020-02-26 12:44:56 +00:00
|
|
|
onValueChange={this.handleValueUpdate}
|
2022-07-14 05:00:30 +00:00
|
|
|
ref={this.componentRef}
|
2021-04-28 10:28:39 +00:00
|
|
|
value={propertyValue}
|
2020-02-26 12:44:56 +00:00
|
|
|
/>
|
2020-01-23 07:53:36 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-14 05:35:16 +00:00
|
|
|
static getControlType() {
|
2020-01-23 07:53:36 +00:00
|
|
|
return "ACTION_SELECTOR";
|
|
|
|
|
}
|
2022-06-03 05:07:02 +00:00
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
|
static canDisplayValueInUI(config: ControlData, value: any): boolean {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-01-23 07:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
2020-02-18 10:41:52 +00:00
|
|
|
export default ActionSelectorControl;
|