This is an automated email from the ASF dual-hosted git repository.

amaan pushed a commit to branch amaan/time_shift_ag_grid_migration
in repository https://gitbox.apache.org/repos/asf/superset.git

commit d87b93042503ed071524b99080d02a7195323cab
Author: amaannawab923 <[email protected]>
AuthorDate: Mon Jan 12 23:33:16 2026 +0530

    feat(ag-grid-table): Enable Time Shift feature for AG Grid Table
    
    The Time Shift (time comparison) feature was already implemented in the
    AG Grid Table plugin but was gated behind the TableV2TimeComparisonEnabled
    feature flag. This commit enables the feature and adds dashboard override
    support to bring AG Grid Table to full parity with the normal Table plugin.
    
    Changes:
    - Removed feature flag checks from controlPanel.tsx and transformProps.ts
    - Added extra_form_data.time_compare override logic in buildQuery.ts so
      dashboard-level time shifts can override chart-level settings
    - Added merge() for extra_form_data in transformProps.ts to properly
      propagate dashboard filter overrides to the chart
    
    This allows users to:
    - Use Time Comparison controls in Aggregate mode (1 week ago, 1 month ago, 
etc.)
    - See expanded columns (Main, #, △, %) for each metric
    - Have dashboard filters override chart-level time shift settings
    
    Related PRs: apache#33947, apache#34014
---
 .../plugin-chart-ag-grid-table/src/buildQuery.ts       |  9 +++++++++
 .../plugin-chart-ag-grid-table/src/controlPanel.tsx    |  6 +-----
 .../plugin-chart-ag-grid-table/src/transformProps.ts   | 18 ++++++++++++------
 3 files changed, 22 insertions(+), 11 deletions(-)

diff --git 
a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts 
b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts
index 293509ff1a..85dcd2612f 100644
--- a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts
+++ b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts
@@ -120,6 +120,15 @@ const buildQuery: BuildQuery<TableChartFormData> = (
       }
     }
 
+    // Dashboard filter override - allows dashboard-level time shifts to 
OVERRIDE
+    // chart-level time shift settings (from PRs #33947 and #34014)
+    if (
+      extra_form_data?.time_compare &&
+      !timeOffsets.includes(extra_form_data.time_compare)
+    ) {
+      timeOffsets = [extra_form_data.time_compare];
+    }
+
     let temporalColumnAdded = false;
     let temporalColumn = null;
 
diff --git 
a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/controlPanel.tsx 
b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/controlPanel.tsx
index ef0204805e..4ab4d8139b 100644
--- a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/controlPanel.tsx
+++ b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/controlPanel.tsx
@@ -43,9 +43,7 @@ import {
 import { t } from '@apache-superset/core';
 import {
   ensureIsArray,
-  FeatureFlag,
   isAdhocColumn,
-  isFeatureEnabled,
   isPhysicalColumn,
   validateInteger,
   QueryFormColumn,
@@ -752,9 +750,7 @@ const config: ControlPanelConfig = {
         showCalculationType: false,
         showFullChoices: false,
       }),
-      visibility: ({ controls }) =>
-        isAggMode({ controls }) &&
-        isFeatureEnabled(FeatureFlag.TableV2TimeComparisonEnabled),
+      visibility: isAggMode,
     },
   ],
   formDataOverrides: formData => ({
diff --git 
a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts 
b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts
index 465f744425..73cee040fa 100644
--- a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts
@@ -25,12 +25,10 @@ import {
   DataRecord,
   ensureIsArray,
   extractTimegrain,
-  FeatureFlag,
   getMetricLabel,
   getNumberFormatter,
   getTimeFormatter,
   getTimeFormatterForGranularity,
-  isFeatureEnabled,
   NumberFormats,
   QueryMode,
   SMART_DATE_ID,
@@ -38,7 +36,7 @@ import {
   TimeFormatter,
 } from '@superset-ui/core';
 import { GenericDataType } from '@apache-superset/core/api/core';
-import { isEmpty, isEqual } from 'lodash';
+import { isEmpty, isEqual, merge } from 'lodash';
 import {
   ConditionalFormattingConfig,
   getColorFormatters,
@@ -465,7 +463,7 @@ const transformProps = (
   const {
     height,
     width,
-    rawFormData: formData,
+    rawFormData: originalFormData,
     queriesData = [],
     ownState: serverPaginationData,
     filterState,
@@ -474,6 +472,15 @@ const transformProps = (
     theme,
   } = chartProps;
 
+  // Merge extra_form_data (dashboard filter overrides) into formData
+  // This ensures dashboard-level settings (like time_compare) override 
chart-level settings
+  // From PRs #33947 and #34014
+  const formData = merge(
+    {},
+    originalFormData,
+    originalFormData.extra_form_data,
+  );
+
   const {
     include_search: includeSearch = false,
     page_length: pageLength,
@@ -499,8 +506,7 @@ const transformProps = (
   const isUsingTimeComparison =
     !isEmpty(time_compare) &&
     queryMode === QueryMode.Aggregate &&
-    comparison_type === ComparisonType.Values &&
-    isFeatureEnabled(FeatureFlag.TableV2TimeComparisonEnabled);
+    comparison_type === ComparisonType.Values;
 
   const nonCustomNorInheritShifts = 
ensureIsArray(formData.time_compare).filter(
     (shift: string) => shift !== 'custom' && shift !== 'inherit',

Reply via email to