bito-code-review[bot] commented on code in PR #37141:
URL: https://github.com/apache/superset/pull/37141#discussion_r3651461659
##########
superset-frontend/src/components/ListView/ListView.tsx:
##########
@@ -659,6 +702,40 @@ export function ListView<T extends object = any>({
)}
</div>
</div>
+
+ {/* Mobile filter drawer */}
+ {filterable && setMobileFiltersOpen && (
+ <Drawer
+ title={mobileFiltersDrawerTitle || t('Search')}
+ placement="left"
+ onClose={() => setMobileFiltersOpen(false)}
+ open={mobileFiltersOpen}
+ width={300}
+ >
+ <MobileFilterDrawerContent>
+ <FilterControls
+ ref={filterControlsRef}
+ filters={filters}
+ internalFilters={internalFilters}
+ updateFilterValue={applyFilterValue}
+ />
+ {viewMode === 'card' && cardSortSelectOptions && (
+ <CardSortSelect
+ initialSort={sortBy}
+ onChange={(value: SortColumn[]) => setSortBy(value)}
+ options={cardSortSelectOptions}
+ />
+ )}
+ <ClearAllButton
+ type="button"
+ disabled={!hasActiveFilters}
+ onClick={() => filterControlsRef.current?.clearFilters()}
+ >
+ {t('Clear all')}
+ </ClearAllButton>
+ </MobileFilterDrawerContent>
Review Comment:
<!-- Bito Reply -->
This is a good improvement. Applying the tooltip to the drawer button
ensures consistent user experience and provides helpful feedback when the clear
action is disabled, matching the behavior of the inline version.
**superset-frontend/src/components/ListView/ListView.tsx**
```
<Tooltip
title={!hasActiveFilters ? t('No filters applied') : undefined}
>
<span>
<ClearAllButton
type="button"
disabled={!hasActiveFilters}
onClick={() => filterControlsRef.current?.clearFilters()}
>
{t('Clear all')}
</ClearAllButton>
</span>
</Tooltip>
```
##########
superset/initialization/__init__.py:
##########
@@ -1063,6 +1063,7 @@ def enforce_session_validity() -> Any:
@self.superset_app.context_processor
def get_common_bootstrap_data() -> dict[str, Any]:
# Import here to avoid circular imports
+ from superset.extensions import feature_flag_manager
Review Comment:
<!-- Bito Reply -->
The suggestion to remove the inline import is appropriate. Since
`feature_flag_manager` is already imported at the module level, removing the
redundant inline import simplifies the code and avoids unnecessary re-imports
within the function.
**superset/initialization/__init__.py**
```
@self.superset_app.context_processor
def get_common_bootstrap_data() -> dict[str, Any]:
# Import here to avoid circular imports
return { ... }
```
##########
superset-frontend/playwright/tests/mobile/mobile-dashboard.spec.ts:
##########
@@ -0,0 +1,325 @@
+/**
+ * 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 { test, expect, devices } from '@playwright/test';
+
+// NOTE: These tests exercise the mobile consumption experience and require
+// the MOBILE_CONSUMPTION_MODE feature flag to be enabled in the target
+// environment (FEATURE_FLAGS = {"MOBILE_CONSUMPTION_MODE": True}).
+import { TIMEOUT } from '../../utils/constants';
+
+/**
+ * Mobile dashboard viewing tests verify that dashboards can be viewed
+ * and interacted with on mobile devices.
+ *
+ * These tests assume the World Bank's Health sample dashboard exists.
+ */
+
+// Use iPhone 12 viewport for mobile tests
+const mobileViewport = devices['iPhone 12'];
+
+test.describe('Mobile Dashboard Viewing', () => {
+ test.use({
+ viewport: mobileViewport.viewport,
+ userAgent: mobileViewport.userAgent,
+ });
+
+ test.beforeEach(async ({ page }) => {
+ // Navigate to dashboard list to find a dashboard
+ await page.goto('dashboard/list/');
Review Comment:
<!-- Bito Reply -->
The suggestion to use `URL.DASHBOARD_LIST` instead of the hardcoded
`'dashboard/list/'` string is appropriate. Using the centralized constant
improves maintainability and ensures consistency with other tests in the
codebase, such as `mobile-navigation.spec.ts`.
**superset-frontend/playwright/tests/mobile/mobile-dashboard.spec.ts**
```
test.beforeEach(async ({ page }) => {
// Navigate to dashboard list to find a dashboard
await page.goto(URL.DASHBOARD_LIST);
```
##########
superset-frontend/src/pages/DashboardList/DashboardList.test.tsx:
##########
@@ -50,6 +50,15 @@ jest.mock('src/utils/getBootstrapData', () =>
mockUserSubjectsBootstrapData([1]),
);
+// Mock useBreakpoint to return desktop breakpoints (prevents mobile rendering)
+jest.mock('antd', () => ({
+ ...jest.requireActual('antd'),
+ Grid: {
+ ...jest.requireActual('antd').Grid,
+ useBreakpoint: () => ({ xs: true, sm: true, md: true, lg: true, xl: true
}),
+ },
+}));
Review Comment:
<!-- Bito Reply -->
The suggestion to use `mockAntdWithDesktopBreakpoint()` is appropriate. It
replaces the manual `useBreakpoint` mock with a centralized utility, which
improves maintainability and ensures consistency across the test suite.
**superset-frontend/src/pages/DashboardList/DashboardList.test.tsx**
```
jest.mock('antd', () => ({
...jest.requireActual('antd'),
Grid: {
...jest.requireActual('antd').Grid,
useBreakpoint: () => ({ xs: true, sm: true, md: true, lg: true, xl: true
}),
},
}));
```
##########
superset-frontend/src/pages/Home/Home.test.tsx:
##########
@@ -146,6 +146,15 @@ jest.mock('@superset-ui/core', () => ({
isFeatureEnabled: jest.fn(),
}));
+// Mock useBreakpoint to return desktop breakpoints (prevents mobile rendering)
+jest.mock('antd', () => ({
+ ...jest.requireActual('antd'),
+ Grid: {
+ ...jest.requireActual('antd').Grid,
+ useBreakpoint: () => ({ xs: true, sm: true, md: true, lg: true, xl: true
}),
+ },
+}));
Review Comment:
<!-- Bito Reply -->
The suggestion to use the shared utility is appropriate because it promotes
consistency and maintainability across the test suite by centralizing
breakpoint logic. Applying this change is recommended to align with established
project standards.
**superset-frontend/src/pages/Home/Home.test.tsx**
```
jest.mock('antd', () => ({
...jest.requireActual('antd'),
Grid: {
...jest.requireActual('antd').Grid,
useBreakpoint: () => ({ xs: true, sm: true, md: true, lg: true, xl: true
}),
},
}));
```
--
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]