From 77dea1915beee2761c9fc214f1196ef8d79832c8 Mon Sep 17 00:00:00 2001 From: David Aaron Suddjian Date: Wed, 31 Mar 2021 13:03:28 -0700 Subject: [PATCH] certainty --- .../src/dashboard/actions/hydrate.js | 18 +++++++++--------- .../src/dashboard/components/Header.jsx | 4 ++-- .../src/dashboard/components/SaveModal.tsx | 2 +- .../src/dashboard/containers/Chart.jsx | 2 +- .../src/dashboard/containers/Dashboard.jsx | 2 +- .../src/dashboard/containers/FiltersBadge.tsx | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/superset-frontend/src/dashboard/actions/hydrate.js b/superset-frontend/src/dashboard/actions/hydrate.js index a3e7fbe336..58081f2ecc 100644 --- a/superset-frontend/src/dashboard/actions/hydrate.js +++ b/superset-frontend/src/dashboard/actions/hydrate.js @@ -76,7 +76,7 @@ export const hydrateDashboard = (dashboardData, chartData, datasourcesData) => ( getState, ) => { const { user, common } = getState(); - const metadata = JSON.parse(dashboardData.json_metadata); + const metadata = JSON.parse(dashboardData.json_metadata) || {}; const queryParams = querystring.parse(window.location.search); const urlParams = extractUrlParams(queryParams); const editMode = queryParams.edit === 'true'; @@ -98,7 +98,7 @@ export const hydrateDashboard = (dashboardData, chartData, datasourcesData) => ( // Priming the color palette with user's label-color mapping provided in // the dashboard's JSON metadata - if (metadata?.label_colors) { + if (metadata.label_colors) { const scheme = metadata.color_scheme; const namespace = metadata.color_namespace; const colorMap = isString(metadata.label_colors) @@ -134,7 +134,7 @@ export const hydrateDashboard = (dashboardData, chartData, datasourcesData) => ( let newSlicesContainer; let newSlicesContainerWidth = 0; - const filterScopes = metadata?.filter_scopes || {}; + const filterScopes = metadata.filter_scopes || {}; const chartQueries = {}; const dashboardFilters = {}; @@ -293,8 +293,8 @@ export const hydrateDashboard = (dashboardData, chartData, datasourcesData) => ( } const nativeFilters = getInitialNativeFilterState({ - filterConfig: metadata?.native_filter_configuration || [], - filterSetsConfig: metadata?.filter_sets_configuration || [], + filterConfig: metadata.native_filter_configuration || [], + filterSetsConfig: metadata.filter_sets_configuration || [], }); const { roles } = getState().user; @@ -330,14 +330,14 @@ export const hydrateDashboard = (dashboardData, chartData, datasourcesData) => ( directPathToChild, directPathLastUpdated: Date.now(), focusedFilterField: null, - expandedSlices: metadata?.expanded_slices || {}, - refreshFrequency: metadata?.refresh_frequency || 0, + expandedSlices: metadata.expanded_slices || {}, + refreshFrequency: metadata.refresh_frequency || 0, // dashboard viewers can set refresh frequency for the current visit, // only persistent refreshFrequency will be saved to backend shouldPersistRefreshFrequency: false, css: dashboardData.css || '', - colorNamespace: metadata?.color_namespace || null, - colorScheme: metadata?.color_scheme || null, + colorNamespace: metadata.color_namespace || null, + colorScheme: metadata.color_scheme || null, editMode: getPermissions('can_write', 'Dashboard', roles) && editMode, isPublished: dashboardData.published, hasUnsavedChanges: false, diff --git a/superset-frontend/src/dashboard/components/Header.jsx b/superset-frontend/src/dashboard/components/Header.jsx index 8ad6c57e69..5e2e494b90 100644 --- a/superset-frontend/src/dashboard/components/Header.jsx +++ b/superset-frontend/src/dashboard/components/Header.jsx @@ -298,7 +298,7 @@ class Header extends React.PureComponent { let labelColors = colorScheme ? scale.getColorMap() : {}; // but allow metadata to overwrite if it exists // eslint-disable-next-line camelcase - const metadataLabelColors = dashboardInfo.metadata?.label_colors; + const metadataLabelColors = dashboardInfo.metadata.label_colors; if (metadataLabelColors) { labelColors = { ...labelColors, ...metadataLabelColors }; } @@ -306,7 +306,7 @@ class Header extends React.PureComponent { // check refresh frequency is for current session or persist const refreshFrequency = shouldPersistRefreshFrequency ? currentRefreshFrequency - : dashboardInfo.metadata?.refresh_frequency; // eslint-disable-line camelcase + : dashboardInfo.metadata.refresh_frequency; // eslint-disable-line camelcase const data = { positions, diff --git a/superset-frontend/src/dashboard/components/SaveModal.tsx b/superset-frontend/src/dashboard/components/SaveModal.tsx index 1d3141df05..0bbc327767 100644 --- a/superset-frontend/src/dashboard/components/SaveModal.tsx +++ b/superset-frontend/src/dashboard/components/SaveModal.tsx @@ -140,7 +140,7 @@ class SaveModal extends React.PureComponent { // check refresh frequency is for current session or persist const refreshFrequency = shouldPersistRefreshFrequency ? currentRefreshFrequency - : dashboardInfo.metadata?.refresh_frequency; // eslint-disable camelcase + : dashboardInfo.metadata.refresh_frequency; // eslint-disable camelcase const data = { positions, diff --git a/superset-frontend/src/dashboard/containers/Chart.jsx b/superset-frontend/src/dashboard/containers/Chart.jsx index 94f88d3a9e..f874380668 100644 --- a/superset-frontend/src/dashboard/containers/Chart.jsx +++ b/superset-frontend/src/dashboard/containers/Chart.jsx @@ -62,7 +62,7 @@ function mapStateToProps( layout: dashboardLayout.present, chart, // eslint-disable-next-line camelcase - chartConfiguration: dashboardInfo.metadata?.chart_configuration, + chartConfiguration: dashboardInfo.metadata.chart_configuration, charts: chartQueries, filters: getAppliedFilterValues(id), colorScheme, diff --git a/superset-frontend/src/dashboard/containers/Dashboard.jsx b/superset-frontend/src/dashboard/containers/Dashboard.jsx index 53acf6ae95..0077f5bd6d 100644 --- a/superset-frontend/src/dashboard/containers/Dashboard.jsx +++ b/superset-frontend/src/dashboard/containers/Dashboard.jsx @@ -60,7 +60,7 @@ function mapStateToProps(state) { ...getActiveFilters(), ...getAllActiveFilters({ // eslint-disable-next-line camelcase - chartConfiguration: dashboardInfo.metadata?.chart_configuration, + chartConfiguration: dashboardInfo.metadata.chart_configuration, nativeFilters: nativeFilters.filters, dataMask, layout: dashboardLayout.present, diff --git a/superset-frontend/src/dashboard/containers/FiltersBadge.tsx b/superset-frontend/src/dashboard/containers/FiltersBadge.tsx index 546b96303f..9ee544ffed 100644 --- a/superset-frontend/src/dashboard/containers/FiltersBadge.tsx +++ b/superset-frontend/src/dashboard/containers/FiltersBadge.tsx @@ -78,7 +78,7 @@ const mapStateToProps = ( chartId, charts, present, - dashboardInfo.metadata?.chart_configuration, + dashboardInfo.metadata.chart_configuration, ); const indicators = uniqWith(