Skip to content

[Map layers]: add offlineMode option to MapLayerOptions - #1831

Merged
mdastous-bentley merged 9 commits into
iTwin:masterfrom
rowmanempire:map-layers/read-only-option
Oct 21, 2026
Merged

mdastous-bentley merged 9 commits into
iTwin:masterfrom
rowmanempire:map-layers/read-only-option

Conversation

@rowmanempire

@rowmanempire rowmanempire commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an optional MapLayerOptions.offlineMode flag so desktop apps can keep the Map Layers widget visible while offline instead of hiding it.

Today iTwin Studio hides the widget when offline, because attach, base map provider change, sign-in and map settings need the network. With offlineMode: true:

Kept Hidden / disabled
Map layers on/off switch Attach layer buttons
Layer visibility, Show all / Hide all / Invert Map settings popup
Base map visibility, transparency, color Base map provider select (disabled)
Layer transparency, Zoom to layer, sub-layer visibility Detach (toolbar, checkboxes, layer menu)
Sign-in (RequireAuth) buttons
Drag reorder

Map layer sources (MapLayerSources.create, MapLayerPreferences.getSources) are not loaded in offline mode; they load again when the flag switches back to false.

Compatibility

offlineMode is optional and defaults to false; no existing behavior, props or exports change. A test covers that all actions are still shown when it is not set.

Usage

<MapLayersWidget mapLayerOptions={{ offlineMode: !isOnline }} />

Open question

Should offline mode allow switching the base map to "Color fill" (works offline)? This PR disables the provider select entirely to keep the change minimal.

Testing

  • New tests in MapLayerManager.test.tsx (offline mode: hidden actions, layer menu, visibility controls, no source loading, default unchanged).
  • pnpm build, pnpm test, pnpm lint, pnpm format, cspell pass locally.

@CLAassistant

CLAassistant commented Oct 9, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rowmanempire
rowmanempire marked this pull request as ready for review October 9, 2026 18:51
Copilot AI balanced review requested due to automatic review settings October 9, 2026 18:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An in-flight source request can continue after switching to read-only mode, violating the offline-loading guarantee.

4 open findings
What changed in this PR

Adds an optional read-only mode to keep Map Layers usable offline while preventing network-dependent configuration changes.

Changes:

  • Hides or disables attach, detach, sign-in, reorder, settings, and provider controls.
  • Preserves visibility, transparency, zoom, color, and sub-layer controls.
  • Skips source loading and adds read-only tests and documentation.
File Description
MapLayersList.tsx Hides attach controls.
MapLayerSettingsMenu.tsx Hides detach action.
MapLayerManager.tsx Propagates read-only state.
MapLayerItem.tsx Hides selection and authentication controls.
MapLayerDroppable.tsx Disables reordering and attachment.
MapLayerActionButtons.tsx Hides selection and bulk detach.
BasemapPanel.tsx Disables provider selection.
Interfaces.ts Defines the public option.
useMapLayerSources.ts Skips source loading.
MapLayerManager.test.tsx Tests read-only behavior.
Changeset Documents the new option.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mdastous-bentley mdastous-bentley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 readOnly  is understandable, but a bit misleading: the widget still lets users change map-layer visibility, transparency, and other display state. “Read-only” usually suggests no changes at all.

offlineMode is a reasonable alternative if the intent is specifically to support offline apps, though it describes the use case rather than the behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rowmanempire rowmanempire changed the title [Map layers]: add readOnly option to MapLayerOptions [Map layers]: add offlineMode option to MapLayerOptions Oct 21, 2026
@rowmanempire

rowmanempire commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

@mdastous-bentley Good point

@mdastous-bentley
mdastous-bentley merged commit 161d005 into iTwin:master Oct 21, 2026
12 checks passed
@imodeljs-admin imodeljs-admin mentioned this pull request Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants