Compare commits

..

26 Commits

Author SHA1 Message Date
Evan Rusackas
a8e85ee6d9 refactor: Migrate control components to @superset-ui/chart-controls package
- Created wrapper components for controls not yet in the package:
  - CheckboxControl, TextControl, SelectControl, SliderControl
  - DndFilterSelect, Control (generic wrapper)
- Updated all Timeseries control panels to import from @superset-ui/chart-controls
  - Bar, Line, Scatter, SmoothLine control panels now use package imports
  - Eliminated deep relative imports for better reusability
- Ensures better reusability and cleaner architecture
- All components compile successfully with webpack

This completes the migration of control components to the npm package
for better modularity and reusability across the codebase.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 09:42:31 -07:00
Evan Rusackas
361a7f0f94 chore: Remove unused jsonforms dependencies and files
- Removed SupersetControlRenderers.tsx which imported non-existent jsonforms packages
- Removed migrate-control-panels.js migration script that's no longer needed
- These files were causing TypeScript errors due to missing @jsonforms dependencies

The ModernControlPanelRenderer is still needed as it bridges our new React-based
control panels with the legacy ControlPanelsContainer system.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 21:57:02 -07:00
Evan Rusackas
184f800ec1 feat: Complete migration of ALL ECharts control panels to React architecture 🎉
Migrated 25 chart control panels from legacy config-based to modern React-based:

Core Charts:
- Pie, Funnel, Sankey, Treemap (already done)
- BoxPlot, Bubble, Gantt, Gauge, Graph
- Heatmap, Histogram, Radar, Sunburst, Tree, Waterfall

BigNumber Variants (3):
- BigNumberTotal
- BigNumberPeriodOverPeriod
- BigNumberWithTrendline

Timeseries Variants (7):
- Area, Step, Line, Bar, Scatter, SmoothLine
- MixedTimeseries (most complex with dual Y-axes)

Key improvements across all migrations:
- Direct React components instead of config objects
- Full TypeScript support with proper types
- Tab-based organization (Data/Customize/Options)
- Proper safety checks and validation
- Conditional rendering for dependent controls
- Single column handling where needed
- Modern control components (DndColumnSelect, etc.)

All charts compile successfully with webpack dev server.
This completes the control panel modernization effort!

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 21:25:23 -07:00
Evan Rusackas
a5bc492a95 feat: Migrate Sankey and Treemap control panels to React architecture
- Created SankeyControlPanelSimple.tsx with React-based controls
- Created TreemapControlPanelSimple.tsx with tab-based layout
- Both follow established patterns from Pie and Funnel migrations
- Added special handling for single-column selection in Sankey
- Updated migration agent with new patterns and common issues
- All charts compile successfully with webpack dev server

Key improvements:
- Direct React components instead of config objects
- Full TypeScript support with proper types
- Tab-based organization (Data/Customize)
- Proper safety checks and validation
- Consistent with modern control panel architecture

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 16:48:57 -07:00
Evan Rusackas
544236ff20 fix: Import Tabs from antd instead of @superset-ui/core in Funnel control panel
The @superset-ui/core package doesn't export a Tabs component, causing
'Element type is invalid' error. Fixed by importing Tabs directly from antd,
matching the pattern used in PieControlPanelSimple.tsx.

Also fixed React hooks order issue in PieControlPanelSimple.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 16:00:56 -07:00
Evan Rusackas
2670c3e951 Revert "refactor: Split control panel to work with existing Superset tabs"
This reverts commit 0f60a8d57b.
2025-08-18 13:49:23 -07:00
Evan Rusackas
0f60a8d57b refactor: Split control panel to work with existing Superset tabs
- Removed custom Tabs implementation - we don't create our own tabs
- Split into two components: PieDataPanel and PieCustomizePanel
- PieDataPanel provides content for the existing Data tab
- PieCustomizePanel provides content for the existing Customize tab
- Both components share the same props and state through common interface
- Used controlPanelSections with tabOverride to place controls in correct tabs
- Chart type selector remains above tabs (handled by Superset UI)
- Maintains all controls and conditional rendering logic
2025-08-18 13:32:24 -07:00
Evan Rusackas
51c40dc971 feat: Restructure Pie control panel with tabs for Data and Customize
- Added Ant Design Tabs to split controls into Data and Customize tabs
- Data tab contains: Group by, Metric, Filters, Row limit, Sort by metric
- Customize tab contains: Chart Options, Labels, and Pie shape sections
- Added chart/viz type picker above the tabs showing 'Pie Chart' title and description
- Maintains all existing controls and their conditional rendering logic
- Uses useState hook to manage active tab state
2025-08-18 13:22:20 -07:00
Evan Rusackas
5c90fca556 feat: Add all missing controls to Pie chart React control panel
- Added Filters control (adhoc_filters) to Query section
- Added Percentage threshold and Threshold for Other controls
- Added Rose Type control for Nightingale chart visualization
- Added comprehensive Labels section with:
  - Label Type selector with all 8 options
  - Conditional Label Template field
  - Number format, Currency format, and Date format controls
  - Conditional Put labels outside control
  - Show Total checkbox
- Reorganized controls into logical sections: Query, Chart Options, Labels, and Pie shape
- All controls now use proper React components with conditional rendering
- Added all missing controlOverrides with proper defaults and renderTrigger flags
2025-08-18 13:01:13 -07:00
Evan Rusackas
859e627c30 fix: Restore all missing features to Pie control panel
- Added back outer radius slider control with min/max constraints
- Added conditional inner radius control that only shows when Donut is checked
- Added color palette selector component
- Added conditional Label Line control that only shows when Show Labels is checked
- Fixed double headers on Metric and Group by controls by removing duplicate labels
- All controls now properly configured with renderTrigger where appropriate
2025-08-17 10:36:47 -07:00
Evan Rusackas
980c06e7d7 refactor: Clean up Pie control panel implementation
- Remove unnecessary control panel files (controlPanel.tsx, controlPanelModern.tsx, PieControlPanel.tsx)
- Keep only the simplified working version (PieControlPanelSimple.tsx)
- Fix all linting and type-checking errors
- Remove unused imports and color literals
2025-08-17 10:29:21 -07:00
Evan Rusackas
204b32e4a0 feat: Add infrastructure for modern React control panels
- Modified expandControlConfig to handle modern panel components
- Added ModernControlPanelRenderer component for bridging
- Updated ControlPanelsContainer to render modern panels directly
- Modified getAllControlsState to process controlOverrides from modern panels
- Updated getSectionsToRender to handle modern control panels
- Created PieControlPanelSimple with React-based controls, tooltips, and dynamic rendering

This sets up the foundation for migrating from config-based to React component-based control panels.
2025-08-17 10:12:06 -07:00
Evan Rusackas
3603775df1 feat: Create TRUE React-based control panel for Pie chart
- Complete abandonment of controlPanelSections/controlSetRows architecture
- Use Ant Design Collapse and Grid for layout instead of proprietary constructs
- Import actual React control components from controlMap
- Direct component usage, no config objects
- Clean, modern React component approach with proper props

This is the actual React-based control panel we want - pure components,
no legacy structures, just React + Ant Design.
2025-08-14 10:47:51 -07:00
Evan Rusackas
cf3b93b7bc fix: Update Pie chart control panel to use proper shared controls
- Fix groupby and metric control configurations
- Use spread operator to properly extend shared controls
- Add proper labels and descriptions for controls
- Temporarily disable formDataOverrides to debug column issues
- Fix sort_by_metric control type definition

The 'Referenced columns not available in DataFrame' error should now be resolved.
2025-08-14 10:03:05 -07:00
Evan Rusackas
df772a9afa feat: Implement nuclear approach for control panel migration
- Create empty control panel placeholder for non-migrated charts
- Switch Bar and Line charts to empty panels temporarily
- Update Pie chart to use traditional control config structure
- Remove experimental React-based PieControlPanel component
- Fix TypeScript errors in control panel configurations
- Simplify migration path by focusing on one working chart first

This approach allows us to get one chart (Pie) working properly
before migrating others, avoiding complex dual-architecture issues.
2025-08-14 09:51:09 -07:00
Evan Rusackas
d01c038471 feat: Implement phased control panel migration approach
- Create modern Pie chart control panel using React/AntD components
- Add ModernControlPanelRenderer bridge for backward compatibility
- Create ReactControlWrappers for control components
- Update ControlPanelsContainer to support both legacy and modern formats
- Add comprehensive migration documentation and plan

This establishes the foundation for migrating from controlSetRows to
modern React-based control panels while maintaining full backward
compatibility. The Pie chart serves as the proof of concept for the
phased migration approach.

Note: This is a work-in-progress implementation that demonstrates
the migration approach. TypeScript errors and linting issues will
be resolved as the migration progresses.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 17:25:53 -07:00
Evan Rusackas
7f4a3a3d0f refactor: Modernize control panel layouts with Ant Design Grid
- Replace Bootstrap grid classes with Ant Design Row/Col components
- Update ControlRow.tsx to use Ant Design grid system
- Replace all className="control-row" with Row/Col components
- Import Row/Col from @superset-ui/core/components for consistency
- Add new ControlPanelLayout utilities for flexible layouts
- Standardize spacing with gutter={[16, 8]} across all control groups

This modernizes the control panel layout system to use Ant Design's
consistent grid system instead of mixed Bootstrap/custom CSS classes,
improving maintainability and visual consistency.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 14:34:06 -07:00
Evan Rusackas
c198b990a3 chore: Remove JSONForms dependencies
Remove @jsonforms/core and @jsonforms/react as they are no longer needed
after migrating to React-based control panels.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 13:40:57 -07:00
Evan Rusackas
286b4d81e9 chore: Clean up files not needed for PR
- Add .claude_rc to .gitignore (local development file)
- Remove ARCHITECTURE_PLAN.md (development planning document)
- Remove CONTROL_PANEL_MIGRATION.md and MIGRATION_GUIDE.md
  (internal migration documentation not needed in final PR)

Note: LLMS.md, CLAUDE.md, GEMINI.md, GPT.md are existing Apache Superset
documentation files and remain untouched.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 13:40:08 -07:00
Evan Rusackas
446beb4d2e refactor: Remove string control processing logic
- Simplify getSectionsToRender to remove string control checks
- Remove invalidControls logic since all controls are now React components
- Clean up control filtering to only check for null/undefined

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 13:04:58 -07:00
Evan Rusackas
0ea89c1c57 refactor: Complete migration to React-based control panels
- Remove all string-based control references
- Delete deprecated controls.jsx file
- Update all control panels to use React component functions
- Fix inline control function signatures (name, overrides)
- Remove JSONForms migration utilities
- Update store.js to work without old controls
- Add RadioButtonControl to InternalControlType
- Fix tests to work with new architecture

This completes the migration away from string-based control references
to fully React-based control panels with proper TypeScript support.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 12:48:05 -07:00
Evan Rusackas
26f0556bef chore(controls): Remove all extraneous control panel files
- Delete all controlPanelModern.tsx files (JSONForms format)
- Delete controlPanelReact.tsx and other experimental variants
- Rename Word Cloud controlPanelFixed.ts to controlPanel.ts
- Update imports to use standard controlPanel files
- Verify no string references remain in control panels

All visualizations now use their standard controlPanel.ts/tsx files with
React component functions. The codebase is now consistent with the new
control panel architecture.
2025-08-13 11:02:09 -07:00
Evan Rusackas
1137185842 fix(controls): Add InlineCheckboxControl and fix build errors
- Add InlineCheckboxControl function for creating checkbox controls
- Fix calendar control panel to use correct function signatures
- Remove deleted JSONForms container references
- Remove controlPanelMigration export that no longer exists
- Fix ReactControlPanel export to match actual export

All control panels now compile successfully and the new control system is working.
2025-08-12 22:29:41 -07:00
Evan Rusackas
97913203e1 feat(explore): Migrate control panels to React-based architecture
- Replace string-referenced control system with React components
- Add useFormData hook for direct Redux integration
- Create reusable control wrapper components (SeriesControl, MetricControl, etc.)
- Support both camelCase and snake_case for backward compatibility
- Successfully migrate Word Cloud control panel as proof of concept
- Remove JSONForms implementation in favor of simpler React approach
- Add migration guide to CLAUDE.md for other control panels

This simplifies the control panel architecture by:
1. Eliminating string references in favor of React components
2. Providing type-safe control definitions
3. Connecting controls directly to Redux state
4. Making control panels easier to understand and maintain

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-12 18:22:00 -07:00
Evan Rusackas
06b98c1095 feat(controls): Migrate control panels to JSON Forms format
Major milestone in modernizing the control panel system:

## Changes Made

### Infrastructure
- Created ControlPanelsContainerWrapper to auto-detect JSON Forms vs legacy format
- Updated ExploreViewContainer to use the wrapper for automatic format detection
- Both legacy and JSON Forms control panels now work seamlessly

### Migrated Control Panels (15 total)
- 10 legacy-plugin-chart-* control panels
- 2 BigNumber ECharts control panels
- 1 Deck.gl Arc layer control panel
- 1 Word Cloud control panel (test case)
- 1 Chord diagram (previously attempted, now proper)

### Migration Pattern Established
- JSON Schema for data structure
- UI Schema for layout with collapsible groups
- Preserved all controlOverrides and formDataOverrides
- Full TypeScript support with proper types

### Benefits
- Industry-standard JSON Forms format
- Better separation of data model and UI
- Cleaner, more maintainable code
- Foundation for future enhancements

Next phase: Migrate remaining 40+ control panels and deprecate legacy format.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-08 14:48:15 -07:00
Evan Rusackas
fe0ea69280 feat(controls): Migrate all control panels to React component functions
Major refactor to modernize control panel system:

## Changes Made

### Core Infrastructure
- Created InlineControls.tsx with helper functions for all control types
- Added SharedControlComponents for replacing string control references
- Fixed TypeScript types and imports across all control panels
- Added proper exports and type definitions

### Control Panel Migrations
- Converted 20+ control panel files from inline configurations to React components
- Eliminated all string control references (e.g., ['metric'] → MetricControl())
- Updated all legacy-plugin-chart-* plugins
- Updated all legacy-preset-chart-deckgl layers
- Fixed chord diagram control panel (was prematurely using JSON Forms)

### Type Safety Improvements
- Fixed choice array type mismatches (now supports mixed types)
- Resolved import conflicts by renaming inline control helpers
- Added proper TypeScript types for all control configurations
- Reduced TypeScript errors by 57% (44 → 19)

### Pattern Conversion
Before: { name: 'control', config: { type: 'SelectControl', ... } }
After: SelectControl({ name: 'control', ... })

This sets the foundation for the next phase: migrating to JSON Forms format.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-08 14:14:39 -07:00
469 changed files with 33783 additions and 16747 deletions

40
.claude_rc Normal file
View File

@@ -0,0 +1,40 @@
# Claude Code RC for move-controls
This is a claudette-managed Apache Superset development environment.
## Project: move-controls
- Worktree Path: /Users/evan_1/.claudette/worktrees/move-controls
- Frontend Port: 9004
- Frontend URL: http://localhost:9004
## Quick Commands
Start services:
```bash
claudette docker up
```
Access frontend:
```bash
open http://localhost:9004
```
Run tests:
```bash
# Backend
pytest tests/unit_tests/
# Frontend
cd superset-frontend && npm test
```
## Environment Details
- Python venv: `.venv/` (auto-activated in claudette shell)
- Node modules: `superset-frontend/node_modules/`
- Docker prefix: `move-controls_`
## Development Tips
- Always use `claudette shell` to work in this project
- Run `pre-commit run --all-files` before committing
- Use `claudette docker` instead of docker-compose directly
- The frontend dev server runs on port 9004 to avoid conflicts

2
.github/CODEOWNERS vendored
View File

@@ -2,7 +2,7 @@
# https://github.com/apache/superset/issues/13351
/superset/migrations/ @mistercrunch @michael-s-molina @betodealmeida @eschutho @sadpandajoe
/superset/migrations/ @mistercrunch @michael-s-molina @betodealmeida @eschutho
# Notify some committers of changes in the components

4
.gitignore vendored
View File

@@ -26,6 +26,7 @@ __pycache__
.cache
.bento*
.cache-loader
.claude_rc
.coverage
cover
.DS_Store
@@ -131,6 +132,3 @@ superset/static/stats/statistics.html
# LLM-related
CLAUDE.local.md
.aider*
.claude_rc*
.env.local
PROJECT.md

View File

@@ -0,0 +1,802 @@
# Control Panel Migration Agent
A comprehensive guide for migrating Apache Superset control panels from the legacy config-based approach to the new React-based approach.
## Overview
This migration transforms control panels from complex string-referenced configurations (`controlPanelSections`/`controlSetRows`) to pure React components. The new approach provides:
- **Direct React components** instead of config objects
- **Full TypeScript support** with proper type safety
- **Simplified architecture** with no JSON intermediary
- **Better developer experience** with IDE autocomplete and refactoring support
## Architecture Comparison
### Legacy Architecture
```typescript
// Old approach: Config-based with string references and config objects
const config: ControlPanelConfig = {
controlPanelSections: [
{
label: t('Query'),
expanded: true,
controlSetRows: [
[GroupByControl()], // String reference
[MetricControl()], // String reference
[
{
name: 'show_labels',
config: {
type: 'CheckboxControl',
label: t('Show Labels'),
renderTrigger: true,
default: true,
},
},
], // Config object
],
},
],
};
```
### New React-Based Architecture
```typescript
// New approach: Pure React components with direct JSX
export const PieControlPanel: FC<PieControlPanelProps> = ({ ... }) => {
return (
<div>
<DndColumnSelect
value={formValues.groupby || []}
onChange={handleChange('groupby')}
// ... other props
/>
<CheckboxControl
label={t('Show Labels')}
value={formValues.show_labels ?? true}
onChange={handleChange('show_labels')}
renderTrigger
/>
</div>
);
};
// Mark as modern panel
(PieControlPanel as any).isModernPanel = true;
```
## Migration Steps
### 1. File Structure
Keep the existing file location but change from config to React component:
- `controlPanel.ts``[ChartName]ControlPanelSimple.tsx`
- The file remains in the same directory as the original
### 2. Update Imports
**From (Legacy):**
```typescript
import {
ControlPanelConfig,
sharedControls,
GroupByControl,
MetricControl
} from '@superset-ui/chart-controls';
```
**To (Modern):**
```typescript
import { FC, useState } from 'react';
import { t } from '@superset-ui/core';
import { Tabs } from 'antd';
import {
ColorSchemeControl,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
D3_FORMAT_DOCS,
D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT,
} from '@superset-ui/chart-controls';
// Direct component imports
import { DndColumnSelect } from '../../../../src/explore/components/controls/DndColumnSelectControl/DndColumnSelect';
import { DndMetricSelect } from '../../../../src/explore/components/controls/DndColumnSelectControl/DndMetricSelect';
import { DndFilterSelect } from '../../../../src/explore/components/controls/DndColumnSelectControl/DndFilterSelect';
import TextControl from '../../../../src/explore/components/controls/TextControl';
import CheckboxControl from '../../../../src/explore/components/controls/CheckboxControl';
import SliderControl from '../../../../src/explore/components/controls/SliderControl';
import SelectControl from '../../../../src/explore/components/controls/SelectControl';
import CurrencyControl from '../../../../src/explore/components/controls/CurrencyControl';
import ControlHeader from '../../../../src/explore/components/ControlHeader';
import Control from '../../../../src/explore/components/Control';
```
### 3. Component Structure Template
Create a React component with this structure:
```typescript
interface [ChartName]ControlPanelProps {
onChange?: (field: string, value: any) => void;
value?: Record<string, any>;
datasource?: any;
actions?: any;
controls?: any;
form_data?: any;
}
export const [ChartName]ControlPanel: FC<[ChartName]ControlPanelProps> = ({
onChange,
value,
datasource,
form_data,
actions,
controls,
}) => {
// Safety checks for datasource
if (!datasource || !form_data) {
return <div>Loading control panel...</div>;
}
// Ensure safe data structures
const safeColumns = Array.isArray(datasource?.columns) ? datasource.columns : [];
const safeMetrics = Array.isArray(datasource?.metrics) ? datasource.metrics : [];
// Helper for control changes
const handleChange = (field: string) => (val: any) => {
if (actions?.setControlValue) {
actions.setControlValue(field, val);
} else if (onChange) {
onChange(field, val);
}
};
// Get form values
const formValues = form_data || value || {};
// Tab state (if using tabs)
const [activeTab, setActiveTab] = useState('data');
// Component implementation here...
return (
<div style={{ padding: '16px' }}>
{/* Your controls here */}
</div>
);
};
// CRITICAL: Mark as modern panel
([ChartName]ControlPanel as any).isModernPanel = true;
// Export wrapper config for compatibility
const config = {
controlPanelSections: [
{
label: null,
expanded: true,
controlSetRows: [[[ChartName]ControlPanel as any]],
},
],
controlOverrides: {
// Move all defaults here
field_name: {
default: defaultValue,
label: t('Field Label'),
renderTrigger: true,
},
},
};
export default config;
```
### 4. Control Mapping Reference
#### String References → React Components
| Legacy String | Modern React Component | Notes |
|---------------|----------------------|--------|
| `['groupby']` | `<DndColumnSelect ... />` | Multi-select columns |
| `['metric']` | `<DndMetricSelect ... />` | Single metric select |
| `['metrics']` | `<DndMetricSelect ... />` | Multi metric select |
| `['adhoc_filters']` | `<DndFilterSelect ... />` | Advanced filters |
| `['row_limit']` | `<TextControl isInt ... />` | Numeric input |
| `['color_scheme']` | `ColorSchemeControl()` with `Control` wrapper | Special handling needed |
#### Config Objects → React Components
| Legacy Config | Modern Component | Example |
|---------------|------------------|---------|
| `{ type: 'TextControl', ... }` | `<TextControl ... />` | `<TextControl value={val} onChange={fn} />` |
| `{ type: 'CheckboxControl', ... }` | `<CheckboxControl ... />` | `<CheckboxControl label="..." value={val} />` |
| `{ type: 'SelectControl', ... }` | `<SelectControl ... />` | `<SelectControl choices={[...]} value={val} />` |
| `{ type: 'SliderControl', ... }` | `<SliderControl ... />` | `<SliderControl {...{min: 0, max: 100}} />` |
### 5. Props Mapping Guide
| Legacy Config Property | Modern React Prop | Notes |
|----------------------|------------------|-------|
| `label` | `label` prop OR `<ControlHeader>` | Use ControlHeader for tooltips |
| `description` | `description` prop OR `<ControlHeader>` | ControlHeader for complex descriptions |
| `default` | Move to `controlOverrides` | Don't set as component prop |
| `renderTrigger: true` | `renderTrigger` prop | Controls instant chart updates |
| `visibility` | Conditional rendering | `{condition && <Control />}` |
| `choices` | `choices` prop | For SelectControl |
| `min/max/step` | Spread object | `{...{ min: 10, max: 100, step: 1 }}` |
### 6. Implementing Tabbed Layout
Most modern control panels use a Data/Customize tab structure:
```typescript
const [activeTab, setActiveTab] = useState('data');
const dataTabContent = (
<div>
{/* Query-related controls: columns, metrics, filters, row limit */}
<div style={{ marginBottom: 16 }}>
<ControlHeader
label={t('Group by')}
description={t('Columns to group by')}
hovered
/>
<DndColumnSelect
value={formValues.groupby || []}
onChange={handleChange('groupby')}
options={safeColumns}
name="groupby"
label="" // Avoid duplicate labels
multi
canDelete
ghostButtonText={t('Add dimension')}
type="DndColumnSelect"
actions={actions}
/>
</div>
{/* More data controls... */}
</div>
);
const customizeTabContent = (
<div>
{/* Styling and display controls */}
<div style={{ marginBottom: 24 }}>
<h4>{t('Chart Options')}</h4>
{/* Styling controls... */}
</div>
</div>
);
const tabItems = [
{ key: 'data', label: t('Data'), children: dataTabContent },
{ key: 'customize', label: t('Customize'), children: customizeTabContent },
];
return (
<div style={{ padding: '16px' }}>
<Tabs
activeKey={activeTab}
onChange={setActiveTab}
items={tabItems}
size="large"
/>
</div>
);
```
### 7. Common Control Patterns
#### Drag-and-Drop Controls
```typescript
{/* Group By - Column Selection */}
<DndColumnSelect
value={formValues.groupby || []}
onChange={handleChange('groupby')}
options={safeColumns}
name="groupby"
label="" // Empty to avoid duplicate with ControlHeader
multi
canDelete
ghostButtonText={t('Add dimension')}
type="DndColumnSelect"
actions={actions}
/>
{/* Metric Selection */}
<DndMetricSelect
value={formValues.metric}
onChange={handleChange('metric')}
datasource={safeDataSource}
name="metric"
label=""
multi={false}
savedMetrics={safeMetrics}
/>
{/* Filters */}
<DndFilterSelect
value={formValues.adhoc_filters || []}
onChange={handleChange('adhoc_filters')}
datasource={safeDataSource}
columns={safeColumns}
formData={formValues}
name="adhoc_filters"
savedMetrics={safeMetrics}
selectedMetrics={formValues.metric ? [formValues.metric] : []}
type="DndFilterSelect"
actions={actions}
/>
```
#### Color Scheme Control (Special Case)
```typescript
{/* Color Scheme requires special Control wrapper */}
{(() => {
const colorSchemeControl = ColorSchemeControl();
const { hidden, ...cleanConfig } = colorSchemeControl.config || {};
return (
<Control
{...cleanConfig}
name="color_scheme"
value={formValues.color_scheme}
actions={{
...actions,
setControlValue: (field: string, val: any) => {
handleChange('color_scheme')(val);
},
}}
renderTrigger
/>
);
})()}
```
#### Basic Controls
```typescript
{/* Text Input */}
<TextControl
value={formValues.row_limit}
onChange={handleChange('row_limit')}
isInt
placeholder="100"
controlId="row_limit"
/>
{/* Checkbox */}
<CheckboxControl
label={t('Show Labels')}
description={t('Whether to display the labels.')}
value={formValues.show_labels ?? true}
onChange={handleChange('show_labels')}
renderTrigger
hovered
/>
{/* Select Dropdown */}
<SelectControl
label={t('Label Type')}
description={t('What should be shown on the label?')}
value={formValues.label_type || 'key'}
onChange={handleChange('label_type')}
choices={[
['key', t('Category Name')],
['value', t('Value')],
['percent', t('Percentage')],
]}
clearable={false}
renderTrigger
hovered
/>
{/* Slider */}
<SliderControl
value={formValues.outerRadius || 70}
onChange={handleChange('outerRadius')}
{...{ min: 10, max: 100, step: 1 }}
/>
```
#### Control Headers with Tooltips
```typescript
<ControlHeader
label={t('Percentage threshold')}
description={t('Minimum threshold in percentage points for showing labels.')}
renderTrigger
hovered
/>
```
#### Conditional Rendering
```typescript
{/* Show control only when condition is met */}
{formValues.show_labels && (
<CheckboxControl
label={t('Put labels outside')}
description={t('Put the labels outside of the pie?')}
value={formValues.labels_outside ?? true}
onChange={handleChange('labels_outside')}
renderTrigger
hovered
/>
)}
{/* Nested conditional rendering */}
{formValues.label_type === 'template' && (
<TextControl
value={formValues.label_template || ''}
onChange={handleChange('label_template')}
placeholder="{name}: {value}"
controlId="label_template"
/>
)}
```
### 8. Section Organization
Use HTML headers and spacing for logical groupings:
```typescript
{/* Chart Options Section */}
<div style={{ marginBottom: 24 }}>
<h4>{t('Chart Options')}</h4>
{/* Controls for this section */}
<div style={{ marginBottom: 16 }}>
{/* Individual control */}
</div>
</div>
{/* Labels Section */}
<div style={{ marginBottom: 24 }}>
<h4>{t('Labels')}</h4>
{/* Label-related controls */}
</div>
```
### 9. Control Defaults in controlOverrides
Move all default values to the `controlOverrides` section:
```typescript
const config = {
controlPanelSections: [
{
label: null,
expanded: true,
controlSetRows: [[PieControlPanel as any]],
},
],
controlOverrides: {
groupby: {
default: [],
label: t('Group by'),
},
metric: {
default: null,
label: t('Metric'),
},
show_labels: {
default: true,
label: t('Show labels'),
renderTrigger: true,
},
color_scheme: {
default: 'supersetColors',
label: t('Color scheme'),
renderTrigger: true,
},
// ... all other defaults
},
};
```
### 10. Chart Plugin Integration
Update the chart plugin to use the new control panel:
```typescript
// In your chart's index.ts file
import controlPanel from './PieControlPanelSimple'; // New React-based panel
export default class EchartsPieChartPlugin extends EchartsChartPlugin {
constructor() {
super({
controlPanel,
// ... other config
});
}
}
```
## Testing Your Migration
### 1. Visual Validation
- [ ] All controls render properly in the UI
- [ ] Tab navigation works (if using tabs)
- [ ] Control layout matches the original
- [ ] Conditional controls show/hide correctly
### 2. Functional Testing
- [ ] Control changes update the chart immediately (if `renderTrigger: true`)
- [ ] Form values persist when switching between tabs
- [ ] Drag-and-drop controls work with datasource
- [ ] Error states display appropriately
- [ ] Default values apply correctly
### 3. Integration Testing
- [ ] Control panel works in Explore view
- [ ] Values save correctly when creating charts
- [ ] Dashboard filters work with the controls
- [ ] Chart reloading preserves control values
## Common Issues & Solutions
### Issue: Double Labels on Controls
**Problem:** Control shows both ControlHeader label and control's built-in label
**Solution:** Set `label=""` on the control when using ControlHeader:
```typescript
<ControlHeader label={t('Group by')} />
<DndColumnSelect
label="" // Empty to prevent duplicate
// ... other props
/>
```
### Issue: Slider Min/Max Not Working
**Problem:** Slider doesn't respect min/max values
**Solution:** Use spread operator with object literal:
```typescript
<SliderControl
value={formValues.outerRadius || 70}
onChange={handleChange('outerRadius')}
{...{ min: 10, max: 100, step: 1 }} // Use spread with object
/>
```
### Issue: Controls Not Triggering Chart Updates
**Problem:** Chart doesn't refresh when controls change
**Solution:** Ensure `renderTrigger` is set where needed:
```typescript
<CheckboxControl
// ... other props
renderTrigger // Add this for instant updates
/>
```
### Issue: "Cannot read properties of undefined"
**Problem:** Attempting to access undefined datasource or form_data
**Solution:** Add safety checks and fallbacks:
```typescript
// Safety checks at component start
if (!datasource || !form_data) {
return <div>Loading control panel...</div>;
}
// Safe array access
const safeColumns = Array.isArray(datasource?.columns) ? datasource.columns : [];
```
### Issue: Color Scheme Control Not Working
**Problem:** ColorSchemeControl doesn't integrate properly
**Solution:** Use the special Control wrapper pattern:
```typescript
{(() => {
const colorSchemeControl = ColorSchemeControl();
const { hidden, ...cleanConfig } = colorSchemeControl.config || {};
return (
<Control
{...cleanConfig}
name="color_scheme"
value={formValues.color_scheme}
actions={{
...actions,
setControlValue: (field: string, val: any) => {
handleChange('color_scheme')(val);
},
}}
renderTrigger
/>
);
})()}
```
## Migration Checklist
### Pre-Migration
- [ ] Identify all controls in the legacy control panel
- [ ] Note any conditional control visibility rules
- [ ] Check for custom control configurations
- [ ] Understand the chart's specific requirements
### During Migration
- [ ] Create new `[ChartName]ControlPanelSimple.tsx` file
- [ ] Implement component structure with proper interface
- [ ] Map all legacy controls to React components
- [ ] Add safety checks for datasource/form_data
- [ ] Implement tab structure (Data/Customize)
- [ ] Add all control defaults to `controlOverrides`
- [ ] Mark component as modern with `isModernPanel = true`
- [ ] Update chart plugin to import new control panel
### Post-Migration Testing
- [ ] Test all control interactions
- [ ] Verify chart updates on control changes
- [ ] Check conditional control visibility
- [ ] Validate default values
- [ ] Test with different datasources
- [ ] Run pre-commit hooks: `pre-commit run`
- [ ] Test in Explore and Dashboard contexts
## Advanced Patterns
### Dynamic Control Visibility
```typescript
// Show additional controls based on current selection
{formValues.chart_type === 'pie' && (
<div>
{/* Pie-specific controls */}
<CheckboxControl
label={t('Show as Donut')}
value={formValues.donut ?? false}
onChange={handleChange('donut')}
/>
{formValues.donut && (
<SliderControl
value={formValues.innerRadius || 30}
onChange={handleChange('innerRadius')}
{...{ min: 0, max: 100, step: 1 }}
/>
)}
</div>
)}
```
### Complex Control Groups
```typescript
{/* Side-by-side controls */}
<div style={{ display: 'flex', gap: 16 }}>
<div style={{ flex: 1 }}>
<ControlHeader label={t('Min Value')} />
<TextControl
value={formValues.min_value}
onChange={handleChange('min_value')}
isFloat
/>
</div>
<div style={{ flex: 1 }}>
<ControlHeader label={t('Max Value')} />
<TextControl
value={formValues.max_value}
onChange={handleChange('max_value')}
isFloat
/>
</div>
</div>
```
### Custom Validation
```typescript
// Add validation logic to handleChange
const handleChange = (field: string) => (val: any) => {
// Custom validation
if (field === 'row_limit' && val && val < 1) {
console.warn('Row limit must be positive');
return;
}
if (actions?.setControlValue) {
actions.setControlValue(field, val);
} else if (onChange) {
onChange(field, val);
}
};
```
## Additional Migration Patterns
### Single Column Selection
When a control expects a single column value (not an array):
```typescript
// For Sankey source/target columns
const handleSingleColumnChange = (field: string) => (val: any) => {
const singleValue = Array.isArray(val) ? val[0] : val;
actions.setControlValue(field, singleValue);
};
// Usage
<DndColumnSelect
value={formValues.source ? [formValues.source] : []}
onChange={handleSingleColumnChange('source')}
options={safeColumns}
multi={false}
/>
```
### Required Field Validation
For controls that must have values:
```typescript
import { validateNonEmpty } from '@superset-ui/core';
// In controlOverrides
source: {
validators: [validateNonEmpty],
label: t('Source Column'),
},
```
### Chart Type Descriptions
Add helpful descriptions at the top of control panels:
```typescript
<div style={{ marginBottom: 16, padding: '12px', borderRadius: '4px' }}>
<div style={{ fontSize: '16px', fontWeight: 500, marginBottom: '8px' }}>
{t('Sankey Diagram')}
</div>
<div style={{ fontSize: '12px', opacity: 0.65 }}>
{t('Visualize flow between different entities')}
</div>
</div>
```
## Common Migration Issues & Solutions
### Issue 1: "Cannot read properties of undefined (reading 'map')"
**Problem:** DndColumnSelect crashes when datasource is undefined
**Solution:** Pass `options={datasource?.columns || []}` instead of `datasource={datasource}`
### Issue 2: Tabs import error ("Element type is invalid")
**Problem:** Runtime error when loading control panel
**Solution:** Import from 'antd' directly: `import { Tabs } from 'antd';` (NOT from '@superset-ui/core')
### Issue 3: React hooks error
**Problem:** "React Hook 'useState' is called conditionally"
**Solution:** Always declare state hooks before any conditional returns:
```typescript
const [activeTab, setActiveTab] = useState('data'); // FIRST
if (!datasource) return <div>Loading...</div>; // THEN conditions
```
### Issue 4: ESLint color literal warnings
**Problem:** theme-colors/no-literal-colors ESLint rule
**Solution:** Use opacity instead of color literals:
```typescript
// Bad: style={{ color: '#666' }}
// Good: style={{ opacity: 0.65 }}
```
### Issue 5: Single value vs array handling
**Problem:** Some controls expect single values but DndColumnSelect returns arrays
**Solution:** See "Single Column Selection" pattern above
### Issue 6: antd import warnings
**Problem:** "'antd' should be listed in the project's dependencies"
**Solution:** Use `SKIP=eslint-frontend` when committing if antd is already available
## Reference Implementation
The Pie chart control panel migration (`PieControlPanelSimple.tsx`) serves as the definitive reference implementation showing:
- Complete tab-based layout (Data/Customize)
- All major control types (DndColumnSelect, CheckboxControl, SelectControl, SliderControl, etc.)
- Conditional control rendering
- Proper safety checks and error handling
- Color scheme integration
- Control grouping and organization
- Modern React patterns and TypeScript usage
Study this implementation for best practices and patterns that can be applied to any chart control panel migration.
## Summary
The new React-based control panel approach provides:
1. **Better Developer Experience** - Direct React components with TypeScript
2. **Improved Maintainability** - Clear component structure and patterns
3. **Enhanced Flexibility** - Easy conditional rendering and dynamic controls
4. **Type Safety** - Full TypeScript support with proper interfaces
5. **Simplified Architecture** - No complex config intermediaries
The migration process involves converting string references and config objects to direct React components, implementing proper safety checks, and organizing controls in a logical tab-based structure. The key is to maintain compatibility with the existing Superset infrastructure while providing a more modern and maintainable development experience.

