villebro commented on code in PR #24020:
URL: https://github.com/apache/superset/pull/24020#discussion_r1192939054
##########
superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx:
##########
@@ -240,66 +243,56 @@ const ViewResultsModalTrigger = ({
);
};
-class SliceHeaderControls extends React.PureComponent<
- SliceHeaderControlsPropsWithRouter,
- State
-> {
- constructor(props: SliceHeaderControlsPropsWithRouter) {
- super(props);
- this.toggleControls = this.toggleControls.bind(this);
- this.refreshChart = this.refreshChart.bind(this);
- this.handleMenuClick = this.handleMenuClick.bind(this);
-
- this.state = {
- showControls: false,
- };
- }
+const SliceHeaderControls = (props: SliceHeaderControlsPropsWithRouter) => {
Review Comment:
Big thanks for class -> function! 🚀
##########
superset/migrations/versions/2023-05-11_12-41_4ea966691069_cross_filter_global_scoping.py:
##########
@@ -0,0 +1,109 @@
+# 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.
+"""cross-filter-global-scoping
+
+Revision ID: 4ea966691069
+Revises: 9c2a5681ddfd
+Create Date: 2023-05-11 12:41:38.095717
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "4ea966691069"
+down_revision = "9c2a5681ddfd"
+
+import copy
+import json
+
+import sqlalchemy as sa
+from alembic import op
+from sqlalchemy.ext.declarative import declarative_base
+
+from superset import db
+
+Base = declarative_base()
+
+
+class Dashboard(Base):
+ __tablename__ = "dashboards"
+
+ id = sa.Column(sa.Integer, primary_key=True)
+ json_metadata = sa.Column(sa.Text)
+
+
+def upgrade():
+ bind = op.get_bind()
+ session = db.Session(bind=bind)
+ for dashboard in session.query(Dashboard).all():
Review Comment:
Since this is a pretty huge migration, I think we should paginate this.
Check migration `9c2a5681ddfd` for an example of a paginated update.
##########
superset-frontend/src/dashboard/actions/dashboardInfo.ts:
##########
@@ -114,28 +114,28 @@ export const setChartConfiguration =
dispatch({
type: SET_CHART_CONFIG_COMPLETE,
chartConfiguration,
+ globalChartConfiguration,
});
} catch (err) {
- dispatch({ type: SET_CHART_CONFIG_FAIL, chartConfiguration });
+ dispatch({
+ type: SET_CHART_CONFIG_FAIL,
Review Comment:
To align these with the new function name that changes `set` to `save`,
could we rename these to `SAVE_CHART_CONFIG_*`?
##########
superset-frontend/src/dashboard/util/charts/useChartIds.ts:
##########
@@ -0,0 +1,28 @@
+/**
+ * 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.
+ */
+import { useMemo } from 'react';
+import { useSelector } from 'react-redux';
+import { RootState } from 'src/dashboard/types';
+
+export const useChartIds = () => {
+ const chartIds = useSelector<RootState, number[]>(state =>
+ Object.values(state.charts).map(chart => chart.id),
+ );
+ return useMemo(() => chartIds, [chartIds]);
+};
Review Comment:
As we're reducing the scope to just the ids, it would be cool to do deep
comparison here to reduce unnecessary rerenders.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]