Skip to content
Merged
14 changes: 14 additions & 0 deletions packages/base/src/commands/BaseCommandIDs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,17 @@ export const selectCompleter = 'jupytergis:selectConsoleCompleter';
export const addAnnotation = 'jupytergis:addAnnotation';
export const zoomToLayer = 'jupytergis:zoomToLayer';
export const downloadGeoJSON = 'jupytergis:downloadGeoJSON';

// Panel toggles
export const toggleLeftPanel = 'jupytergis:toggleLeftPanel';
export const toggleRightPanel = 'jupytergis:toggleRightPanel';

// Left panel tabs
export const showLayersTab = 'jupytergis:showLayersTab';
export const showStacBrowserTab = 'jupytergis:showStacBrowserTab';
export const showFiltersTab = 'jupytergis:showFiltersTab';

// Right panel tabs
export const showObjectPropertiesTab = 'jupytergis:showObjectPropertiesTab';
export const showAnnotationsTab = 'jupytergis:showAnnotationsTab';
export const showIdentifyPanelTab = 'jupytergis:showIdentifyPanelTab';
179 changes: 179 additions & 0 deletions packages/base/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,185 @@ export function addCommands(
icon: targetWithCenterIcon,
});

// Panel visibility commands
commands.addCommand(CommandIDs.toggleLeftPanel, {
label: trans.__('Toggle Left Panel'),
isEnabled: () => Boolean(tracker.currentWidget),
isToggled: () => {
const current = tracker.currentWidget;
return current ? current.model.jgisSettings.jgisLeftPanelVisible : false;
},
execute: async () => {
const current = tracker.currentWidget;
if (!current) {
return;
}

try {
const settings = await current.model.getSettings();

if (settings?.composite) {
const currentValue = settings.composite.jgisLeftPanelVisible ?? true;
await settings.set('jgisLeftPanelVisible', !currentValue);
} else {
const currentValue = current.model.jgisSettings.jgisLeftPanelVisible;
current.model.jgisSettings.jgisLeftPanelVisible = !currentValue;
}

// Optional: emit a signal if you have one for panel changes
// current.model.emitSettingChanged('jgisLeftPanelVisible');

commands.notifyCommandChanged(CommandIDs.toggleLeftPanel);
} catch (err) {
console.error('Failed to toggle Left Panel:', err);
}
},
});

commands.addCommand(CommandIDs.toggleRightPanel, {
label: trans.__('Toggle Right Panel'),
isEnabled: () => Boolean(tracker.currentWidget),
isToggled: () => {
const current = tracker.currentWidget;
return current ? current.model.jgisSettings.jgisRightPanelVisible : false;
},
execute: async () => {
const current = tracker.currentWidget;
if (!current) {
return;
}

try {
const settings = await current.model.getSettings();

if (settings?.composite) {
const currentValue = settings.composite.jgisRightPanelVisible ?? true;
await settings.set('jgisRightPanelVisible', !currentValue);
} else {
const currentValue = current.model.jgisSettings.jgisRightPanelVisible;
current.model.jgisSettings.jgisRightPanelVisible = !currentValue;
}

// Optional: emit a signal if you have one for panel changes
// current.model.emitSettingChanged('jgisRightPanelVisible');

commands.notifyCommandChanged(CommandIDs.toggleRightPanel);
} catch (err) {
console.error('Failed to toggle Right Panel:', err);
}
},
});

// Left panel tabs
commands.addCommand(CommandIDs.showLayersTab, {
label: trans.__('Show Layers Tab'),
isEnabled: () => Boolean(tracker.currentWidget),
isToggled: () =>
tracker.currentWidget?.model.jgisSettings.jgisLeftTabLayers ?? false,
execute: async () => {
const current = tracker.currentWidget;
if (!current) {
return;
}
const settings = await current.model.getSettings();
const currentValue = settings?.composite?.jgisLeftTabLayers ?? false;
await settings.set('jgisLeftTabLayers', !currentValue);
commands.notifyCommandChanged(CommandIDs.showLayersTab);
},
});

commands.addCommand(CommandIDs.showStacBrowserTab, {
label: trans.__('Show STAC Browser Tab'),
isEnabled: () => Boolean(tracker.currentWidget),
isToggled: () =>
tracker.currentWidget?.model.jgisSettings.jgisLeftTabStac ?? false,
execute: async () => {
const current = tracker.currentWidget;
if (!current) {
return;
}
const settings = await current.model.getSettings();
const currentValue = settings?.composite?.jgisLeftTabStac ?? false;
await settings.set('jgisLeftTabStac', !currentValue);
commands.notifyCommandChanged(CommandIDs.showStacBrowserTab);
},
});

commands.addCommand(CommandIDs.showFiltersTab, {
label: trans.__('Show Filters Tab'),
isEnabled: () => Boolean(tracker.currentWidget),
isToggled: () =>
tracker.currentWidget?.model.jgisSettings.jgisLeftTabFilters ?? false,
execute: async () => {
const current = tracker.currentWidget;
if (!current) {
return;
}
const settings = await current.model.getSettings();
const currentValue = settings?.composite?.jgisLeftTabFilters ?? false;
await settings.set('jgisLeftTabFilters', !currentValue);
commands.notifyCommandChanged(CommandIDs.showFiltersTab);
},
});