View File

@@ -0,0 +1,153 @@
# Control Panel Modernization Guide
## Current State
Apache Superset's control panels currently use a legacy `controlSetRows` structure that relies on nested arrays to define layout. This approach has several limitations:
1. **Rigid Layout**: The nested array structure makes it difficult to create responsive or complex layouts
2. **Poor Type Safety**: Arrays of arrays don't provide good TypeScript support
3. **Mixed Paradigms**: String references, configuration objects, and React components are mixed together
4. **Limited Reusability**: Layout logic is embedded in the structure rather than using composable components
## Migration Strategy
### Phase 1: Component Modernization ✅ COMPLETED
- Replaced string-based control references with React components
- Updated individual control components to use Ant Design
- Modernized the `ControlRow` component to use Ant Design's Grid
### Phase 2: Layout Utilities ✅ COMPLETED
- Created `ControlPanelLayout.tsx` with reusable layout components
- Implemented `ControlSection`, `SingleControlRow`, `TwoColumnRow`, `ThreeColumnRow`
- Updated control group components to use Ant Design Row/Col
### Phase 3: React-Based Control Panels 🚧 IN PROGRESS
- Create `ReactControlPanel` component for rendering modern panels
- Support both legacy and modern formats during transition
- Provide migration helpers and examples
### Phase 4: Gradual Migration 📋 TODO
- Migrate chart control panels one by one
- Start with simpler charts (Pie, Bar) before complex ones
- Maintain backward compatibility throughout
## Modern Control Panel Structure
### Legacy Structure (controlSetRows)
```typescript
const config: ControlPanelConfig = {
controlPanelSections: [
{
label: t('Query'),
expanded: true,
controlSetRows: [
[GroupByControl()],
[MetricControl()],
[AdhocFiltersControl()],
[RowLimitControl()],
],
},
],
};
```
### Modern Structure (React Components)
```typescript
const modernConfig: ReactControlPanelConfig = {
sections: [
{
key: 'query',
label: t('Query'),
expanded: true,
render: ({ values, onChange }) => (
<>
<SingleControlRow>
<GroupByControl value={values.groupby} onChange={onChange} />
</SingleControlRow>
<SingleControlRow>
<MetricControl value={values.metrics} onChange={onChange} />
</SingleControlRow>
<TwoColumnRow
left={<AdhocFiltersControl value={values.adhoc_filters} onChange={onChange} />}
right={<RowLimitControl value={values.row_limit} onChange={onChange} />}
/>
</>
),
},
],
};
```
## Benefits of Modernization
1. **Better Type Safety**: Full TypeScript support with proper interfaces
2. **Flexible Layouts**: Use Ant Design's Grid system for responsive layouts
3. **Cleaner Code**: React components instead of nested arrays
4. **Improved DX**: Better IDE support and autocomplete
5. **Easier Testing**: Component-based architecture is easier to test
6. **Consistent Styling**: Leverage Ant Design's theme system
## Migration Example
To migrate a control panel:
1. **Create a modern version** alongside the existing one:
```typescript
// controlPanelModern.tsx
export const modernConfig: ReactControlPanelConfig = {
sections: [/* ... */]
};
```
2. **Use the compatibility wrapper** for backward compatibility:
```typescript
export default createReactControlPanel(modernConfig);
```
3. **Update the chart plugin** to use the new control panel:
```typescript
import controlPanel from './controlPanelModern';
```
## Layout Components Available
- `ControlSection`: Collapsible section container
- `SingleControlRow`: Full-width single control
- `TwoColumnRow`: Two controls side by side (50/50)
- `ThreeColumnRow`: Three controls in a row (33/33/33)
- `Row` and `Col` from Ant Design for custom layouts
## Files Created
1. `packages/superset-ui-chart-controls/src/shared-controls/components/ControlPanelLayout.tsx`
- Layout utility components
2. `packages/superset-ui-chart-controls/src/shared-controls/components/ModernControlPanelExample.tsx`
- Example of modern control panel structure
3. `plugins/plugin-chart-echarts/src/Pie/controlPanelModern.tsx`
- Modern version of Pie chart control panel
## Next Steps
1. **Complete the ReactControlPanel integration** with ControlPanelsContainer
2. **Create migration tooling** to help convert existing panels
3. **Document best practices** for control panel design
4. **Update chart plugin template** to use modern structure
5. **Gradually migrate all 90+ control panels** in the codebase
## Technical Debt Addressed
- Eliminates nested array layout structure
- Removes string-based control references
- Reduces coupling between layout and configuration
- Improves maintainability and testability
- Enables better code splitting and lazy loading
## Backward Compatibility
The migration maintains full backward compatibility:
- Existing control panels continue to work
- Both formats can coexist during migration
- No breaking changes to the public API
- Charts can be migrated incrementally

74
LLMS.md
View File

@@ -189,3 +189,77 @@ pre-commit run eslint # Frontend linting
---
**LLM Note**: This codebase is actively modernizing toward full TypeScript and type safety. Always run `pre-commit run` to validate changes. Follow the ongoing refactors section to avoid deprecated patterns.
## Control Panel Migration Guide
### New React-Based Control Panel Architecture
We've successfully migrated from the complex string-referenced control panel system to a simpler React-based approach. Here's how to migrate existing control panels:
#### Key Changes
1. **No more string references** - Use React component functions instead of strings
2. **Redux integration** - Controls connect directly to Redux via useFormData hook
3. **Type safety** - Full TypeScript support with proper types
4. **Simplified architecture** - Direct React components, no JSON intermediary
#### Migration Steps
##### 1. Update imports
Replace string references with component imports:
```typescript
// OLD
controlSetRows: [
['series'],
['metric'],
]
// NEW
import { SeriesControl, MetricControl } from '@superset-ui/chart-controls';
controlSetRows: [
[SeriesControl()],
[MetricControl()],
]
```
##### 2. Custom controls
Use InlineTextControl or InlineSelectControl for custom controls:
```typescript
// OLD
{
name: 'size_from',
config: { type: 'TextControl', ... }
}
// NEW
InlineTextControl('sizeFrom', {
label: t('Minimum Font Size'),
default: 10,
...
})
```
##### 3. Control naming
Use camelCase for new controls, but handle both in transformProps:
```typescript
// In transformProps.ts
const finalSizeFrom = sizeFrom ?? size_from ?? 10;
```
#### Available Control Components
All these return CustomControlItem and can be used in controlSetRows:
- `SeriesControl()` - Column selection
- `MetricControl()` - Metric selection
- `AdhocFiltersControl()` - Filter configuration
- `RowLimitControl()` - Row limit
- `ColorSchemeControl()` - Color scheme picker
- `InlineTextControl(name, config)` - Custom text input
- `InlineSelectControl(name, config)` - Custom select
#### Example Migration
See `plugins/plugin-chart-word-cloud/src/plugin/controlPanelFixed.ts` for a complete example.
# important-instruction-reminders
Do what has been asked; nothing more, nothing less.
NEVER create files unless they're absolutely necessary for achieving your goal.
ALWAYS prefer editing an existing file to creating a new one.
NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.

257
PIE_CHART_MIGRATION_PLAN.md Normal file
View File

@@ -0,0 +1,257 @@
# Pie Chart Control Panel Migration - Phased Approach
## Phase 1: Parallel Implementation ✅ COMPLETED
We've created a modern control panel alongside the legacy one:
### Files Created:
1. **`controlPanelModern.tsx`** - Modern React-based control panel
2. **`ModernControlPanelRenderer.tsx`** - Bridge component for compatibility
3. **Updated `ControlPanelsContainer.tsx`** - Support for modern panels
### Key Features:
- Full React component structure (no `controlSetRows`)
- Uses Ant Design Grid directly
- Type-safe with TypeScript interfaces
- Conditional rendering based on form values
- Organized into logical sections
## Phase 2: Integration Testing 🚧 NEXT STEP
### 2.1 Update the Pie Chart Plugin
```typescript
// In plugins/plugin-chart-echarts/src/Pie/index.ts
import controlPanel from './controlPanel'; // Legacy
import controlPanelModern from './controlPanelModern'; // Modern
// Feature flag to toggle between old and new
const useModernPanel = window.featureFlags?.MODERN_CONTROL_PANELS;
export default class EchartsPieChartPlugin extends ChartPlugin {
constructor() {
super({
// ... other config
controlPanel: useModernPanel ? controlPanelModern : controlPanel,
});
}
}
```
### 2.2 Test the Modern Panel
Create test file to verify both panels produce same output:
```typescript
// controlPanel.test.tsx
describe('Pie Control Panel Migration', () => {
it('modern panel handles all legacy controls', () => {
// Test that all controls from legacy panel exist in modern
});
it('produces same form_data structure', () => {
// Verify form_data compatibility
});
it('visibility conditions work correctly', () => {
// Test conditional rendering
});
});
```
## Phase 3: Feature Flag Rollout
### 3.1 Add Feature Flag
```python
# In superset/config.py
FEATURE_FLAGS = {
"MODERN_CONTROL_PANELS": False, # Start disabled
}
```
### 3.2 Gradual Rollout
1. **Internal Testing**: Enable for development environment
2. **Beta Users**: Enable for select users (5%)
3. **Wider Rollout**: Increase to 50%
4. **Full Migration**: Enable for all users
5. **Cleanup**: Remove legacy code
## Phase 4: Migration Utilities
### 4.1 Control Panel Converter
```typescript
// convertLegacyPanel.ts
export function convertControlSetRows(rows: ControlSetRow[]): ReactElement {
return rows.map(row => {
if (row.length === 1) {
return <SingleControlRow>{convertControl(row[0])}</SingleControlRow>;
}
if (row.length === 2) {
return (
<TwoColumnRow
left={convertControl(row[0])}
right={convertControl(row[1])}
/>
);
}
// ... handle other cases
});
}
```
### 4.2 Common Patterns Library
```typescript
// commonPanelPatterns.tsx
export const QuerySection = ({ values, onChange }) => (
<>
<GroupByControl />
<MetricControl />
<AdhocFiltersControl />
<RowLimitControl />
</>
);
export const AppearanceSection = ({ values, onChange }) => (
<>
<ColorSchemeControl />
<OpacityControl />
<LegendControls />
</>
);
```
## Phase 5: Migrate Other Charts
### Priority Order (Simple to Complex):
1. **Simple Charts** (1-2 weeks each)
- Bar Chart
- Line Chart
- Area Chart
- Scatter Plot
2. **Medium Complexity** (2-3 weeks each)
- Table
- Pivot Table
- Heatmap
- Treemap
3. **Complex Charts** (3-4 weeks each)
- Mixed Time Series
- Box Plot
- Sankey
- Graph/Network
### Migration Checklist per Chart:
- [ ] Create `controlPanelModern.tsx`
- [ ] Update plugin index to support both
- [ ] Write migration tests
- [ ] Test with feature flag
- [ ] Document any chart-specific patterns
- [ ] Update TypeScript types if needed
## Phase 6: System-Wide Updates
### 6.1 Update Control Panel Registry
```typescript
// getChartControlPanelRegistry.ts
export interface ModernControlPanelRegistry {
get(key: string): ControlPanelConfig | ReactControlPanelConfig;
registerModern(key: string, config: ReactControlPanelConfig): void;
}
```
### 6.2 Update Explore Components
- `ControlPanelsContainer` - Full support for modern panels ✅
- `Control` - Ensure all control types work
- `ControlRow` - Already modernized ✅
- `getSectionsToRender` - Update to handle React components
### 6.3 Update Types
```typescript
// types.ts
export type ControlPanelConfig = LegacyControlPanelConfig | ModernControlPanelConfig;
export interface ModernControlPanelConfig {
type: 'modern';
sections: ReactControlPanelSection[];
controlOverrides?: ControlOverrides;
formDataOverrides?: FormDataOverrides;
}
```
## Benefits Tracking
### Metrics to Monitor:
1. **Developer Velocity**: Time to add new controls
2. **Bug Rate**: Control panel-related issues
3. **Performance**: Rendering time for control panels
4. **Type Safety**: TypeScript coverage percentage
5. **Code Maintainability**: Lines of code, complexity metrics
### Expected Improvements:
- 50% reduction in control panel code
- 80% reduction in control panel bugs
- 100% TypeScript coverage
- 30% faster control panel rendering
- Easier onboarding for new developers
## Rollback Plan
If issues arise:
1. **Feature Flag**: Immediately disable `MODERN_CONTROL_PANELS`
2. **Hotfix**: Revert to legacy panel for affected charts
3. **Investigation**: Debug issues in staging environment
4. **Fix Forward**: Address issues and re-enable gradually
## Timeline Estimate
- **Phase 1**: ✅ Completed
- **Phase 2**: 1 week (testing and integration)
- **Phase 3**: 2 weeks (feature flag and rollout)
- **Phase 4**: 1 week (utilities and patterns)
- **Phase 5**: 3-6 months (all charts migration)
- **Phase 6**: 2 weeks (system updates)
- **Cleanup**: 1 week (remove legacy code)
**Total: 4-7 months for complete migration**
## Next Immediate Steps
1. Test the modern Pie control panel in development
2. Fix any issues with value binding and onChange handlers
3. Create feature flag in Python backend
4. Write comprehensive tests
5. Get team buy-in on approach
6. Start incremental migration
## Code Snippets for Testing
```bash
# Test the modern panel
cd superset-frontend
npm run dev
# In browser console
window.featureFlags = { MODERN_CONTROL_PANELS: true };
# Create a new Pie chart and verify controls work
```
## Success Criteria
- [ ] All control panels migrated to modern format
- [ ] No regression in functionality
- [ ] Improved developer experience
- [ ] Better performance metrics
- [ ] Reduced maintenance burden
- [ ] Full TypeScript coverage

View File

@@ -32,10 +32,11 @@ else
SUPERSET_VERSION="${1}"
SUPERSET_RC="${2}"
SUPERSET_PGP_FULLNAME="${3}"
SUPERSET_VERSION_RC="${SUPERSET_VERSION}rc${SUPERSET_RC}"
SUPERSET_RELEASE_RC_TARBALL="apache_superset-${SUPERSET_VERSION_RC}-source.tar.gz"
fi
SUPERSET_VERSION_RC="${SUPERSET_VERSION}rc${SUPERSET_RC}"
if [ -z "${SUPERSET_SVN_DEV_PATH}" ]; then
SUPERSET_SVN_DEV_PATH="$HOME/svn/superset_dev"
fi

View File

@@ -94,9 +94,9 @@ under the License.
| can available domains on Superset |:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O|
| can request access on Superset |:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O|
| can dashboard on Superset |:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O|
| can post on TableSchemaView |:heavy_check_mark:|O|O|:heavy_check_mark:|
| can expanded on TableSchemaView |:heavy_check_mark:|O|O|:heavy_check_mark:|
| can delete on TableSchemaView |:heavy_check_mark:|O|O|:heavy_check_mark:|
| can post on TableSchemaView |:heavy_check_mark:|:heavy_check_mark:|O|O|
| can expanded on TableSchemaView |:heavy_check_mark:|:heavy_check_mark:|O|O|
| can delete on TableSchemaView |:heavy_check_mark:|:heavy_check_mark:|O|O|
| can get on TabStateView |:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|
| can post on TabStateView |:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|
| can delete query on TabStateView |:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|

View File

