From eee2e97728c954edc2a0cb860f690a023ac9d477 Mon Sep 17 00:00:00 2001 From: Pranav Kanade Date: Tue, 7 Sep 2021 10:15:13 +0530 Subject: [PATCH] fix: safeguarding selected widgets saga (#7133) --- app/client/src/constants/messages.ts | 7 +++++++ app/client/src/sagas/SnipingModeSagas.ts | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/client/src/constants/messages.ts b/app/client/src/constants/messages.ts index 666dad8e9c..03ce88662e 100644 --- a/app/client/src/constants/messages.ts +++ b/app/client/src/constants/messages.ts @@ -480,3 +480,10 @@ export const MORE_OPTIONS = () => "More Options"; export const ADD_REACTION = () => "Add Reaction"; export const RESOLVE_THREAD = () => "Resolve Thread"; export const EMOJI = () => "Emoji"; + +// Sniping mode messages +export const SNIPING_SELECT_WIDGET_AGAIN = () => + "Unable to detect the widget, please select the widget again."; + +export const SNIPING_NOT_SUPPORTED = () => + "Binding on selection is not supported for this type of widget!"; diff --git a/app/client/src/sagas/SnipingModeSagas.ts b/app/client/src/sagas/SnipingModeSagas.ts index f763f6f36c..0c34cfd0e3 100644 --- a/app/client/src/sagas/SnipingModeSagas.ts +++ b/app/client/src/sagas/SnipingModeSagas.ts @@ -16,6 +16,10 @@ import { RenderModes, WidgetTypes } from "../constants/WidgetConstants"; import { Toaster } from "../components/ads/Toast"; import { Variant } from "../components/ads/common"; import AnalyticsUtil from "../utils/AnalyticsUtil"; +import { + SNIPING_NOT_SUPPORTED, + SNIPING_SELECT_WIDGET_AGAIN, +} from "../constants/messages"; export function* bindDataToWidgetSaga( action: ReduxAction<{ @@ -37,6 +41,14 @@ export function* bindDataToWidgetSaga( action.payload.widgetId ]; + if (!selectedWidget || !selectedWidget.type) { + Toaster.show({ + text: SNIPING_SELECT_WIDGET_AGAIN(), + variant: Variant.warning, + }); + return; + } + let propertyPath = ""; let propertyValue: any = ""; let isValidProperty = true; @@ -143,7 +155,7 @@ export function* bindDataToWidgetSaga( } else { queryId && Toaster.show({ - text: "Binding on selection is not supported for this type of widget!", + text: SNIPING_NOT_SUPPORTED(), variant: Variant.warning, }); }