fix: safeguarding selected widgets saga (#7133)

This commit is contained in:
Pranav Kanade 2021-09-07 10:15:13 +05:30 committed by GitHub
parent 77a33f770d
commit eee2e97728
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -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!";

View File

@ -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,
});
}