suddjian commented on a change in pull request #13306:
URL: https://github.com/apache/superset/pull/13306#discussion_r605960443



##########
File path: superset-frontend/src/dashboard/actions/hydrate.js
##########
@@ -17,59 +17,93 @@
  * under the License.
  */
 /* eslint-disable camelcase */
-import { isString } from 'lodash';
+import { isString, keyBy } from 'lodash';
 import shortid from 'shortid';
 import { CategoricalColorNamespace } from '@superset-ui/core';
+import querystring from 'query-string';
 
+import { chart } from 'src/chart/chartReducer';
 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 './dashboardFilters';
-import { chart } from '../../chart/chartReducer';
+} from 'src/dashboard/reducers/dashboardFilters';
 import {
   DASHBOARD_HEADER_ID,
   GRID_DEFAULT_CHART_WIDTH,
   GRID_COLUMN_COUNT,
-} from '../util/constants';
+} from 'src/dashboard/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';
+} from 'src/dashboard/util/componentTypes';
+import findFirstParentContainerId from 
'src/dashboard/util/findFirstParentContainer';
+import getEmptyLayout from 'src/dashboard/util/getEmptyLayout';
+import getFilterConfigsFromFormdata from 
'src/dashboard/util/getFilterConfigsFromFormdata';
+import getLocationHash from 'src/dashboard/util/getLocationHash';
+import newComponentFactory from 'src/dashboard/util/newComponentFactory';
+import { TIME_RANGE } from 'src/visualizations/FilterBox/FilterBox';
 
-export default function getInitialState(bootstrapData) {
-  const { user_id, datasources, common, editMode, urlParams } = bootstrapData;
+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],

Review comment:
       Multiple url parameters can share the same key (e.g. 
`http://example.com/page?foo=bar&foo=baz`). In this case, the values will come 
through from the `query-string` library as an array instead of a string (an 
inconsistent api surface). This function is a frontend reimplementation of the 
`urlParams` processing that [was happening on the 
backend](https://github.com/apache/superset/pull/13306/files/52b31118b074d3e2bf9c33e1880788c9da985b31#diff-76c6a0b5c14a297c62ac3207416870471affdb153c5ae12b96d7b7da9304e9ddL1869),
 and throws away all but the first instance of a given url param key, which 
matches Flask behavior when calling `request.args.items()`.
   
   I'll add a comment to the code.




-- 
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]

Reply via email to