suddjian commented on a change in pull request #13306: URL: https://github.com/apache/superset/pull/13306#discussion_r604357346
########## File path: superset-frontend/src/dashboard/actions/hydrate.js ########## @@ -0,0 +1,352 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* eslint-disable camelcase */ +import { isString, keyBy } from 'lodash'; +import shortid from 'shortid'; +import { CategoricalColorNamespace } from '@superset-ui/core'; +import querystring from 'query-string'; + +import { initSliceEntities } from 'src/dashboard/reducers/sliceEntities'; +import { getInitialState as getInitialNativeFilterState } from 'src/dashboard/reducers/nativeFilters'; +import { getParam } from 'src/modules/utils'; +import { applyDefaultFormData } from 'src/explore/store'; +import { buildActiveFilters } from 'src/dashboard/util/activeDashboardFilters'; +import getPermissions from 'src/dashboard/util/getPermissions'; +import { + DASHBOARD_FILTER_SCOPE_GLOBAL, + dashboardFilter, +} from '../reducers/dashboardFilters'; +import { chart } from '../../chart/chartReducer'; +import { + DASHBOARD_HEADER_ID, + GRID_DEFAULT_CHART_WIDTH, + GRID_COLUMN_COUNT, +} from '../util/constants'; +import { + DASHBOARD_HEADER_TYPE, + CHART_TYPE, + ROW_TYPE, +} from '../util/componentTypes'; +import findFirstParentContainerId from '../util/findFirstParentContainer'; +import getEmptyLayout from '../util/getEmptyLayout'; +import getFilterConfigsFromFormdata from '../util/getFilterConfigsFromFormdata'; +import getLocationHash from '../util/getLocationHash'; +import newComponentFactory from '../util/newComponentFactory'; +import { TIME_RANGE } from '../../visualizations/FilterBox/FilterBox'; + +const reservedQueryParams = new Set(['standalone', 'edit']); + +/** + * Returns the url params that are used to customize queries + * in datasets built using sql lab. + * We may want to extract this to some kind of util in the future. + */ +const extractUrlParams = queryParams => + Object.entries(queryParams).reduce((acc, [key, value]) => { + if (reservedQueryParams.has(key)) return acc; + if (Array.isArray(value)) { + return { + ...acc, + [key]: value[0], + }; + } + return { ...acc, [key]: value }; + }, {}); + +export const HYDRATE_DASHBOARD = 'HYDRATE_DASHBOARD'; + +export const hydrateDashboard = (dashboardData, chartData, datasourcesData) => ( Review comment: This function is essentially the same functionality as what used to be in `getInitialState`, but now it happens asynchronously. The initial state is now just a shell containing no information until `hydrateDashboard` is called. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
