From 4584d4269061acb42230780c8e33fe5aeb038ca9 Mon Sep 17 00:00:00 2001 From: Chandaluri Vamsi Krishna Date: Fri, 16 Aug 2024 19:40:49 +0530 Subject: [PATCH 1/4] fix: loading specific event handler on click Signed-off-by: Chandaluri Vamsi Krishna --- .../src/Editor/Inspector/EventManager.jsx | 99 ++++++++++--------- 1 file changed, 55 insertions(+), 44 deletions(-) diff --git a/frontend/src/Editor/Inspector/EventManager.jsx b/frontend/src/Editor/Inspector/EventManager.jsx index a1321a846d..a5ea03795f 100644 --- a/frontend/src/Editor/Inspector/EventManager.jsx +++ b/frontend/src/Editor/Inspector/EventManager.jsx @@ -85,6 +85,7 @@ export const EventManager = ({ const [events, setEvents] = useState([]); const [focusedEventIndex, setFocusedEventIndex] = useState(null); + const [loadingStates, setLoadingStates] = useState({}); const { t } = useTranslation(); @@ -353,7 +354,8 @@ export const EventManager = ({ } function addHandler() { - let newEvents = events; + setLoadingStates((prev) => ({ ...prev, [sourceId]: true })); + let newEvents = [...events]; const eventIndex = newEvents.length; createAppVersionEventHandlers({ event: { @@ -366,9 +368,13 @@ export const EventManager = ({ eventType: eventSourceType, attachedTo: sourceId, index: eventIndex, - }); - - handleYmapEventUpdates(); + }) + .then(() => { + handleYmapEventUpdates(); + }) + .finally(() => { + setLoadingStates((prev) => ({ ...prev, [sourceId]: false })); + }); } //following two are functions responsible for on change and value for the control specific actions @@ -414,7 +420,7 @@ export const EventManager = ({ }} >
-
+
{t('editor.inspector.eventManager.event', 'Event')}
@@ -431,8 +437,8 @@ export const EventManager = ({ />
-
-
+
+
{t('editor.inspector.eventManager.action', 'Action')}
@@ -450,8 +456,8 @@ export const EventManager = ({
-
-
+
+
{t('editor.inspector.eventManager.runOnlyIf', 'Run Only If')}
@@ -474,7 +480,7 @@ export const EventManager = ({ {event.actionId === 'show-alert' && ( <>
-
+
{t('editor.inspector.eventManager.message', 'Message')}
@@ -488,8 +494,8 @@ export const EventManager = ({ />
-
-
+
+
{t('editor.inspector.eventManager.alertType', 'Alert Type')}
@@ -511,7 +517,7 @@ export const EventManager = ({ {event.actionId === 'open-webpage' && (
- + -
{t('editor.inspector.eventManager.modal', 'Modal')}
+
{t('editor.inspector.eventManager.modal', 'Modal')}
- +
-
{t('editor.inspector.eventManager.query', 'Query')}
+
{t('editor.inspector.eventManager.query', 'Query')}
-
-
{t('editor.inspector.eventManager.fileName', 'File name')}
+
+
{t('editor.inspector.eventManager.fileName', 'File name')}
-
-
{t('editor.inspector.eventManager.data', 'Data')}
+
+
{t('editor.inspector.eventManager.data', 'Data')}
-
{t('editor.inspector.eventManager.table', 'Table')}
+
{t('editor.inspector.eventManager.table', 'Table')}
-
{t('editor.inspector.eventManager.modal', 'Modal')}
+
{t('editor.inspector.eventManager.modal', 'Modal')}
-
{t('editor.inspector.eventManager.key', 'Key')}
+
{t('editor.inspector.eventManager.key', 'Key')}
-
-
{t('editor.inspector.eventManager.value', 'Value')}
+
+
{t('editor.inspector.eventManager.value', 'Value')}
-
{t('editor.inspector.eventManager.type', 'Type')}
+
{t('editor.inspector.eventManager.type', 'Type')}
-
-
{t('editor.inspector.eventManager.pageIndex', 'Page index')}
+
+
{t('editor.inspector.eventManager.pageIndex', 'Page index')}
-
{t('editor.inspector.eventManager.key', 'Key')}
+
{t('editor.inspector.eventManager.key', 'Key')}
-
-
{t('editor.inspector.eventManager.value', 'Value')}
+
+
{t('editor.inspector.eventManager.value', 'Value')}
-
{t('editor.inspector.eventManager.key', 'Key')}
+
{t('editor.inspector.eventManager.key', 'Key')}
-
{t('editor.inspector.eventManager.key', 'Key')}
+
{t('editor.inspector.eventManager.key', 'Key')}
-
-
{t('editor.inspector.eventManager.value', 'Value')}
+
+
{t('editor.inspector.eventManager.value', 'Value')}
-
{t('editor.inspector.eventManager.key', 'Key')}
+
{t('editor.inspector.eventManager.key', 'Key')}
-
+
{t('editor.inspector.eventManager.component', 'Component')}
@@ -860,8 +860,8 @@ export const EventManager = ({ />
-
-
+
+
{t('editor.inspector.eventManager.action', 'Action')}
@@ -883,8 +883,8 @@ export const EventManager = ({ {event?.componentId && event?.componentSpecificActionHandle && (getAction(event?.componentId, event?.componentSpecificActionHandle)?.params ?? []).map((param) => ( -
-
+
+
{param?.displayName}
{param.type === 'select' ? ( @@ -929,8 +929,8 @@ export const EventManager = ({ ))} )} -
-
{t('editor.inspector.eventManager.debounce', 'Debounce')}
+
+
{t('editor.inspector.eventManager.debounce', 'Debounce')}