You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/10/13 00:13:13 UTC
[GitHub] [superset] suddjian commented on a change in pull request #16992: feat(native_filter_migration):add transition mode
suddjian commented on a change in pull request #16992:
URL: https://github.com/apache/superset/pull/16992#discussion_r727603993
##########
File path: superset-frontend/src/dashboard/containers/DashboardPage.tsx
##########
@@ -60,14 +84,83 @@ const DashboardPage: FC = () => {
const error = dashboardApiError || chartsApiError;
const readyToRender = Boolean(dashboard && charts);
- const { dashboard_title, css } = dashboard || {};
+
+ const migrationStateParam = getUrlParam(
+ URL_PARAMS.migrationState,
+ ) as FILTER_BOX_MIGRATION_STATES;
+ const isMigrationEnabled = isFeatureEnabled(
+ FeatureFlag.ENABLE_FILTER_BOX_MIGRATION,
+ );
+ const { dashboard_title, css, metadata, id = 0 } = dashboard || {};
+ const [filterboxMigrationState, setFilterboxMigrationState] = useState(
+ migrationStateParam || FILTER_BOX_MIGRATION_STATES.NOOP,
+ );
+
+ useEffect(() => {
+ // should convert filter_box to filter component?
+ const hasFilterBox =
+ charts &&
+ charts.some(chart => chart.form_data?.viz_type === 'filter_box');
+ const canEdit = dashboard && canUserEditDashboard(dashboard, user);
+
+ if (canEdit) {
+ // can user edit dashboard?
+ if (metadata?.native_filter_configuration) {
+ setFilterboxMigrationState(
+ isMigrationEnabled
+ ? FILTER_BOX_MIGRATION_STATES.CONVERTED
+ : FILTER_BOX_MIGRATION_STATES.NOOP,
+ );
+ return;
+ }
+
+ // set filterbox migration state if has filter_box in the dash:
+ if (hasFilterBox) {
+ if (isMigrationEnabled) {
+ // has url param?
+ if (
+ migrationStateParam &&
+ Object.values(FILTER_BOX_MIGRATION_STATES).includes(
+ migrationStateParam,
+ )
+ ) {
+ setFilterboxMigrationState(migrationStateParam);
+ return;
+ }
+
+ // has cookie?
+ const snoozeDash =
+ getFromLocalStorage(FILTER_BOX_TRANSITION_SNOOZED_AT, 0) || {};
+ if (
+ Date.now() - (snoozeDash[id] || 0) <
+ FILTER_BOX_TRANSITION_SNOOZE_DURATION
+ ) {
+ setFilterboxMigrationState(FILTER_BOX_MIGRATION_STATES.SNOOZED);
+ return;
+ }
+
+ setFilterboxMigrationState(FILTER_BOX_MIGRATION_STATES.UNDECIDED);
+ } else {
+ dispatch(
+ addWarningToast(
+ t(
+ 'filter_box will be deprecated from Superset by ' +
+ 'the end of this year. Please replace filter_box by dashboard ' +
Review comment:
Can this say "in version x.x.x" instead of "by the end of this year"? Or just "in a future version of Superset"
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org