This is an automated email from the ASF dual-hosted git repository.
yongjiezhao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 557cf4b739 fix(dashboard): add toast if JSON metadata is invalid
(#20823)
557cf4b739 is described below
commit 557cf4b739a8a7933f947a034812e295a0ae95cb
Author: Stephen Liu <[email protected]>
AuthorDate: Sat Jul 23 14:14:28 2022 +0800
fix(dashboard): add toast if JSON metadata is invalid (#20823)
---
.../src/dashboard/components/PropertiesModal/index.tsx | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git
a/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx
b/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx
index 749411f2e9..7a80f6155f 100644
--- a/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx
+++ b/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx
@@ -59,6 +59,7 @@ type PropertiesModalProps = {
setColorSchemeAndUnsavedChanges?: () => void;
onSubmit?: (params: Record<string, any>) => void;
addSuccessToast: (message: string) => void;
+ addDangerToast: (message: string) => void;
onlyApply?: boolean;
};
@@ -80,6 +81,7 @@ type DashboardInfo = {
const PropertiesModal = ({
addSuccessToast,
+ addDangerToast,
colorScheme: currentColorScheme,
dashboardId,
dashboardInfo: currentDashboardInfo,
@@ -294,7 +296,12 @@ const PropertiesModal = ({
// color scheme in json metadata has precedence over selection
if (currentJsonMetadata?.length) {
- const metadata = JSON.parse(currentJsonMetadata);
+ let metadata;
+ try {
+ metadata = JSON.parse(currentJsonMetadata);
+ } catch (error) {
+ addDangerToast(t('JSON metadata is invalid!'));
+ }
currentColorScheme = metadata?.color_scheme || colorScheme;
colorNamespace = metadata?.color_namespace || '';