From 8e8b21b01911311416417f7bae4d24bc3ca11a8a Mon Sep 17 00:00:00 2001 From: Kamil Gabryjelski Date: Mon, 18 Nov 2024 19:29:36 +0100 Subject: [PATCH] Add nullchecks --- .../src/dashboard/components/gridComponents/Chart.jsx | 6 ++++-- .../src/dashboard/containers/DashboardComponent.jsx | 9 --------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx b/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx index dadfcde60ff1f..335f314d7d330 100644 --- a/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx +++ b/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx @@ -127,7 +127,9 @@ const Chart = props => { ); const chart = useSelector(state => state.charts[props.id] || EMPTY_OBJECT); - const slice = useSelector(state => state.sliceEntities.slices[props.id]); + const slice = useSelector( + state => state.sliceEntities.slices[props.id] || EMPTY_OBJECT, + ); const editMode = useSelector(state => state.dashboardState.editMode); const isExpanded = useSelector( state => !!state.dashboardState.expandedSlices[props.id], @@ -401,7 +403,7 @@ const Chart = props => { ], ); - if (!chart || !slice) { + if (chart === EMPTY_OBJECT || slice === EMPTY_OBJECT) { return ; } diff --git a/superset-frontend/src/dashboard/containers/DashboardComponent.jsx b/superset-frontend/src/dashboard/containers/DashboardComponent.jsx index 07e41a0795797..4f773c96bd3ca 100644 --- a/superset-frontend/src/dashboard/containers/DashboardComponent.jsx +++ b/superset-frontend/src/dashboard/containers/DashboardComponent.jsx @@ -25,7 +25,6 @@ import { addDangerToast } from 'src/components/MessageToasts/actions'; import { componentLookup } from 'src/dashboard/components/gridComponents'; import getDetailedComponentWidth from 'src/dashboard/util/getDetailedComponentWidth'; import { getActiveFilters } from 'src/dashboard/util/activeDashboardFilters'; -import { componentShape } from 'src/dashboard/util/propShapes'; import { COLUMN_TYPE, ROW_TYPE } from 'src/dashboard/util/componentTypes'; import { createComponent, @@ -47,16 +46,8 @@ const propTypes = { renderHoverMenu: PropTypes.bool, renderTabContent: PropTypes.bool, onChangeTab: PropTypes.func, - component: componentShape.isRequired, - parentComponent: componentShape.isRequired, - createComponent: PropTypes.func.isRequired, - deleteComponent: PropTypes.func.isRequired, - updateComponents: PropTypes.func.isRequired, - handleComponentDrop: PropTypes.func.isRequired, - logEvent: PropTypes.func.isRequired, directPathToChild: PropTypes.arrayOf(PropTypes.string), directPathLastUpdated: PropTypes.number, - dashboardId: PropTypes.number.isRequired, isComponentVisible: PropTypes.bool, };