// Right panel tabs
commands.addCommand(CommandIDs.showObjectPropertiesTab, {
label: trans.__('Show Object Properties Tab'),
isEnabled: () => Boolean(tracker.currentWidget),
isToggled: () =>
tracker.currentWidget?.model.jgisSettings.jgisRightTabObjectProperties ??
false,
execute: async () => {
const current = tracker.currentWidget;
if (!current) {
return;
}
const settings = await current.model.getSettings();
const currentValue =
settings?.composite?.jgisRightTabObjectProperties ?? false;
await settings.set('jgisRightTabObjectProperties', !currentValue);
commands.notifyCommandChanged(CommandIDs.showObjectPropertiesTab);
},
});

commands.addCommand(CommandIDs.showAnnotationsTab, {
label: trans.__('Show Annotations Tab'),
isEnabled: () => Boolean(tracker.currentWidget),
isToggled: () =>
tracker.currentWidget?.model.jgisSettings.jgisRightTabAnnotations ??
false,
execute: async () => {
const current = tracker.currentWidget;
if (!current) {
return;
}
const settings = await current.model.getSettings();
const currentValue =
settings?.composite?.jgisRightTabAnnotations ?? false;
await settings.set('jgisRightTabAnnotations', !currentValue);
commands.notifyCommandChanged(CommandIDs.showAnnotationsTab);
},
});

commands.addCommand(CommandIDs.showIdentifyPanelTab, {
label: trans.__('Show Identify Panel Tab'),
isEnabled: () => Boolean(tracker.currentWidget),
isToggled: () =>
tracker.currentWidget?.model.jgisSettings.jgisRightTabIdentifyPanel ??
false,
execute: async () => {
const current = tracker.currentWidget;
if (!current) {
return;
}
const settings = await current.model.getSettings();
const currentValue =
settings?.composite?.jgisRightTabIdentifyPanel ?? false;
await settings.set('jgisRightTabIdentifyPanel', !currentValue);
commands.notifyCommandChanged(CommandIDs.showIdentifyPanelTab);
},
});

loadKeybindings(commands, keybindings);
}

Expand Down
72 changes: 42 additions & 30 deletions packages/base/src/panelview/leftpanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,58 +33,70 @@ export const LeftPanel: React.FC<ILeftPanelProps> = (
) => {
const hideStacPanel = PageConfig.getOption('HIDE_STAC_PANEL') === 'true';

const settings = props.model.jgisSettings;
const leftPanelVisible = settings?.jgisLeftPanelVisible ?? true;

if (!leftPanelVisible) {
return null;
}

const tabInfo = [
{ name: 'layers', title: 'Layers' },
...(hideStacPanel ? [] : [{ name: 'stac', title: 'Stac Browser' }]),
{ name: 'filters', title: 'Filters' },
];
settings?.jgisLeftTabLayers ? { name: 'layers', title: 'Layers' } : null,
settings?.jgisLeftTabStac && !hideStacPanel
? { name: 'stac', title: 'Stac Browser' }
: null,
settings?.jgisLeftTabFilters ? { name: 'filters', title: 'Filters' } : null,
].filter(Boolean) as { name: string; title: string }[];

const [curTab, setCurTab] = React.useState<string | undefined>(
tabInfo[0].name,
tabInfo.length > 0 ? tabInfo[0].name : undefined,
);

return (
<div className="jgis-left-panel-container">
<PanelTabs curTab={curTab} className="jgis-panel-tabs">
<TabsList>
{tabInfo.map(e => {
return (
<TabsTrigger
className="jGIS-layer-browser-category"
value={e.name}
{tabInfo.map(e => (
<TabsTrigger
className="jGIS-layer-browser-category"
value={e.name}
onClick={() => {
if (curTab !== e.name) {
setCurTab(e.name);
} else {
setCurTab('');
}
}}
>
{e.title}
</TabsTrigger>
);
})}
>
{e.title}
</TabsTrigger>
))}
</TabsList>
<TabsContent
value="layers"
className="jgis-panel-tab-content jp-gis-layerPanel"
>
<LayersBodyComponent
model={props.model}
commands={props.commands}
state={props.state}

{settings?.jgisLeftTabLayers && (
<TabsContent
value="layers"
className="jgis-panel-tab-content jp-gis-layerPanel"
>
<LayersBodyComponent
model={props.model}
commands={props.commands}
state={props.state}
></LayersBodyComponent>
</TabsContent>
</TabsContent>
)}

{!hideStacPanel && (
<TabsContent value="stac">
<StacPanel model={props.model}></StacPanel>
{settings?.jgisLeftTabStac && !hideStacPanel && (
<TabsContent value="stac" className="jgis-panel-tab-content">
<StacPanel model={props.model} />
</TabsContent>
)}

<TabsContent value="filters" className="jgis-panel-tab-content">
<FilterComponent model={props.model}></FilterComponent>,
</TabsContent>
{settings?.jgisLeftTabFilters && (
<TabsContent value="filters" className="jgis-panel-tab-content">
<FilterComponent model={props.model}></FilterComponent>
</TabsContent>
)}
</PanelTabs>
</div>
);
Expand Down
Loading
Loading