Skip to content

Commit 610c435

Browse files
Superset Devclaude
andcommitted
feat(plugin-chart-country-map): wire up the "Show flying islands" toggle end-to-end
The control was removed earlier because it was a documented no-op — the build pipeline repositioned features per flying_islands.yaml but didn't tag them, so the runtime drop logic had nothing to filter on. Now actually functional: - build.py: apply_flying_islands sets `_flying: true` on every feature it repositions (FRA's 5 DROMs, USA's Hawaii/Alaska/Puerto Rico, ESP Canary Islands, NOR Svalbard, PRT Madeira/Azores, etc.) - controlPanel.tsx: re-add the `show_flying_islands` checkbox (default on, renderTrigger so the projection refits without re-querying) - CountryMap.tsx: filterFeatures drops _flying-tagged features when the toggle is off; fit-to-selection projection automatically zooms to the remaining mainland - types: declare optional `_flying` property - Tests: assert control presence + default value; remove the intentionally-absent assertion - Regenerated 5 admin1 files + the france_overseas composite to embed the new tags (only countries with flying_islands rules differ) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent df479e7 commit 610c435

13 files changed

Lines changed: 70 additions & 40 deletions

File tree

superset-frontend/plugins/plugin-chart-country-map/scripts/build.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,10 @@ def apply_flying_islands(
793793
f["geometry"] = _translate_and_scale(
794794
f["geometry"], offset=offset, scale=scale
795795
)
796+
# Tag the feature so the frontend can drop it at runtime
797+
# via the "Show flying islands" toggle. Without this tag
798+
# the toggle would have nothing to filter on.
799+
props["_flying"] = True
796800
n_repos += 1
797801

798802
# Drop outside bbox — only meaningful at Admin 1 (where each

superset-frontend/plugins/plugin-chart-country-map/src/CountryMap.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ interface FeatureProps {
4040
iso_3166_2?: string;
4141
adm0_a3?: string;
4242
name?: string;
43+
/** Set by the build pipeline on features moved by flying_islands.yaml's
44+
* repositions — drives the "Show flying islands" runtime toggle. */
45+
_flying?: boolean;
4346
[k: string]: unknown;
4447
}
4548

@@ -74,27 +77,31 @@ function featureName(feature: Feature, language: string): string {
7477
return (p[langKey] as string) || p.name || '';
7578
}
7679

80+
/**
7781
/**
7882
* Filter a feature collection by include/exclude lists + the
7983
* flying-islands toggle.
8084
*
8185
* - includes: if non-empty, keep ONLY features whose key is in this list
8286
* - excludes: drop features whose key is in this list
83-
* - showFlyingIslands: when false, drop features tagged as "flying" (the
84-
* build pipeline doesn't currently tag these in feature properties; for
85-
* the POC we treat the flag as a no-op until tagging is added)
87+
* - showFlyingIslands: when false, drop features the build pipeline
88+
* tagged as repositioned (`_flying: true`) — e.g. France's DROMs
89+
* moved into insets near the mainland. Projection auto-refits to
90+
* the remaining features.
8691
*/
8792
function filterFeatures(
8893
features: Feature[],
8994
includes: string[],
9095
excludes: string[],
96+
showFlyingIslands: boolean,
9197
): Feature[] {
9298
const incSet = new Set(includes);
9399
const excSet = new Set(excludes);
94100
return features.filter(f => {
95101
const k = featureKey(f);
96102
if (incSet.size > 0 && !incSet.has(k)) return false;
97103
if (excSet.has(k)) return false;
104+
if (!showFlyingIslands && f.properties?._flying === true) return false;
98105
return true;
99106
});
100107
}
@@ -180,8 +187,14 @@ const CountryMap: FC<CountryMapTransformedProps> = props => {
180187
geo.features as Feature[],
181188
formData.region_includes ?? [],
182189
formData.region_excludes ?? [],
190+
formData.show_flying_islands !== false,
183191
);
184-
}, [geo, formData.region_includes, formData.region_excludes]);
192+
}, [
193+
geo,
194+
formData.region_includes,
195+
formData.region_excludes,
196+
formData.show_flying_islands,
197+
]);
185198

186199
// ---- Color scale -----------------------------------------------------
187200
const colorByKey = useMemo<Record<string, string>>(() => {

superset-frontend/plugins/plugin-chart-country-map/src/data/manifest.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
"usa",
3737
"vnm"
3838
],
39-
"admin_levels": [0, 1],
39+
"admin_levels": [
40+
0,
41+
1
42+
],
4043
"countries_by_worldview": {
4144
"arg": [],
4245
"bdg": [],
@@ -317,7 +320,7 @@
317320
{
318321
"id": "france_overseas",
319322
"worldview": "ukr",
320-
"size_bytes": 322058,
323+
"size_bytes": 322133,
321324
"country": "FRA"
322325
}
323326
]

superset-frontend/plugins/plugin-chart-country-map/src/plugin/controlPanel.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -484,13 +484,24 @@ const config: ControlPanelConfig = {
484484
},
485485
},
486486
],
487-
// `show_flying_islands` is intentionally absent from this control
488-
// set: the build pipeline already repositions known flying-islands
489-
// groups (Hawaii, Alaska, French overseas territories, ...) at
490-
// build time per `flying_islands.yaml`, and the runtime drop
491-
// toggle requires per-feature `_flying: true` tags which the
492-
// build doesn't currently emit. Bringing the control back is a
493-
// single-line follow-up once that tagging lands — see the SIP.
487+
[
488+
{
489+
name: 'show_flying_islands',
490+
config: {
491+
type: 'CheckboxControl',
492+
label: t('Show flying islands'),
493+
description: t(
494+
'When on (default), territories that the build pipeline ' +
495+
'repositioned into insets near the mainland (e.g. ' +
496+
'Hawaii/Alaska for US, French DROMs for France) are ' +
497+
'visible. Turn off to drop those features entirely; the ' +
498+
'projection auto-refits to the remaining mainland.',
499+
),
500+
default: true,
501+
renderTrigger: true,
502+
},
503+
},
504+
],
494505
[
495506
{
496507
name: 'name_language',

superset-frontend/plugins/plugin-chart-country-map/test/plugin/controlPanel.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ const findControl = (name: string) => {
5656

5757
test('all required new controls are present', () => {
5858
const names = allControlNames();
59-
// The full set of controls the redesign introduced. `show_flying_islands`
60-
// is intentionally absent — it's a no-op until the build pipeline tags
61-
// features as flying, and showing a dead toggle was misleading.
6259
for (const required of [
6360
'worldview',
6461
'admin_level',
@@ -67,15 +64,17 @@ test('all required new controls are present', () => {
6764
'composite',
6865
'region_includes',
6966
'region_excludes',
67+
'show_flying_islands',
7068
'name_language',
7169
]) {
7270
expect(names).toContain(required);
7371
}
7472
});
7573

76-
test('show_flying_islands is intentionally absent (no-op until features are tagged)', () => {
77-
const names = allControlNames();
78-
expect(names).not.toContain('show_flying_islands');
74+
test('show_flying_islands defaults to true', () => {
75+
const c = findControl('show_flying_islands');
76+
expect(c).not.toBeNull();
77+
expect(c.default).toBe(true);
7978
});
8079

8180
test('worldview defaults to ukr (Superset editorial choice)', () => {

0 commit comments

Comments
 (0)