@@ -23,13 +23,6 @@ This file documents any backwards-incompatible changes in Superset and
assists people when migrating to a new version.
## Next
- [34536](https://github.com/apache/superset/pull/34536): The `ENVIRONMENT_TAG_CONFIG` color values have changed to support only Ant Design semantic colors. Update your `superset_config.py`:
- Change `"error.base"` to just `"error"` after this PR
- Change any hex color values to one of: `"success"`, `"processing"`, `"error"`, `"warning"`, `"default"`
- Custom colors are no longer supported to maintain consistency with Ant Design components
- [34561](https://github.com/apache/superset/pull/34561) Added tiled screenshot functionality for Playwright-based reports to handle large dashboards more efficiently. When enabled (default: `SCREENSHOT_TILED_ENABLED = True`), dashboards with 20+ charts or height exceeding 5000px will be captured using multiple viewport-sized tiles and combined into a single image. This improves report generation performance and reliability for large dashboards.
Note: Pillow is now a required dependency (previously optional) to support image processing for tiled screenshots.
`thumbnails` optional dependency is now deprecated and will be removed in the next major release (7.0).
- [33084](https://github.com/apache/superset/pull/33084) The DISALLOWED_SQL_FUNCTIONS configuration now includes additional potentially sensitive database functions across PostgreSQL, MySQL, SQLite, MS SQL Server, and ClickHouse. Existing queries using these functions may now be blocked. Review your SQL Lab queries and dashboards if you encounter "disallowed function" errors after upgrading
- [34235](https://github.com/apache/superset/pull/34235) CSV exports now use `utf-8-sig` encoding by default to include a UTF-8 BOM, improving compatibility with Excel.
- [34258](https://github.com/apache/superset/pull/34258) changing the default in Dockerfile to INCLUDE_CHROMIUM="false" (from "true") in the past. This ensures the `lean` layer is lean by default, and people can opt-in to the `chromium` layer by setting the build arg `INCLUDE_CHROMIUM=true`. This is a breaking change for anyone using the `lean` layer, as it will no longer include Chromium by default.

View File

@@ -17,47 +17,16 @@
# -----------------------------------------------------------------------
# Lightweight docker-compose for running multiple Superset instances
# This includes only essential services: database and Superset app (no Redis)
# This includes only essential services: database, Redis, and Superset app
#
# RUNNING SUPERSET:
# 1. Start services: docker-compose -f docker-compose-light.yml up
# 2. Access at: http://localhost:9001 (or NODE_PORT if specified)
#
# RUNNING MULTIPLE INSTANCES:
# IMPORTANT: To run multiple instances in parallel:
# - Use different project names: docker-compose -p project1 -f docker-compose-light.yml up
# - Use different NODE_PORT values: NODE_PORT=9002 docker-compose -p project2 -f docker-compose-light.yml up
# - Volumes are isolated by project name (e.g., project1_db_home_light, project2_db_home_light)
# - Database name is intentionally different (superset_light) to prevent accidental cross-connections
#
# RUNNING TESTS WITH PYTEST:
# Tests run in an isolated environment with a separate test database.
# The pytest-runner service automatically creates and initializes the test database on first use.
#
# Basic usage:
# docker-compose -f docker-compose-light.yml run --rm pytest-runner pytest tests/unit_tests/
#
# Run specific test file:
# docker-compose -f docker-compose-light.yml run --rm pytest-runner pytest tests/unit_tests/test_foo.py
#
# Run with pytest options:
# docker-compose -f docker-compose-light.yml run --rm pytest-runner pytest -v -s -x tests/
#
# Force reload test database and run tests (when tests are failing due to bad state):
# docker-compose -f docker-compose-light.yml run --rm -e FORCE_RELOAD=true pytest-runner pytest tests/
#
# Run any command in test environment:
# docker-compose -f docker-compose-light.yml run --rm pytest-runner bash
# docker-compose -f docker-compose-light.yml run --rm pytest-runner pytest --collect-only
#
# For parallel test execution with different projects:
# docker-compose -p project1 -f docker-compose-light.yml run --rm pytest-runner pytest tests/
#
# DEVELOPMENT TIPS:
# - First test run takes ~20-30 seconds (database creation + initialization)
# - Subsequent runs are fast (~2-3 seconds startup)
# - Use FORCE_RELOAD=true when you need a clean test database
# - Tests use SimpleCache instead of Redis (no Redis required)
# - Set SUPERSET_LOG_LEVEL=debug in docker/.env-local for detailed logs
# For verbose logging during development:
# - Set SUPERSET_LOG_LEVEL=debug in docker/.env-local for detailed Superset logs
# -----------------------------------------------------------------------
x-superset-user: &superset-user root
x-superset-volumes: &superset-volumes
@@ -87,14 +56,13 @@ services:
required: false
image: postgres:16
restart: unless-stopped
# No host port mapping - only accessible within Docker network
volumes:
- db_home_light:/var/lib/postgresql/data
- ./docker/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
environment:
# Override database name to avoid conflicts
POSTGRES_DB: superset_light
# Increase max connections for test runs
command: postgres -c max_connections=200
superset-light:
env_file:
@@ -182,34 +150,6 @@ services:
required: false
volumes: *superset-volumes
pytest-runner:
build:
<<: *common-build
entrypoint: ["/app/docker/docker-pytest-entrypoint.sh"]
env_file:
- path: docker/.env # default
required: true
- path: docker/.env-local # optional override
required: false
profiles:
- test # Only starts when --profile test is used
depends_on:
db-light:
condition: service_started
user: *superset-user
volumes: *superset-volumes
environment:
# Test-specific database configuration
DATABASE_HOST: db-light
DATABASE_DB: test
POSTGRES_DB: test
# Point to test database
SUPERSET__SQLALCHEMY_DATABASE_URI: postgresql+psycopg2://superset:superset@db-light:5432/test
# Use the light test config that doesn't require Redis
SUPERSET_CONFIG: superset_test_config_light
# Python path includes test directory
PYTHONPATH: /app/pythonpath:/app/docker/pythonpath_dev:/app
volumes:
superset_home_light:
external: false

View File

@@ -1,152 +0,0 @@
#!/bin/bash
#
# 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.
#
set -e
# Wait for PostgreSQL to be ready
echo "Waiting for database to be ready..."
for i in {1..30}; do
if python3 -c "
import psycopg2
try:
conn = psycopg2.connect(host='db-light', user='superset', password='superset', database='superset_light')
conn.close()
print('Database is ready!')
except:
exit(1)
" 2>/dev/null; then
echo "Database connection established!"
break
fi
echo "Waiting for database... ($i/30)"
if [ $i -eq 30 ]; then
echo "Database connection timeout after 30 seconds"
exit 1
fi
sleep 1
done
# Handle database setup based on FORCE_RELOAD
if [ "${FORCE_RELOAD}" = "true" ]; then
echo "Force reload requested - resetting test database"
# Drop and recreate the test database using Python
python3 -c "
import psycopg2
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
# Connect to default database
conn = psycopg2.connect(host='db-light', user='superset', password='superset', database='superset_light')
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cur = conn.cursor()
# Drop and recreate test database
try:
cur.execute('DROP DATABASE IF EXISTS test')
except:
pass
cur.execute('CREATE DATABASE test')
conn.close()
# Connect to test database to create schemas
conn = psycopg2.connect(host='db-light', user='superset', password='superset', database='test')
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cur = conn.cursor()
cur.execute('CREATE SCHEMA sqllab_test_db')
cur.execute('CREATE SCHEMA admin_database')
cur.close()
conn.close()
print('Test database reset successfully')
"
# Use --no-reset-db since we already reset it
FLAGS="--no-reset-db"
else
echo "Using existing test database (set FORCE_RELOAD=true to reset)"
FLAGS="--no-reset-db"
# Ensure test database exists using Python
python3 -c "
import psycopg2
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
# Check if test database exists
try:
conn = psycopg2.connect(host='db-light', user='superset', password='superset', database='test')
conn.close()
print('Test database already exists')
except:
print('Creating test database...')
# Connect to default database to create test database
conn = psycopg2.connect(host='db-light', user='superset', password='superset', database='superset_light')
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cur = conn.cursor()
# Create test database
cur.execute('CREATE DATABASE test')
conn.close()
# Connect to test database to create schemas
conn = psycopg2.connect(host='db-light', user='superset', password='superset', database='test')
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cur = conn.cursor()
cur.execute('CREATE SCHEMA IF NOT EXISTS sqllab_test_db')
cur.execute('CREATE SCHEMA IF NOT EXISTS admin_database')
cur.close()
conn.close()
print('Test database created successfully')
"
fi
# Always run database migrations to ensure schema is up to date
echo "Running database migrations..."
cd /app
superset db upgrade
# Initialize test environment if needed
if [ "${FORCE_RELOAD}" = "true" ] || [ ! -f "/app/superset_home/.test_initialized" ]; then
echo "Initializing test environment..."
# Run initialization commands
superset init
echo "Loading test users..."
superset load-test-users
# Mark as initialized
touch /app/superset_home/.test_initialized
else
echo "Test environment already initialized (skipping init and load-test-users)"
echo "Tip: Use FORCE_RELOAD=true to reinitialize the test database"
fi
# Create missing scripts needed for tests
if [ ! -f "/app/scripts/tag_latest_release.sh" ]; then
echo "Creating missing tag_latest_release.sh script for tests..."
cp /app/docker/tag_latest_release.sh /app/scripts/tag_latest_release.sh 2>/dev/null || true
fi
# Install pip module for Shillelagh compatibility (aligns with CI environment)
echo "Installing pip module for Shillelagh compatibility..."
uv pip install pip
# If arguments provided, execute them
if [ $# -gt 0 ]; then
exec "$@"
fi

View File

@@ -1,55 +0,0 @@
# 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.
#
# Test configuration for docker-compose-light.yml - uses SimpleCache instead of Redis
# Import all settings from the main test config first
import os
import sys
# Add the tests directory to the path to import the test config
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
from tests.integration_tests.superset_test_config import * # noqa: F403
# Override Redis-based caching to use simple in-memory cache
CACHE_CONFIG = {
"CACHE_TYPE": "SimpleCache",
"CACHE_DEFAULT_TIMEOUT": 300,
"CACHE_KEY_PREFIX": "superset_test_",
}
DATA_CACHE_CONFIG = {
**CACHE_CONFIG,
"CACHE_DEFAULT_TIMEOUT": 30,
"CACHE_KEY_PREFIX": "superset_test_data_",
}
# Keep SimpleCache for these as they're already using it
# FILTER_STATE_CACHE_CONFIG - already SimpleCache in parent
# EXPLORE_FORM_DATA_CACHE_CONFIG - already SimpleCache in parent
# Disable Celery for lightweight testing
CELERY_CONFIG = None
# Use FileSystemCache for SQL Lab results instead of Redis
from flask_caching.backends.filesystemcache import FileSystemCache # noqa: E402
RESULTS_BACKEND = FileSystemCache("/app/superset_home/sqllab_test")
# Override WEBDRIVER_BASEURL for tests to match expected values
WEBDRIVER_BASEURL = "http://0.0.0.0:8080/"
WEBDRIVER_BASEURL_USER_FRIENDLY = WEBDRIVER_BASEURL

View File

@@ -1,190 +0,0 @@
#! /bin/bash
# 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.
run_git_tag () {
if [[ "$DRY_RUN" == "false" ]] && [[ "$SKIP_TAG" == "false" ]]
then
git tag -a -f latest "${GITHUB_TAG_NAME}" -m "latest tag"
echo "${GITHUB_TAG_NAME} has been tagged 'latest'"
fi
exit 0
}
###
# separating out git commands into functions so they can be mocked in unit tests
###
git_show_ref () {
if [[ "$TEST_ENV" == "true" ]]
then
if [[ "$GITHUB_TAG_NAME" == "does_not_exist" ]]
# mock return for testing only
then
echo ""
else
echo "2817aebd69dc7d199ec45d973a2079f35e5658b6 refs/tags/${GITHUB_TAG_NAME}"
fi
fi
result=$(git show-ref "${GITHUB_TAG_NAME}")
echo "${result}"
}
get_latest_tag_list () {
if [[ "$TEST_ENV" == "true" ]]
then
echo "(tag: 2.1.0, apache/2.1test)"
else
result=$(git show-ref --tags --dereference latest | awk '{print $2}' | xargs git show --pretty=tformat:%d -s | grep tag:)
echo "${result}"
fi
}
###
split_string () {
local version="$1"
local delimiter="$2"
local components=()
local tmp=""
for (( i=0; i<${#version}; i++ )); do
local char="${version:$i:1}"
if [[ "$char" != "$delimiter" ]]; then
tmp="$tmp$char"
elif [[ -n "$tmp" ]]; then
components+=("$tmp")
tmp=""
fi
done
if [[ -n "$tmp" ]]; then
components+=("$tmp")
fi
echo "${components[@]}"
}
DRY_RUN=false
# get params passed in with script when it was run
# --dry-run is optional and returns the value of SKIP_TAG, but does not run the git tag statement
# A tag name is required as a param. A SHA won't work. You must first tag a sha with a release number
# and then run this script
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--dry-run)
DRY_RUN=true
shift # past value
;;
*) # this should be the tag name
GITHUB_TAG_NAME=$key
shift # past value
;;
esac
done
if [ -z "${GITHUB_TAG_NAME}" ]; then
echo "Missing tag parameter, usage: ./scripts/tag_latest_release.sh <GITHUB_TAG_NAME>"
echo "SKIP_TAG=true" >> $GITHUB_OUTPUT
exit 1
fi
if [ -z "$(git_show_ref)" ]; then
echo "The tag ${GITHUB_TAG_NAME} does not exist. Please use a different tag."
echo "SKIP_TAG=true" >> $GITHUB_OUTPUT
exit 0
fi
# check that this tag only contains a proper semantic version
if ! [[ ${GITHUB_TAG_NAME} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
then
echo "This tag ${GITHUB_TAG_NAME} is not a valid release version. Not tagging."
echo "SKIP_TAG=true" >> $GITHUB_OUTPUT
exit 1
fi
## split the current GITHUB_TAG_NAME into an array at the dot
THIS_TAG_NAME=$(split_string "${GITHUB_TAG_NAME}" ".")
# look up the 'latest' tag on git
LATEST_TAG_LIST=$(get_latest_tag_list) || echo 'not found'
# if 'latest' tag doesn't exist, then set this commit to latest
if [[ -z "$LATEST_TAG_LIST" ]]
then
echo "there are no latest tags yet, so I'm going to start by tagging this sha as the latest"
run_git_tag
exit 0
fi
# remove parenthesis and tag: from the list of tags
LATEST_TAGS_STRINGS=$(echo "$LATEST_TAG_LIST" | sed 's/tag: \([^,]*\)/\1/g' | tr -d '()')
LATEST_TAGS=$(split_string "$LATEST_TAGS_STRINGS" ",")
TAGS=($(split_string "$LATEST_TAGS" " "))
# Initialize a flag for comparison result
compare_result=""
# Iterate through the tags of the latest release
for tag in $TAGS
do
if [[ $tag == "latest" ]]; then
continue
else
## extract just the version from this tag
LATEST_RELEASE_TAG="$tag"
echo "LATEST_RELEASE_TAG: ${LATEST_RELEASE_TAG}"
# check that this only contains a proper semantic version
if ! [[ ${LATEST_RELEASE_TAG} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
then
echo "'Latest' has been associated with tag ${LATEST_RELEASE_TAG} which is not a valid release version. Looking for another."
continue
fi
echo "The current release with the latest tag is version ${LATEST_RELEASE_TAG}"
# Split the version strings into arrays
THIS_TAG_NAME_ARRAY=($(split_string "$THIS_TAG_NAME" "."))
LATEST_RELEASE_TAG_ARRAY=($(split_string "$LATEST_RELEASE_TAG" "."))
# Iterate through the components of the version strings
for (( j=0; j<${#THIS_TAG_NAME_ARRAY[@]}; j++ )); do
echo "Comparing ${THIS_TAG_NAME_ARRAY[$j]} to ${LATEST_RELEASE_TAG_ARRAY[$j]}"
if [[ $((THIS_TAG_NAME_ARRAY[$j])) > $((LATEST_RELEASE_TAG_ARRAY[$j])) ]]; then
compare_result="greater"
break
elif [[ $((THIS_TAG_NAME_ARRAY[$j])) < $((LATEST_RELEASE_TAG_ARRAY[$j])) ]]; then
compare_result="lesser"
break
fi
done
fi
done
# Determine the result based on the comparison
if [[ -z "$compare_result" ]]; then
echo "Versions are equal"
echo "SKIP_TAG=true" >> $GITHUB_OUTPUT
elif [[ "$compare_result" == "greater" ]]; then
echo "This release tag ${GITHUB_TAG_NAME} is newer than the latest."
echo "SKIP_TAG=false" >> $GITHUB_OUTPUT
# Add other actions you want to perform for a newer version
elif [[ "$compare_result" == "lesser" ]]; then
echo "This release tag ${GITHUB_TAG_NAME} is older than the latest."
echo "This release tag ${GITHUB_TAG_NAME} is not the latest. Not tagging."
# if you've gotten this far, then we don't want to run any tags in the next step
echo "SKIP_TAG=true" >> $GITHUB_OUTPUT
fi

View File

@@ -13,9 +13,9 @@ apache-superset>=6.0
Superset now rides on **Ant Design v5's token-based theming**.
Every Antd token works, plus a handful of Superset-specific ones for charts and dashboard chrome.
## Managing Themes via UI
## Managing Themes via CRUD Interface
Superset includes a built-in **Theme Management** interface accessible from the admin menu under **Settings > Themes**.
Superset now includes a built-in **Theme Management** interface accessible from the admin menu under **Settings > Themes**.
### Creating a New Theme
@@ -29,38 +29,22 @@ Superset includes a built-in **Theme Management** interface accessible from the
You can also extend with Superset-specific tokens (documented in the default theme object) before you import.
### System Theme Administration
When `ENABLE_UI_THEME_ADMINISTRATION = True` is configured, administrators can manage system-wide themes directly from the UI:
#### Setting System Themes
- **System Default Theme**: Click the sun icon on any theme to set it as the system-wide default
- **System Dark Theme**: Click the moon icon on any theme to set it as the system dark mode theme
- **Automatic OS Detection**: When both default and dark themes are set, Superset automatically detects and applies the appropriate theme based on OS preferences
#### Managing System Themes
- System themes are indicated with special badges in the theme list
- Only administrators with write permissions can modify system theme settings
- Removing a system theme designation reverts to configuration file defaults
### Applying Themes to Dashboards
Once created, themes can be applied to individual dashboards:
- Edit any dashboard and select your custom theme from the theme dropdown
- Each dashboard can have its own theme, allowing for branded or context-specific styling
## Configuration Options
## Alternative: Instance-wide Configuration
### Python Configuration
For system-wide theming, you can configure default themes via Python configuration:
Configure theme behavior via `superset_config.py`:
### Setting Default Themes
```python
# Enable UI-based theme administration for admins
ENABLE_UI_THEME_ADMINISTRATION = True
# superset_config.py
# Optional: Set initial default themes via configuration
# These can be overridden via the UI when ENABLE_UI_THEME_ADMINISTRATION = True
# Default theme (light mode)
THEME_DEFAULT = {
"token": {
"colorPrimary": "#2893B3",
@@ -69,7 +53,7 @@ THEME_DEFAULT = {
}
}
# Optional: Dark theme configuration
# Dark theme configuration
THEME_DARK = {
"algorithm": "dark",
"token": {
@@ -78,28 +62,23 @@ THEME_DARK = {
}
}
# To force a single theme on all users, set THEME_DARK = None
# When both themes are defined (via UI or config):
# - Users can manually switch between themes
# - OS preference detection is automatically enabled
# Theme behavior settings
THEME_SETTINGS = {
"enforced": False, # If True, forces default theme always
"allowSwitching": True, # Allow users to switch between themes
"allowOSPreference": True, # Auto-detect system theme preference
}
```
### Migration from Configuration to UI
### Copying Themes from CRUD Interface
When `ENABLE_UI_THEME_ADMINISTRATION = True`:
To use a theme created via the CRUD interface as your system default:
1. System themes set via the UI take precedence over configuration file settings
2. The UI shows which themes are currently set as system defaults
3. Administrators can change system themes without restarting Superset
4. Configuration file themes serve as fallbacks when no UI themes are set
1. Navigate to **Settings > Themes** and edit your desired theme
2. Copy the complete JSON configuration from the theme definition field
3. Paste it directly into your `superset_config.py` as shown above
### Copying Themes Between Systems
To export a theme for use in configuration files or another instance:
1. Navigate to **Settings > Themes** and click the export icon on your desired theme
2. Extract the JSON configuration from the exported YAML file
3. Use this JSON in your `superset_config.py` or import it into another Superset instance
Restart Superset to apply changes.
## Theme Development Workflow
@@ -167,26 +146,7 @@ This feature works with the stock Docker image - no custom build required!
## Advanced Features
- **System Themes**: Manage system-wide default and dark themes via UI or configuration
- **System Themes**: Superset includes built-in light and dark themes
- **Per-Dashboard Theming**: Each dashboard can have its own visual identity
- **JSON Editor**: Edit theme configurations directly within Superset's interface
- **Custom Fonts**: Load external fonts via configuration without rebuilding
- **OS Dark Mode Detection**: Automatically switches themes based on system preferences
- **Theme Import/Export**: Share themes between instances via YAML files
## API Access
For programmatic theme management, Superset provides REST endpoints:
- `GET /api/v1/theme/` - List all themes
- `POST /api/v1/theme/` - Create a new theme
- `PUT /api/v1/theme/{id}` - Update a theme
- `DELETE /api/v1/theme/{id}` - Delete a theme
- `PUT /api/v1/theme/{id}/set_system_default` - Set as system default theme (admin only)
- `PUT /api/v1/theme/{id}/set_system_dark` - Set as system dark theme (admin only)
- `DELETE /api/v1/theme/unset_system_default` - Remove system default designation
- `DELETE /api/v1/theme/unset_system_dark` - Remove system dark designation
- `GET /api/v1/theme/export/` - Export themes as YAML
- `POST /api/v1/theme/import/` - Import themes from YAML
These endpoints require appropriate permissions and are subject to RBAC controls.

View File

@@ -2,20 +2,6 @@
title: CVEs fixed by release
sidebar_position: 2
---
#### Version 5.0.0
| CVE | Title | Affected |
|:---------------|:-----------------------------------------------------------------------------------|---------:|
| CVE-2025-55673 | Exposure of Sensitive Information to an Unauthorized Actor | < 5.0.0 |
| CVE-2025-55674 | Improper Neutralization of Special Elements used in an SQL Command | < 5.0.0 |
| CVE-2025-55675 | Improper Access Control leading to Information Disclosure | < 5.0.0 |
#### Version 4.1.3
| CVE | Title | Affected |
|:---------------|:-----------------------------------------------------------------------------------|---------:|
| CVE-2025-55672 | Improper Neutralization of Input During Web Page Generation | < 4.1.3 |
#### Version 4.1.2
| CVE | Title | Affected |

View File

@@ -44,14 +44,14 @@
"@types/react": "^19.1.8",
"@typescript-eslint/eslint-plugin": "^8.37.0",
"@typescript-eslint/parser": "^8.37.0",
"eslint": "^9.32.0",
"eslint": "^9.31.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.3",
"eslint-plugin-prettier": "^5.5.1",
"eslint-plugin-react": "^7.37.5",
"globals": "^16.3.0",
"prettier": "^3.6.2",
"typescript": "~5.8.3",
"typescript-eslint": "^8.39.0",
"typescript-eslint": "^8.37.0",
"webpack": "^5.101.0"
},
"browserslist": {

View File

@@ -2150,7 +2150,14 @@
resolved "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.2.5.tgz"
integrity sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA==
"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.7.0":
"@eslint-community/eslint-utils@^4.2.0":
version "4.4.1"
resolved "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz"
integrity sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==
dependencies:
eslint-visitor-keys "^3.4.3"
"@eslint-community/eslint-utils@^4.7.0":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.7.0.tgz#607084630c6c033992a082de6e6fbc1a8b52175a"
integrity sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==
@@ -2198,7 +2205,12 @@
minimatch "^3.1.2"
strip-json-comments "^3.1.1"
"@eslint/js@9.32.0", "@eslint/js@^9.32.0":
"@eslint/js@9.31.0":
version "9.31.0"
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.31.0.tgz#adb1f39953d8c475c4384b67b67541b0d7206ed8"
integrity sha512-LOm5OVt7D4qiKCqoiPbA7LWmI+tbw1VbTUowBcUMgQSuM6poJufkFkYDcQpo5KfgD39TnNySV26QjOh7VFpSyw==
"@eslint/js@^9.32.0":
version "9.32.0"
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.32.0.tgz#a02916f58bd587ea276876cb051b579a3d75d091"
integrity sha512-BBpRFZK3eX6uMLKz8WxFOBIFFcGFJ/g8XuwjTHCqHROSIsopI+ddn/d5Cfh36+7+e5edVS8dbSHnBNhrLEX0zg==
@@ -2208,10 +2220,10 @@
resolved "https://registry.yarnpkg.com/@eslint/object-schema/-/object-schema-2.1.6.tgz#58369ab5b5b3ca117880c0f6c0b0f32f6950f24f"
integrity sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==
"@eslint/plugin-kit@^0.3.4":
version "0.3.4"
resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.3.4.tgz#c6b9f165e94bf4d9fdd493f1c028a94aaf5fc1cc"
integrity sha512-Ul5l+lHEcw3L5+k8POx6r74mxEYKG5kOb6Xpy2gCRW6zweT6TEhAf8vhxGgjhqrd/VO/Dirhsb+1hNpD1ue9hw==
"@eslint/plugin-kit@^0.3.1":
version "0.3.3"
resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.3.3.tgz#32926b59bd407d58d817941e48b2a7049359b1fd"
integrity sha512-1+WqvgNMhmlAambTvT3KPtCl/Ibr68VldY2XY40SL1CE0ZXiakFR/cbTspaF5HsnpDMvcYYoJHfl4980NBjGag==
dependencies:
"@eslint/core" "^0.15.1"
levn "^0.4.1"
@@ -3717,79 +3729,79 @@
dependencies:
"@types/yargs-parser" "*"
"@typescript-eslint/eslint-plugin@8.39.0", "@typescript-eslint/eslint-plugin@^8.37.0":
version "8.39.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.39.0.tgz#c9afec1866ee1a6ea3d768b5f8e92201efbbba06"
integrity sha512-bhEz6OZeUR+O/6yx9Jk6ohX6H9JSFTaiY0v9/PuKT3oGK0rn0jNplLmyFUGV+a9gfYnVNwGDwS/UkLIuXNb2Rw==
"@typescript-eslint/eslint-plugin@8.37.0", "@typescript-eslint/eslint-plugin@^8.37.0":
version "8.37.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.37.0.tgz#332392883f936137cd6252c8eb236d298e514e70"
integrity sha512-jsuVWeIkb6ggzB+wPCsR4e6loj+rM72ohW6IBn2C+5NCvfUVY8s33iFPySSVXqtm5Hu29Ne/9bnA0JmyLmgenA==
dependencies:
"@eslint-community/regexpp" "^4.10.0"
"@typescript-eslint/scope-manager" "8.39.0"
"@typescript-eslint/type-utils" "8.39.0"
"@typescript-eslint/utils" "8.39.0"
"@typescript-eslint/visitor-keys" "8.39.0"
"@typescript-eslint/scope-manager" "8.37.0"
"@typescript-eslint/type-utils" "8.37.0"
"@typescript-eslint/utils" "8.37.0"
"@typescript-eslint/visitor-keys" "8.37.0"
graphemer "^1.4.0"
ignore "^7.0.0"
natural-compare "^1.4.0"
ts-api-utils "^2.1.0"
"@typescript-eslint/parser@8.39.0", "@typescript-eslint/parser@^8.37.0":
version "8.39.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.39.0.tgz#c4b895d7a47f4cd5ee6ee77ea30e61d58b802008"
integrity sha512-g3WpVQHngx0aLXn6kfIYCZxM6rRJlWzEkVpqEFLT3SgEDsp9cpCbxxgwnE504q4H+ruSDh/VGS6nqZIDynP+vg==
"@typescript-eslint/parser@8.37.0", "@typescript-eslint/parser@^8.37.0":
version "8.37.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.37.0.tgz#b87f6b61e25ad5cc5bbf8baf809b8da889c89804"
integrity sha512-kVIaQE9vrN9RLCQMQ3iyRlVJpTiDUY6woHGb30JDkfJErqrQEmtdWH3gV0PBAfGZgQXoqzXOO0T3K6ioApbbAA==
dependencies:
"@typescript-eslint/scope-manager" "8.39.0"
"@typescript-eslint/types" "8.39.0"
"@typescript-eslint/typescript-estree" "8.39.0"
"@typescript-eslint/visitor-keys" "8.39.0"
"@typescript-eslint/scope-manager" "8.37.0"
"@typescript-eslint/types" "8.37.0"
"@typescript-eslint/typescript-estree" "8.37.0"
"@typescript-eslint/visitor-keys" "8.37.0"
debug "^4.3.4"
"@typescript-eslint/project-service@8.39.0":
version "8.39.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/project-service/-/project-service-8.39.0.tgz#71cb29c3f8139f99a905b8705127bffc2ae84759"
integrity sha512-CTzJqaSq30V/Z2Og9jogzZt8lJRR5TKlAdXmWgdu4hgcC9Kww5flQ+xFvMxIBWVNdxJO7OifgdOK4PokMIWPew==
"@typescript-eslint/project-service@8.37.0":
version "8.37.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/project-service/-/project-service-8.37.0.tgz#0594352e32a4ac9258591b88af77b5653800cdfe"
integrity sha512-BIUXYsbkl5A1aJDdYJCBAo8rCEbAvdquQ8AnLb6z5Lp1u3x5PNgSSx9A/zqYc++Xnr/0DVpls8iQ2cJs/izTXA==
dependencies:
"@typescript-eslint/tsconfig-utils" "^8.39.0"
"@typescript-eslint/types" "^8.39.0"
"@typescript-eslint/tsconfig-utils" "^8.37.0"
"@typescript-eslint/types" "^8.37.0"
debug "^4.3.4"
"@typescript-eslint/scope-manager@8.39.0":
version "8.39.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.39.0.tgz#ba4bf6d8257bbc172c298febf16bc22df4856570"
integrity sha512-8QOzff9UKxOh6npZQ/4FQu4mjdOCGSdO3p44ww0hk8Vu+IGbg0tB/H1LcTARRDzGCC8pDGbh2rissBuuoPgH8A==
"@typescript-eslint/scope-manager@8.37.0":
version "8.37.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.37.0.tgz#a31a3c80ca2ef4ed58de13742debb692e7d4c0a4"
integrity sha512-0vGq0yiU1gbjKob2q691ybTg9JX6ShiVXAAfm2jGf3q0hdP6/BruaFjL/ManAR/lj05AvYCH+5bbVo0VtzmjOA==
dependencies:
"@typescript-eslint/types" "8.39.0"
"@typescript-eslint/visitor-keys" "8.39.0"
"@typescript-eslint/types" "8.37.0"
"@typescript-eslint/visitor-keys" "8.37.0"
"@typescript-eslint/tsconfig-utils@8.39.0", "@typescript-eslint/tsconfig-utils@^8.39.0":
version "8.39.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.39.0.tgz#b2e87fef41a3067c570533b722f6af47be213f13"
integrity sha512-Fd3/QjmFV2sKmvv3Mrj8r6N8CryYiCS8Wdb/6/rgOXAWGcFuc+VkQuG28uk/4kVNVZBQuuDHEDUpo/pQ32zsIQ==
"@typescript-eslint/tsconfig-utils@8.37.0", "@typescript-eslint/tsconfig-utils@^8.37.0":
version "8.37.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.37.0.tgz#47a2760d265c6125f8e7864bc5c8537cad2bd053"
integrity sha512-1/YHvAVTimMM9mmlPvTec9NP4bobA1RkDbMydxG8omqwJJLEW/Iy2C4adsAESIXU3WGLXFHSZUU+C9EoFWl4Zg==
"@typescript-eslint/type-utils@8.39.0":
version "8.39.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.39.0.tgz#310ec781ae5e7bb0f5940bfd652573587f22786b"
integrity sha512-6B3z0c1DXVT2vYA9+z9axjtc09rqKUPRmijD5m9iv8iQpHBRYRMBcgxSiKTZKm6FwWw1/cI4v6em35OsKCiN5Q==
"@typescript-eslint/type-utils@8.37.0":
version "8.37.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.37.0.tgz#2a682e4c6ff5886712dad57e9787b5e417124507"
integrity sha512-SPkXWIkVZxhgwSwVq9rqj/4VFo7MnWwVaRNznfQDc/xPYHjXnPfLWn+4L6FF1cAz6e7dsqBeMawgl7QjUMj4Ow==
dependencies:
"@typescript-eslint/types" "8.39.0"
"@typescript-eslint/typescript-estree" "8.39.0"
"@typescript-eslint/utils" "8.39.0"
"@typescript-eslint/types" "8.37.0"
"@typescript-eslint/typescript-estree" "8.37.0"
"@typescript-eslint/utils" "8.37.0"
debug "^4.3.4"
ts-api-utils "^2.1.0"
"@typescript-eslint/types@8.39.0", "@typescript-eslint/types@^8.39.0":
version "8.39.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.39.0.tgz#80f010b7169d434a91cd0529d70a528dbc9c99c6"
integrity sha512-ArDdaOllnCj3yn/lzKn9s0pBQYmmyme/v1HbGIGB0GB/knFI3fWMHloC+oYTJW46tVbYnGKTMDK4ah1sC2v0Kg==
"@typescript-eslint/types@8.37.0", "@typescript-eslint/types@^8.37.0":
version "8.37.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.37.0.tgz#09517aa9625eb3c68941dde3ac8835740587b6ff"
integrity sha512-ax0nv7PUF9NOVPs+lmQ7yIE7IQmAf8LGcXbMvHX5Gm+YJUYNAl340XkGnrimxZ0elXyoQJuN5sbg6C4evKA4SQ==
"@typescript-eslint/typescript-estree@8.39.0":
version "8.39.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.39.0.tgz#b9477a5c47a0feceffe91adf553ad9a3cd4cb3d6"
integrity sha512-ndWdiflRMvfIgQRpckQQLiB5qAKQ7w++V4LlCHwp62eym1HLB/kw7D9f2e8ytONls/jt89TEasgvb+VwnRprsw==
"@typescript-eslint/typescript-estree@8.37.0":
version "8.37.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.37.0.tgz#a07e4574d8e6e4355a558f61323730c987f5fcbc"
integrity sha512-zuWDMDuzMRbQOM+bHyU4/slw27bAUEcKSKKs3hcv2aNnc/tvE/h7w60dwVw8vnal2Pub6RT1T7BI8tFZ1fE+yg==
dependencies:
"@typescript-eslint/project-service" "8.39.0"
"@typescript-eslint/tsconfig-utils" "8.39.0"
"@typescript-eslint/types" "8.39.0"
"@typescript-eslint/visitor-keys" "8.39.0"
"@typescript-eslint/project-service" "8.37.0"
"@typescript-eslint/tsconfig-utils" "8.37.0"
"@typescript-eslint/types" "8.37.0"
"@typescript-eslint/visitor-keys" "8.37.0"
debug "^4.3.4"
fast-glob "^3.3.2"
is-glob "^4.0.3"
@@ -3797,22 +3809,22 @@
semver "^7.6.0"
ts-api-utils "^2.1.0"
"@typescript-eslint/utils@8.39.0":
version "8.39.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.39.0.tgz#dfea42f3c7ec85f9f3e994ff0bba8f3b2f09e220"
integrity sha512-4GVSvNA0Vx1Ktwvf4sFE+exxJ3QGUorQG1/A5mRfRNZtkBT2xrA/BCO2H0eALx/PnvCS6/vmYwRdDA41EoffkQ==
"@typescript-eslint/utils@8.37.0":
version "8.37.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.37.0.tgz#189ea59b2709f5d898614611f091a776751ee335"
integrity sha512-TSFvkIW6gGjN2p6zbXo20FzCABbyUAuq6tBvNRGsKdsSQ6a7rnV6ADfZ7f4iI3lIiXc4F4WWvtUfDw9CJ9pO5A==
dependencies:
"@eslint-community/eslint-utils" "^4.7.0"
"@typescript-eslint/scope-manager" "8.39.0"
"@typescript-eslint/types" "8.39.0"
"@typescript-eslint/typescript-estree" "8.39.0"
"@typescript-eslint/scope-manager" "8.37.0"
"@typescript-eslint/types" "8.37.0"
"@typescript-eslint/typescript-estree" "8.37.0"
"@typescript-eslint/visitor-keys@8.39.0":
version "8.39.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.39.0.tgz#5d619a6e810cdd3fd1913632719cbccab08bf875"
integrity sha512-ldgiJ+VAhQCfIjeOgu8Kj5nSxds0ktPOSO9p4+0VDH2R2pLvQraaM5Oen2d7NxzMCm+Sn/vJT+mv2H5u6b/3fA==
"@typescript-eslint/visitor-keys@8.37.0":
version "8.37.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.37.0.tgz#cdb6a6bd3e8d6dd69bd70c1bdda36e2d18737455"
integrity sha512-YzfhzcTnZVPiLfP/oeKtDp2evwvHLMe0LOy7oe+hb9KKIumLNohYS9Hgp1ifwpu42YWxhZE8yieggz6JpqO/1w==
dependencies:
"@typescript-eslint/types" "8.39.0"
"@typescript-eslint/types" "8.37.0"
eslint-visitor-keys "^4.2.1"
"@ungap/structured-clone@^1.0.0":
@@ -5605,13 +5617,20 @@ debug@2.6.9:
dependencies:
ms "2.0.0"
debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.4.0:
debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a"
integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==
dependencies:
ms "^2.1.3"
debug@^4.3.2, debug@^4.3.4:
version "4.3.4"
resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"
decode-named-character-reference@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/decode-named-character-reference/-/decode-named-character-reference-1.1.0.tgz#5d6ce68792808901210dac42a8e9853511e2b8bf"
@@ -6137,10 +6156,10 @@ eslint-config-prettier@^10.1.8:
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-10.1.8.tgz#15734ce4af8c2778cc32f0b01b37b0b5cd1ecb97"
integrity sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==
eslint-plugin-prettier@^5.5.3:
version "5.5.3"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.5.3.tgz#1f88e9220a72ac8be171eec5f9d4e4d529b5f4a0"
integrity sha512-NAdMYww51ehKfDyDhv59/eIItUVzU0Io9H2E8nHNGKEeeqlnci+1gCvrHib6EmZdf6GxF+LCV5K7UC65Ezvw7w==
eslint-plugin-prettier@^5.5.1:
version "5.5.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.5.1.tgz#470820964de9aedb37e9ce62c3266d2d26d08d15"
integrity sha512-dobTkHT6XaEVOo8IO90Q4DOSxnm3Y151QxPJlM/vKC0bVy+d6cVWQZLlFiuZPP0wS6vZwSKeJgKkcS+KfMBlRw==
dependencies:
prettier-linter-helpers "^1.0.0"
synckit "^0.11.7"
@@ -6195,10 +6214,10 @@ eslint-visitor-keys@^4.2.1:
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz#4cfea60fe7dd0ad8e816e1ed026c1d5251b512c1"
integrity sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==
eslint@^9.32.0:
version "9.32.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.32.0.tgz#4ea28df4a8dbc454e1251e0f3aed4bcf4ce50a47"
integrity sha512-LSehfdpgMeWcTZkWZVIJl+tkZ2nuSkyyB9C27MZqFWXuph7DvaowgcTvKqxvpLW1JZIk8PN7hFY3Rj9LQ7m7lg==
eslint@^9.31.0:
version "9.31.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.31.0.tgz#9a488e6da75bbe05785cd62e43c5ea99356d21ba"
integrity sha512-QldCVh/ztyKJJZLr4jXNUByx3gR+TDYZCRXEktiZoUR3PGy4qCmSbkxcIle8GEwGpb5JBZazlaJ/CxLidXdEbQ==
dependencies:
"@eslint-community/eslint-utils" "^4.2.0"
"@eslint-community/regexpp" "^4.12.1"
@@ -6206,8 +6225,8 @@ eslint@^9.32.0:
"@eslint/config-helpers" "^0.3.0"
"@eslint/core" "^0.15.0"
"@eslint/eslintrc" "^3.3.1"
"@eslint/js" "9.32.0"
"@eslint/plugin-kit" "^0.3.4"
"@eslint/js" "9.31.0"
"@eslint/plugin-kit" "^0.3.1"
"@humanfs/node" "^0.16.6"
"@humanwhocodes/module-importer" "^1.0.1"
"@humanwhocodes/retry" "^0.4.2"
@@ -9040,6 +9059,11 @@ ms@2.0.0:
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==
ms@2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
ms@2.1.3, ms@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
@@ -12348,15 +12372,15 @@ types-ramda@^0.30.0:
dependencies:
ts-toolbelt "^9.6.0"
typescript-eslint@^8.39.0:
version "8.39.0"
resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-8.39.0.tgz#b19c1a925cf8566831ae3875d2881ee2349808a5"
integrity sha512-lH8FvtdtzcHJCkMOKnN73LIn6SLTpoojgJqDAxPm1jCR14eWSGPX8ul/gggBdPMk/d5+u9V854vTYQ8T5jF/1Q==
typescript-eslint@^8.37.0:
version "8.37.0"
resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-8.37.0.tgz#2235ddfa40cdbdadb1afb05f8bda688a2294b4c2"
integrity sha512-TnbEjzkE9EmcO0Q2zM+GE8NQLItNAJpMmED1BdgoBMYNdqMhzlbqfdSwiRlAzEK2pA9UzVW0gzaaIzXWg2BjfA==
dependencies:
"@typescript-eslint/eslint-plugin" "8.39.0"
"@typescript-eslint/parser" "8.39.0"
"@typescript-eslint/typescript-estree" "8.39.0"
"@typescript-eslint/utils" "8.39.0"
"@typescript-eslint/eslint-plugin" "8.37.0"
"@typescript-eslint/parser" "8.37.0"
"@typescript-eslint/typescript-estree" "8.37.0"
"@typescript-eslint/utils" "8.37.0"
typescript@~5.8.3:
version "5.8.3"

View File

@@ -15,7 +15,7 @@
# limitations under the License.
#
apiVersion: v2
appVersion: "5.0.0"
appVersion: "4.1.2"
description: Apache Superset is a modern, enterprise-ready business intelligence web application
name: superset
icon: https://artifacthub.io/image/68c1d717-0e97-491f-b046-754e46f46922@2x
@@ -29,7 +29,7 @@ maintainers:
- name: craig-rueda
email: craig@craigrueda.com
url: https://github.com/craig-rueda
version: 0.15.0 # See [README](https://github.com/apache/superset/blob/master/helm/superset/README.md#versioning) for version details.
version: 0.14.3
dependencies:
- name: postgresql
version: 13.4.4

View File

@@ -23,7 +23,7 @@ NOTE: This file is generated by helm-docs: https://github.com/norwoodj/helm-docs
# superset
![Version: 0.15.0](https://img.shields.io/badge/Version-0.15.0-informational?style=flat-square)
![Version: 0.14.3](https://img.shields.io/badge/Version-0.14.3-informational?style=flat-square)
Apache Superset is a modern, enterprise-ready business intelligence web application
@@ -336,6 +336,3 @@ On helm this can be set on `extraSecretEnv.SUPERSET_SECRET_KEY` or `configOverri
| supersetWorker.topologySpreadConstraints | list | `[]` | TopologySpreadConstrains to be added to supersetWorker deployments |
| tolerations | list | `[]` | |
| topologySpreadConstraints | list | `[]` | TopologySpreadConstrains to be added to all deployments |
## Versioning
This chart follows [semantic versioning](https://semver.org/). The chart version is independent of the Superset version. The chart version is incremented when there are changes to the chart itself, such as new features, bug fixes, or changes in configuration options. In addition to semver, the chart version is also incremented in the minor version when there is a breaking change in the Superset appVersion itself. When there are non-breaking changes in the Superset appVersion, the chart version is incremented in the patch version.

View File

@@ -48,6 +48,3 @@ On helm this can be set on `extraSecretEnv.SUPERSET_SECRET_KEY` or `configOverri
{{ template "chart.requirementsSection" . }}
{{ template "chart.valuesSection" . }}
## Versioning
This chart follows [semantic versioning](https://semver.org/). The chart version is independent of the Superset version. The chart version is incremented when there are changes to the chart itself, such as new features, bug fixes, or changes in configuration options. In addition to semver, the chart version is also incremented in the minor version when there is a breaking change in the Superset appVersion itself. When there are non-breaking changes in the Superset appVersion, the chart version is incremented in the patch version.

486
package-lock.json generated Normal file
View File

@@ -0,0 +1,486 @@
{
"name": "move-controls",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"glob": "^11.0.3"
}
},
"node_modules/@isaacs/balanced-match": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz",
"integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==",
"license": "MIT",
"engines": {
"node": "20 || >=22"
}
},
"node_modules/@isaacs/brace-expansion": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz",
"integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==",
"license": "MIT",
"dependencies": {
"@isaacs/balanced-match": "^4.0.1"
},
"engines": {
"node": "20 || >=22"
}
},
"node_modules/@isaacs/cliui": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
"integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==",
"license": "ISC",
"dependencies": {
"string-width": "^5.1.2",
"string-width-cjs": "npm:string-width@^4.2.0",
"strip-ansi": "^7.0.1",
"strip-ansi-cjs": "npm:strip-ansi@^6.0.1",
"wrap-ansi": "^8.1.0",
"wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/ansi-regex": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz",
"integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
}
},
"node_modules/ansi-styles": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz",
"integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"license": "MIT",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"license": "MIT"
},
"node_modules/cross-spawn": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"license": "MIT",
"dependencies": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/eastasianwidth": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
"integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==",
"license": "MIT"
},
"node_modules/emoji-regex": {
"version": "9.2.2",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
"integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==",
"license": "MIT"
},
"node_modules/foreground-child": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz",
"integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==",
"license": "ISC",
"dependencies": {
"cross-spawn": "^7.0.6",
"signal-exit": "^4.0.1"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/glob": {
"version": "11.0.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz",
"integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==",
"license": "ISC",
"dependencies": {
"foreground-child": "^3.3.1",
"jackspeak": "^4.1.1",
"minimatch": "^10.0.3",
"minipass": "^7.1.2",
"package-json-from-dist": "^1.0.0",
"path-scurry": "^2.0.0"
},
"bin": {
"glob": "dist/esm/bin.mjs"
},
"engines": {
"node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
"license": "ISC"
},
"node_modules/jackspeak": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.1.1.tgz",
"integrity": "sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==",
"license": "BlueOak-1.0.0",
"dependencies": {
"@isaacs/cliui": "^8.0.2"
},
"engines": {
"node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/lru-cache": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.1.0.tgz",
"integrity": "sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==",
"license": "ISC",
"engines": {
"node": "20 || >=22"
}
},
"node_modules/minimatch": {
"version": "10.0.3",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz",
"integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==",
"license": "ISC",
"dependencies": {
"@isaacs/brace-expansion": "^5.0.0"
},
"engines": {
"node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/minipass": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
"integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==",
"license": "ISC",
"engines": {
"node": ">=16 || 14 >=14.17"
}
},
"node_modules/package-json-from-dist": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==",
"license": "BlueOak-1.0.0"
},
"node_modules/path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/path-scurry": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz",
"integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==",
"license": "BlueOak-1.0.0",
"dependencies": {
"lru-cache": "^11.0.0",
"minipass": "^7.1.2"
},
"engines": {
"node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"license": "MIT",
"dependencies": {
"shebang-regex": "^3.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/shebang-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/signal-exit": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
"license": "ISC",
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/string-width": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
"integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==",
"license": "MIT",
"dependencies": {
"eastasianwidth": "^0.2.0",
"emoji-regex": "^9.2.2",
"strip-ansi": "^7.0.1"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/string-width-cjs": {
"name": "string-width",
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/string-width-cjs/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/string-width-cjs/node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"license": "MIT"
},
"node_modules/string-width-cjs/node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-ansi": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz",
"integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==",
"license": "MIT",
"dependencies": {
"ansi-regex": "^6.0.1"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
}
},
"node_modules/strip-ansi-cjs": {
"name": "strip-ansi",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-ansi-cjs/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"license": "ISC",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/node-which"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/wrap-ansi": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz",
"integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==",
"license": "MIT",
"dependencies": {
"ansi-styles": "^6.1.0",
"string-width": "^5.0.1",
"strip-ansi": "^7.0.1"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/wrap-ansi-cjs": {
"name": "wrap-ansi",
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/wrap-ansi-cjs/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/wrap-ansi-cjs/node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/wrap-ansi-cjs/node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"license": "MIT"
},
"node_modules/wrap-ansi-cjs/node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/wrap-ansi-cjs/node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
}
}
}

5
package.json Normal file
View File

@@ -0,0 +1,5 @@
{
"dependencies": {
"glob": "^11.0.3"
}
}

View File

@@ -79,7 +79,6 @@ dependencies = [
"parsedatetime",
"paramiko>=3.4.0",
"pgsanity",
"Pillow>=11.0.0, <12",
"polyline>=2.0.0, <3.0",
"pyparsing>=3.0.6, <4",
"python-dateutil",
@@ -182,7 +181,7 @@ tdengine = [
"taos-ws-py>=0.3.8"
]
teradata = ["teradatasql>=16.20.0.23"]
thumbnails = [] # deprecated, will be removed in 7.0
thumbnails = ["Pillow>=10.0.1, <11"]
vertica = ["sqlalchemy-vertica-python>=0.5.9, < 0.6"]
netezza = ["nzalchemy>=11.0.2"]
starrocks = ["starrocks>=1.0.0"]
@@ -196,7 +195,6 @@ development = [
"grpcio>=1.55.3",
"openapi-spec-validator",
"parameterized",
"pip",
"pre-commit",
"progress>=1.5,<2",
"psutil",
@@ -401,7 +399,6 @@ authorized_licenses = [
"isc license (iscl)",
"isc license",
"mit",
"mit-cmu",
"mozilla public license 2.0 (mpl 2.0)",
"osi approved",
"osi approved",

View File

@@ -266,8 +266,6 @@ parsedatetime==2.6
# via apache-superset (pyproject.toml)
pgsanity==0.2.9
# via apache-superset (pyproject.toml)
pillow==11.3.0
# via apache_superset (pyproject.toml)
platformdirs==4.3.8
# via requests-cache
ply==3.11

View File

@@ -537,12 +537,10 @@ pgsanity==0.2.9
# via
# -c requirements/base.txt
# apache-superset
pillow==11.3.0
pillow==10.3.0
# via
# apache-superset
# matplotlib
pip==25.1.1
# via apache-superset
platformdirs==4.3.8
# via
# -c requirements/base.txt

View File

@@ -403,7 +403,6 @@ module.exports = {
'theme-colors/no-literal-colors': 'error',
'icons/no-fa-icons-usage': 'error',
'i18n-strings/no-template-vars': ['error', true],
'i18n-strings/sentence-case-buttons': 'error',
camelcase: [
'error',
{

View File

@@ -19,7 +19,7 @@
import { LOGIN } from 'cypress/utils/urls';
function interceptLogin() {
cy.intercept('POST', '**/login/').as('login');
cy.intercept('POST', '/login/').as('login');
}
describe('Login view', () => {

View File

@@ -155,7 +155,7 @@ describe('Horizontal FilterBar', () => {
]);
setFilterBarOrientation('horizontal');
cy.get('.filter-item-wrapper').should('have.length', 4);
cy.get('.filter-item-wrapper').should('have.length', 3);
openMoreFilters();
cy.getBySel('form-item-value').should('have.length', 12);
cy.getBySel('filter-control-name').contains('test_3').should('be.visible');

View File

@@ -22,6 +22,7 @@ import {
dataTestChartName,
} from 'cypress/support/directories';
import { waitForChartLoad } from 'cypress/utils';
import {
addParentFilterWithValue,
applyNativeFilterValueWithIndex,
@@ -343,7 +344,7 @@ describe('Native filters', () => {
it('User can delete a native filter', () => {
enterNativeFilterEditModal(false);
cy.get(nativeFilters.filtersList.removeIcon).first().click();
cy.contains('Restore filter').should('not.exist', { timeout: 10000 });
cy.contains('Restore Filter').should('not.exist', { timeout: 10000 });
});
it('User can cancel creating a new filter', () => {

View File

@@ -10227,11 +10227,14 @@
"peer": true
},
"node_modules/tmp": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.4.tgz",
"integrity": "sha512-UdiSoX6ypifLmrfQ/XfiawN6hkjSBpCjhKxxZcWlUUmoXLaCKQU0bx4HF/tdDK2uzRuchf1txGvrWBzYREssoQ==",
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz",
"integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==",
"dependencies": {
"rimraf": "^3.0.0"
},
"engines": {
"node": ">=14.14"
"node": ">=8.17.0"
}
},
"node_modules/to-regex-range": {
@@ -18595,9 +18598,12 @@
"peer": true
},
"tmp": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.4.tgz",
"integrity": "sha512-UdiSoX6ypifLmrfQ/XfiawN6hkjSBpCjhKxxZcWlUUmoXLaCKQU0bx4HF/tdDK2uzRuchf1txGvrWBzYREssoQ=="
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz",
"integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==",
"requires": {
"rimraf": "^3.0.0"
}
},
"to-regex-range": {
"version": "5.0.1",

View File

@@ -41,7 +41,7 @@ module.exports = {
context.report({
node,
message:
"Don't use variables in translation string templates. Flask-babel is a static translation service, so it can't handle strings that include variables",
"Don't use variables in translation string templates. Flask-babel is a static translation service, so it cant handle strings that include variables",
});
}
}
@@ -52,67 +52,5 @@ module.exports = {
};
},
},
'sentence-case-buttons': {
create(context) {
function isTitleCase(str) {
// Match "Delete Dataset", "Create Chart", etc. (2+ title-cased words)
return /^[A-Z][a-z]+(\s+[A-Z][a-z]*)+$/.test(str);
}
function isButtonContext(node) {
const { parent } = node;
if (!parent) return false;
// Check for button-specific props
if (parent.type === 'Property') {
const key = parent.key.name;
return [
'primaryButtonName',
'secondaryButtonName',
'confirmButtonText',
'cancelButtonText',
].includes(key);
}
// Check for Button components
if (parent.type === 'JSXExpressionContainer') {
const jsx = parent.parent;
if (jsx?.type === 'JSXElement') {
const elementName = jsx.openingElement.name.name;
return elementName === 'Button';
}
}
return false;
}
function handler(node) {
if (node.arguments.length) {
const firstArg = node.arguments[0];
if (
firstArg.type === 'Literal' &&
typeof firstArg.value === 'string'
) {
const text = firstArg.value;
if (isButtonContext(node) && isTitleCase(text)) {
const sentenceCase = text
.toLowerCase()
.replace(/^\w/, c => c.toUpperCase());
context.report({
node: firstArg,
message: `Button text should use sentence case: "${text}" should be "${sentenceCase}"`,
});
}
}
}
}
return {
"CallExpression[callee.name='t']": handler,
"CallExpression[callee.name='tn']": handler,
};
},
},
},
};

File diff suppressed because it is too large Load Diff

View File

@@ -88,7 +88,7 @@
"@reduxjs/toolkit": "^1.9.3",
"@rjsf/core": "^5.21.1",
"@rjsf/utils": "^5.24.3",
"@rjsf/validator-ajv8": "^5.24.12",
"@rjsf/validator-ajv8": "^5.24.9",
"@scarf/scarf": "^1.4.0",
"@superset-ui/chart-controls": "file:./packages/superset-ui-chart-controls",
"@superset-ui/core": "file:./packages/superset-ui-core",
@@ -121,6 +121,8 @@
"@visx/scale": "^3.5.0",
"@visx/tooltip": "^3.0.0",
"@visx/xychart": "^3.5.1",
"ag-grid-community": "^34.0.2",
"ag-grid-react": "34.0.2",
"antd": "^5.24.6",
"chrono-node": "^2.7.8",
"classnames": "^2.2.5",
@@ -142,7 +144,7 @@
"geostyler-qgis-parser": "2.0.1",
"geostyler-style": "7.5.0",
"geostyler-wfs-parser": "^2.0.3",
"googleapis": "^154.1.0",
"googleapis": "^130.0.0",
"immer": "^10.1.1",
"interweave": "^13.1.0",
"jquery": "^3.7.1",
@@ -174,7 +176,7 @@
"react-hot-loader": "^4.13.1",
"react-intersection-observer": "^9.16.0",
"react-json-tree": "^0.20.0",
"react-lines-ellipsis": "^0.16.1",
"react-lines-ellipsis": "^0.15.4",
"react-loadable": "^5.5.0",
"react-redux": "^7.2.9",
"react-resize-detector": "^7.1.2",
@@ -214,11 +216,11 @@
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
"@babel/plugin-transform-runtime": "^7.27.1",
"@babel/preset-env": "^7.27.2",
"@babel/preset-react": "^7.27.1",
"@babel/preset-react": "^7.26.3",
"@babel/preset-typescript": "^7.26.0",
"@babel/register": "^7.23.7",
"@babel/runtime": "^7.28.2",
"@babel/runtime-corejs3": "^7.28.2",
"@babel/runtime": "^7.26.0",
"@babel/runtime-corejs3": "^7.26.0",
"@babel/types": "^7.26.9",
"@cypress/react": "^8.0.2",
"@emotion/babel-plugin": "^11.13.5",
@@ -241,6 +243,7 @@
"@testing-library/react": "^12.1.5",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/user-event": "^12.8.3",
"@types/classnames": "^2.3.4",
"@types/dom-to-image": "^2.6.7",
"@types/jest": "^29.5.14",
"@types/js-levenshtein": "^1.1.3",
@@ -282,7 +285,7 @@
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^7.2.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-import-resolver-typescript": "^4.4.4",
"eslint-import-resolver-typescript": "^3.7.0",
"eslint-plugin-cypress": "^3.6.0",
"eslint-plugin-file-progress": "^1.5.0",
"eslint-plugin-icons": "file:eslint-rules/eslint-plugin-icons",

View File

@@ -36,7 +36,7 @@
"devDependencies": {
"cross-env": "^7.0.3",
"fs-extra": "^11.3.0",
"jest": "^30.0.5",
"jest": "^30.0.4",
"yeoman-test": "^10.1.1"
},
"engines": {

View File

@@ -0,0 +1,72 @@
/**
* 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 React, { useState } from 'react';
import { styled } from '@superset-ui/core';
import { Collapse } from '@superset-ui/core/components';
const { Panel } = Collapse;
const StyledCollapse = styled(Collapse)`
margin-bottom: ${({ theme }: any) => theme.gridUnit * 3}px;
border: none;
background: transparent;
.ant-collapse-item {
border: 1px solid ${({ theme }: any) => theme.colors.grayscale.light2};
border-radius: ${({ theme }: any) => theme.borderRadius}px;
margin-bottom: ${({ theme }: any) => theme.gridUnit * 2}px;
.ant-collapse-header {
font-weight: ${({ theme }: any) => theme.typography.weights.bold};
background: ${({ theme }: any) => theme.colors.grayscale.light5};
border-radius: ${({ theme }: any) => theme.borderRadius}px
${({ theme }: any) => theme.borderRadius}px 0 0;
}
.ant-collapse-content {
background: white;
padding: ${({ theme }: any) => theme.gridUnit * 3}px;
}
}
`;
export interface ControlPanelSectionProps {
title: string;
children: React.ReactNode;
expanded?: boolean;
}
export const ControlPanelSection: React.FC<ControlPanelSectionProps> = ({
title,
children,
expanded = false,
}) => {
const [activeKey, setActiveKey] = useState(expanded ? ['1'] : []);
return (
<StyledCollapse
activeKey={activeKey}
onChange={keys => setActiveKey(keys as string[])}
>
<Panel header={title} key="1">
{children}
</Panel>
</StyledCollapse>
);
};

View File

@@ -16,24 +16,27 @@
* specific language governing permissions and limitations
* under the License.
*/
import { SupersetClient } from '@superset-ui/core';
import React from 'react';
import { styled } from '@superset-ui/core';
export const setSystemDefaultTheme = (themeId: number) =>
SupersetClient.put({
endpoint: `/api/v1/theme/${themeId}/set_system_default`,
});
const StyledRow = styled.div`
display: flex;
gap: ${({ theme }: any) => theme.gridUnit * 3}px;
margin-bottom: ${({ theme }: any) => theme.gridUnit * 3}px;
export const setSystemDarkTheme = (themeId: number) =>
SupersetClient.put({
endpoint: `/api/v1/theme/${themeId}/set_system_dark`,
});
& > * {
flex: 1;
}
export const unsetSystemDefaultTheme = () =>
SupersetClient.delete({
endpoint: `/api/v1/theme/unset_system_default`,
});
.control-wrapper {
min-width: 0; // Allow flex items to shrink
}
`;
export const unsetSystemDarkTheme = () =>
SupersetClient.delete({
endpoint: `/api/v1/theme/unset_system_dark`,
});
export interface ControlRowProps {
children: React.ReactNode;
}
export const ControlRow: React.FC<ControlRowProps> = ({ children }) => (
<StyledRow>{children}</StyledRow>
);

View File

@@ -0,0 +1,75 @@
/**
* 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 React from 'react';
import { useSelector } from 'react-redux';
import { ExplorePageState } from 'src/explore/types';
import AdhocFilterControlOriginal from 'src/explore/components/controls/FilterControl/AdhocFilterControl/index';
import { ControlHeader } from '../ControlHeader';
export interface AdhocFilterControlProps {
name: string;
value?: any[];
onChange: (value: any[]) => void;
label?: string;
description?: string;
required?: boolean;
renderTrigger?: boolean;
}
/**
* Wrapper around the existing AdhocFilterControl that simplifies its API
*/
export const AdhocFilterControl: React.FC<AdhocFilterControlProps> = ({
name,
value = [],
onChange,
label,
description,
required,
renderTrigger,
}) => {
// Get datasource from Redux state
const datasource = useSelector<ExplorePageState>(
state => state.explore.datasource,
) as any;
const columns = datasource?.columns || [];
const savedMetrics = datasource?.metrics || [];
return (
<div className="control-wrapper">
{label && (
<ControlHeader
label={label}
description={description}
renderTrigger={renderTrigger}
required={required}
/>
)}
<AdhocFilterControlOriginal
name={name}
value={value}
onChange={onChange}
columns={columns}
savedMetrics={savedMetrics}
datasource={datasource}
/>
</div>
);
};

View File

@@ -0,0 +1,39 @@
/**
* 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 { ReactElement } from 'react';
// @ts-ignore
import CheckboxControlComponent from '../../../../../../../src/explore/components/controls/CheckboxControl';
export interface CheckboxControlProps {
value?: boolean;
onChange: (value: boolean) => void;
label?: string;
description?: string;
disabled?: boolean;
renderTrigger?: boolean;
hovered?: boolean;
[key: string]: any;
}
/**
* Checkbox control component
*/
export const CheckboxControl: React.FC<CheckboxControlProps> = (
props,
): ReactElement => <CheckboxControlComponent {...props} />;

View File

@@ -0,0 +1,68 @@
/**
* 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 React from 'react';
import { getCategoricalSchemeRegistry } from '@superset-ui/core';
import { SelectControl } from './SimpleSelectControl';
export interface ColorSchemeControlProps {
name: string;
value?: string;
onChange: (value: string) => void;
label?: string;
description?: string;
required?: boolean;
renderTrigger?: boolean;
clearable?: boolean;
}
/**
* Color scheme selector control
*/
export const ColorSchemeControl: React.FC<ColorSchemeControlProps> = ({
name,
value,
onChange,
label,
description,
required,
renderTrigger,
clearable = false,
}) => {
// Get available color schemes from the categorical scheme registry
const colorSchemes = getCategoricalSchemeRegistry().keys();
const choices: [string, string][] = colorSchemes.map((scheme: string) => [
scheme,
scheme,
]);
return (
<SelectControl
name={name}
value={value}
onChange={onChange as (value: string | string[]) => void}
label={label}
description={description}
required={required}
renderTrigger={renderTrigger}
choices={choices}
clearable={clearable}
multiple={false}
/>
);
};

View File

@@ -0,0 +1,38 @@
/**
* 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 { ReactElement } from 'react';
// @ts-ignore
import ControlComponent from '../../../../../../../src/explore/components/Control';
export interface ControlProps {
type?: string;
name: string;
value?: any;
actions?: any;
formData?: any;
renderTrigger?: boolean;
[key: string]: any;
}
/**
* Generic control wrapper component
*/
export const Control: React.FC<ControlProps> = (props): ReactElement => (
<ControlComponent {...props} />
);

View File

@@ -0,0 +1,94 @@
/**
* 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 { useSelector } from 'react-redux';
import { ExplorePageState } from 'src/explore/types';
import { DndColumnSelect as DndColumnSelectControl } from 'src/explore/components/controls/DndColumnSelectControl/DndColumnSelect';
import { ControlHeader } from '../ControlHeader';
export interface DndColumnSelectProps {
name: string;
value?: any;
onChange: (value: any) => void;
label?: string;
description?: string;
multi?: boolean;
required?: boolean;
renderTrigger?: boolean;
canDelete?: boolean;
ghostButtonText?: string;
isTemporal?: boolean;
}
/**
* Wrapper around the existing DndColumnSelect that simplifies its API
*/
export const DndColumnSelect: React.FC<DndColumnSelectProps> = ({
name,
value,
onChange,
label,
description,
multi = false,
required,
renderTrigger,
canDelete = true,
ghostButtonText,
isTemporal,
}) => {
// Get columns from Redux state
const columns = useSelector<ExplorePageState>(
state => state.explore.datasource?.columns || [],
) as any[];
return (
<div className="control-wrapper">
{label && (
<ControlHeader
label={label}
description={description}
renderTrigger={renderTrigger}
required={required}
/>
)}
<DndColumnSelectControl
name={name}
value={value}
onChange={onChange}
options={columns}
multi={multi}
canDelete={canDelete}
ghostButtonText={
ghostButtonText || (multi ? 'Drop columns here' : 'Drop column here')
}
isTemporal={isTemporal}
type="DndColumnSelect"
actions={
{
setControlValue: (controlName: string, value: any) => ({
type: 'SET_CONTROL_VALUE',
controlName,
value,
validationErrors: undefined,
}),
} as any
}
/>
</div>
);
};

View File

@@ -0,0 +1,83 @@
/**
* 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 { ReactElement } from 'react';
// @ts-ignore
import { DndFilterSelect as DndFilterSelectControl } from '../../../../../../../src/explore/components/controls/DndColumnSelectControl/DndFilterSelect';
import { Datasource } from '../../types';
export interface DndFilterSelectProps {
value?: any[];
onChange: (value: any[]) => void;
datasource?: Datasource;
columns?: any[];
formData?: any;
savedMetrics?: any[];
selectedMetrics?: any[];
name?: string;
actions?: any;
type?: string;
[key: string]: any;
}
/**
* Wrapper around the existing DndFilterSelect that simplifies its API
*/
export const DndFilterSelect: React.FC<DndFilterSelectProps> = ({
value = [],
onChange,
datasource,
columns = [],
formData = {},
savedMetrics = [],
selectedMetrics = [],
name = 'adhoc_filters',
actions,
type = 'DndFilterSelect',
...restProps
}): ReactElement => {
// Handle the case where onChange needs to be wrapped for actions.setControlValue
const handleChange = (val: any) => {
if (actions?.setControlValue) {
actions.setControlValue(name, val);
} else if (onChange) {
onChange(val);
}
};
// For compatibility with the original component
const componentProps = {
value,
onChange: handleChange,
datasource,
columns,
formData,
name,
savedMetrics,
selectedMetrics,
type,
actions,
...restProps,
};
return (
<div className="filter-select-wrapper">
<DndFilterSelectControl {...componentProps} />
</div>
);
};

View File

@@ -0,0 +1,95 @@
/**
* 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 { useSelector } from 'react-redux';
import { ExplorePageState } from 'src/explore/types';
import { DndMetricSelect as DndMetricSelectControl } from 'src/explore/components/controls/DndColumnSelectControl/DndMetricSelect';
import { ControlHeader } from '../ControlHeader';
export interface DndMetricSelectProps {
name: string;
value?: any;
onChange: (value: any) => void;
label?: string;
description?: string;
multi?: boolean;
required?: boolean;
renderTrigger?: boolean;
canDelete?: boolean;
ghostButtonText?: string;
}
/**
* Wrapper around the existing DndMetricSelect that simplifies its API
*/
export const DndMetricSelect: React.FC<DndMetricSelectProps> = ({
name,
value,
onChange,
label,
description,
multi = false,
required,
renderTrigger,
canDelete = true,
ghostButtonText,
}) => {
// Get datasource from Redux state
const datasource = useSelector<ExplorePageState>(
state => state.explore.datasource,
) as any;
const columns = datasource?.columns || [];
const savedMetrics = datasource?.metrics || [];
return (
<div className="control-wrapper">
{label && (
<ControlHeader
label={label}
description={description}
renderTrigger={renderTrigger}
required={required}
/>
)}
<DndMetricSelectControl
name={name}
value={value}
onChange={onChange}
columns={columns}
savedMetrics={savedMetrics}
multi={multi}
canDelete={canDelete}
ghostButtonText={
ghostButtonText || (multi ? 'Drop metrics here' : 'Drop metric here')
}
type="DndMetricSelect"
actions={
{
setControlValue: (controlName: string, value: any) => ({
type: 'SET_CONTROL_VALUE',
controlName,
value,
validationErrors: undefined,
}),
} as any
}
/>
</div>
);
};

View File

@@ -0,0 +1,43 @@
/**
* 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 { ReactElement } from 'react';
// @ts-ignore
import SelectControlComponent from '../../../../../../../src/explore/components/controls/SelectControl';
export interface SelectControlProps {
value?: any;
onChange: (value: any) => void;
choices?: Array<[string | number, string]>;
clearable?: boolean;
multi?: boolean;
label?: string;
description?: string;
disabled?: boolean;
renderTrigger?: boolean;
hovered?: boolean;
placeholder?: string;
[key: string]: any;
}
/**
* Select control component
*/
export const SelectControl: React.FC<SelectControlProps> = (
props,
): ReactElement => <SelectControlComponent {...props} />;

View File

@@ -0,0 +1,80 @@
/**
* 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 React from 'react';
import { Select } from '@superset-ui/core/components';
import { ControlHeader } from '../ControlHeader';
export interface SelectControlProps {
name: string;
value?: string | string[];
onChange: (value: string | string[]) => void;
label?: string;
description?: string;
placeholder?: string;
disabled?: boolean;
choices: Array<[string, string]>;
clearable?: boolean;
multiple?: boolean;
renderTrigger?: boolean;
required?: boolean;
}
export const SelectControl: React.FC<SelectControlProps> = ({
name,
value,
onChange,
label,
description,
placeholder,
disabled,
choices,
clearable = true,
multiple = false,
renderTrigger,
required,
}) => {
const options = choices.map(([val, label]) => ({
value: val,
label,
}));
return (
<div className="control-wrapper">
{label && (
<ControlHeader
label={label}
description={description}
renderTrigger={renderTrigger}
required={required}
/>
)}
<Select
name={name}
value={value}
onChange={onChange}
placeholder={placeholder}
disabled={disabled}
options={options}
allowClear={clearable}
mode={multiple ? 'multiple' : undefined}
css={{ width: '100%' }}
/>
</div>
);
};

View File

@@ -0,0 +1,94 @@
/**
* 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 React, { useCallback } from 'react';
import { Input } from '@superset-ui/core/components';
import { ControlHeader } from '../ControlHeader';
export interface TextControlProps {
name: string;
value?: string | number;
onChange: (value: string | number) => void;
label?: string;
description?: string;
placeholder?: string;
disabled?: boolean;
isInt?: boolean;
isFloat?: boolean;
min?: number;
max?: number;
renderTrigger?: boolean;
required?: boolean;
}
export const TextControl: React.FC<TextControlProps> = ({
name,
value,
onChange,
label,
description,
placeholder,
disabled,
isInt,
isFloat,
min,
max,
renderTrigger,
required,
}) => {
const handleChange = useCallback(
(e: React.ChangeEvent<HTMLInputElement>) => {
let newValue: string | number = e.target.value;
if (isInt) {
newValue = parseInt(newValue, 10) || 0;
} else if (isFloat) {
newValue = parseFloat(newValue) || 0;
}
onChange(newValue);
},
[onChange, isInt, isFloat],
);
const inputType = isInt || isFloat ? 'number' : 'text';
return (
<div className="control-wrapper">
{label && (
<ControlHeader
label={label}
description={description}
renderTrigger={renderTrigger}
required={required}
/>
)}
<Input
name={name}
type={inputType}
value={value ?? ''}
onChange={handleChange}
placeholder={placeholder}
disabled={disabled}
min={min}
max={max}
css={{ width: '100%' }}
/>
</div>
);
};

View File

@@ -0,0 +1,41 @@
/**
* 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 { ReactElement } from 'react';
// @ts-ignore
import SliderControlComponent from '../../../../../../../src/explore/components/controls/SliderControl';
export interface SliderControlProps {
value?: number;
onChange: (value: number) => void;
min?: number;
max?: number;
step?: number;
label?: string;
description?: string;
disabled?: boolean;
renderTrigger?: boolean;
[key: string]: any;
}
/**
* Slider control component
*/
export const SliderControl: React.FC<SliderControlProps> = (
props,
): ReactElement => <SliderControlComponent {...props} />;

View File

@@ -0,0 +1,39 @@
/**
* 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 { ReactElement } from 'react';
// @ts-ignore
import TextControlComponent from '../../../../../../../src/explore/components/controls/TextControl';
export interface TextControlProps {
value?: string | number;
onChange: (value: string | number) => void;
placeholder?: string;
isInt?: boolean;
isFloat?: boolean;
disabled?: boolean;
controlId?: string;
[key: string]: any;
}
/**
* Text input control component
*/
export const TextControl: React.FC<TextControlProps> = (
props,
): ReactElement => <TextControlComponent {...props} />;

View File

@@ -0,0 +1,39 @@
/**
* 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.
*/
// Layout components
export { ControlPanelSection } from './ControlPanelSection';
export { ControlRow } from './ControlRow';
export { ControlHeader } from './ControlHeader';
// Control components
export { TextControl as SimpleTextControl } from './controls/SimpleTextControl';
export { SelectControl as SimpleSelectControl } from './controls/SimpleSelectControl';
// Wrapper controls for new simplified API
export { DndColumnSelect } from './controls/DndColumnSelectWrapper';
export { DndMetricSelect } from './controls/DndMetricSelectWrapper';
export { DndFilterSelect } from './controls/DndFilterSelectWrapper';
export { AdhocFilterControl } from './controls/AdhocFilterControlWrapper';
export { ColorSchemeControl as SimpleColorSchemeControl } from './controls/ColorSchemeControlWrapper';
export { TextControl } from './controls/TextControlWrapper';
export { CheckboxControl } from './controls/CheckboxControlWrapper';
export { SelectControl } from './controls/SelectControlWrapper';
export { SliderControl } from './controls/SliderControlWrapper';
export { Control } from './controls/ControlWrapper';

View File

@@ -0,0 +1,81 @@
/**
* 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 { useCallback } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { QueryFormData } from '@superset-ui/core';
// Define minimal types to avoid circular dependencies
interface ExploreState {
form_data: QueryFormData;
[key: string]: any;
}
interface RootState {
explore: ExploreState;
[key: string]: any;
}
/**
* Hook to access and update form data from Redux store
* Provides a simple interface for control components
*
* NOTE: This hook assumes the Redux store structure used by Superset's explore view.
* The actual setControlValue action should be provided by the app via context or props.
*/
export function useFormData() {
const dispatch = useDispatch();
// Get form data from Redux
const formData = useSelector<RootState, QueryFormData>(state => {
console.log('useFormData - state.explore:', state.explore);
return state.explore?.form_data || {};
});
// Update a single control value
// This is a placeholder - the actual action should be injected
const updateControl = useCallback(
(controlName: string, value: any) => {
console.log('updateControl:', controlName, value);
// In production, this would dispatch the actual setControlValue action
// For now, we'll dispatch a generic action
dispatch({
type: 'SET_CONTROL_VALUE',
controlName,
value,
});
},
[dispatch],
);
// Update multiple controls at once
const updateControls = useCallback(
(updates: Partial<QueryFormData>) => {
Object.entries(updates).forEach(([key, value]) => {
updateControl(key, value);
});
},
[updateControl],
);
return {
formData,
updateControl,
updateControls,
};
}

View File

@@ -21,6 +21,7 @@ import * as sectionsModule from './sections';
export * from './utils';
export * from './constants';
export * from './operators';
export * from './hooks/useFormData';
// can't do `export * as sections from './sections'`, babel-transformer will fail
export const sections = sectionsModule;
@@ -32,7 +33,26 @@ export * from './components/Dropdown';
export * from './components/Menu';
export * from './components/MetricOption';
export * from './components/ControlHeader';
export * from './components';
// Export individual control components for easier access
export {
DndColumnSelect,
DndMetricSelect,
DndFilterSelect,
TextControl,
CheckboxControl,
SelectControl,
SliderControl,
Control,
} from './components';
export * from './shared-controls';
export {
GranularityControl,
RadioButtonControl,
ReactControlPanel,
} from './shared-controls/components';
// Export all from shared-controls/components which includes inline control functions
export * from './shared-controls/components';
export * from './types';
export * from './fixtures';

View File

@@ -36,19 +36,18 @@ export const renameOperator: PostProcessingFactory<PostProcessingRename> = (
const columns = ensureIsArray(
queryObject.series_columns || queryObject.columns,
);
const timeOffsets = ensureIsArray(formData.time_compare);
const { truncate_metric } = formData;
const xAxisLabel = getXAxisLabel(formData);
const isTimeComparisonValue = isTimeComparison(formData, queryObject);
// remove or rename top level of column name(metric name) in the MultiIndex when
// 1) at least 1 metric
// 2) dimension exist or multiple time shift metrics exist
// 2) dimension exist
// 3) xAxis exist
// 4) truncate_metric in form_data and truncate_metric is true
if (
metrics.length > 0 &&
(columns.length > 0 || timeOffsets.length > 1) &&
columns.length > 0 &&
xAxisLabel &&
truncate_metric !== undefined &&
!!truncate_metric
@@ -85,8 +84,7 @@ export const renameOperator: PostProcessingFactory<PostProcessingRename> = (
ComparisonType.Percentage,
ComparisonType.Ratio,
].includes(formData.comparison_type) &&
metrics.length === 1 &&
renamePairs.length === 0
metrics.length === 1
) {
renamePairs.push([getMetricLabel(metrics[0]), null]);
}

View File

@@ -18,6 +18,20 @@
*/
import { t } from '@superset-ui/core';
import { ControlPanelSectionConfig, ControlSetRow } from '../types';
import {
AdhocFiltersControl,
GroupByControl,
GroupOthersWhenLimitReachedControl,
LimitControl,
MetricsControl,
OrderDescControl,
RowLimitControl,
ShowEmptyColumnsControl,
TimeGrainSqlaControl,
TimeLimitMetricControl,
TruncateMetricControl,
XAxisControl,
} from '../shared-controls/components/SharedControlComponents';
import {
contributionModeControl,
xAxisForceCategoricalControl,
@@ -26,30 +40,34 @@ import {
} from '../shared-controls';
const controlsWithoutXAxis: ControlSetRow[] = [
['metrics'],
['groupby'],
[MetricsControl()],
[GroupByControl()],
[contributionModeControl],
['adhoc_filters'],
['limit', 'group_others_when_limit_reached'],
['timeseries_limit_metric'],
['order_desc'],
['row_limit'],
['truncate_metric'],
['show_empty_columns'],
[AdhocFiltersControl()],
[LimitControl(), GroupOthersWhenLimitReachedControl()],
[TimeLimitMetricControl()],
[OrderDescControl()],
[RowLimitControl()],
[TruncateMetricControl()],
[ShowEmptyColumnsControl()],
];
export const echartsTimeSeriesQuery: ControlPanelSectionConfig = {
label: t('Query'),
expanded: true,
controlSetRows: [['x_axis'], ['time_grain_sqla'], ...controlsWithoutXAxis],
controlSetRows: [
[XAxisControl()],
[TimeGrainSqlaControl()],
...controlsWithoutXAxis,
],
};
export const echartsTimeSeriesQueryWithXAxisSort: ControlPanelSectionConfig = {
label: t('Query'),
expanded: true,
controlSetRows: [
['x_axis'],
['time_grain_sqla'],
[XAxisControl()],
[TimeGrainSqlaControl()],
[xAxisForceCategoricalControl],
[xAxisSortControl],
[xAxisSortAscControl],

View File

@@ -18,6 +18,15 @@
*/
import { t } from '@superset-ui/core';
import { ControlPanelSectionConfig } from '../types';
import {
GranularityControl,
GranularitySqlaControl,
TimeGrainSqlaControl,
TimeRangeControl,
DatasourceControl,
VizTypeControl,
ColorSchemeControl,
} from '../shared-controls/components/SharedControlComponents';
// A few standard controls sections that are used internally.
// Not recommended for use in third-party plugins.
@@ -31,10 +40,10 @@ const baseTimeSection = {
export const legacyTimeseriesTime: ControlPanelSectionConfig = {
...baseTimeSection,
controlSetRows: [
['granularity'],
['granularity_sqla'],
['time_grain_sqla'],
['time_range'],
[GranularityControl()],
[GranularitySqlaControl()],
[TimeGrainSqlaControl()],
[TimeRangeControl()],
],
};
@@ -42,8 +51,8 @@ export const datasourceAndVizType: ControlPanelSectionConfig = {
label: t('Datasource & Chart Type'),
expanded: true,
controlSetRows: [
['datasource'],
['viz_type'],
[DatasourceControl()],
[VizTypeControl()],
[
{
name: 'slice_id',
@@ -91,7 +100,7 @@ export const datasourceAndVizType: ControlPanelSectionConfig = {
export const colorScheme: ControlPanelSectionConfig = {
label: t('Color Scheme'),
controlSetRows: [['color_scheme']],
controlSetRows: [[ColorSchemeControl()]],
};
export const annotations: ControlPanelSectionConfig = {

View File

@@ -0,0 +1,252 @@
/**
* 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 { FC } from 'react';
import { t } from '@superset-ui/core';
import { Input, Select, Switch, InputNumber } from 'antd';
import { Row, Col } from '@superset-ui/core/components';
export interface AxisControlSectionProps {
axis: 'x' | 'y';
showTitle?: boolean;
showFormat?: boolean;
showRotation?: boolean;
showBounds?: boolean;
showLogarithmic?: boolean;
showMinorTicks?: boolean;
showTruncate?: boolean;
timeFormat?: boolean;
values?: Record<string, any>;
onChange?: (name: string, value: any) => void;
}
const D3_FORMAT_OPTIONS = [
['SMART_NUMBER', t('Adaptive formatting')],
['~g', t('Original value')],
['d', t('Signed integer')],
['.1f', t('1 decimal place')],
['.2f', t('2 decimal places')],
['.3f', t('3 decimal places')],
['+,', t('Positive integer')],
['$,.2f', t('Currency (2 decimals)')],
[',.0%', t('Percentage')],
['.1%', t('Percentage (1 decimal)')],
];
const D3_TIME_FORMAT_OPTIONS = [
['smart_date', t('Adaptive formatting')],
['%Y-%m-%d', t('2023-01-01')],
['%Y-%m-%d %H:%M', t('2023-01-01 10:30')],
['%m/%d/%Y', t('01/01/2023')],
['%d/%m/%Y', t('01/01/2023')],
['%Y', t('2023')],
['%B %Y', t('January 2023')],
['%b %Y', t('Jan 2023')],
['%B %-d, %Y', t('January 1, 2023')],
];
const ROTATION_OPTIONS = [
[0, '0°'],
[45, '45°'],
[90, '90°'],
[-45, '-45°'],
[-90, '-90°'],
];
export const AxisControlSection: FC<AxisControlSectionProps> = ({
axis,
showTitle = true,
showFormat = true,
showRotation = false,
showBounds = false,
showLogarithmic = false,
showMinorTicks = false,
showTruncate = false,
timeFormat = false,
values = {},
onChange = () => {},
}) => {
const isXAxis = axis === 'x';
const axisUpper = axis.toUpperCase();
const titleKey = `${axis}_axis_title`;
const formatKey = timeFormat
? `${axis}_axis_time_format`
: `${axis}_axis_format`;
const rotationKey = `${axis}_axis_label_rotation`;
const boundsMinKey = `${axis}_axis_bounds_min`;
const boundsMaxKey = `${axis}_axis_bounds_max`;
const logScaleKey = `log_scale`;
const minorTicksKey = `${axis}_axis_minor_ticks`;
const truncateKey = `truncate_${axis}axis`;
const truncateLabelsKey = `${axis}_axis_truncate_labels`;
return (
<div className="axis-control-section">
{showTitle && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t(`${axisUpper} Axis Title`)}</label>
<Input
value={values[titleKey] || ''}
onChange={e => onChange(titleKey, e.target.value)}
placeholder={t(`Enter ${axis} axis title`)}
/>
<small className="text-muted">
{t(
'Overrides the axis title derived from the metric or column name',
)}
</small>
</Col>
</Row>
)}
{showFormat && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t(`${axisUpper} Axis Format`)}</label>
<Select
value={
values[formatKey] ||
(timeFormat ? 'smart_date' : 'SMART_NUMBER')
}
onChange={value => onChange(formatKey, value)}
style={{ width: '100%' }}
showSearch
placeholder={t('Select or type a format')}
options={(timeFormat
? D3_TIME_FORMAT_OPTIONS
: D3_FORMAT_OPTIONS
).map(([value, label]) => ({
value,
label,
}))}
/>
<small className="text-muted">
{timeFormat
? t('D3 time format for x axis')
: t('D3 format for axis values')}
</small>
</Col>
</Row>
)}
{showRotation && isXAxis && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Label Rotation')}</label>
<Select
value={values[rotationKey] || 0}
onChange={value => onChange(rotationKey, value)}
style={{ width: '100%' }}
options={ROTATION_OPTIONS.map(([value, label]) => ({
value,
label,
}))}
/>
<small className="text-muted">
{t('Rotation angle for axis labels')}
</small>
</Col>
</Row>
)}
{showBounds && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t(`${axisUpper} Axis Bounds`)}</label>
<div style={{ display: 'flex', gap: 8 }}>
<InputNumber
value={values[boundsMinKey]}
onChange={value => onChange(boundsMinKey, value)}
placeholder={t('Min')}
style={{ flex: 1 }}
/>
<InputNumber
value={values[boundsMaxKey]}
onChange={value => onChange(boundsMaxKey, value)}
placeholder={t('Max')}
style={{ flex: 1 }}
/>
</div>
<small className="text-muted">
{t('Bounds for axis values. Leave empty for automatic scaling.')}
</small>
</Col>
</Row>
)}
{showLogarithmic && !isXAxis && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values[logScaleKey] || false}
onChange={checked => onChange(logScaleKey, checked)}
/>
{t('Logarithmic Scale')}
</label>
<small className="text-muted">
{t('Use a logarithmic scale for the Y-axis')}
</small>
</Col>
</Row>
)}
{showMinorTicks && !isXAxis && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values[minorTicksKey] || false}
onChange={checked => onChange(minorTicksKey, checked)}
/>
{t('Show Minor Ticks')}
</label>
<small className="text-muted">
{t('Show minor grid lines on the axis')}
</small>
</Col>
</Row>
)}
{showTruncate && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={
values[truncateKey] || values[truncateLabelsKey] || false
}
onChange={checked => {
onChange(truncateKey, checked);
onChange(truncateLabelsKey, checked);
}}
/>
{t(`Truncate ${axisUpper} Axis Labels`)}
</label>
<small className="text-muted">
{t('Truncate long axis labels to prevent overlap')}
</small>
</Col>
</Row>
)}
</div>
);
};
export default AxisControlSection;

View File

@@ -0,0 +1,634 @@
/**
* 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 { ReactElement } from 'react';
import type { CustomControlItem, ControlValueValidator } from '../../types';
// Base control props that all controls share
interface BaseControlProps {
name: string;
label?: ReactElement | string;
description?: string;
default?: any;
renderTrigger?: boolean;
validators?: ControlValueValidator[];
warning?: string;
error?: string;
mapStateToProps?: (state: any, control: any) => any;
visibility?: (props: any) => boolean;
value?: any;
onChange?: (value: any) => void;
}
// Use the existing CustomControlItem type instead of creating a duplicate
// This ensures type compatibility with the rest of the codebase
export type ControlComponentConfig = CustomControlItem;
// CheckboxControl Component
interface CheckboxControlProps extends BaseControlProps {
default?: boolean;
}
export const CheckboxControl = (
props: CheckboxControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'CheckboxControl',
label: props.label,
description: props.description,
default: props.default ?? false,
renderTrigger: props.renderTrigger ?? false,
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
},
});
// SelectControl Component
interface SelectControlProps extends BaseControlProps {
choices?: Array<[string, string]> | (() => Array<[string, string]>);
clearable?: boolean;
freeForm?: boolean;
multi?: boolean;
placeholder?: string;
optionRenderer?: (option: any) => ReactElement;
valueRenderer?: (value: any) => ReactElement;
valueKey?: string;
labelKey?: string;
}
export const SelectControl = (
props: SelectControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'SelectControl',
label: props.label,
description: props.description,
choices: props.choices ?? [],
clearable: props.clearable ?? true,
freeForm: props.freeForm ?? false,
multi: props.multi ?? false,
default: props.default,
renderTrigger: props.renderTrigger ?? false,
placeholder: props.placeholder,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
validators: props.validators,
warning: props.warning,
error: props.error,
optionRenderer: props.optionRenderer,
valueRenderer: props.valueRenderer,
valueKey: props.valueKey,
labelKey: props.labelKey,
},
});
// TextControl Component
interface TextControlProps extends BaseControlProps {
placeholder?: string;
disabled?: boolean;
isInt?: boolean;
isFloat?: boolean;
}
export const TextControl = (
props: TextControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'TextControl',
label: props.label,
description: props.description,
placeholder: props.placeholder,
default: props.default ?? '',
renderTrigger: props.renderTrigger ?? false,
disabled: props.disabled ?? false,
isInt: props.isInt ?? false,
isFloat: props.isFloat ?? false,
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
},
});
// TextAreaControl Component
interface TextAreaControlProps extends BaseControlProps {
placeholder?: string;
rows?: number;
language?: 'json' | 'html' | 'sql' | 'markdown' | 'javascript';
offerEditInModal?: boolean;
disabled?: boolean;
}
export const TextAreaControl = (
props: TextAreaControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'TextAreaControl',
label: props.label,
description: props.description,
placeholder: props.placeholder,
rows: props.rows ?? 3,
language: props.language,
offerEditInModal: props.offerEditInModal ?? true,
default: props.default ?? '',
renderTrigger: props.renderTrigger ?? false,
disabled: props.disabled ?? false,
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
},
});
// SliderControl Component
interface SliderControlProps extends BaseControlProps {
min?: number;
max?: number;
step?: number;
default?: number;
}
export const SliderControl = (
props: SliderControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'SliderControl',
label: props.label,
description: props.description,
min: props.min ?? 0,
max: props.max ?? 100,
step: props.step ?? 1,
default: props.default ?? 0,
renderTrigger: props.renderTrigger ?? false,
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
},
});
// RadioButtonControl Component
interface RadioButtonControlProps extends BaseControlProps {
options?: Array<[string, string | ReactElement]>;
default?: string;
}
export const RadioButtonControl = (
props: RadioButtonControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'RadioButtonControl',
label: props.label,
description: props.description,
options: props.options ?? [],
default: props.default,
renderTrigger: props.renderTrigger ?? false,
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
},
});
// NumberControl Component
interface NumberControlProps extends BaseControlProps {
min?: number;
max?: number;
default?: number;
placeholder?: string;
}
export const NumberControl = (
props: NumberControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'TextControl',
label: props.label,
description: props.description,
placeholder: props.placeholder,
default: props.default,
renderTrigger: props.renderTrigger ?? false,
isFloat: true,
controlHeader: {
label: props.label,
description: props.description,
},
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
min: props.min,
max: props.max,
},
});
// ColorPickerControl Component
interface ColorPickerControlProps extends BaseControlProps {
default?: { r: number; g: number; b: number; a?: number };
}
export const ColorPickerControl = (
props: ColorPickerControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'ColorPickerControl',
label: props.label,
description: props.description,
default: props.default ?? { r: 0, g: 122, b: 135, a: 1 },
renderTrigger: props.renderTrigger ?? false,
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
},
});
// DateFilterControl Component
interface DateFilterControlProps extends BaseControlProps {
default?: string;
}
export const DateFilterControl = (
props: DateFilterControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'DateFilterControl',
label: props.label,
description: props.description,
default: props.default,
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
renderTrigger: props.renderTrigger,
},
});
// BoundsControl Component
interface BoundsControlProps extends BaseControlProps {
default?: [number | null, number | null];
min?: number;
max?: number;
}
export const BoundsControl = (
props: BoundsControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'BoundsControl',
label: props.label,
description: props.description,
default: props.default ?? [null, null],
min: props.min,
max: props.max,
renderTrigger: props.renderTrigger ?? false,
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
},
});
// SwitchControl Component
interface SwitchControlProps extends BaseControlProps {
default?: boolean;
}
export const SwitchControl = (
props: SwitchControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'CheckboxControl',
label: props.label,
description: props.description,
default: props.default ?? false,
renderTrigger: props.renderTrigger ?? false,
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
},
});
// HiddenControl Component (for hidden fields)
interface HiddenControlProps {
name: string;
value?: any;
default?: any;
}
export const HiddenControl = (
props: HiddenControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'HiddenControl',
default: props.default,
value: props.value,
renderTrigger: false,
visible: false,
},
});
// MetricsControl Component
interface MetricsControlProps extends BaseControlProps {
multi?: boolean;
clearable?: boolean;
savedMetrics?: any[];
columns?: any[];
datasourceType?: string;
}
export const MetricsControl = (
props: MetricsControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'MetricsControl',
label: props.label,
description: props.description,
multi: props.multi ?? true,
clearable: props.clearable ?? true,
validators: props.validators ?? [],
mapStateToProps:
props.mapStateToProps ||
((state: any) => ({
columns: state.datasource?.columns || [],
savedMetrics: state.datasource?.metrics || [],
datasourceType: state.datasource?.type,
})),
default: props.default,
renderTrigger: props.renderTrigger,
warning: props.warning,
error: props.error,
visibility: props.visibility,
savedMetrics: props.savedMetrics,
columns: props.columns,
datasourceType: props.datasourceType,
},
});
// GroupByControl Component
interface GroupByControlProps extends BaseControlProps {
multi?: boolean;
clearable?: boolean;
columns?: any[];
}
export const GroupByControl = (
props: GroupByControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'SelectControl',
label: props.label,
description: props.description,
multi: props.multi ?? true,
clearable: props.clearable ?? true,
validators: props.validators ?? [],
mapStateToProps:
props.mapStateToProps ||
((state: any) => ({
choices: state.datasource?.columns || [],
})),
default: props.default,
renderTrigger: props.renderTrigger,
warning: props.warning,
error: props.error,
visibility: props.visibility,
columns: props.columns,
},
});
// AdhocFilterControl Component
interface AdhocFilterControlProps extends BaseControlProps {
columns?: any[];
savedMetrics?: any[];
datasourceType?: string;
}
export const AdhocFilterControl = (
props: AdhocFilterControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'AdhocFilterControl',
label: props.label,
description: props.description,
mapStateToProps:
props.mapStateToProps ||
((state: any) => ({
columns: state.datasource?.columns || [],
savedMetrics: state.datasource?.metrics || [],
datasourceType: state.datasource?.type,
})),
default: props.default,
renderTrigger: props.renderTrigger,
validators: props.validators,
warning: props.warning,
error: props.error,
visibility: props.visibility,
columns: props.columns,
savedMetrics: props.savedMetrics,
datasourceType: props.datasourceType,
},
});
// SpatialControl Component
interface SpatialControlProps extends BaseControlProps {
choices?: any[];
}
export const SpatialControl = (
props: SpatialControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'SpatialControl',
label: props.label,
description: props.description,
validators: props.validators,
mapStateToProps:
props.mapStateToProps ||
((state: any) => ({
choices: state.datasource?.columns || [],
})),
default: props.default,
renderTrigger: props.renderTrigger,
warning: props.warning,
error: props.error,
visibility: props.visibility,
},
});
// ColorSchemeControl Component
interface ColorSchemeControlProps extends BaseControlProps {
choices?: (() => Array<[string, string]>) | Array<[string, string]>;
schemes?: () => any;
isLinear?: boolean;
}
export const ColorSchemeControl = (
props: ColorSchemeControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'ColorSchemeControl',
label: props.label,
description: props.description,
default: props.default,
renderTrigger: props.renderTrigger ?? true,
choices: props.choices,
schemes: props.schemes,
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
isLinear: props.isLinear,
},
});
// SelectAsyncControl Component
interface SelectAsyncControlProps extends BaseControlProps {
dataEndpoint?: string;
multi?: boolean;
mutator?: (data: any) => any;
placeholder?: string;
onAsyncErrorMessage?: string;
cacheOptions?: boolean;
}
export const SelectAsyncControl = (
props: SelectAsyncControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'SelectAsyncControl',
label: props.label,
description: props.description,
default: props.default,
dataEndpoint: props.dataEndpoint,
multi: props.multi ?? false,
mutator: props.mutator,
placeholder: props.placeholder,
onAsyncErrorMessage: props.onAsyncErrorMessage,
cacheOptions: props.cacheOptions ?? true,
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
renderTrigger: props.renderTrigger,
},
});
// ContourControl Component
interface ContourControlProps extends BaseControlProps {
renderTrigger?: boolean;
choices?: Array<[string, string]>;
}
export const ContourControl = (
props: ContourControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'ContourControl',
label: props.label,
description: props.description,
default: props.default,
renderTrigger: props.renderTrigger ?? true,
choices: props.choices,
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
},
});
// ColumnConfigControl Component
interface ColumnConfigControlProps extends BaseControlProps {
renderTrigger?: boolean;
}
export const ColumnConfigControl = (
props: ColumnConfigControlProps,
): ControlComponentConfig => ({
name: props.name,
config: {
type: 'ColumnConfigControl',
label: props.label,
description: props.description,
default: props.default,
renderTrigger: props.renderTrigger ?? true,
validators: props.validators,
warning: props.warning,
error: props.error,
mapStateToProps: props.mapStateToProps,
visibility: props.visibility,
},
});
// Export all components
export default {
CheckboxControl,
SelectControl,
TextControl,
TextAreaControl,
SliderControl,
RadioButtonControl,
NumberControl,
ColorPickerControl,
DateFilterControl,
BoundsControl,
SwitchControl,
HiddenControl,
MetricsControl,
GroupByControl,
AdhocFilterControl,
SpatialControl,
ColorSchemeControl,
SelectAsyncControl,
ContourControl,
ColumnConfigControl,
};

View File

@@ -0,0 +1,154 @@
/**
* 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 { ReactNode, FC } from 'react';
import { Row, Col, Collapse } from '@superset-ui/core/components';
/**
* Props for control panel sections
*/
export interface ControlSectionProps {
label?: ReactNode;
description?: ReactNode;
expanded?: boolean;
children: ReactNode;
}
/**
* A collapsible section in the control panel
*/
export const ControlSection: FC<ControlSectionProps> = ({
label,
description,
expanded = true,
children,
}) => {
if (!label) {
// No label means no collapsible wrapper
return <>{children}</>;
}
return (
<Collapse defaultActiveKey={expanded ? ['1'] : []} ghost>
<Collapse.Panel
header={
<span>
{label}
{description && (
<span style={{ marginLeft: 8, fontSize: '0.85em', opacity: 0.7 }}>
{description}
</span>
)}
</span>
}
key="1"
>
{children}
</Collapse.Panel>
</Collapse>
);
};
/**
* Props for control row - uses Ant Design grid
*/
export interface ControlRowProps {
children: ReactNode;
gutter?: number | [number, number];
}
/**
* A row of controls using Ant Design's grid system
* Automatically distributes controls evenly across columns
*/
export const ControlPanelRow: FC<ControlRowProps> = ({
children,
gutter = [16, 16],
}) => {
const childArray = Array.isArray(children) ? children : [children];
const validChildren = childArray.filter(
child => child !== null && child !== undefined,
);
const colSpan =
validChildren.length > 0 ? Math.floor(24 / validChildren.length) : 24;
return (
<Row gutter={gutter} style={{ marginBottom: 16 }}>
{validChildren.map((child, index) => (
<Col key={index} span={colSpan}>
{child}
</Col>
))}
</Row>
);
};
/**
* Props for the main control panel layout
*/
export interface ControlPanelLayoutProps {
children: ReactNode;
}
/**
* Main control panel layout container
*/
export const ControlPanelLayout: FC<ControlPanelLayoutProps> = ({
children,
}) => (
<div className="control-panel-layout" style={{ padding: '16px 0' }}>
{children}
</div>
);
/**
* Helper function to create a full-width single control row
*/
export const SingleControlRow: FC<{ children: ReactNode }> = ({ children }) => (
<Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
<Col span={24}>{children}</Col>
</Row>
);
/**
* Helper function to create a two-column control row
*/
export const TwoColumnRow: FC<{ left: ReactNode; right: ReactNode }> = ({
left,
right,
}) => (
<Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
<Col span={12}>{left}</Col>
<Col span={12}>{right}</Col>
</Row>
);
/**
* Helper function to create a three-column control row
*/
export const ThreeColumnRow: FC<{
left: ReactNode;
center: ReactNode;
right: ReactNode;
}> = ({ left, center, right }) => (
<Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
<Col span={8}>{left}</Col>
<Col span={8}>{center}</Col>
<Col span={8}>{right}</Col>
</Row>
);

View File

@@ -0,0 +1,360 @@
/**
* 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 { FC } from 'react';
import { t } from '@superset-ui/core';
import { Switch, Select, Input, Slider } from 'antd';
import { Row, Col } from '@superset-ui/core/components';
export interface DeckGLControlsSectionProps {
layerType?:
| 'scatter'
| 'polygon'
| 'path'
| 'heatmap'
| 'hex'
| 'grid'
| 'screengrid'
| 'contour'
| 'geojson'
| 'arc';
showViewport?: boolean;
showMapStyle?: boolean;
showColorScheme?: boolean;
showLegend?: boolean;
showTooltip?: boolean;
showFilters?: boolean;
showAnimation?: boolean;
show3D?: boolean;
showMultiplier?: boolean;
showPointRadius?: boolean;
showLineWidth?: boolean;
showFillColor?: boolean;
showStrokeColor?: boolean;
showOpacity?: boolean;
showCoverage?: boolean;
showElevation?: boolean;
values?: Record<string, any>;
onChange?: (name: string, value: any) => void;
}
const DeckGLControlsSection: FC<DeckGLControlsSectionProps> = ({
layerType = 'scatter',
showViewport = true,
showMapStyle = true,
showColorScheme = true,
showLegend = true,
showTooltip = true,
showFilters = true,
showAnimation = false,
show3D = false,
showMultiplier = false,
showPointRadius = false,
showLineWidth = false,
showFillColor = false,
showStrokeColor = false,
showOpacity = true,
showCoverage = false,
showElevation = false,
values = {},
onChange = () => {},
}) => (
<div className="deckgl-controls-section">
{/* Map Style */}
{showMapStyle && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Map Style')}</label>
<Select
value={values.mapbox_style || 'mapbox://styles/mapbox/light-v9'}
onChange={value => onChange('mapbox_style', value)}
style={{ width: '100%' }}
options={[
{
value: 'mapbox://styles/mapbox/streets-v11',
label: t('Streets'),
},
{ value: 'mapbox://styles/mapbox/light-v9', label: t('Light') },
{ value: 'mapbox://styles/mapbox/dark-v9', label: t('Dark') },
{
value: 'mapbox://styles/mapbox/satellite-v9',
label: t('Satellite'),
},
{
value: 'mapbox://styles/mapbox/outdoors-v11',
label: t('Outdoors'),
},
]}
/>
<small className="text-muted">
{t('Base map style for the visualization')}
</small>
</Col>
</Row>
)}
{/* Viewport */}
{showViewport && (
<>
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Zoom')}</label>
<Slider
value={values.zoom || 11}
onChange={value => onChange('zoom', value)}
min={0}
max={22}
step={0.1}
marks={{ 0: '0', 11: '11', 22: '22' }}
/>
<small className="text-muted">{t('Map zoom level')}</small>
</Col>
</Row>
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.autozoom || true}
onChange={checked => onChange('autozoom', checked)}
/>
{t('Auto Zoom')}
</label>
<small className="text-muted">
{t('Automatically zoom to fit data bounds')}
</small>
</Col>
</Row>
</>
)}
{/* Point/Shape Size Controls */}
{showPointRadius && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Point Radius')}</label>
<Slider
value={values.point_radius_fixed?.value || 1000}
onChange={value =>
onChange('point_radius_fixed', { type: 'fix', value })
}
min={1}
max={10000}
step={10}
/>
<small className="text-muted">
{t('Fixed radius for points in meters')}
</small>
</Col>
</Row>
)}
{showLineWidth && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Line Width')}</label>
<Slider
value={values.line_width || 1}
onChange={value => onChange('line_width', value)}
min={1}
max={50}
step={1}
/>
<small className="text-muted">{t('Width of lines in pixels')}</small>
</Col>
</Row>
)}
{/* 3D Controls */}
{show3D && (
<>
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.extruded || false}
onChange={checked => onChange('extruded', checked)}
/>
{t('3D')}
</label>
<small className="text-muted">{t('Show data in 3D')}</small>
</Col>
</Row>
{values.extruded && showElevation && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Elevation')}</label>
<Slider
value={values.elevation || 0.1}
onChange={value => onChange('elevation', value)}
min={0}
max={1}
step={0.01}
/>
<small className="text-muted">
{t('Elevation multiplier for 3D rendering')}
</small>
</Col>
</Row>
)}
</>
)}
{/* Opacity */}
{showOpacity && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Opacity')}</label>
<Slider
value={values.opacity || 80}
onChange={value => onChange('opacity', value)}
min={0}
max={100}
step={1}
marks={{ 0: '0%', 50: '50%', 100: '100%' }}
/>
<small className="text-muted">{t('Layer opacity')}</small>
</Col>
</Row>
)}
{/* Coverage (for hex, grid) */}
{showCoverage && (layerType === 'hex' || layerType === 'grid') && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Coverage')}</label>
<Slider
value={values.coverage || 1}
onChange={value => onChange('coverage', value)}
min={0}
max={1}
step={0.01}
/>
<small className="text-muted">{t('Cell coverage radius')}</small>
</Col>
</Row>
)}
{/* Legend */}
{showLegend && (
<>
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Legend Position')}</label>
<Select
value={values.legend_position || 'top_right'}
onChange={value => onChange('legend_position', value)}
style={{ width: '100%' }}
options={[
{ value: 'top_left', label: t('Top left') },
{ value: 'top_right', label: t('Top right') },
{ value: 'bottom_left', label: t('Bottom left') },
{ value: 'bottom_right', label: t('Bottom right') },
]}
/>
</Col>
</Row>
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Legend Format')}</label>
<Input
value={values.legend_format || ''}
onChange={e => onChange('legend_format', e.target.value)}
placeholder=".3s"
/>
<small className="text-muted">
{t('D3 number format for legend')}
</small>
</Col>
</Row>
</>
)}
{/* Filters */}
{showFilters && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.filter_nulls || true}
onChange={checked => onChange('filter_nulls', checked)}
/>
{t('Filter Nulls')}
</label>
<small className="text-muted">
{t('Filter out null values from data')}
</small>
</Col>
</Row>
)}
{/* Tooltip */}
{showTooltip && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Tooltip')}</label>
<Input.TextArea
value={values.js_tooltip || ''}
onChange={e => onChange('js_tooltip', e.target.value)}
placeholder={t('JavaScript tooltip generator')}
rows={3}
/>
<small className="text-muted">
{t('JavaScript code for custom tooltip')}
</small>
</Col>
</Row>
)}
{/* Animation */}
{showAnimation && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.animation || false}
onChange={checked => onChange('animation', checked)}
/>
{t('Animate')}
</label>
<small className="text-muted">
{t('Animate visualization over time')}
</small>
</Col>
</Row>
)}
{/* Multiplier for some visualizations */}
{showMultiplier && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Multiplier')}</label>
<Slider
value={values.multiplier || 1}
onChange={value => onChange('multiplier', value)}
min={0.01}
max={10}
step={0.01}
/>
<small className="text-muted">{t('Value multiplier')}</small>
</Col>
</Row>
)}
</div>
);
export default DeckGLControlsSection;

View File

@@ -0,0 +1,336 @@
/**
* 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 { FC } from 'react';
import { t } from '@superset-ui/core';
import { Switch, Select, Input, InputNumber } from 'antd';
import { Row, Col } from '@superset-ui/core/components';
export interface FilterControlsSectionProps {
filterType: 'select' | 'range' | 'time' | 'time_column' | 'time_grain';
showMultiple?: boolean;
showSearch?: boolean;
showParentFilter?: boolean;
showDefaultValue?: boolean;
showInverseSelection?: boolean;
showDateFilter?: boolean;
values?: Record<string, any>;
onChange?: (name: string, value: any) => void;
}
const FilterControlsSection: FC<FilterControlsSectionProps> = ({
filterType,
showMultiple = true,
showSearch = true,
showParentFilter = true,
showDefaultValue = true,
showInverseSelection = false,
showDateFilter = false,
values = {},
onChange = () => {},
}) => {
const isSelect = filterType === 'select';
const isRange = filterType === 'range';
const isTime = filterType === 'time';
const isTimeColumn = filterType === 'time_column';
const isTimeGrain = filterType === 'time_grain';
return (
<div className="filter-controls-section">
{/* Multiple Selection */}
{showMultiple && isSelect && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.multiSelect || false}
onChange={checked => onChange('multiSelect', checked)}
/>
{t('Multiple Select')}
</label>
<small className="text-muted">
{t('Allow selecting multiple values')}
</small>
</Col>
</Row>
)}
{/* Search */}
{showSearch && isSelect && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.enableEmptyFilter || false}
onChange={checked => onChange('enableEmptyFilter', checked)}
/>
{t('Enable Empty Filter')}
</label>
<small className="text-muted">
{t('Allow empty filter values')}
</small>
</Col>
</Row>
)}
{/* Inverse Selection */}
{showInverseSelection && isSelect && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.inverseSelection || false}
onChange={checked => onChange('inverseSelection', checked)}
/>
{t('Inverse Selection')}
</label>
<small className="text-muted">
{t('Exclude selected values instead of including them')}
</small>
</Col>
</Row>
)}
{/* Parent Filter */}
{showParentFilter && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.parentFilter || false}
onChange={checked => onChange('parentFilter', checked)}
/>
{t('Parent Filter')}
</label>
<small className="text-muted">
{t('Filter is dependent on another filter')}
</small>
</Col>
</Row>
)}
{/* Default Value */}
{showDefaultValue && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Default Value')}</label>
{isSelect ? (
<Input
value={values.defaultValue || ''}
onChange={e => onChange('defaultValue', e.target.value)}
placeholder={t('Enter default value')}
/>
) : isRange ? (
<div style={{ display: 'flex', gap: 8 }}>
<InputNumber
value={values.defaultValueMin}
onChange={value => onChange('defaultValueMin', value)}
placeholder={t('Min')}
style={{ flex: 1 }}
/>
<InputNumber
value={values.defaultValueMax}
onChange={value => onChange('defaultValueMax', value)}
placeholder={t('Max')}
style={{ flex: 1 }}
/>
</div>
) : (
<Input
value={values.defaultValue || ''}
onChange={e => onChange('defaultValue', e.target.value)}
placeholder={t('Enter default value')}
/>
)}
<small className="text-muted">
{t('Default value to use when filter is first loaded')}
</small>
</Col>
</Row>
)}
{/* Sort Options for Select */}
{isSelect && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Sort Filter Values')}</label>
<Select
value={values.sortFilter || false}
onChange={value => onChange('sortFilter', value)}
style={{ width: '100%' }}
options={[
{ value: false, label: t('No Sort') },
{ value: true, label: t('Sort Ascending') },
{ value: 'desc', label: t('Sort Descending') },
]}
/>
<small className="text-muted">
{t('Sort filter values alphabetically')}
</small>
</Col>
</Row>
)}
{/* Search for Select Filter */}
{isSelect && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.searchAllOptions || false}
onChange={checked => onChange('searchAllOptions', checked)}
/>
{t('Search All Options')}
</label>
<small className="text-muted">
{t('Search all filter options, not just displayed ones')}
</small>
</Col>
</Row>
)}
{/* Range Options */}
{isRange && (
<>
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Min Value')}</label>
<InputNumber
value={values.rangeMin}
onChange={value => onChange('rangeMin', value)}
style={{ width: '100%' }}
/>
<small className="text-muted">
{t('Minimum value for the range')}
</small>
</Col>
</Row>
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Max Value')}</label>
<InputNumber
value={values.rangeMax}
onChange={value => onChange('rangeMax', value)}
style={{ width: '100%' }}
/>
<small className="text-muted">
{t('Maximum value for the range')}
</small>
</Col>
</Row>
</>
)}
{/* Time Options */}
{(isTime || isTimeColumn) && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.defaultToFirstValue || false}
onChange={checked => onChange('defaultToFirstValue', checked)}
/>
{t('Default to First Value')}
</label>
<small className="text-muted">
{t('Default to the first available time value')}
</small>
</Col>
</Row>
)}
{/* Time Grain Options */}
{isTimeGrain && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Default Time Grain')}</label>
<Select
value={values.defaultTimeGrain || 'day'}
onChange={value => onChange('defaultTimeGrain', value)}
style={{ width: '100%' }}
options={[
{ value: 'minute', label: t('Minute') },
{ value: 'hour', label: t('Hour') },
{ value: 'day', label: t('Day') },
{ value: 'week', label: t('Week') },
{ value: 'month', label: t('Month') },
{ value: 'quarter', label: t('Quarter') },
{ value: 'year', label: t('Year') },
]}
/>
<small className="text-muted">
{t('Default time granularity')}
</small>
</Col>
</Row>
)}
{/* UI Configuration */}
<h4 style={{ marginTop: 24, marginBottom: 16 }}>
{t('UI Configuration')}
</h4>
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.instant_filtering || true}
onChange={checked => onChange('instant_filtering', checked)}
/>
{t('Instant Filtering')}
</label>
<small className="text-muted">
{t('Apply filters instantly as they change')}
</small>
</Col>
</Row>
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.show_apply || false}
onChange={checked => onChange('show_apply', checked)}
/>
{t('Show Apply Button')}
</label>
<small className="text-muted">
{t('Show an apply button for the filter')}
</small>
</Col>
</Row>
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.show_clear || true}
onChange={checked => onChange('show_clear', checked)}
/>
{t('Show Clear Button')}
</label>
<small className="text-muted">
{t('Show a clear button for the filter')}
</small>
</Col>
</Row>
</div>
);
};
export default FilterControlsSection;

