diff --git a/frontend/src/Editor/ActionTypes.js b/frontend/src/Editor/ActionTypes.js
index ff531764e2..c762af2275 100644
--- a/frontend/src/Editor/ActionTypes.js
+++ b/frontend/src/Editor/ActionTypes.js
@@ -34,6 +34,13 @@ export const ActionTypes = [
{ name: 'modal', type: 'text', default: '' }
]
},
+ {
+ name: 'Close Modal',
+ id: 'close-modal',
+ options: [
+ { name: 'modal', type: 'text', default: '' }
+ ]
+ },
{
name: 'Copy to clipboard',
id: 'copy-to-clipboard',
diff --git a/frontend/src/Editor/Inspector/EventManager.jsx b/frontend/src/Editor/Inspector/EventManager.jsx
index 2b6e95e223..5ba3c2eb59 100644
--- a/frontend/src/Editor/Inspector/EventManager.jsx
+++ b/frontend/src/Editor/Inspector/EventManager.jsx
@@ -188,6 +188,26 @@ export const EventManager = ({
)}
+ {event.actionId === 'close-modal' && (
+
+
+ Modal
+
+
+ {
+ handlerChanged(index, 'modal', value);
+ }}
+ filterOptions={fuzzySearch}
+ placeholder="Select.."
+ />
+
+
+ )}
+
{event.actionId === 'copy-to-clipboard' && (
diff --git a/frontend/src/Editor/Inspector/EventSelector.jsx b/frontend/src/Editor/Inspector/EventSelector.jsx
index 394aeb38dd..9afa21c753 100644
--- a/frontend/src/Editor/Inspector/EventSelector.jsx
+++ b/frontend/src/Editor/Inspector/EventSelector.jsx
@@ -156,6 +156,22 @@ export const EventSelector = ({
)}
+ {definition.actionId === 'close-modal' && (
+
+
+ {
+ eventOptionUpdated(param, 'modal', value, extraData);
+ }}
+ filterOptions={fuzzySearch}
+ placeholder="Select.."
+ />
+
+ )}
+
{definition.actionId === 'copy-to-clipboard' && (
diff --git a/frontend/src/_helpers/appUtils.js b/frontend/src/_helpers/appUtils.js
index e1abafdb16..5f6ef6d740 100644
--- a/frontend/src/_helpers/appUtils.js
+++ b/frontend/src/_helpers/appUtils.js
@@ -94,6 +94,29 @@ async function copyToClipboard(text) {
}
};
+function showModal(_ref, modalId, show) {
+ const modalMeta = _ref.state.appDefinition.components[modalId];
+
+ const newState = {
+ currentState: {
+ ..._ref.state.currentState,
+ components: {
+ ..._ref.state.currentState.components,
+ [modalMeta.component.name]: {
+ ..._ref.state.currentState.components[modalMeta.component.name],
+ show: show
+ }
+ }
+ }
+ }
+
+ _ref.setState(newState)
+
+ return new Promise(function (resolve, reject) {
+ resolve();
+ })
+}
+
function executeAction(_ref, event, mode) {
if (event) {
if (event.actionId === 'show-alert') {
@@ -129,34 +152,11 @@ function executeAction(_ref, event, mode) {
})
}
- if (event.actionId === 'run-query') {
- const { queryId, queryName } = event;
- return runQuery(_ref, queryId, queryName);
- }
+ if (event.actionId === 'show-modal')
+ return showModal(_ref, event.modal, true)
- if (event.actionId === 'show-modal') {
- const modalId = event.modal;
- const modalMeta = _ref.state.appDefinition.components[modalId];
-
- const newState = {
- currentState: {
- ..._ref.state.currentState,
- components: {
- ..._ref.state.currentState.components,
- [modalMeta.component.name]: {
- ..._ref.state.currentState.components[modalMeta.component.name],
- show: true
- }
- }
- }
- }
-
- _ref.setState(newState)
-
- return new Promise(function (resolve, reject) {
- resolve();
- })
- }
+ if (event.actionId === 'close-modal')
+ return showModal(_ref, event.modal, false)
if (event.actionId === 'copy-to-clipboard') {
const contentToCopy = resolveReferences(event.contentToCopy, _ref.state.currentState);