View File

@@ -0,0 +1,241 @@
/**
* 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 { FC } from 'react';
import { t } from '@superset-ui/core';
import { Select } from 'antd';
import { Row, Col } from '@superset-ui/core/components';
export interface FormatControlGroupProps {
showNumber?: boolean;
showCurrency?: boolean;
showDate?: boolean;
showPercentage?: boolean;
numberFormatLabel?: string;
currencyFormatLabel?: string;
dateFormatLabel?: string;
percentageFormatLabel?: string;
customFormatOptions?: Array<[string, string]>;
values?: Record<string, any>;
onChange?: (name: string, value: any) => void;
}
export const D3_FORMAT_OPTIONS = [
['SMART_NUMBER', t('Adaptive formatting')],
['~g', t('Original value')],
['d', t('Signed integer')],
['.0f', t('Integer')],
['.1f', t('1 decimal place')],
['.2f', t('2 decimal places')],
['.3f', t('3 decimal places')],
['.4f', t('4 decimal places')],
['.5f', t('5 decimal places')],
['+,', t('Positive integer')],
['+,.0f', t('Positive number')],
['+,.1f', t('Positive (1 decimal)')],
['+,.2f', t('Positive (2 decimals)')],
[',.0f', t('Number (no decimals)')],
[',.1f', t('Number (1 decimal)')],
[',.2f', t('Number (2 decimals)')],
[',.3f', t('Number (3 decimals)')],
['.0%', t('Percentage')],
['.1%', t('Percentage (1 decimal)')],
['.2%', t('Percentage (2 decimals)')],
['.3%', t('Percentage (3 decimals)')],
[',.0%', t('Percentage with thousands')],
['.1s', t('SI notation')],
['.2s', t('SI notation (2 decimals)')],
['.3s', t('SI notation (3 decimals)')],
['$,.0f', t('Currency (no decimals)')],
['$,.1f', t('Currency (1 decimal)')],
['$,.2f', t('Currency (2 decimals)')],
['$,.3f', t('Currency (3 decimals)')],
];
export const D3_TIME_FORMAT_OPTIONS = [
['smart_date', t('Adaptive formatting')],
['%Y-%m-%d', t('YYYY-MM-DD')],
['%Y-%m-%d %H:%M', t('YYYY-MM-DD HH:MM')],
['%Y-%m-%d %H:%M:%S', t('YYYY-MM-DD HH:MM:SS')],
['%Y/%m/%d', t('YYYY/MM/DD')],
['%m/%d/%Y', t('MM/DD/YYYY')],
['%d/%m/%Y', t('DD/MM/YYYY')],
['%d.%m.%Y', t('DD.MM.YYYY')],
['%Y', t('Year (YYYY)')],
['%B %Y', t('Month Year (January 2023)')],
['%b %Y', t('Month Year (Jan 2023)')],
['%B', t('Month (January)')],
['%b', t('Month (Jan)')],
['%B %-d, %Y', t('Month Day, Year')],
['%b %-d, %Y', t('Mon Day, Year')],
['%a', t('Day of week (short)')],
['%A', t('Day of week (full)')],
['%H:%M', t('Time (24-hour)')],
['%I:%M %p', t('Time (12-hour)')],
['%H:%M:%S', t('Time with seconds')],
];
const CURRENCY_OPTIONS = [
{ value: 'USD', label: 'USD ($)' },
{ value: 'EUR', label: 'EUR (€)' },
{ value: 'GBP', label: 'GBP (£)' },
{ value: 'JPY', label: 'JPY (¥)' },
{ value: 'CNY', label: 'CNY (¥)' },
{ value: 'INR', label: 'INR (₹)' },
{ value: 'CAD', label: 'CAD ($)' },
{ value: 'AUD', label: 'AUD ($)' },
{ value: 'CHF', label: 'CHF (Fr)' },
{ value: 'SEK', label: 'SEK (kr)' },
{ value: 'NOK', label: 'NOK (kr)' },
{ value: 'DKK', label: 'DKK (kr)' },
{ value: 'KRW', label: 'KRW (₩)' },
{ value: 'BRL', label: 'BRL (R$)' },
{ value: 'MXN', label: 'MXN ($)' },
{ value: 'RUB', label: 'RUB (₽)' },
];
const FormatControlGroup: FC<FormatControlGroupProps> = ({
showNumber = true,
showCurrency = false,
showDate = false,
showPercentage = false,
numberFormatLabel = t('Number format'),
currencyFormatLabel = t('Currency'),
dateFormatLabel = t('Date format'),
percentageFormatLabel = t('Percentage format'),
customFormatOptions = [],
values = {},
onChange = () => {},
}) => {
const formatOptions =
customFormatOptions.length > 0 ? customFormatOptions : D3_FORMAT_OPTIONS;
return (
<div className="format-control-group">
{showNumber && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{numberFormatLabel}</label>
<Select
value={values.number_format || 'SMART_NUMBER'}
onChange={value => onChange('number_format', value)}
style={{ width: '100%' }}
showSearch
placeholder={t('Select or type a custom format')}
options={formatOptions.map(([value, label]) => ({
value,
label,
}))}
/>
<small className="text-muted">
{t('D3 format string for numbers. See ')}
<a
href="https://github.com/d3/d3-format/blob/main/README.md#format"
target="_blank"
rel="noopener noreferrer"
>
{t('D3 format docs')}
</a>
{t(' for details.')}
</small>
</Col>
</Row>
)}
{showCurrency && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{currencyFormatLabel}</label>
<Select
value={values.currency_format || 'USD'}
onChange={value => onChange('currency_format', value)}
style={{ width: '100%' }}
showSearch
placeholder={t('Select currency')}
options={CURRENCY_OPTIONS}
/>
<small className="text-muted">
{t('Currency to use for formatting')}
</small>
</Col>
</Row>
)}
{showDate && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{dateFormatLabel}</label>
<Select
value={values.date_format || 'smart_date'}
onChange={value => onChange('date_format', value)}
style={{ width: '100%' }}
showSearch
placeholder={t('Select or type a custom format')}
options={D3_TIME_FORMAT_OPTIONS.map(([value, label]) => ({
value,
label,
}))}
/>
<small className="text-muted">
{t('D3 time format string. See ')}
<a
href="https://github.com/d3/d3-time-format/blob/main/README.md#locale_format"
target="_blank"
rel="noopener noreferrer"
>
{t('D3 time format docs')}
</a>
{t(' for details.')}
</small>
</Col>
</Row>
)}
{showPercentage && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{percentageFormatLabel}</label>
<Select
value={values.percentage_format || '.0%'}
onChange={value => onChange('percentage_format', value)}
style={{ width: '100%' }}
showSearch
placeholder={t('Select or type a custom format')}
options={[
['.0%', t('0%')],
['.1%', t('0.1%')],
['.2%', t('0.12%')],
['.3%', t('0.123%')],
[',.0%', t('1,234%')],
[',.1%', t('1,234.5%')],
].map(([value, label]) => ({
value,
label,
}))}
/>
<small className="text-muted">
{t('D3 format for percentages')}
</small>
</Col>
</Row>
)}
</div>
);
};
export default FormatControlGroup;

View File

@@ -0,0 +1,131 @@
/**
* 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 { FC, useMemo } from 'react';
import { t } from '@superset-ui/core';
import { Select } from '@superset-ui/core/components';
import { ControlComponentProps, ColumnMeta } from '../../types';
import { ControlHeader } from '../../components/ControlHeader';
export interface GranularityControlValue {
column_name: string;
type?: string;
is_dttm?: boolean;
}
export interface GranularityControlProps
extends ControlComponentProps<GranularityControlValue | string> {
columns?: ColumnMeta[];
datasource?: {
columns?: ColumnMeta[];
verbose_map?: Record<string, string>;
};
clearable?: boolean;
temporalColumnsOnly?: boolean;
}
const GranularityControl: FC<GranularityControlProps> = ({
value,
onChange,
columns = [],
datasource,
clearable = false,
temporalColumnsOnly = true,
name,
label,
description,
validationErrors,
renderTrigger,
...props
}) => {
const allColumns = useMemo(() => {
const cols = columns.length > 0 ? columns : datasource?.columns || [];
if (temporalColumnsOnly) {
return cols.filter(col => col.is_dttm);
}
return cols;
}, [columns, datasource?.columns, temporalColumnsOnly]);
const options = useMemo(
() =>
allColumns.map(col => ({
value: col.column_name,
label:
datasource?.verbose_map?.[col.column_name] ||
col.verbose_name ||
col.column_name,
})),
[allColumns, datasource?.verbose_map],
);
const currentValue = useMemo(() => {
if (typeof value === 'string') {
return value;
}
return value?.column_name;
}, [value]);
const handleChange = (newValue: string | undefined) => {
if (onChange) {
if (!newValue && clearable) {
onChange(null as any);
} else if (newValue) {
const column = allColumns.find(col => col.column_name === newValue);
if (column) {
onChange({
column_name: column.column_name,
type: column.type,
is_dttm: column.is_dttm,
});
}
}
}
};
return (
<div>
<ControlHeader
name={name}
label={label || t('Time Column')}
description={
description ||
t(
'The time column for the visualization. Note that you ' +
'can define arbitrary expression that return a DATETIME ' +
'column in the table. Also note that the ' +
'filter below is applied against this column or ' +
'expression',
)
}
validationErrors={validationErrors}
renderTrigger={renderTrigger}
/>
<Select
value={currentValue}
onChange={handleChange}
options={options}
placeholder={t('Select a temporal column')}
allowClear={clearable}
showSearch
css={{ width: '100%' }}
/>
</div>
);
};
export default GranularityControl;

View File

@@ -0,0 +1,268 @@
/**
* 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 type { CustomControlItem } from '../../types';
/**
* Helper function to create a SelectControl configuration
*/
export const SelectControl = (config: {
name: string;
label: string;
default?: any;
choices?: any[][] | (() => any[][]) | any[];
description?: string;
freeForm?: boolean;
clearable?: boolean;
multiple?: boolean;
validators?: any[];
renderTrigger?: boolean;
[key: string]: any;
}): CustomControlItem => ({
name: config.name,
config: {
type: 'SelectControl',
...config,
},
});
/**
* Helper function to create a TextControl configuration
*/
export const TextControl = (config: {
name: string;
label: string;
default?: any;
description?: string;
isInt?: boolean;
isFloat?: boolean;
validators?: any[];
renderTrigger?: boolean;
placeholder?: string;
[key: string]: any;
}): CustomControlItem => ({
name: config.name,
config: {
type: 'TextControl',
...config,
},
});
/**
* Helper function to create a CheckboxControl configuration
*/
export const CheckboxControl = (config: {
name: string;
label: string;
default?: boolean;
description?: string;
renderTrigger?: boolean;
[key: string]: any;
}): CustomControlItem => ({
name: config.name,
config: {
type: 'CheckboxControl',
...config,
},
});
/**
* Helper function to create a SliderControl configuration
*/
export const SliderControl = (config: {
name: string;
label: string;
default?: number;
min?: number;
max?: number;
step?: number;
description?: string;
renderTrigger?: boolean;
[key: string]: any;
}): CustomControlItem => ({
name: config.name,
config: {
type: 'SliderControl',
...config,
},
});
/**
* Helper function to create a RadioButtonControl configuration
*/
export const RadioButtonControl = (config: {
name: string;
label: string;
default?: any;
options?: any[][] | any[];
description?: string;
renderTrigger?: boolean;
[key: string]: any;
}): CustomControlItem => ({
name: config.name,
config: {
type: 'RadioButtonControl',
...config,
},
});
/**
* Helper function to create a BoundsControl configuration
*/
export const BoundsControl = (config: {
name: string;
label: string;
default?: [number | null, number | null];
description?: string;
renderTrigger?: boolean;
[key: string]: any;
}): CustomControlItem => ({
name: config.name,
config: {
type: 'BoundsControl',
...config,
},
});
/**
* Helper function to create a ColorPickerControl configuration
*/
export const ColorPickerControl = (config: {
name: string;
label: string;
default?: { r: number; g: number; b: number; a: number };
description?: string;
renderTrigger?: boolean;
[key: string]: any;
}): CustomControlItem => ({
name: config.name,
config: {
type: 'ColorPickerControl',
...config,
},
});
/**
* Helper function to create a DateFilterControl configuration
*/
export const DateFilterControl = (config: {
name: string;
label: string;
default?: string;
description?: string;
[key: string]: any;
}): CustomControlItem => ({
name: config.name,
config: {
type: 'DateFilterControl',
...config,
},
});
/**
* Helper function to create a SwitchControl configuration
*/
export const SwitchControl = (config: {
name: string;
label: string;
default?: boolean;
description?: string;
renderTrigger?: boolean;
[key: string]: any;
}): CustomControlItem => ({
name: config.name,
config: {
type: 'SwitchControl',
...config,
},
});
/**
* Helper function to create a HiddenControl configuration
*/
export const HiddenControl = (config: {
name: string;
default?: any;
initialValue?: any;
description?: string;
[key: string]: any;
}): CustomControlItem => ({
name: config.name,
config: {
type: 'HiddenControl',
...config,
},
});
/**
* Helper function to create a SpatialControl configuration
*/
export const SpatialControl = (config: {
name: string;
label: string;
description?: string;
validators?: any[];
mapStateToProps?: (state: any) => any;
renderTrigger?: boolean;
[key: string]: any;
}): CustomControlItem => ({
name: config.name,
config: {
type: 'SpatialControl',
...config,
},
});
/**
* Helper function to create a ContourControl configuration
*/
export const ContourControl = (config: {
name: string;
label: string;
description?: string;
renderTrigger?: boolean;
mapStateToProps?: (state: any) => any;
[key: string]: any;
}): CustomControlItem => ({
name: config.name,
config: {
type: 'ContourControl',
...config,
},
});
/**
* Helper function to create a TextAreaControl configuration
*/
export const TextAreaControl = (config: {
name: string;
label: string;
default?: string;
description?: string;
renderTrigger?: boolean;
rows?: number;
placeholder?: string;
[key: string]: any;
}): CustomControlItem => ({
name: config.name,
config: {
type: 'TextAreaControl',
...config,
},
});

View File

@@ -0,0 +1,241 @@
/**
* 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 { FC } from 'react';
import { t } from '@superset-ui/core';
import { Select, Switch, InputNumber, Input } from 'antd';
import { Row, Col } from '@superset-ui/core/components';
export interface LabelControlGroupProps {
chartType?: 'pie' | 'sunburst' | 'treemap' | 'funnel' | 'gauge';
showLabelType?: boolean;
showTemplate?: boolean;
showThreshold?: boolean;
showOutside?: boolean;
showLabelLine?: boolean;
showRotation?: boolean;
showUpperLabels?: boolean;
values?: Record<string, any>;
onChange?: (name: string, value: any) => void;
}
const LABEL_TYPE_OPTIONS = [
['key', t('Category Name')],
['value', t('Value')],
['percent', t('Percentage')],
['key_value', t('Category and Value')],
['key_percent', t('Category and Percentage')],
['key_value_percent', t('Category, Value and Percentage')],
['value_percent', t('Value and Percentage')],
['template', t('Template')],
];
const LABEL_ROTATION_OPTIONS = [
['0', t('Horizontal')],
['45', t('45°')],
['90', t('Vertical')],
['-45', t('-45°')],
];
const LabelControlGroup: FC<LabelControlGroupProps> = ({
chartType = 'pie',
showLabelType = true,
showTemplate = true,
showThreshold = true,
showOutside = false,
showLabelLine = false,
showRotation = false,
showUpperLabels = false,
values = {},
onChange = () => {},
}) => {
const showLabels = values.show_labels ?? true;
const labelType = values.label_type || 'key';
return (
<div className="label-control-group">
{/* Show Labels Toggle */}
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={showLabels}
onChange={checked => onChange('show_labels', checked)}
/>
{t('Show Labels')}
</label>
<small className="text-muted">
{t('Whether to display the labels')}
</small>
</Col>
</Row>
{showLabels && (
<>
{/* Label Type */}
{showLabelType && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Label Type')}</label>
<Select
value={labelType}
onChange={value => onChange('label_type', value)}
style={{ width: '100%' }}
options={LABEL_TYPE_OPTIONS.map(([value, label]) => ({
value,
label,
}))}
/>
<small className="text-muted">
{t('What should be shown on the label?')}
</small>
</Col>
</Row>
)}
{/* Label Template */}
{showTemplate && labelType === 'template' && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Label Template')}</label>
<Input.TextArea
value={values.label_template || ''}
onChange={e => onChange('label_template', e.target.value)}
placeholder="{name}: {value} ({percent}%)"
rows={3}
/>
<small className="text-muted">
{t(
'Format data labels. Use variables: {name}, {value}, {percent}. \\n represents a new line.',
)}
</small>
</Col>
</Row>
)}
{/* Label Threshold */}
{showThreshold && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Label Threshold')}</label>
<InputNumber
value={values.show_labels_threshold ?? 5}
onChange={value => onChange('show_labels_threshold', value)}
min={0}
max={100}
step={0.5}
formatter={value => `${value}%`}
parser={value => Number((value as string).replace('%', ''))}
style={{ width: '100%' }}
/>
<small className="text-muted">
{t(
'Minimum threshold in percentage points for showing labels',
)}
</small>
</Col>
</Row>
)}
{/* Labels Outside (Pie specific) */}
{showOutside && chartType === 'pie' && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label
style={{ display: 'flex', alignItems: 'center', gap: 8 }}
>
<Switch
checked={values.labels_outside || false}
onChange={checked => onChange('labels_outside', checked)}
/>
{t('Put labels outside')}
</label>
<small className="text-muted">
{t('Put the labels outside of the pie?')}
</small>
</Col>
</Row>
)}
{/* Label Line (Pie specific) */}
{showLabelLine && chartType === 'pie' && values.labels_outside && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label
style={{ display: 'flex', alignItems: 'center', gap: 8 }}
>
<Switch
checked={values.label_line || false}
onChange={checked => onChange('label_line', checked)}
/>
{t('Label Line')}
</label>
<small className="text-muted">
{t('Draw a line from the label to the slice')}
</small>
</Col>
</Row>
)}
{/* Label Rotation */}
{showRotation && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Label Rotation')}</label>
<Select
value={values.label_rotation || '0'}
onChange={value => onChange('label_rotation', value)}
style={{ width: '100%' }}
options={LABEL_ROTATION_OPTIONS.map(([value, label]) => ({
value,
label,
}))}
/>
<small className="text-muted">
{t('Rotation angle of labels')}
</small>
</Col>
</Row>
)}
{/* Show Upper Labels (Treemap specific) */}
{showUpperLabels && chartType === 'treemap' && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label
style={{ display: 'flex', alignItems: 'center', gap: 8 }}
>
<Switch
checked={values.show_upper_labels || false}
onChange={checked => onChange('show_upper_labels', checked)}
/>
{t('Show Upper Labels')}
</label>
<small className="text-muted">
{t('Show labels for parent nodes')}
</small>
</Col>
</Row>
)}
</>
)}
</div>
);
};
export default LabelControlGroup;

View File

@@ -0,0 +1,133 @@
/**
* 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 { FC } from 'react';
import { t } from '@superset-ui/core';
import { Switch, Slider, InputNumber } from 'antd';
import { Row, Col } from '@superset-ui/core/components';
export interface MarkerControlGroupProps {
enabledLabel?: string;
sizeLabel?: string;
maxSize?: number;
minSize?: number;
defaultSize?: number;
values?: {
markerEnabled?: boolean;
markerSize?: number;
};
onChange?: (name: string, value: any) => void;
disabled?: boolean;
}
const MarkerControlGroup: FC<MarkerControlGroupProps> = ({
enabledLabel = t('Show markers'),
sizeLabel = t('Marker size'),
maxSize = 20,
minSize = 0,
defaultSize = 6,
values = {},
onChange = () => {},
disabled = false,
}) => {
const markerEnabled = values.markerEnabled ?? false;
const markerSize = values.markerSize ?? defaultSize;
const handleEnabledChange = (checked: boolean) => {
onChange('markerEnabled', checked);
if (checked && !values.markerSize) {
onChange('markerSize', defaultSize);
}
};
const handleSizeChange = (value: number) => {
onChange('markerSize', value);
};
const handleInputChange = (value: number | null) => {
if (value !== null) {
const clampedValue = Math.max(minSize, Math.min(maxSize, value));
onChange('markerSize', clampedValue);
}
};
return (
<div className="marker-control-group">
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={markerEnabled}
onChange={handleEnabledChange}
disabled={disabled}
/>
{enabledLabel}
</label>
<small className="text-muted">
{t('Draw markers on data points for better visibility')}
</small>
</Col>
</Row>
{markerEnabled && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'block', marginBottom: 8 }}>
{sizeLabel}
</label>
<Row gutter={16} align="middle">
<Col span={16}>
<Slider
min={minSize}
max={maxSize}
step={1}
value={markerSize}
onChange={handleSizeChange}
disabled={disabled || !markerEnabled}
marks={{
[minSize]: minSize.toString(),
[Math.floor(maxSize / 2)]: Math.floor(
maxSize / 2,
).toString(),
[maxSize]: maxSize.toString(),
}}
/>
</Col>
<Col span={8}>
<InputNumber
min={minSize}
max={maxSize}
step={1}
value={markerSize}
onChange={handleInputChange}
disabled={disabled || !markerEnabled}
style={{ width: '100%' }}
/>
</Col>
</Row>
<small className="text-muted">
{t('Size of the markers in pixels')}
</small>
</Col>
</Row>
)}
</div>
);
};
export default MarkerControlGroup;

View File

@@ -0,0 +1,114 @@
/**
* 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 { FC } from 'react';
import { t } from '@superset-ui/core';
import { Slider, InputNumber } from 'antd';
import { Row, Col } from '@superset-ui/core/components';
export interface OpacityControlProps {
name?: string;
label?: string;
description?: string;
min?: number;
max?: number;
step?: number;
value?: number;
onChange?: (value: number) => void;
disabled?: boolean;
marks?: Record<number, string>;
}
const OpacityControl: FC<OpacityControlProps> = ({
name = 'opacity',
label = t('Opacity'),
description = t('Opacity of the elements'),
min = 0,
max = 1,
step = 0.1,
value = 0.8,
onChange = () => {},
disabled = false,
marks,
}) => {
const defaultMarks = marks || {
0: '0%',
0.25: '25%',
0.5: '50%',
0.75: '75%',
1: '100%',
};
const handleSliderChange = (val: number) => {
onChange(val);
};
const handleInputChange = (val: number | null) => {
if (val !== null) {
const clampedValue = Math.max(min, Math.min(max, val));
onChange(clampedValue);
}
};
const percentageValue = Math.round(value * 100);
return (
<div className="opacity-control" data-name={name}>
<label style={{ display: 'block', marginBottom: 8 }}>{label}</label>
<Row gutter={16} align="middle">
<Col span={16}>
<Slider
min={min}
max={max}
step={step}
value={value}
onChange={handleSliderChange}
marks={defaultMarks}
disabled={disabled}
tooltip={{
formatter: val => `${Math.round((val as number) * 100)}%`,
}}
/>
</Col>
<Col span={8}>
<InputNumber
min={min * 100}
max={max * 100}
step={step * 100}
value={percentageValue}
onChange={val => handleInputChange(val !== null ? val / 100 : null)}
formatter={val => `${val}%`}
parser={val => Number((val as string).replace('%', ''))}
disabled={disabled}
style={{ width: '100%' }}
/>
</Col>
</Row>
{description && (
<small
className="text-muted"
style={{ display: 'block', marginTop: 4 }}
>
{description}
</small>
)}
</div>
);
};
export default OpacityControl;

View File

@@ -0,0 +1,175 @@
/**
* 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 { FC } from 'react';
import { t } from '@superset-ui/core';
import { Select, Switch, Slider, InputNumber } from 'antd';
import { Row, Col } from '@superset-ui/core/components';
export interface PieShapeControlProps {
showDonut?: boolean;
showRoseType?: boolean;
showRadius?: boolean;
values?: Record<string, any>;
onChange?: (name: string, value: any) => void;
}
const ROSE_TYPE_OPTIONS = [
['area', t('Area')],
['radius', t('Radius')],
[null, t('None')],
];
const PieShapeControl: FC<PieShapeControlProps> = ({
showDonut = true,
showRoseType = true,
showRadius = true,
values = {},
onChange = () => {},
}) => {
const isDonut = values.donut || false;
const innerRadius = values.innerRadius || 30;
const outerRadius = values.outerRadius || 70;
return (
<div className="pie-shape-control">
{/* Donut Toggle */}
{showDonut && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={isDonut}
onChange={checked => onChange('donut', checked)}
/>
{t('Donut')}
</label>
<small className="text-muted">
{t('Do you want a donut or a pie?')}
</small>
</Col>
</Row>
)}
{/* Inner Radius (for Donut) */}
{showRadius && isDonut && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Inner Radius')}</label>
<Row gutter={16} align="middle">
<Col span={16}>
<Slider
min={0}
max={100}
step={1}
value={innerRadius}
onChange={value => onChange('innerRadius', value)}
marks={{
0: '0%',
50: '50%',
100: '100%',
}}
/>
</Col>
<Col span={8}>
<InputNumber
min={0}
max={100}
step={1}
value={innerRadius}
onChange={value => onChange('innerRadius', value)}
formatter={value => `${value}%`}
parser={value => Number((value as string).replace('%', ''))}
style={{ width: '100%' }}
/>
</Col>
</Row>
<small className="text-muted">
{t('Inner radius of donut hole')}
</small>
</Col>
</Row>
)}
{/* Outer Radius */}
{showRadius && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Outer Radius')}</label>
<Row gutter={16} align="middle">
<Col span={16}>
<Slider
min={0}
max={100}
step={1}
value={outerRadius}
onChange={value => onChange('outerRadius', value)}
marks={{
0: '0%',
50: '50%',
100: '100%',
}}
/>
</Col>
<Col span={8}>
<InputNumber
min={0}
max={100}
step={1}
value={outerRadius}
onChange={value => onChange('outerRadius', value)}
formatter={value => `${value}%`}
parser={value => Number((value as string).replace('%', ''))}
style={{ width: '100%' }}
/>
</Col>
</Row>
<small className="text-muted">
{t('Outer edge of the pie/donut')}
</small>
</Col>
</Row>
)}
{/* Rose Type (Nightingale Chart) */}
{showRoseType && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Rose Type')}</label>
<Select
value={values.roseType || null}
onChange={value => onChange('roseType', value)}
style={{ width: '100%' }}
allowClear
placeholder={t('None')}
options={ROSE_TYPE_OPTIONS.map(([value, label]) => ({
value,
label,
}))}
/>
<small className="text-muted">
{t('Whether to show as Nightingale chart (polar area chart)')}
</small>
</Col>
</Row>
)}
</div>
);
};
export default PieShapeControl;

View File

@@ -0,0 +1,104 @@
/**
* 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 { FC, ReactElement, useMemo } from 'react';
import { JsonValue } from '@superset-ui/core';
export interface ReactControlPanelSection {
key: string;
label: string;
description?: string;
expanded?: boolean;
render: (props: ControlPanelRenderProps) => ReactElement;
}
export interface ControlPanelRenderProps {
values: Record<string, JsonValue>;
onChange: (name: string, value: JsonValue) => void;
datasource?: any;
formData?: any;
validationErrors?: Record<string, string[]>;
}
export interface ReactControlPanelConfig {
sections: ReactControlPanelSection[];
onFormDataChange?: (formData: any) => any;
}
/**
* A wrapper component that allows rendering control panels with actual React components
* instead of configuration objects. This provides a stepping stone toward JSON-driven forms.
*/
export const ReactControlPanel: FC<{
config: ReactControlPanelConfig;
values: Record<string, JsonValue>;
onChange: (name: string, value: JsonValue) => void;
datasource?: any;
formData?: any;
validationErrors?: Record<string, string[]>;
}> = ({ config, values, onChange, datasource, formData, validationErrors }) => {
const renderProps: ControlPanelRenderProps = useMemo(
() => ({
values,
onChange,
datasource,
formData,
validationErrors,
}),
[values, onChange, datasource, formData, validationErrors],
);
return (
<div className="react-control-panel">
{config.sections.map(section => (
<div key={section.key} className="control-panel-section">
<h4>{section.label}</h4>
{section.description && (
<p className="section-description">{section.description}</p>
)}
{section.render(renderProps)}
</div>
))}
</div>
);
};
/**
* Helper function to create a control panel configuration that works with
* both the old and new systems
*/
export function createReactControlPanel(config: ReactControlPanelConfig): any {
return {
controlPanelSections: config.sections.map(section => ({
label: section.label,
description: section.description,
expanded: section.expanded ?? true,
controlSetRows: [
[
// Return a React element that will be rendered directly
<ReactControlPanel
key={section.key}
config={{ sections: [section] }}
values={{}}
onChange={() => {}}
/>,
],
],
})),
};
}

View File

@@ -0,0 +1,306 @@
/**
* 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 type { CustomControlItem } from '../../types';
import sharedControls from '../sharedControls';
/**
* React component wrappers for shared controls.
* These replace string references like ['metrics'] with actual component calls.
*/
// Metrics controls
export const MetricsControl = (): CustomControlItem => ({
name: 'metrics',
config: sharedControls.metrics,
});
export const MetricControl = (): CustomControlItem => ({
name: 'metric',
config: sharedControls.metric,
});
export const SecondaryMetricControl = (): CustomControlItem => ({
name: 'secondary_metric',
config: sharedControls.secondary_metric,
});
export const Metric2Control = (): CustomControlItem => ({
name: 'metric_2',
config: sharedControls.metric_2,
});
export const TimeLimitMetricControl = (): CustomControlItem => ({
name: 'timeseries_limit_metric',
config: sharedControls.timeseries_limit_metric,
});
export const OrderByControl = (): CustomControlItem => ({
name: 'orderby',
config: sharedControls.orderby,
});
export const SeriesLimitMetricControl = (): CustomControlItem => ({
name: 'series_limit_metric',
config: sharedControls.series_limit_metric,
});
export const SortByMetricControl = (): CustomControlItem => ({
name: 'sort_by_metric',
config: sharedControls.sort_by_metric,
});
// Dimension controls
export const GroupByControl = (): CustomControlItem => ({
name: 'groupby',
config: sharedControls.groupby,
});
export const ColumnsControl = (): CustomControlItem => ({
name: 'columns',
config: sharedControls.columns,
});
// Note: These controls are not in sharedControls, using columns as fallback
export const AllColumnsControl = (): CustomControlItem => ({
name: 'all_columns',
config: sharedControls.columns || {},
});
export const AllColumnsXControl = (): CustomControlItem => ({
name: 'all_columns_x',
config: sharedControls.columns || {},
});
export const AllColumnsYControl = (): CustomControlItem => ({
name: 'all_columns_y',
config: sharedControls.columns || {},
});
export const SeriesControl = (): CustomControlItem => ({
name: 'series',
config: sharedControls.series,
});
export const EntityControl = (): CustomControlItem => ({
name: 'entity',
config: sharedControls.entity,
});
export const XControl = (): CustomControlItem => ({
name: 'x',
config: sharedControls.x,
});
export const YControl = (): CustomControlItem => ({
name: 'y',
config: sharedControls.y,
});
// Note: sort_by is not in sharedControls, using a default config
export const SortByControl = (): CustomControlItem => ({
name: 'sort_by',
config: {
type: 'SelectControl',
label: 'Sort By',
description: 'Sort by column',
},
});
export const SizeControl = (): CustomControlItem => ({
name: 'size',
config: sharedControls.size,
});
export const XAxisControl = (): CustomControlItem => ({
name: 'x_axis',
config: sharedControls.x_axis,
});
// Filter controls
export const AdhocFiltersControl = (): CustomControlItem => ({
name: 'adhoc_filters',
config: sharedControls.adhoc_filters,
});
export const TimeRangeControl = (): CustomControlItem => ({
name: 'time_range',
config: sharedControls.time_range,
});
export const TimeGrainSqlaControl = (): CustomControlItem => ({
name: 'time_grain_sqla',
config: sharedControls.time_grain_sqla,
});
export const GranularityControl = (): CustomControlItem => ({
name: 'granularity',
config: sharedControls.granularity,
});
export const GranularitySqlaControl = (): CustomControlItem => ({
name: 'granularity_sqla',
config: sharedControls.granularity_sqla,
});
// Limit controls
export const RowLimitControl = (): CustomControlItem => ({
name: 'row_limit',
config: sharedControls.row_limit,
});
export const LimitControl = (): CustomControlItem => ({
name: 'limit',
config: sharedControls.limit,
});
export const GroupOthersWhenLimitReachedControl = (): CustomControlItem => ({
name: 'group_others_when_limit_reached',
config: sharedControls.group_others_when_limit_reached,
});
export const SeriesLimitControl = (): CustomControlItem => ({
name: 'series_limit',
config: sharedControls.series_limit,
});
// Sort controls
export const OrderDescControl = (): CustomControlItem => ({
name: 'order_desc',
config: sharedControls.order_desc,
});
export const OrderByColsControl = (): CustomControlItem => ({
name: 'order_by_cols',
config: sharedControls.order_by_cols,
});
// Color controls
export const ColorSchemeControl = (): CustomControlItem => ({
name: 'color_scheme',
config: sharedControls.color_scheme,
});
export const LinearColorSchemeControl = (): CustomControlItem => ({
name: 'linear_color_scheme',
config: sharedControls.linear_color_scheme,
});
export const ColorPickerControl = (): CustomControlItem => ({
name: 'color_picker',
config: sharedControls.color_picker,
});
export const TimeShiftColorControl = (): CustomControlItem => ({
name: 'time_shift_color',
config: sharedControls.time_shift_color,
});
export const CurrencyFormatControl = (): CustomControlItem => ({
name: 'currency_format',
config: sharedControls.currency_format,
});
export const TruncateMetricControl = (): CustomControlItem => ({
name: 'truncate_metric',
config: sharedControls.truncate_metric,
});
export const ShowEmptyColumnsControl = (): CustomControlItem => ({
name: 'show_empty_columns',
config: sharedControls.show_empty_columns,
});
// Other controls
export const ZoomableControl = (): CustomControlItem => ({
name: 'zoomable',
config: sharedControls.zoomable,
});
export const DatasourceControl = (): CustomControlItem => ({
name: 'datasource',
config: sharedControls.datasource,
});
export const VizTypeControl = (): CustomControlItem => ({
name: 'viz_type',
config: sharedControls.viz_type,
});
// Tooltip controls
export const TooltipColumnsControl = (): CustomControlItem => ({
name: 'tooltip_columns',
config: sharedControls.tooltip_columns,
});
export const TooltipMetricsControl = (): CustomControlItem => ({
name: 'tooltip_metrics',
config: sharedControls.tooltip_metrics,
});
// Format controls
export const YAxisFormatControl = (): CustomControlItem => ({
name: 'y_axis_format',
config: sharedControls.y_axis_format,
});
export const XAxisTimeFormatControl = (): CustomControlItem => ({
name: 'x_axis_time_format',
config: sharedControls.x_axis_time_format,
});
// Hidden controls
export const TemporalColumnsLookupControl = (): CustomControlItem => ({
name: 'temporal_columns_lookup',
config: sharedControls.temporal_columns_lookup,
});
// Inline controls - for creating custom controls with overrides
export const InlineTextControl = (
name: string,
overrides?: Partial<CustomControlItem['config']>,
): CustomControlItem => ({
name,
config: {
type: 'TextControl',
...overrides,
},
});
export const InlineSelectControl = (
name: string,
overrides?: Partial<CustomControlItem['config']>,
): CustomControlItem => ({
name,
config: {
type: 'SelectControl',
...overrides,
},
});
export const InlineCheckboxControl = (
name: string,
overrides?: Partial<CustomControlItem['config']>,
): CustomControlItem => ({
name,
config: {
type: 'CheckboxControl',
...overrides,
},
});

View File

@@ -0,0 +1,272 @@
/**
* 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 { FC } from 'react';
import { t } from '@superset-ui/core';
import { Switch, Select, Input } from 'antd';
import { Row, Col } from '@superset-ui/core/components';
import FormatControlGroup from './FormatControlGroup';
export interface TableControlsSectionProps {
variant?: 'table' | 'pivot' | 'ag-grid';
showPagination?: boolean;
showCellBars?: boolean;
showTotals?: boolean;
showConditionalFormatting?: boolean;
showTimestampFormat?: boolean;
showAllowHtml?: boolean;
values?: Record<string, any>;
onChange?: (name: string, value: any) => void;
}
const TableControlsSection: FC<TableControlsSectionProps> = ({
variant = 'table',
showPagination = false,
showCellBars = false,
showTotals = false,
showConditionalFormatting = true,
showTimestampFormat = false,
showAllowHtml = true,
values = {},
onChange = () => {},
}) => {
const isPivot = variant === 'pivot';
return (
<div className="table-controls-section">
{/* Pagination Controls */}
{showPagination && !isPivot && (
<>
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.server_pagination || false}
onChange={checked => onChange('server_pagination', checked)}
/>
{t('Server Pagination')}
</label>
<small className="text-muted">
{t('Enable server-side pagination for large datasets')}
</small>
</Col>
</Row>
{values.server_pagination && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Page Length')}</label>
<Select
value={values.server_page_length || 10}
onChange={value => onChange('server_page_length', value)}
style={{ width: '100%' }}
options={[
{ value: 10, label: '10' },
{ value: 25, label: '25' },
{ value: 50, label: '50' },
{ value: 100, label: '100' },
{ value: 200, label: '200' },
]}
/>
<small className="text-muted">
{t('Number of rows per page')}
</small>
</Col>
</Row>
)}
</>
)}
{/* Cell Bars */}
{showCellBars && !isPivot && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.show_cell_bars || false}
onChange={checked => onChange('show_cell_bars', checked)}
/>
{t('Show Cell Bars')}
</label>
<small className="text-muted">
{t('Display mini bar charts in numeric columns')}
</small>
</Col>
</Row>
)}
{/* Totals */}
{showTotals && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.show_totals || values.rowTotals || false}
onChange={checked => {
if (isPivot) {
onChange('rowTotals', checked);
onChange('colTotals', checked);
} else {
onChange('show_totals', checked);
}
}}
/>
{t('Show Totals')}
</label>
<small className="text-muted">
{isPivot
? t('Show row and column totals')
: t('Show total row at bottom')}
</small>
</Col>
</Row>
)}
{/* Subtotals for Pivot */}
{isPivot && (
<>
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.rowSubTotals || false}
onChange={checked => onChange('rowSubTotals', checked)}
/>
{t('Show Row Subtotals')}
</label>
<small className="text-muted">
{t('Show subtotals for row groups')}
</small>
</Col>
</Row>
{values.rowSubTotals && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Subtotal Position')}</label>
<Select
value={values.rowSubtotalPosition || 'bottom'}
onChange={value => onChange('rowSubtotalPosition', value)}
style={{ width: '100%' }}
options={[
{ value: 'top', label: t('Top') },
{ value: 'bottom', label: t('Bottom') },
]}
/>
</Col>
</Row>
)}
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.colSubTotals || false}
onChange={checked => onChange('colSubTotals', checked)}
/>
{t('Show Column Subtotals')}
</label>
<small className="text-muted">
{t('Show subtotals for column groups')}
</small>
</Col>
</Row>
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.transposePivot || false}
onChange={checked => onChange('transposePivot', checked)}
/>
{t('Transpose Pivot')}
</label>
<small className="text-muted">{t('Swap rows and columns')}</small>
</Col>
</Row>
</>
)}
{/* Conditional Formatting */}
{showConditionalFormatting && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Conditional Formatting')}</label>
<Input.TextArea
value={values.conditional_formatting || ''}
onChange={e => onChange('conditional_formatting', e.target.value)}
placeholder={t('Enter conditional formatting rules as JSON')}
rows={4}
/>
<small className="text-muted">
{t('Apply conditional color formatting to cells')}
</small>
</Col>
</Row>
)}
{/* Timestamp Format */}
{showTimestampFormat && !isPivot && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label>{t('Timestamp Format')}</label>
<Input
value={values.table_timestamp_format || ''}
onChange={e => onChange('table_timestamp_format', e.target.value)}
placeholder="%Y-%m-%d %H:%M:%S"
/>
<small className="text-muted">
{t('D3 time format for timestamp columns')}
</small>
</Col>
</Row>
)}
{/* Allow HTML */}
{showAllowHtml && (
<Row gutter={[16, 8]} style={{ marginBottom: 16 }}>
<Col span={24}>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Switch
checked={values.allow_render_html || false}
onChange={checked => onChange('allow_render_html', checked)}
/>
{t('Allow HTML')}
</label>
<small className="text-muted">
{t(
'Render HTML content in cells (security warning: only enable for trusted data)',
)}
</small>
</Col>
</Row>
)}
{/* Format Controls */}
<div style={{ marginTop: 24 }}>
<h4>{t('Value Formats')}</h4>
<FormatControlGroup
showNumber
showCurrency
showPercentage={isPivot}
showDate={!isPivot}
values={values}
onChange={onChange}
/>
</div>
</div>
);
};
export default TableControlsSection;

View File

@@ -0,0 +1,237 @@
/**
* 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 { FC } from 'react';
import { t } from '@superset-ui/core';
import { Select, Radio } from 'antd';
import { Row, Col } from '@superset-ui/core/components';
import AxisControlSection from './AxisControlSection';
import FormatControlGroup from './FormatControlGroup';
import OpacityControl from './OpacityControl';
import MarkerControlGroup from './MarkerControlGroup';
export interface TimeseriesControlPanelProps {
variant: 'area' | 'bar' | 'line' | 'scatter' | 'smooth' | 'step';
showSeriesType?: boolean;
showStack?: boolean;
showArea?: boolean;
showMarkers?: boolean;
showOpacity?: boolean;
showOrientation?: boolean;
values?: Record<string, any>;
onChange?: (name: string, value: any) => void;
}
const SERIES_TYPE_OPTIONS: Record<string, Array<[string, string]>> = {
line: [
['line', t('Line')],
['scatter', t('Scatter')],
['smooth', t('Smooth')],
],
area: [
['line', t('Line')],
['smooth', t('Smooth Line')],
['start', t('Step - start')],
['middle', t('Step - middle')],
['end', t('Step - end')],
],
step: [
['start', t('Step - start')],
['middle', t('Step - middle')],
['end', t('Step - end')],
],
bar: [],
scatter: [],
smooth: [],
};
const STACK_OPTIONS = [
['stack', t('Stack')],
['stream', t('Stream')],
['expand', t('Expand')],
];
const TimeseriesControlPanel: FC<TimeseriesControlPanelProps> = ({
variant,
showSeriesType = true,
showStack = false,
showArea = false,
showMarkers = true,
showOpacity = false,
showOrientation = false,
values = {},
onChange = () => {},
}) => {
const hasAreaOptions = variant === 'area' || showArea;
const hasBarOptions = variant === 'bar';
const hasLineOptions = variant === 'line' || variant === 'smooth';
return (
<div className="timeseries-control-panel">
{/* Series Type Selection */}
{showSeriesType && SERIES_TYPE_OPTIONS[variant] && (
<Row gutter={[16, 8]} style={{ marginBottom: 24 }}>
<Col span={24}>
<label>{t('Series Style')}</label>
<Select
value={
values.seriesType ||
(SERIES_TYPE_OPTIONS[variant][0]
? SERIES_TYPE_OPTIONS[variant][0][0]
: 'line')
}
onChange={value => onChange('seriesType', value)}
style={{ width: '100%' }}
options={SERIES_TYPE_OPTIONS[variant].map(
([value, label]: [string, string]) => ({
value,
label,
}),
)}
/>
<small className="text-muted">
{t('Series chart type (line, smooth, step, etc)')}
</small>
</Col>
</Row>
)}
{/* Stack Options */}
{showStack && (
<Row gutter={[16, 8]} style={{ marginBottom: 24 }}>
<Col span={24}>
<label>{t('Stacking')}</label>
<Select
value={values.stack || null}
onChange={value => onChange('stack', value)}
style={{ width: '100%' }}
allowClear
placeholder={t('No stacking')}
options={STACK_OPTIONS.map(([value, label]) => ({
value,
label,
}))}
/>
<small className="text-muted">
{t('Stack series on top of each other')}
</small>
</Col>
</Row>
)}
{/* Bar Orientation */}
{showOrientation && hasBarOptions && (
<Row gutter={[16, 8]} style={{ marginBottom: 24 }}>
<Col span={24}>
<label>{t('Bar Orientation')}</label>
<Radio.Group
value={values.orientation || 'vertical'}
onChange={e => onChange('orientation', e.target.value)}
>
<Radio value="vertical">{t('Vertical')}</Radio>
<Radio value="horizontal">{t('Horizontal')}</Radio>
</Radio.Group>
<small
className="text-muted"
style={{ display: 'block', marginTop: 8 }}
>
{t('Orientation of bar chart')}
</small>
</Col>
</Row>
)}
{/* Area Chart Options */}
{hasAreaOptions && (
<div style={{ marginBottom: 24 }}>
<h4>{t('Area Chart')}</h4>
<OpacityControl
name="opacity"
label={t('Area opacity')}
description={t(
'Opacity of area under the line. Set to 0 to disable area.',
)}
value={values.opacity || (variant === 'area' ? 0.2 : 0)}
onChange={value => onChange('opacity', value)}
/>
</div>
)}
{/* Line/Marker Options */}
{showMarkers && (hasLineOptions || variant === 'area') && (
<div style={{ marginBottom: 24 }}>
<h4>{t('Markers')}</h4>
<MarkerControlGroup
values={{
markerEnabled: values.markerEnabled || false,
markerSize: values.markerSize || 6,
}}
onChange={onChange}
/>
</div>
)}
{/* X Axis Controls */}
<div style={{ marginBottom: 24 }}>
<h4>{t('X Axis')}</h4>
<AxisControlSection
axis="x"
showTitle
showFormat
showRotation
showBounds={hasBarOptions}
showTruncate
timeFormat
values={values}
onChange={onChange}
/>
</div>
{/* Y Axis Controls */}
<div style={{ marginBottom: 24 }}>
<h4>{t('Y Axis')}</h4>
<AxisControlSection
axis="y"
showTitle
showFormat
showBounds
showLogarithmic
showMinorTicks
showTruncate
values={values}
onChange={onChange}
/>
</div>
{/* Value Formats */}
<div style={{ marginBottom: 24 }}>
<h4>{t('Value Formats')}</h4>
<FormatControlGroup
showNumber
showCurrency={hasBarOptions}
showDate
showPercentage={showStack}
values={values}
onChange={onChange}
/>
</div>
</div>
);
};
export default TimeseriesControlPanel;

View File

@@ -16,14 +16,42 @@
* specific language governing permissions and limitations
* under the License.
*/
import RadioButtonControl from './RadioButtonControl';
export * from './RadioButtonControl';
export { default as RadioButtonControl } from './RadioButtonControl';
export { default as GranularityControl } from './GranularityControl';
export * from './ReactControlPanel';
export { default as AxisControlSection } from './AxisControlSection';
export { default as FormatControlGroup } from './FormatControlGroup';
export { default as OpacityControl } from './OpacityControl';
export { default as MarkerControlGroup } from './MarkerControlGroup';
export { default as TimeseriesControlPanel } from './TimeseriesControlPanel';
export { default as LabelControlGroup } from './LabelControlGroup';
export { default as PieShapeControl } from './PieShapeControl';
export { default as TableControlsSection } from './TableControlsSection';
export { default as FilterControlsSection } from './FilterControlsSection';
export { default as DeckGLControlsSection } from './DeckGLControlsSection';
// Export ControlComponents with specific names
// ColorPickerControl from ControlComponents takes props, renamed to avoid conflict
export {
CheckboxControl,
NumberControl,
SelectControl,
SliderControl,
SwitchControl,
TextAreaControl,
TextControl,
ColorPickerControl as ColorPickerControlWithProps,
type ControlComponentConfig,
} from './ControlComponents';
/**
* Shared chart controls. Can be referred via string shortcuts in chart control
* configs.
*/
export default {
RadioButtonControl,
};
// Export all SharedControlComponents which replace string references
// ColorPickerControl from here does NOT take props - it's for the shared 'color_picker' control
export * from './SharedControlComponents';
// Export React control panel
export { ReactControlPanel } from './ReactControlPanel';
// Export control panel layout components
export * from './ControlPanelLayout';
// Inline control functions are exported from SharedControlComponents

View File

@@ -17,8 +17,8 @@
* under the License.
*/
export { default as sharedControls } from './sharedControls';
// React control components
export { default as sharedControlComponents } from './components';
// sharedControlComponents is deprecated - import components directly instead
// export { default as sharedControlComponents } from './components';
export { aggregationControl } from './customControls';
export * from './components';
export * from './customControls';

View File

@@ -32,7 +32,7 @@ import type {
QueryFormMetric,
QueryResponse,
} from '@superset-ui/core';
import { sharedControls, sharedControlComponents } from './shared-controls';
import { sharedControls } from './shared-controls';
export type { Metric } from '@superset-ui/core';
export type { ControlComponentProps } from './shared-controls/components/types';
@@ -45,8 +45,6 @@ interface Action {
interface AnyAction extends Action, AnyDict {}
export type SharedControls = typeof sharedControls;
export type SharedControlAlias = keyof typeof sharedControls;
export type SharedControlComponents = typeof sharedControlComponents;
/** ----------------------------------------------
* Input data/props while rendering
@@ -185,7 +183,7 @@ export type InternalControlType =
| 'Select'
| 'Slider'
| 'Input'
| keyof SharedControlComponents; // expanded in `expandControlConfig`
| 'RadioButtonControl';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type ControlType = InternalControlType | ComponentType<any>;
@@ -359,7 +357,7 @@ export type SharedSectionAlias =
| 'NVD3TimeSeries';
export interface OverrideSharedControlItem<
A extends SharedControlAlias = SharedControlAlias,
A extends keyof SharedControls = keyof SharedControls,
> {
name: A;
override: Partial<SharedControls[A]>;
@@ -382,16 +380,16 @@ export const isCustomControlItem = (obj: unknown): obj is CustomControlItem =>
// interfere with other ControlSetItem types
export type ExpandedControlItem = CustomControlItem | ReactElement | null;
export type ControlSetItem =
| SharedControlAlias
| OverrideSharedControlItem
| ExpandedControlItem;
// All controls must be React components or control configuration objects
export type ControlSetItem = OverrideSharedControlItem | ExpandedControlItem;
export type ControlSetRow = ControlSetItem[];
// Ref:
// - superset-frontend/src/explore/components/ControlPanelsContainer.jsx
// - superset-frontend/src/explore/components/ControlPanelSection.jsx
// DEPRECATED: Legacy control panel types - use JsonFormsControlPanelConfig instead
// These are kept temporarily for backward compatibility during migration
export interface ControlPanelSectionConfig {
label?: ReactNode;
description?: ReactNode;
@@ -428,6 +426,7 @@ export const isStandardizedFormData = (
Array.isArray(formData.standardizedFormData.controls.metrics) &&
Array.isArray(formData.standardizedFormData.controls.columns);
// DEPRECATED: Use JsonFormsControlPanelConfig from './types/jsonForms' instead
export interface ControlPanelConfig {
controlPanelSections: (ControlPanelSectionConfig | null)[];
controlOverrides?: ControlOverrides;
@@ -437,7 +436,7 @@ export interface ControlPanelConfig {
}
export type ControlOverrides = {
[P in SharedControlAlias]?: Partial<SharedControls[P]>;
[P in keyof SharedControls]?: Partial<SharedControls[P]>;
};
export type SectionOverrides = {

View File

@@ -0,0 +1,20 @@
/**
* 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.
*/
// Type exports placeholder

View File

@@ -17,28 +17,15 @@
* under the License.
*/
import { isValidElement, ReactElement } from 'react';
import { sharedControls, sharedControlComponents } from '../shared-controls';
import { sharedControls } from '../shared-controls';
import {
ControlType,
ControlSetItem,
ExpandedControlItem,
ControlOverrides,
} from '../types';
export function expandControlType(controlType: ControlType) {
if (
typeof controlType === 'string' &&
controlType in sharedControlComponents
) {
return sharedControlComponents[
controlType as keyof typeof sharedControlComponents
];
}
return controlType;
}
/**
* Expand a shorthand control config item to full config in the format of
* Expand a control config item to full config in the format of
* {
* name: ...,
* config: {
@@ -46,26 +33,31 @@ export function expandControlType(controlType: ControlType) {
* ...
* }
* }
*
* Note: String references to shared controls are no longer supported.
* All controls must be React components or control configuration objects.
*/
export function expandControlConfig(
control: ControlSetItem,
controlOverrides: ControlOverrides = {},
): ExpandedControlItem {
// one of the named shared controls
if (typeof control === 'string' && control in sharedControls) {
const name = control;
return {
name,
config: {
...sharedControls[name],
...controlOverrides[name],
},
};
}
// JSX/React element or NULL
if (!control || typeof control === 'string' || isValidElement(control)) {
if (!control || isValidElement(control)) {
return control as ReactElement;
}
// Check if it's a modern panel component (function with isModernPanel flag)
if (typeof control === 'function' && (control as any).isModernPanel) {
console.log('expandControlConfig - Found modern panel, returning as-is');
return control as any;
}
// String controls are no longer supported - they must be migrated to React components
if (typeof control === 'string') {
throw new Error(
`String control reference "${control}" is not supported. ` +
`Use the corresponding React component from @superset-ui/chart-controls instead. ` +
`For example, replace ['metrics'] with [MetricsControl()].`,
);
}
// already fully expanded control config, e.g.
// {
// name: 'metric',
@@ -74,13 +66,7 @@ export function expandControlConfig(
// }
// }
if ('name' in control && 'config' in control) {
return {
...control,
config: {
...control.config,
type: expandControlType(control.config.type as ControlType),
},
};
return control;
}
// apply overrides with shared controls
if ('override' in control && control.name in sharedControls) {

View File

@@ -29,4 +29,3 @@ export * from './getStandardizedControls';
export * from './getTemporalColumns';
export * from './displayTimeRelatedControls';
export * from './colorControls';
export * from './metricColumnFilter';

View File

@@ -1,135 +0,0 @@
/**
* 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 { QueryFormMetric, SqlaFormData } from '@superset-ui/core';
import {
shouldSkipMetricColumn,
isRegularMetric,
isPercentMetric,
} from './metricColumnFilter';
const createMetric = (label: string): QueryFormMetric =>
({
label,
expressionType: 'SIMPLE',
column: { column_name: label },
aggregate: 'SUM',
}) as QueryFormMetric;
describe('metricColumnFilter', () => {
const createFormData = (
metrics: string[],
percentMetrics: string[],
): SqlaFormData =>
({
datasource: 'test_datasource',
viz_type: 'table',
metrics: metrics.map(createMetric),
percent_metrics: percentMetrics.map(createMetric),
}) as SqlaFormData;
describe('shouldSkipMetricColumn', () => {
it('should skip unprefixed percent metric columns if prefixed version exists', () => {
const colnames = ['metric1', '%metric1'];
const formData = createFormData([], ['metric1']);
const result = shouldSkipMetricColumn({
colname: 'metric1',
colnames,
formData,
});
expect(result).toBe(true);
});
it('should not skip if column is also a regular metric', () => {
const colnames = ['metric1', '%metric1'];
const formData = createFormData(['metric1'], ['metric1']);
const result = shouldSkipMetricColumn({
colname: 'metric1',
colnames,
formData,
});
expect(result).toBe(false);
});
it('should not skip if column starts with %', () => {
const colnames = ['%metric1'];
const formData = createFormData(['metric1'], []);
const result = shouldSkipMetricColumn({
colname: '%metric1',
colnames,
formData,
});
expect(result).toBe(false);
});
it('should not skip if no prefixed version exists', () => {
const colnames = ['metric1'];
const formData = createFormData([], ['metric1']);
const result = shouldSkipMetricColumn({
colname: 'metric1',
colnames,
formData,
});
expect(result).toBe(false);
});
});
describe('isRegularMetric', () => {
it('should return true for regular metrics', () => {
const formData = createFormData(['metric1', 'metric2'], []);
expect(isRegularMetric('metric1', formData)).toBe(true);
expect(isRegularMetric('metric2', formData)).toBe(true);
});
it('should return false for non-metrics', () => {
const formData = createFormData(['metric1'], []);
expect(isRegularMetric('non_metric', formData)).toBe(false);
});
it('should return false for percentage metrics', () => {
const formData = createFormData([], ['percent_metric1']);
expect(isRegularMetric('percent_metric1', formData)).toBe(false);
});
});
describe('isPercentMetric', () => {
it('should return true for percentage metrics', () => {
const formData = createFormData([], ['percent_metric1']);
expect(isPercentMetric('%percent_metric1', formData)).toBe(true);
});
it('should return false for non-percentage metrics', () => {
const formData = createFormData(['regular_metric'], []);
expect(isPercentMetric('regular_metric', formData)).toBe(false);
});
it('should return false for regular metrics', () => {
const formData = createFormData(['metric1'], []);
expect(isPercentMetric('metric1', formData)).toBe(false);
});
});
});

View File

@@ -1,95 +0,0 @@
/**
* 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 {
QueryFormMetric,
getMetricLabel,
SqlaFormData,
} from '@superset-ui/core';
export interface MetricColumnFilterParams {
colname: string;
colnames: string[];
formData: SqlaFormData;
}
/**
* Determines if a column should be skipped based on metric filtering logic.
*
* This function implements the logic to skip unprefixed percent metric columns
* if a prefixed version exists, but doesn't skip if it's also a regular metric.
*
* @param params - The parameters for metric column filtering
* @returns true if the column should be skipped, false otherwise
*/
export function shouldSkipMetricColumn({
colname,
colnames,
formData,
}: MetricColumnFilterParams): boolean {
if (!colname) {
return false;
}
// Check if this column name exists as a percent metric in form data
const isPercentMetric = formData.percent_metrics?.some(
(metric: QueryFormMetric) => getMetricLabel(metric) === colname,
);
// Check if this column name exists as a regular metric in form data
const isRegularMetric = formData.metrics?.some(
(metric: QueryFormMetric) => getMetricLabel(metric) === colname,
);
// Check if there's a prefixed version of this column in the column list
const hasPrefixedVersion = colnames.includes(`%${colname}`);
// Skip if: has prefixed version AND is percent metric AND is NOT regular metric
return hasPrefixedVersion && isPercentMetric && !isRegularMetric;
}
/**
* Determines if a column is a regular metric.
*
* @param colname - The column name to check
* @param formData - The form data containing metrics
* @returns true if the column is a regular metric, false otherwise
*/
export function isRegularMetric(
colname: string,
formData: SqlaFormData,
): boolean {
return !!formData.metrics?.some(metric => getMetricLabel(metric) === colname);
}
/**
* Determines if a column is a percentage metric.
*
* @param colname: string,
* @param formData - The form data containing percent_metrics
* @returns true if the column is a percentage metric, false otherwise
*/
export function isPercentMetric(
colname: string,
formData: SqlaFormData,
): boolean {
return !!formData.percent_metrics?.some(
(metric: QueryFormMetric) => `%${getMetricLabel(metric)}` === colname,
);
}

View File

@@ -65,20 +65,6 @@ test('should skip renameOperator if series does not exist', () => {
).toEqual(undefined);
});
test('should skip renameOperator if series does not exist and a single time shift exists', () => {
expect(
renameOperator(
{ ...formData, ...{ time_compare: ['1 year ago'] } },
{
...queryObject,
...{
columns: [],
},
},
),
).toEqual(undefined);
});
test('should skip renameOperator if does not exist x_axis and is_timeseries', () => {
expect(
renameOperator(
@@ -107,26 +93,6 @@ test('should add renameOperator', () => {
});
});
test('should add renameOperator if a metric exists and multiple time shift', () => {
expect(
renameOperator(
{
...formData,
...{ time_compare: ['1 year ago', '2 years ago'] },
},
{
...queryObject,
...{
columns: [],
},
},
),
).toEqual({
operation: 'rename',
options: { columns: { 'count(*)': null }, inplace: true, level: 0 },
});
});
test('should add renameOperator if exists derived metrics', () => {
[
ComparisonType.Difference,
@@ -210,6 +176,7 @@ test('should add renameOperator if exist "actual value" time comparison', () =>
operation: 'rename',
options: {
columns: {
'count(*)': null,
'count(*)__1 year ago': '1 year ago',
'count(*)__1 year later': '1 year later',
},

View File

@@ -0,0 +1,330 @@
/**
* 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 {
MetricsControl,
MetricControl,
GroupByControl,
ColumnsControl,
AdhocFiltersControl,
LimitControl,
RowLimitControl,
OrderByControl,
OrderDescControl,
SeriesControl,
EntityControl,
XControl,
YControl,
SizeControl,
ColorSchemeControl,
LinearColorSchemeControl,
ColorPickerControl,
TimeRangeControl,
GranularitySqlaControl,
TimeGrainSqlaControl,
DatasourceControl,
VizTypeControl,
XAxisControl,
YAxisFormatControl,
XAxisTimeFormatControl,
ZoomableControl,
SortByMetricControl,
CurrencyFormatControl,
TooltipColumnsControl,
TooltipMetricsControl,
sharedControls,
} from '../../src';
describe('SharedControlComponents', () => {
describe('React Component Controls', () => {
it('should return proper control items for metrics controls', () => {
const metricsControl = MetricsControl();
expect(metricsControl).toEqual({
name: 'metrics',
config: sharedControls.metrics,
});
const metricControl = MetricControl();
expect(metricControl).toEqual({
name: 'metric',
config: sharedControls.metric,
});
});
it('should return proper control items for dimension controls', () => {
const groupByControl = GroupByControl();
expect(groupByControl).toEqual({
name: 'groupby',
config: sharedControls.groupby,
});
const columnsControl = ColumnsControl();
expect(columnsControl).toEqual({
name: 'columns',
config: sharedControls.columns,
});
const seriesControl = SeriesControl();
expect(seriesControl).toEqual({
name: 'series',
config: sharedControls.series,
});
const entityControl = EntityControl();
expect(entityControl).toEqual({
name: 'entity',
config: sharedControls.entity,
});
});
it('should return proper control items for filter controls', () => {
const adhocFiltersControl = AdhocFiltersControl();
expect(adhocFiltersControl).toEqual({
name: 'adhoc_filters',
config: sharedControls.adhoc_filters,
});
});
it('should return proper control items for limit controls', () => {
const limitControl = LimitControl();
expect(limitControl).toEqual({
name: 'limit',
config: sharedControls.limit,
});
const rowLimitControl = RowLimitControl();
expect(rowLimitControl).toEqual({
name: 'row_limit',
config: sharedControls.row_limit,
});
});
it('should return proper control items for sort controls', () => {
const orderByControl = OrderByControl();
expect(orderByControl).toEqual({
name: 'orderby',
config: sharedControls.orderby,
});
const orderDescControl = OrderDescControl();
expect(orderDescControl).toEqual({
name: 'order_desc',
config: sharedControls.order_desc,
});
const sortByMetricControl = SortByMetricControl();
expect(sortByMetricControl).toEqual({
name: 'sort_by_metric',
config: sharedControls.sort_by_metric,
});
});
it('should return proper control items for axis controls', () => {
const xControl = XControl();
expect(xControl).toEqual({
name: 'x',
config: sharedControls.x,
});
const yControl = YControl();
expect(yControl).toEqual({
name: 'y',
config: sharedControls.y,
});
const xAxisControl = XAxisControl();
expect(xAxisControl).toEqual({
name: 'x_axis',
config: sharedControls.x_axis,
});
// Note: YAxisControl doesn't exist, YControl is reused for y axis
const yControl2 = YControl();
expect(yControl2).toEqual({
name: 'y',
config: sharedControls.y,
});
});
it('should return proper control items for formatting controls', () => {
const yAxisFormatControl = YAxisFormatControl();
expect(yAxisFormatControl).toEqual({
name: 'y_axis_format',
config: sharedControls.y_axis_format,
});
const xAxisTimeFormatControl = XAxisTimeFormatControl();
expect(xAxisTimeFormatControl).toEqual({
name: 'x_axis_time_format',
config: sharedControls.x_axis_time_format,
});
const currencyFormatControl = CurrencyFormatControl();
expect(currencyFormatControl).toEqual({
name: 'currency_format',
config: sharedControls.currency_format,
});
});
it('should return proper control items for color controls', () => {
const colorSchemeControl = ColorSchemeControl();
expect(colorSchemeControl).toEqual({
name: 'color_scheme',
config: sharedControls.color_scheme,
});
const linearColorSchemeControl = LinearColorSchemeControl();
expect(linearColorSchemeControl).toEqual({
name: 'linear_color_scheme',
config: sharedControls.linear_color_scheme,
});
const colorPickerControl = ColorPickerControl();
expect(colorPickerControl).toEqual({
name: 'color_picker',
config: sharedControls.color_picker,
});
});
it('should return proper control items for time controls', () => {
const timeRangeControl = TimeRangeControl();
expect(timeRangeControl).toEqual({
name: 'time_range',
config: sharedControls.time_range,
});
const granularitySqlaControl = GranularitySqlaControl();
expect(granularitySqlaControl).toEqual({
name: 'granularity_sqla',
config: sharedControls.granularity_sqla,
});
const timeGrainSqlaControl = TimeGrainSqlaControl();
expect(timeGrainSqlaControl).toEqual({
name: 'time_grain_sqla',
config: sharedControls.time_grain_sqla,
});
});
it('should return proper control items for datasource controls', () => {
const datasourceControl = DatasourceControl();
expect(datasourceControl).toEqual({
name: 'datasource',
config: sharedControls.datasource,
});
const vizTypeControl = VizTypeControl();
expect(vizTypeControl).toEqual({
name: 'viz_type',
config: sharedControls.viz_type,
});
});
it('should return proper control items for tooltip controls', () => {
const tooltipColumnsControl = TooltipColumnsControl();
expect(tooltipColumnsControl).toEqual({
name: 'tooltip_columns',
config: sharedControls.tooltip_columns,
});
const tooltipMetricsControl = TooltipMetricsControl();
expect(tooltipMetricsControl).toEqual({
name: 'tooltip_metrics',
config: sharedControls.tooltip_metrics,
});
});
it('should return proper control items for other controls', () => {
const sizeControl = SizeControl();
expect(sizeControl).toEqual({
name: 'size',
config: sharedControls.size,
});
const zoomableControl = ZoomableControl();
expect(zoomableControl).toEqual({
name: 'zoomable',
config: sharedControls.zoomable,
});
});
});
describe('Control compatibility', () => {
it('should be usable in control panel configurations', () => {
// Simulate a control panel configuration
const controlPanel = {
controlPanelSections: [
{
label: 'Query',
expanded: true,
controlSetRows: [
[MetricsControl()],
[GroupByControl()],
[AdhocFiltersControl()],
[LimitControl(), OrderDescControl()],
[RowLimitControl()],
],
},
{
label: 'Chart Options',
expanded: true,
controlSetRows: [[ColorSchemeControl()], [YAxisFormatControl()]],
},
],
};
// Verify structure
expect(controlPanel.controlPanelSections).toHaveLength(2);
// Verify first section
const querySection = controlPanel.controlPanelSections[0];
expect(querySection.controlSetRows[0][0]).toHaveProperty(
'name',
'metrics',
);
expect(querySection.controlSetRows[1][0]).toHaveProperty(
'name',
'groupby',
);
expect(querySection.controlSetRows[2][0]).toHaveProperty(
'name',
'adhoc_filters',
);
expect(querySection.controlSetRows[3][0]).toHaveProperty('name', 'limit');
expect(querySection.controlSetRows[3][1]).toHaveProperty(
'name',
'order_desc',
);
expect(querySection.controlSetRows[4][0]).toHaveProperty(
'name',
'row_limit',
);
// Verify second section
const optionsSection = controlPanel.controlPanelSections[1];
expect(optionsSection.controlSetRows[0][0]).toHaveProperty(
'name',
'color_scheme',
);
expect(optionsSection.controlSetRows[1][0]).toHaveProperty(
'name',
'y_axis_format',
);
});
});
});

View File

@@ -20,15 +20,19 @@ import {
expandControlConfig,
sharedControls,
CustomControlItem,
sharedControlComponents,
} from '../../src';
describe('expandControlConfig()', () => {
it('expands shared control alias', () => {
expect(expandControlConfig('metrics')).toEqual({
name: 'metrics',
config: sharedControls.metrics,
});
it('throws error when string control is passed', () => {
expect(() => expandControlConfig('metrics' as any)).toThrow(
'String control reference "metrics" is not supported',
);
expect(() => expandControlConfig('groupby' as any)).toThrow(
'String control reference "groupby" is not supported',
);
expect(() => expandControlConfig('columns' as any)).toThrow(
'String control reference "columns" is not supported',
);
});
it('expands control with overrides', () => {
@@ -69,7 +73,7 @@ describe('expandControlConfig()', () => {
};
expect(
(expandControlConfig(input) as CustomControlItem).config.type,
).toEqual(sharedControlComponents.RadioButtonControl);
).toEqual('RadioButtonControl');
});
it('leave NULL and ReactElement untouched', () => {
@@ -78,11 +82,6 @@ describe('expandControlConfig()', () => {
expect(expandControlConfig(input)).toBe(input);
});
it('leave unknown text untouched', () => {
const input = 'superset-ui';
expect(expandControlConfig(input as never)).toBe(input);
});
it('return null for invalid configs', () => {
expect(
expandControlConfig({ type: 'SelectControl', label: 'Hello' } as never),

View File

@@ -25,13 +25,11 @@
],
"dependencies": {
"@ant-design/icons": "^5.2.6",
"@babel/runtime": "^7.28.2",
"@babel/runtime": "^7.25.6",
"@fontsource/fira-code": "^5.2.6",
"@fontsource/inter": "^5.2.6",
"@types/json-bigint": "^1.0.4",
"ace-builds": "^1.43.1",
"ag-grid-community": "^34.0.2",
"ag-grid-react": "34.0.2",
"brace": "^0.11.1",
"classnames": "^2.2.5",
"csstype": "^3.1.3",
@@ -48,10 +46,10 @@
"lodash": "^4.17.21",
"math-expression-evaluator": "^2.0.6",
"pretty-ms": "^9.2.0",
"re-resizable": "^6.11.2",
"re-resizable": "^6.10.1",
"react-ace": "^10.1.0",
"react-js-cron": "^5.2.0",
"react-draggable": "^4.5.0",
"react-draggable": "^4.4.6",
"react-resize-detector": "^7.1.2",
"react-syntax-highlighter": "^15.4.5",
"react-ultimate-pagination": "^1.3.2",
@@ -80,7 +78,7 @@
"@types/lodash": "^4.17.20",
"@types/math-expression-evaluator": "^1.3.3",
"@types/node": "^22.10.3",
"@types/prop-types": "^15.7.15",
"@types/prop-types": "^15.7.2",
"@types/rison": "0.1.0",
"@types/seedrandom": "^3.0.8",
"fetch-mock": "^11.1.4",

View File

@@ -24,7 +24,6 @@ export const Badge = styled((props: BadgeProps) => <AntdBadge {...props} />)`
${({ theme, color, count }) => `
& > sup,
& > sup.ant-badge-count {
box-shadow: none;
${
count !== undefined ? `background: ${color || theme.colorPrimary};` : ''
}

View File

@@ -132,12 +132,11 @@ export function Button(props: ButtonProps) {
'& > span > :first-of-type': {
marginRight: firstChildMargin,
},
':not(:hover)': effectiveButtonStyle === 'secondary' &&
!disabled && {
// NOTE: This is the best we can do contrast wise for the secondary button using antd tokens
// and abusing the semantics. Should be revisited when possible. https://github.com/apache/superset/pull/34253#issuecomment-3104834692
color: `${theme.colorPrimaryTextHover} !important`,
},
':not(:hover)': effectiveButtonStyle === 'secondary' && {
// NOTE: This is the best we can do contrast wise for the secondary button using antd tokens
// and abusing the semantics. Should be revisited when possible. https://github.com/apache/superset/pull/34253#issuecomment-3104834692
color: `${theme.colorPrimaryTextHover} !important`,
},
}}
icon={icon}
{...restProps}

View File

@@ -1,395 +0,0 @@
/**
* 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 {
cloneElement,
forwardRef,
RefObject,
useEffect,
useImperativeHandle,
useLayoutEffect,
useMemo,
useState,
useRef,
useCallback,
} from 'react';
import { Global } from '@emotion/react';
import { css, t, useTheme, usePrevious } from '@superset-ui/core';
import { useResizeDetector } from 'react-resize-detector';
import { Badge, Icons, Button, Tooltip, Popover } from '..';
import { DropdownContainerProps, DropdownItem, DropdownRef } from './types';
const MAX_HEIGHT = 500;
export const DropdownContainer = forwardRef(
(
{
items,
onOverflowingStateChange,
dropdownContent,
dropdownRef,
dropdownStyle = {},
dropdownTriggerCount,
dropdownTriggerIcon,
dropdownTriggerText = t('More'),
dropdownTriggerTooltip = null,
forceRender,
style,
}: DropdownContainerProps,
outerRef: RefObject<DropdownRef>,
) => {
const theme = useTheme();
const { ref, width = 0 } = useResizeDetector<HTMLDivElement>();
const previousWidth = usePrevious(width) || 0;
const { current } = ref;
const [itemsWidth, setItemsWidth] = useState<number[]>([]);
const [popoverVisible, setPopoverVisible] = useState(false);
// We use React.useState to be able to mock the state in Jest
const [overflowingIndex, setOverflowingIndex] = useState<number>(-1);
let targetRef = useRef<HTMLDivElement>(null);
if (dropdownRef) {
targetRef = dropdownRef;
}
const [showOverflow, setShowOverflow] = useState(false);
// callback to update item widths so that the useLayoutEffect runs whenever
// width of any of the child changes
const recalculateItemWidths = useCallback(() => {
const mainItemsContainerNode = current?.children.item(0);
if (mainItemsContainerNode) {
const visibleChildrenElements = Array.from(
mainItemsContainerNode.children,
);
setItemsWidth(prevGlobalWidths => {
if (prevGlobalWidths.length !== items.length) {
return prevGlobalWidths;
}
const newGlobalWidths = [...prevGlobalWidths];
let changed = false;
visibleChildrenElements.forEach((child, indexInVisible) => {
const originalItemIndex = indexInVisible;
if (originalItemIndex < newGlobalWidths.length) {
const newWidth = child.getBoundingClientRect().width;
if (newGlobalWidths[originalItemIndex] !== newWidth) {
newGlobalWidths[originalItemIndex] = newWidth;
changed = true;
}
}
});
return changed ? newGlobalWidths : prevGlobalWidths;
});
}
}, [current?.children, items.length]);
const reduceItems = (items: DropdownItem[]): [DropdownItem[], string[]] =>
items.reduce(
([items, ids], item) => {
items.push({
id: item.id,
element: cloneElement(item.element, { key: item.id }),
});
ids.push(item.id);
return [items, ids];
},
[[], []] as [DropdownItem[], string[]],
);
const [notOverflowedItems, notOverflowedIds] = useMemo(
() =>
reduceItems(
items.slice(
0,
overflowingIndex !== -1 ? overflowingIndex : items.length,
),
),
[items, overflowingIndex],
);
const [overflowedItems, overflowedIds] = useMemo(
() =>
overflowingIndex !== -1
? reduceItems(items.slice(overflowingIndex))
: [[], []],
[items, overflowingIndex],
);
useEffect(() => {
const container = current?.children.item(0);
if (!container) return;
const childrenArray = Array.from(container.children);
const resizeObserver = new ResizeObserver(() => {
recalculateItemWidths();
});
childrenArray.map(child => resizeObserver.observe(child));
// eslint-disable-next-line consistent-return
return () => {
childrenArray.map(child => resizeObserver.unobserve(child));
resizeObserver.disconnect();
};
}, [items.length, current, recalculateItemWidths]);
useLayoutEffect(() => {
if (popoverVisible) {
return;
}
const container = current?.children.item(0);
if (container) {
const { children } = container;
const childrenArray = Array.from(children);
// If items length change, add all items to the container
// and recalculate the widths
if (itemsWidth.length !== items.length) {
if (childrenArray.length === items.length) {
setItemsWidth(
childrenArray.map(child => child.getBoundingClientRect().width),
);
} else {
setOverflowingIndex(-1);
return;
}
}
// Calculates the index of the first overflowed element
// +1 is to give at least one pixel of difference and avoid flakiness
const index = childrenArray.findIndex(
child =>
child.getBoundingClientRect().right >
container.getBoundingClientRect().right + 1,
);
// If elements fit (-1) and there's overflowed items
// then preserve the overflow index. We can't use overflowIndex
// directly because the items may have been modified
let newOverflowingIndex =
index === -1 && overflowedItems.length > 0
? items.length - overflowedItems.length
: index;
if (width > previousWidth) {
// Calculates remaining space in the container
const button = current?.children.item(1);
const buttonRight = button?.getBoundingClientRect().right || 0;
const containerRight = current?.getBoundingClientRect().right || 0;
const remainingSpace = containerRight - buttonRight;
// Checks if some elements in the dropdown fits in the remaining space
let sum = 0;
for (let i = childrenArray.length; i < items.length; i += 1) {
sum += itemsWidth[i];
if (sum <= remainingSpace) {
newOverflowingIndex = i + 1;
} else {
break;
}
}
}
setOverflowingIndex(newOverflowingIndex);
}
}, [
current,
items.length,
itemsWidth,
overflowedItems.length,
previousWidth,
width,
popoverVisible,
]);
useEffect(() => {
if (onOverflowingStateChange) {
onOverflowingStateChange({
notOverflowed: notOverflowedIds,
overflowed: overflowedIds,
});
}
}, [notOverflowedIds, onOverflowingStateChange, overflowedIds]);
const overflowingCount =
overflowingIndex !== -1 ? items.length - overflowingIndex : 0;
const popoverContent = useMemo(
() =>
dropdownContent || overflowingCount ? (
<div
css={css`
display: flex;
flex-direction: column;
gap: ${theme.sizeUnit * 4}px;
`}
data-test="dropdown-content"
style={dropdownStyle}
ref={targetRef}
>
{dropdownContent
? dropdownContent(overflowedItems)
: overflowedItems.map(item => item.element)}
</div>
) : null,
[
dropdownContent,
overflowingCount,
theme.sizeUnit,
dropdownStyle,
overflowedItems,
],
);
useLayoutEffect(() => {
if (popoverVisible) {
// Measures scroll height after rendering the elements
setTimeout(() => {
if (targetRef.current) {
// We only set overflow when there's enough space to display
// Select's popovers because they are restrained by the overflow property.
setShowOverflow(targetRef.current.scrollHeight > MAX_HEIGHT);
}
}, 100);
}
}, [popoverVisible]);
useImperativeHandle(
outerRef,
() => ({
...(ref.current as HTMLDivElement),
open: () => setPopoverVisible(true),
}),
[ref],
);
// Closes the popover when scrolling on the document
useEffect(() => {
document.onscroll = popoverVisible
? () => setPopoverVisible(false)
: null;
return () => {
document.onscroll = null;
};
}, [popoverVisible]);
return (
<div
ref={ref}
css={css`
display: flex;
align-items: center;
`}
>
<div
css={css`
display: flex;
align-items: center;
gap: ${theme.sizeUnit * 4}px;
margin-right: ${theme.sizeUnit * 4}px;
min-width: 0px;
`}
data-test="container"
style={style}
>
{notOverflowedItems.map(item => item.element)}
</div>
{popoverContent && (
<>
<Global
styles={css`
.ant-popover-inner {
// Some OS versions only show the scroll when hovering.
// These settings will make the scroll always visible.
::-webkit-scrollbar {
-webkit-appearance: none;
width: 14px;
}
::-webkit-scrollbar-thumb {
border-radius: 9px;
background-color: ${theme.colors.grayscale.light1};
border: 3px solid transparent;
background-clip: content-box;
}
::-webkit-scrollbar-track {
background-color: ${theme.colors.grayscale.light4};
border-left: 1px solid ${theme.colors.grayscale.light2};
}
}
`}
/>
<Popover
styles={{
body: {
maxHeight: `${MAX_HEIGHT}px`,
overflow: showOverflow ? 'auto' : 'visible',
},
}}
content={popoverContent}
trigger="click"
open={popoverVisible}
onOpenChange={visible => setPopoverVisible(visible)}
placement="bottom"
forceRender={forceRender}
>
<Tooltip title={dropdownTriggerTooltip}>
<Button
buttonStyle="secondary"
data-test="dropdown-container-btn"
icon={dropdownTriggerIcon}
css={css`
padding-left: ${theme.paddingXS}px;
padding-right: ${theme.paddingXXS}px;
gap: ${theme.sizeXXS}px;
`}
>
{dropdownTriggerText}
<Badge
count={dropdownTriggerCount ?? overflowingCount}
color={
(dropdownTriggerCount ?? overflowingCount) > 0
? theme.colorPrimary
: theme.colors.grayscale.light1
}
showZero
css={css`
margin-left: ${theme.sizeUnit * 2}px;
`}
/>
<Icons.DownOutlined
iconSize="m"
iconColor={theme.colors.grayscale.light1}
css={css`
.anticon {
display: flex;
}
`}
/>
</Button>
</Tooltip>
</Popover>
</>
)}
</div>
);
},
);

View File

@@ -16,6 +16,448 @@
* specific language governing permissions and limitations
* under the License.
*/
import {
CSSProperties,
cloneElement,
forwardRef,
ReactElement,
RefObject,
useEffect,
useImperativeHandle,
useLayoutEffect,
useMemo,
useState,
useRef,
ReactNode,
useCallback,
} from 'react';
export { DropdownContainer } from './DropdownContainer';
export type * from './types';
import { Global } from '@emotion/react';
import { css, t, useTheme, usePrevious } from '@superset-ui/core';
import { useResizeDetector } from 'react-resize-detector';
import { Badge, Icons, Button, Tooltip, Popover } from '..';
/**
* Container item.
*/
export interface DropdownItem {
/**
* String that uniquely identifies the item.
*/
id: string;
/**
* The element to be rendered.
*/
element: ReactElement;
}
/**
* Horizontal container that displays overflowed items in a dropdown.
* It shows an indicator of how many items are currently overflowing.
*/
export interface DropdownContainerProps {
/**
* Array of items. The id property is used to uniquely identify
* the elements when rendering or dealing with event handlers.
*/
items: DropdownItem[];
/**
* Event handler called every time an element moves between
* main container and dropdown.
*/
onOverflowingStateChange?: (overflowingState: {
notOverflowed: string[];
overflowed: string[];
}) => void;
/**
* Option to customize the content of the dropdown.
*/
dropdownContent?: (overflowedItems: DropdownItem[]) => ReactElement;
/**
* Dropdown ref.
*/
dropdownRef?: RefObject<HTMLDivElement>;
/**
* Dropdown additional style properties.
*/
dropdownStyle?: CSSProperties;
/**
* Displayed count in the dropdown trigger.
*/
dropdownTriggerCount?: number;
/**
* Icon of the dropdown trigger.
*/
dropdownTriggerIcon?: ReactElement;
/**
* Text of the dropdown trigger.
*/
dropdownTriggerText?: string;
/**
* Text of the dropdown trigger tooltip
*/
dropdownTriggerTooltip?: ReactNode | null;
/**
* Main container additional style properties.
*/
style?: CSSProperties;
/**
* Force render popover content before it's first opened
*/
forceRender?: boolean;
}
export type DropdownRef = HTMLDivElement & { open: () => void };
const MAX_HEIGHT = 500;
export const DropdownContainer = forwardRef(
(
{
items,
onOverflowingStateChange,
dropdownContent,
dropdownRef,
dropdownStyle = {},
dropdownTriggerCount,
dropdownTriggerIcon,
dropdownTriggerText = t('More'),
dropdownTriggerTooltip = null,
forceRender,
style,
}: DropdownContainerProps,
outerRef: RefObject<DropdownRef>,
) => {
const theme = useTheme();
const { ref, width = 0 } = useResizeDetector<HTMLDivElement>();
const previousWidth = usePrevious(width) || 0;
const { current } = ref;
const [itemsWidth, setItemsWidth] = useState<number[]>([]);
const [popoverVisible, setPopoverVisible] = useState(false);
// We use React.useState to be able to mock the state in Jest
const [overflowingIndex, setOverflowingIndex] = useState<number>(-1);
let targetRef = useRef<HTMLDivElement>(null);
if (dropdownRef) {
targetRef = dropdownRef;
}
const [showOverflow, setShowOverflow] = useState(false);
// callback to update item widths so that the useLayoutEffect runs whenever
// width of any of the child changes
const recalculateItemWidths = useCallback(() => {
const mainItemsContainerNode = current?.children.item(0);
if (mainItemsContainerNode) {
const visibleChildrenElements = Array.from(
mainItemsContainerNode.children,
);
setItemsWidth(prevGlobalWidths => {
if (prevGlobalWidths.length !== items.length) {
return prevGlobalWidths;
}
const newGlobalWidths = [...prevGlobalWidths];
let changed = false;
visibleChildrenElements.forEach((child, indexInVisible) => {
const originalItemIndex = indexInVisible;
if (originalItemIndex < newGlobalWidths.length) {
const newWidth = child.getBoundingClientRect().width;
if (newGlobalWidths[originalItemIndex] !== newWidth) {
newGlobalWidths[originalItemIndex] = newWidth;
changed = true;
}
}
});
return changed ? newGlobalWidths : prevGlobalWidths;
});
}
}, [current?.children, items.length]);
const reduceItems = (items: DropdownItem[]): [DropdownItem[], string[]] =>
items.reduce(
([items, ids], item) => {
items.push({
id: item.id,
element: cloneElement(item.element, { key: item.id }),
});
ids.push(item.id);
return [items, ids];
},
[[], []] as [DropdownItem[], string[]],
);
const [notOverflowedItems, notOverflowedIds] = useMemo(
() =>
reduceItems(
items.slice(
0,
overflowingIndex !== -1 ? overflowingIndex : items.length,
),
),
[items, overflowingIndex],
);
const [overflowedItems, overflowedIds] = useMemo(
() =>
overflowingIndex !== -1
? reduceItems(items.slice(overflowingIndex))
: [[], []],
[items, overflowingIndex],
);
useEffect(() => {
const container = current?.children.item(0);
if (!container) return;
const childrenArray = Array.from(container.children);
const resizeObserver = new ResizeObserver(() => {
recalculateItemWidths();
});
childrenArray.map(child => resizeObserver.observe(child));
// eslint-disable-next-line consistent-return
return () => {
childrenArray.map(child => resizeObserver.unobserve(child));
resizeObserver.disconnect();
};
}, [items.length, current, recalculateItemWidths]);
useLayoutEffect(() => {
if (popoverVisible) {
return;
}
const container = current?.children.item(0);
if (container) {
const { children } = container;
const childrenArray = Array.from(children);
// If items length change, add all items to the container
// and recalculate the widths
if (itemsWidth.length !== items.length) {
if (childrenArray.length === items.length) {
setItemsWidth(
childrenArray.map(child => child.getBoundingClientRect().width),
);
} else {
setOverflowingIndex(-1);
return;
}
}
// Calculates the index of the first overflowed element
// +1 is to give at least one pixel of difference and avoid flakiness
const index = childrenArray.findIndex(
child =>
child.getBoundingClientRect().right >
container.getBoundingClientRect().right + 1,
);
// If elements fit (-1) and there's overflowed items
// then preserve the overflow index. We can't use overflowIndex
// directly because the items may have been modified
let newOverflowingIndex =
index === -1 && overflowedItems.length > 0
? items.length - overflowedItems.length
: index;
if (width > previousWidth) {
// Calculates remaining space in the container
const button = current?.children.item(1);
const buttonRight = button?.getBoundingClientRect().right || 0;
const containerRight = current?.getBoundingClientRect().right || 0;
const remainingSpace = containerRight - buttonRight;
// Checks if some elements in the dropdown fits in the remaining space
let sum = 0;
for (let i = childrenArray.length; i < items.length; i += 1) {
sum += itemsWidth[i];
if (sum <= remainingSpace) {
newOverflowingIndex = i + 1;
} else {
break;
}
}
}
setOverflowingIndex(newOverflowingIndex);
}
}, [
current,
items.length,
itemsWidth,
overflowedItems.length,
previousWidth,
width,
popoverVisible,
]);
useEffect(() => {
if (onOverflowingStateChange) {
onOverflowingStateChange({
notOverflowed: notOverflowedIds,
overflowed: overflowedIds,
});
}
}, [notOverflowedIds, onOverflowingStateChange, overflowedIds]);
const overflowingCount =
overflowingIndex !== -1 ? items.length - overflowingIndex : 0;
const popoverContent = useMemo(
() =>
dropdownContent || overflowingCount ? (
<div
css={css`
display: flex;
flex-direction: column;
gap: ${theme.sizeUnit * 4}px;
`}
data-test="dropdown-content"
style={dropdownStyle}
ref={targetRef}
>
{dropdownContent
? dropdownContent(overflowedItems)
: overflowedItems.map(item => item.element)}
</div>
) : null,
[
dropdownContent,
overflowingCount,
theme.sizeUnit,
dropdownStyle,
overflowedItems,
],
);
useLayoutEffect(() => {
if (popoverVisible) {
// Measures scroll height after rendering the elements
setTimeout(() => {
if (targetRef.current) {
// We only set overflow when there's enough space to display
// Select's popovers because they are restrained by the overflow property.
setShowOverflow(targetRef.current.scrollHeight > MAX_HEIGHT);
}
}, 100);
}
}, [popoverVisible]);
useImperativeHandle(
outerRef,
() => ({
...(ref.current as HTMLDivElement),
open: () => setPopoverVisible(true),
}),
[ref],
);
// Closes the popover when scrolling on the document
useEffect(() => {
document.onscroll = popoverVisible
? () => setPopoverVisible(false)
: null;
return () => {
document.onscroll = null;
};
}, [popoverVisible]);
return (
<div
ref={ref}
css={css`
display: flex;
align-items: center;
`}
>
<div
css={css`
display: flex;
align-items: center;
gap: ${theme.sizeUnit * 4}px;
margin-right: ${theme.sizeUnit * 4}px;
min-width: 0px;
`}
data-test="container"
style={style}
>
{notOverflowedItems.map(item => item.element)}
</div>
{popoverContent && (
<>
<Global
styles={css`
.ant-popover-inner {
// Some OS versions only show the scroll when hovering.
// These settings will make the scroll always visible.
::-webkit-scrollbar {
-webkit-appearance: none;
width: 14px;
}
::-webkit-scrollbar-thumb {
border-radius: 9px;
background-color: ${theme.colors.grayscale.light1};
border: 3px solid transparent;
background-clip: content-box;
}
::-webkit-scrollbar-track {
background-color: ${theme.colors.grayscale.light4};
border-left: 1px solid ${theme.colors.grayscale.light2};
}
}
`}
/>
<Popover
styles={{
body: {
maxHeight: `${MAX_HEIGHT}px`,
overflow: showOverflow ? 'auto' : 'visible',
},
}}
content={popoverContent}
trigger="click"
open={popoverVisible}
onOpenChange={visible => setPopoverVisible(visible)}
placement="bottom"
forceRender={forceRender}
>
<Tooltip title={dropdownTriggerTooltip}>
<Button
buttonStyle="secondary"
data-test="dropdown-container-btn"
>
{dropdownTriggerIcon}
{dropdownTriggerText}
<Badge
count={dropdownTriggerCount ?? overflowingCount}
color={
(dropdownTriggerCount ?? overflowingCount) > 0
? theme.colorPrimary
: theme.colors.grayscale.light1
}
showZero
css={css`
margin-left: ${theme.sizeUnit * 2}px;
`}
/>
<Icons.DownOutlined
iconSize="m"
iconColor={theme.colors.grayscale.light1}
css={css`
.anticon {
display: flex;
}
`}
/>
</Button>
</Tooltip>
</Popover>
</>
)}
</div>
);
},
);

View File

@@ -17,7 +17,6 @@
* under the License.
*/
import type { CSSProperties, ReactElement, RefObject, ReactNode } from 'react';
import { IconType } from '../Icons';
/**
* Container item.
@@ -70,7 +69,7 @@ export interface DropdownContainerProps {
/**
* Icon of the dropdown trigger.
*/
dropdownTriggerIcon?: IconType;
dropdownTriggerIcon?: ReactElement;
/**
* Text of the dropdown trigger.
*/

View File

@@ -45,16 +45,7 @@ export const DatasetTypeLabel: React.FC<DatasetTypeLabelProps> = ({
const labelType = datasetType === 'physical' ? 'primary' : 'default';
return (
<Label
icon={icon}
type={labelType}
style={{
color:
datasetType === 'physical'
? theme.colorPrimaryText
: theme.colorPrimary,
}}
>
<Label icon={icon} type={labelType}>
{label}
</Label>
);

View File

@@ -1047,119 +1047,6 @@ test('typing and deleting the last character for a new option displays correctly
jest.useRealTimers();
});
describe('grouped options search', () => {
const GROUPED_OPTIONS = [
{
label: 'Male',
options: OPTIONS.filter(option => option.gender === 'Male'),
},
{
label: 'Female',
options: OPTIONS.filter(option => option.gender === 'Female'),
},
];
it('searches within grouped options and shows matching groups', async () => {
render(<Select {...defaultProps} options={GROUPED_OPTIONS} />);
await open();
await type('John');
expect(await findSelectOption('John')).toBeInTheDocument();
expect(await findSelectOption('Johnny')).toBeInTheDocument();
expect(screen.queryByText('Female')).not.toBeInTheDocument();
expect(screen.queryByText('Olivia')).not.toBeInTheDocument();
expect(screen.getByText('Male')).toBeInTheDocument();
expect(screen.queryByText('Female')).not.toBeInTheDocument();
});
it('shows multiple groups when search matches both', async () => {
render(<Select {...defaultProps} options={GROUPED_OPTIONS} />);
await open();
await type('er');
expect(screen.getByText('Male')).toBeInTheDocument();
expect(screen.getByText('Female')).toBeInTheDocument();
expect(await findSelectOption('Oliver')).toBeInTheDocument();
expect(await findSelectOption('Cher')).toBeInTheDocument();
expect(await findSelectOption('Her')).toBeInTheDocument();
});
it('handles case-insensitive search in grouped options', async () => {
render(<Select {...defaultProps} options={GROUPED_OPTIONS} />);
await open();
await type('EMMA');
expect(await findSelectOption('Emma')).toBeInTheDocument();
expect(screen.getByText('Female')).toBeInTheDocument();
expect(screen.queryByText('Male')).not.toBeInTheDocument();
});
it('shows no options when search matches nothing in any group', async () => {
render(<Select {...defaultProps} options={GROUPED_OPTIONS} />);
await open();
await type('xyz123');
expect(screen.queryByText('Male')).not.toBeInTheDocument();
expect(screen.queryByText('Female')).not.toBeInTheDocument();
expect(
screen.getByText(NO_DATA, { selector: '.ant-empty-description' }),
).toBeInTheDocument();
});
it('works in multiple selection mode with grouped options', async () => {
render(
<Select {...defaultProps} options={GROUPED_OPTIONS} mode="multiple" />,
);
await open();
await type('John');
await userEvent.click(await findSelectOption('John'));
// Clear search and search for female name
await clearTypedText();
await type('Emma');
await userEvent.click(await findSelectOption('Emma'));
// Both should be selected
const values = await findAllSelectValues();
expect(values).toHaveLength(2);
expect(values[0]).toHaveTextContent('John');
expect(values[1]).toHaveTextContent('Emma');
});
it('preserves group structure when not searching', async () => {
render(<Select {...defaultProps} options={GROUPED_OPTIONS} />);
await open();
expect(screen.getByText('Male')).toBeInTheDocument();
expect(screen.getByText('Female')).toBeInTheDocument();
expect(await findSelectOption('John')).toBeInTheDocument();
expect(await findSelectOption('Emma')).toBeInTheDocument();
});
it('handles empty groups gracefully', async () => {
const optionsWithEmptyGroup = [
...GROUPED_OPTIONS,
{
label: 'Empty Group',
options: [],
},
];
render(<Select {...defaultProps} options={optionsWithEmptyGroup} />);
await open();
await type('John');
expect(await findSelectOption('John')).toBeInTheDocument();
expect(screen.queryByText('Empty Group')).not.toBeInTheDocument();
});
});
/*
TODO: Add tests that require scroll interaction. Needs further investigation.
- Fetches more data when scrolling and more data is available

View File

@@ -373,27 +373,9 @@ const Select = forwardRef(
setSelectOptions(updatedOptions);
}
const filteredOptions = updatedOptions
.map((option: any) => {
/*
If it's a group, filter its nested options and only return it
if it has matching options
*/
if ('options' in option && Array.isArray(option.options)) {
const filteredGroupOptions = option.options.filter(
(subOption: AntdLabeledValue) =>
handleFilterOption(search, subOption),
);
return filteredGroupOptions.length > 0
? { ...option, options: filteredGroupOptions }
: null;
}
return handleFilterOption(search, option as AntdLabeledValue)
? option
: null;
})
.filter((option): option is AntdLabeledValue => option !== null);
const filteredOptions = updatedOptions.filter(
(option: AntdLabeledValue) => handleFilterOption(search, option),
);
setVisibleOptions(filteredOptions);
setInputValue(searchValue);

View File

@@ -32,9 +32,8 @@ export const StyledHeader = styled.span<{ headerPosition: string }>`
`;
export const StyledContainer = styled.div<{ headerPosition: string }>`
${({ headerPosition, theme }) => `
${({ headerPosition }) => `
display: flex;
gap: ${theme.sizeUnit}px;
flex-direction: ${headerPosition === 'top' ? 'column' : 'row'};
align-items: ${headerPosition === 'left' ? 'center' : undefined};
width: 100%;

View File

@@ -52,9 +52,7 @@ interface TableCollectionProps<T extends object> {
const StyledTable = styled(Table)`
${({ theme }) => `
th.ant-column-cell {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
min-width: fit-content;
}
.actions {
opacity: 0;
@@ -85,6 +83,7 @@ const StyledTable = styled(Table)`
font-feature-settings: 'tnum' 1;
text-overflow: ellipsis;
overflow: hidden;
max-width: 320px;
line-height: 1;
vertical-align: middle;
padding-left: ${theme.sizeUnit * 4}px;
@@ -150,7 +149,7 @@ function TableCollection<T extends object>({
size={size}
data-test="listview-table"
pagination={false}
tableLayout="fixed"
tableLayout="auto"
rowKey="rowId"
rowSelection={rowSelection}
locale={{ emptyText: null }}

View File

@@ -94,7 +94,7 @@ export function mapColumns<T extends object>(
dataIndex: column.id?.includes('.') ? column.id.split('.') : column.id,
hidden: column.hidden,
key: column.id,
width: column.size ? COLUMN_SIZE_MAP[column.size] : COLUMN_SIZE_MAP.md,
minWidth: column.size ? COLUMN_SIZE_MAP[column.size] : COLUMN_SIZE_MAP.md,
ellipsis: !columnsForWrapText?.includes(column.id),
defaultSortOrder: (isSorted
? isSortedDesc

View File

@@ -22,10 +22,10 @@ import {
userEvent,
waitFor,
within,
} from 'spec/helpers/testing-library';
} from '@superset-ui/core/spec';
import { ThemeMode } from '@superset-ui/core';
import { Menu } from '@superset-ui/core/components';
import { ThemeSubMenuProps, useThemeMenuItems } from './useThemeMenuItems';
import { ThemeSubMenu } from '.';
// Mock the translation function
jest.mock('@superset-ui/core', () => ({
@@ -33,12 +33,7 @@ jest.mock('@superset-ui/core', () => ({
t: (key: string) => key,
}));
const TestComponent = (props: ThemeSubMenuProps) => {
const menuItem = useThemeMenuItems(props);
return <Menu items={[menuItem]} />;
};
describe('useThemeMenuItems', () => {
describe('ThemeSubMenu', () => {
const defaultProps = {
allowOSPreference: true,
setThemeMode: jest.fn(),
@@ -47,8 +42,12 @@ describe('useThemeMenuItems', () => {
onClearLocalSettings: jest.fn(),
};
const renderThemeMenu = (props = defaultProps) =>
render(<TestComponent {...props} />);
const renderThemeSubMenu = (props = defaultProps) =>
render(
<Menu>
<ThemeSubMenu {...props} />
</Menu>,
);
const findMenuWithText = async (text: string) => {
await waitFor(() => {
@@ -67,7 +66,7 @@ describe('useThemeMenuItems', () => {
});
it('renders Light and Dark theme options by default', async () => {
renderThemeMenu();
renderThemeSubMenu();
userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Light');
@@ -77,7 +76,7 @@ describe('useThemeMenuItems', () => {
});
it('does not render Match system option when allowOSPreference is false', async () => {
renderThemeMenu({ ...defaultProps, allowOSPreference: false });
renderThemeSubMenu({ ...defaultProps, allowOSPreference: false });
userEvent.hover(await screen.findByRole('menuitem'));
await waitFor(() => {
@@ -86,7 +85,7 @@ describe('useThemeMenuItems', () => {
});
it('renders with allowOSPreference as true by default', async () => {
renderThemeMenu();
renderThemeSubMenu();
userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Match system');
@@ -96,7 +95,7 @@ describe('useThemeMenuItems', () => {
it('renders clear option when both hasLocalOverride and onClearLocalSettings are provided', async () => {
const mockClear = jest.fn();
renderThemeMenu({
renderThemeSubMenu({
...defaultProps,
hasLocalOverride: true,
onClearLocalSettings: mockClear,
@@ -110,7 +109,7 @@ describe('useThemeMenuItems', () => {
it('does not render clear option when hasLocalOverride is false', async () => {
const mockClear = jest.fn();
renderThemeMenu({
renderThemeSubMenu({
...defaultProps,
hasLocalOverride: false,
onClearLocalSettings: mockClear,
@@ -125,7 +124,7 @@ describe('useThemeMenuItems', () => {
it('calls setThemeMode with DEFAULT when Light is clicked', async () => {
const mockSet = jest.fn();
renderThemeMenu({ ...defaultProps, setThemeMode: mockSet });
renderThemeSubMenu({ ...defaultProps, setThemeMode: mockSet });
userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Light');
@@ -136,7 +135,7 @@ describe('useThemeMenuItems', () => {
it('calls setThemeMode with DARK when Dark is clicked', async () => {
const mockSet = jest.fn();
renderThemeMenu({ ...defaultProps, setThemeMode: mockSet });
renderThemeSubMenu({ ...defaultProps, setThemeMode: mockSet });
userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Dark');
@@ -147,7 +146,7 @@ describe('useThemeMenuItems', () => {
it('calls setThemeMode with SYSTEM when Match system is clicked', async () => {
const mockSet = jest.fn();
renderThemeMenu({ ...defaultProps, setThemeMode: mockSet });
renderThemeSubMenu({ ...defaultProps, setThemeMode: mockSet });
userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Match system');
@@ -158,7 +157,7 @@ describe('useThemeMenuItems', () => {
it('calls onClearLocalSettings when Clear local theme is clicked', async () => {
const mockClear = jest.fn();
renderThemeMenu({
renderThemeSubMenu({
...defaultProps,
hasLocalOverride: true,
onClearLocalSettings: mockClear,
@@ -172,27 +171,27 @@ describe('useThemeMenuItems', () => {
});
it('displays sun icon for DEFAULT theme', () => {
renderThemeMenu({ ...defaultProps, themeMode: ThemeMode.DEFAULT });
renderThemeSubMenu({ ...defaultProps, themeMode: ThemeMode.DEFAULT });
expect(screen.getByTestId('sun')).toBeInTheDocument();
});
it('displays moon icon for DARK theme', () => {
renderThemeMenu({ ...defaultProps, themeMode: ThemeMode.DARK });
renderThemeSubMenu({ ...defaultProps, themeMode: ThemeMode.DARK });
expect(screen.getByTestId('moon')).toBeInTheDocument();
});
it('displays format-painter icon for SYSTEM theme', () => {
renderThemeMenu({ ...defaultProps, themeMode: ThemeMode.SYSTEM });
renderThemeSubMenu({ ...defaultProps, themeMode: ThemeMode.SYSTEM });
expect(screen.getByTestId('format-painter')).toBeInTheDocument();
});
it('displays override icon when hasLocalOverride is true', () => {
renderThemeMenu({ ...defaultProps, hasLocalOverride: true });
renderThemeSubMenu({ ...defaultProps, hasLocalOverride: true });
expect(screen.getByTestId('format-painter')).toBeInTheDocument();
});
it('renders Theme group header', async () => {
renderThemeMenu();
renderThemeSubMenu();
userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Theme');
@@ -201,7 +200,7 @@ describe('useThemeMenuItems', () => {
});
it('renders sun icon for Light theme option', async () => {
renderThemeMenu();
renderThemeSubMenu();
userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Light');
@@ -211,7 +210,7 @@ describe('useThemeMenuItems', () => {
});
it('renders moon icon for Dark theme option', async () => {
renderThemeMenu();
renderThemeSubMenu();
userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Dark');
@@ -221,7 +220,7 @@ describe('useThemeMenuItems', () => {
});
it('renders format-painter icon for Match system option', async () => {
renderThemeMenu({ ...defaultProps, allowOSPreference: true });
renderThemeSubMenu({ ...defaultProps, allowOSPreference: true });
userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Match system');
@@ -233,7 +232,7 @@ describe('useThemeMenuItems', () => {
});
it('renders clear icon for Clear local theme option', async () => {
renderThemeMenu({
renderThemeSubMenu({
...defaultProps,
hasLocalOverride: true,
onClearLocalSettings: jest.fn(),
@@ -249,7 +248,7 @@ describe('useThemeMenuItems', () => {
});
it('renders divider before clear option when clear option is present', async () => {
renderThemeMenu({
renderThemeSubMenu({
...defaultProps,
hasLocalOverride: true,
onClearLocalSettings: jest.fn(),
@@ -264,7 +263,7 @@ describe('useThemeMenuItems', () => {
});
it('does not render divider when clear option is not present', async () => {
renderThemeMenu({ ...defaultProps });
renderThemeSubMenu({ ...defaultProps });
userEvent.hover(await screen.findByRole('menuitem'));
const divider = document.querySelector('.ant-menu-item-divider');

View File

@@ -17,9 +17,44 @@
* under the License.
*/
import { useMemo } from 'react';
import { Icons } from '@superset-ui/core/components';
import type { MenuItem } from '@superset-ui/core/components/Menu';
import { t, ThemeMode, useTheme, ThemeAlgorithm } from '@superset-ui/core';
import { Icons, Menu } from '@superset-ui/core/components';
import {
css,
styled,
t,
ThemeMode,
useTheme,
ThemeAlgorithm,
} from '@superset-ui/core';
const StyledThemeSubMenu = styled(Menu.SubMenu)`
${({ theme }) => css`
[data-icon='caret-down'] {
color: ${theme.colorIcon};
font-size: ${theme.fontSizeXS}px;
margin-left: ${theme.sizeUnit}px;
}
&.ant-menu-submenu-active {
.ant-menu-title-content {
color: ${theme.colorPrimary};
}
}
`}
`;
const StyledThemeSubMenuItem = styled(Menu.Item)<{ selected: boolean }>`
${({ theme, selected }) => css`
&:hover {
color: ${theme.colorPrimary} !important;
cursor: pointer !important;
}
${selected &&
css`
background-color: ${theme.colors.primary.light4} !important;
color: ${theme.colors.primary.dark1} !important;
`}
`}
`;
export interface ThemeSubMenuOption {
key: ThemeMode;
@@ -36,13 +71,13 @@ export interface ThemeSubMenuProps {
allowOSPreference?: boolean;
}
export const useThemeMenuItems = ({
export const ThemeSubMenu: React.FC<ThemeSubMenuProps> = ({
setThemeMode,
themeMode,
hasLocalOverride = false,
onClearLocalSettings,
allowOSPreference = true,
}: ThemeSubMenuProps): MenuItem => {
}: ThemeSubMenuProps) => {
const theme = useTheme();
const handleSelect = (mode: ThemeMode) => {
@@ -72,70 +107,64 @@ export const useThemeMenuItems = ({
[hasLocalOverride, theme.colors.error.base, themeIconMap, themeMode],
);
const themeOptions: MenuItem[] = [
const themeOptions: ThemeSubMenuOption[] = [
{
key: ThemeMode.DEFAULT,
label: (
<>
<Icons.SunOutlined /> {t('Light')}
</>
),
label: t('Light'),
icon: <Icons.SunOutlined />,
onClick: () => handleSelect(ThemeMode.DEFAULT),
},
{
key: ThemeMode.DARK,
label: (
<>
<Icons.MoonOutlined /> {t('Dark')}
</>
),
label: t('Dark'),
icon: <Icons.MoonOutlined />,
onClick: () => handleSelect(ThemeMode.DARK),
},
...(allowOSPreference
? [
{
key: ThemeMode.SYSTEM,
label: (
<>
<Icons.FormatPainterOutlined /> {t('Match system')}
</>
),
label: t('Match system'),
icon: <Icons.FormatPainterOutlined />,
onClick: () => handleSelect(ThemeMode.SYSTEM),
},
]
: []),
];
const children: MenuItem[] = [
{
type: 'group' as const,
label: t('Theme'),
key: 'theme-group',
children: themeOptions,
},
];
// Add clear settings option only when there's a local theme active
if (onClearLocalSettings && hasLocalOverride) {
children.push({
type: 'divider' as const,
key: 'theme-divider',
});
children.push({
key: 'clear-local',
label: (
<>
<Icons.ClearOutlined /> {t('Clear local theme')}
</>
),
onClick: onClearLocalSettings,
});
}
const clearOption =
onClearLocalSettings && hasLocalOverride
? {
key: 'clear-local',
label: t('Clear local theme'),
icon: <Icons.ClearOutlined />,
onClick: onClearLocalSettings,
}
: null;
return {
key: 'theme-sub-menu',
label: selectedThemeModeIcon,
icon: <Icons.CaretDownOutlined iconSize="xs" />,
children,
};
return (
<StyledThemeSubMenu
key="theme-sub-menu"
title={selectedThemeModeIcon}
icon={<Icons.CaretDownOutlined iconSize="xs" />}
>
<Menu.ItemGroup title={t('Theme')} />
{themeOptions.map(option => (
<StyledThemeSubMenuItem
key={option.key}
onClick={option.onClick}
selected={option.key === themeMode}
>
{option.icon} {option.label}
</StyledThemeSubMenuItem>
))}
{clearOption && [
<Menu.Divider key="theme-divider" />,
<Menu.Item key={clearOption.key} onClick={clearOption.onClick}>
{clearOption.icon} {clearOption.label}
</Menu.Item>,
]}
</StyledThemeSubMenu>
);
};

View File

@@ -1,220 +0,0 @@
/**
* 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 { render, screen } from '@superset-ui/core/spec';
import { AgGridReact } from 'ag-grid-react';
import { createRef } from 'react';
import { ThemeProvider, supersetTheme } from '../../theme';
import { ThemedAgGridReact } from './index';
import * as themeUtils from '../../theme/utils/themeUtils';
// Mock useThemeMode hook
jest.mock('../../theme/utils/themeUtils', () => ({
...jest.requireActual('../../theme/utils/themeUtils'),
useThemeMode: jest.fn(() => false), // Default to light mode
}));
// Mock ag-grid-react to avoid complex setup
jest.mock('ag-grid-react', () => ({
AgGridReact: jest.fn(({ theme, ...props }) => (
<div
data-test="ag-grid-react"
data-theme={JSON.stringify(theme)}
{...props}
>
AgGrid Mock
</div>
)),
}));
// Mock ag-grid-community
jest.mock('ag-grid-community', () => ({
themeQuartz: {
withPart: jest.fn().mockReturnThis(),
withParams: jest.fn(params => ({ ...params, _type: 'theme' })),
},
colorSchemeDark: { _type: 'dark' },
colorSchemeLight: { _type: 'light' },
AllCommunityModule: {},
ClientSideRowModelModule: {},
ModuleRegistry: { registerModules: jest.fn() },
}));
const mockRowData = [
{ id: 1, name: 'Test 1' },
{ id: 2, name: 'Test 2' },
];
const mockColumnDefs = [
{ field: 'id', headerName: 'ID' },
{ field: 'name', headerName: 'Name' },
];
beforeEach(() => {
jest.clearAllMocks();
// Reset to light mode by default
(themeUtils.useThemeMode as jest.Mock).mockReturnValue(false);
});
test('renders the AgGridReact component', () => {
render(
<ThemedAgGridReact rowData={mockRowData} columnDefs={mockColumnDefs} />,
);
expect(screen.getByTestId('ag-grid-react')).toBeInTheDocument();
});
test('applies light theme when background is light', () => {
const lightTheme = {
...supersetTheme,
colorBgBase: '#ffffff',
colorText: '#000000',
};
render(
<ThemeProvider theme={lightTheme}>
<ThemedAgGridReact rowData={mockRowData} columnDefs={mockColumnDefs} />
</ThemeProvider>,
);
const agGrid = screen.getByTestId('ag-grid-react');
const theme = JSON.parse(agGrid.getAttribute('data-theme') || '{}');
expect(theme.browserColorScheme).toBe('light');
expect(theme.foregroundColor).toBe('#000000');
});
test('applies dark theme when background is dark', () => {
// Mock dark mode
(themeUtils.useThemeMode as jest.Mock).mockReturnValue(true);
const darkTheme = {
...supersetTheme,
colorBgBase: '#1a1a1a',
colorText: '#ffffff',
};
render(
<ThemeProvider theme={darkTheme}>
<ThemedAgGridReact rowData={mockRowData} columnDefs={mockColumnDefs} />
</ThemeProvider>,
);
const agGrid = screen.getByTestId('ag-grid-react');
const theme = JSON.parse(agGrid.getAttribute('data-theme') || '{}');
expect(theme.browserColorScheme).toBe('dark');
expect(theme.foregroundColor).toBe('#ffffff');
});
test('forwards ref to AgGridReact', () => {
const ref = createRef<AgGridReact>();
render(
<ThemedAgGridReact
ref={ref}
rowData={mockRowData}
columnDefs={mockColumnDefs}
/>,
);
// Check that AgGridReact was called with the ref
expect(AgGridReact).toHaveBeenCalledWith(
expect.objectContaining({
rowData: mockRowData,
columnDefs: mockColumnDefs,
}),
expect.any(Object), // ref is passed as second argument
);
});
test('passes all props through to AgGridReact', () => {
const onGridReady = jest.fn();
const onCellClicked = jest.fn();
render(
<ThemedAgGridReact
rowData={mockRowData}
columnDefs={mockColumnDefs}
onGridReady={onGridReady}
onCellClicked={onCellClicked}
pagination
paginationPageSize={10}
/>,
);
expect(AgGridReact).toHaveBeenCalledWith(
expect.objectContaining({
rowData: mockRowData,
columnDefs: mockColumnDefs,
onGridReady,
onCellClicked,
pagination: true,
paginationPageSize: 10,
}),
expect.any(Object),
);
});
test('applies custom theme colors from Superset theme', () => {
const customTheme = {
...supersetTheme,
colorFillTertiary: '#e5e5e5',
colorSplit: '#d9d9d9',
};
render(
<ThemeProvider theme={customTheme}>
<ThemedAgGridReact rowData={mockRowData} columnDefs={mockColumnDefs} />
</ThemeProvider>,
);
const agGrid = screen.getByTestId('ag-grid-react');
const theme = JSON.parse(agGrid.getAttribute('data-theme') || '{}');
// Just verify a couple key theme properties are applied
expect(theme.headerBackgroundColor).toBe('#e5e5e5');
expect(theme.borderColor).toBe('#d9d9d9');
});
test('wraps component with proper container div', () => {
const { container } = render(
<ThemedAgGridReact rowData={mockRowData} columnDefs={mockColumnDefs} />,
);
const wrapper = container.querySelector('[data-themed-ag-grid="true"]');
expect(wrapper).toBeInTheDocument();
// Styles are now applied via css prop, not inline styles
expect(wrapper).toHaveAttribute('data-themed-ag-grid', 'true');
});
test('handles missing theme gracefully', () => {
const incompleteTheme = {
...supersetTheme,
colorBgBase: undefined,
};
render(
<ThemeProvider theme={incompleteTheme}>
<ThemedAgGridReact rowData={mockRowData} columnDefs={mockColumnDefs} />
</ThemeProvider>,
);
// Should still render without crashing
expect(screen.getByTestId('ag-grid-react')).toBeInTheDocument();
});

View File

@@ -1,190 +0,0 @@
/**
* 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, forwardRef } from 'react';
import { css } from '@emotion/react';
import { AgGridReact, type AgGridReactProps } from 'ag-grid-react';
import {
themeQuartz,
colorSchemeDark,
colorSchemeLight,
} from 'ag-grid-community';
import { useTheme } from '../../theme';
import { useThemeMode } from '../../theme/utils/themeUtils';
// Note: With ag-grid v34's new theming API, CSS files are injected automatically
// Do NOT import 'ag-grid-community/styles/ag-grid.css' or theme CSS files
export interface ThemedAgGridReactProps extends AgGridReactProps {
/**
* Optional theme parameter overrides to customize specific ag-grid theme values.
* These will be merged with the default Superset theme values.
*
* @example
* ```tsx
* <ThemedAgGridReact
* rowData={data}
* columnDefs={columns}
* themeOverrides={{
* headerBackgroundColor: '#custom-color',
* fontSize: 14,
* }}
* />
* ```
*/
themeOverrides?: Record<string, any>;
}
/**
* ThemedAgGridReact - A wrapper around AgGridReact that applies Superset theming
*
* This component:
* - Preserves the full AgGridReactProps interface for drop-in replacement
* - Applies Superset theme variables via ag-grid's JavaScript theming API
* - Supports automatic dark/light mode switching
* - Allows custom theme parameter overrides
*
* @example
* ```tsx
* <ThemedAgGridReact
* rowData={data}
* columnDefs={columns}
* themeOverrides={{ fontSize: 14 }}
* // ... any other AgGridReactProps
* />
* ```
*/
export const ThemedAgGridReact = forwardRef<
AgGridReact,
ThemedAgGridReactProps
>(function ThemedAgGridReact({ themeOverrides, ...props }, ref) {
const theme = useTheme();
const isDarkMode = useThemeMode();
// Get the appropriate ag-grid theme based on dark/light mode
const agGridTheme = useMemo(() => {
// Use quaternary fill for odd rows
const oddRowBg = theme?.colorFillQuaternary;
const baseTheme = isDarkMode
? themeQuartz.withPart(colorSchemeDark)
: themeQuartz.withPart(colorSchemeLight);
// Use withParams to set colors directly via ag-grid's API
const params = {
// Core colors
backgroundColor: 'transparent',
foregroundColor: theme.colorText,
browserColorScheme: isDarkMode ? 'dark' : 'light',
// Header styling
headerBackgroundColor: theme.colorFillTertiary,
headerTextColor: theme.colorTextHeading,
// Cell and row styling
oddRowBackgroundColor: oddRowBg,
rowHoverColor: theme.colorFillSecondary,
selectedRowBackgroundColor: theme.colorPrimaryBg,
cellTextColor: theme.colorText,
// Borders
borderColor: theme.colorSplit,
columnBorderColor: theme.colorSplit,
// Interactive elements
accentColor: theme.colorPrimary,
rangeSelectionBorderColor: theme.colorPrimary,
rangeSelectionBackgroundColor: theme.colorPrimaryBg,
// Input fields (for filters)
inputBackgroundColor: theme.colorBgContainer,
inputBorderColor: theme.colorSplit,
inputTextColor: theme.colorText,
inputPlaceholderTextColor: theme.colorTextPlaceholder,
// Typography
fontFamily: theme.fontFamily,
fontSize: theme.fontSizeSM,
// Spacing
spacing: theme.sizeUnit,
};
// Only apply params if we have a valid theme
if (!theme || !theme.colorBgBase) {
return baseTheme;
}
// Merge theme overrides if provided
const finalParams = themeOverrides
? { ...params, ...themeOverrides }
: params;
return baseTheme.withParams(finalParams);
}, [theme, isDarkMode, themeOverrides]);
return (
<div
css={css`
width: 100%;
height: 100%;
.ag-cell {
-webkit-font-smoothing: antialiased;
}
`}
data-themed-ag-grid="true"
>
<AgGridReact ref={ref} theme={agGridTheme} {...props} />
</div>
);
});
// Re-export commonly used types for convenience
export type { CustomCellRendererProps } from 'ag-grid-react';
// Re-export commonly used ag-grid-community types
export type {
ColDef,
Column,
GridOptions,
GridState,
GridReadyEvent,
CellClickedEvent,
CellClassParams,
IMenuActionParams,
IHeaderParams,
SortModelItem,
ValueFormatterParams,
ValueGetterParams,
} from 'ag-grid-community';
// Re-export modules and themes commonly used with ThemedAgGridReact
export {
AllCommunityModule,
ClientSideRowModelModule,
ModuleRegistry,
themeQuartz,
colorSchemeDark,
colorSchemeLight,
} from 'ag-grid-community';
// Re-export AgGridReact for ref types
export { AgGridReact } from 'ag-grid-react';
// Export the setup function for AG-Grid modules
export { setupAGGridModules } from './setupAGGridModules';

View File

@@ -166,11 +166,7 @@ export * from './Table';
export * from './TableView';
export * from './Tag';
export * from './TelemetryPixel';
export * from './ThemeSubMenu';
export * from './UnsavedChangesModal';
export * from './constants';
export * from './Result';
export {
ThemedAgGridReact,
type ThemedAgGridReactProps,
setupAGGridModules,
} from './ThemedAgGridReact';

View File

@@ -115,15 +115,11 @@ export default class SupersetClientClass {
return this.getCSRFToken();
}
async postForm(
endpoint: string,
payload: Record<string, any>,
target = '_blank',
) {
if (endpoint) {
async postForm(url: string, payload: Record<string, any>, target = '_blank') {
if (url) {
await this.ensureAuth();
const hiddenForm = document.createElement('form');
hiddenForm.action = this.getUrl({ endpoint });
hiddenForm.action = url;
hiddenForm.method = 'POST';
hiddenForm.target = target;
const payloadWithToken: Record<string, any> = {

Some files were not shown because too many files have changed in this diff Show More