Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/shared/MapContainer/MapContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const messages = defineMessages({
id: 'map.activeMap.badge',
defaultMessage: 'Active offline map: {name}',
},
activeMapOnlineBadge: {
id: 'map.activeMap.onlineBadge',
defaultMessage: 'Active map (online): {name}',
},
basemapDisabledHint: {
id: 'map.basemapSwitcher.disabledHint',
defaultMessage: 'Basemap used when offline map is turned off',
Expand Down Expand Up @@ -403,7 +407,7 @@ function MapContainer({
strokeLinecap="round"
/>
</svg>
{intl.formatMessage(messages.activeMapBadge, {
{intl.formatMessage(messages.activeMapOnlineBadge, {
name: activeSavedMap?.name ?? '',
})}
</span>
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,9 @@
"map.activeMap.badge": {
"defaultMessage": "Active offline map: {name}"
},
"map.activeMap.onlineBadge": {
"defaultMessage": "Active map (online): {name}"
},
"map.basemap.label": {
"defaultMessage": "Basemap"
},
Expand Down
1 change: 1 addition & 0 deletions src/i18n/messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,5 +477,6 @@
"theme.light": "Claro",
"theme.system": "Sistema",
"map.activeMap.badge": "Mapa sin conexión activo: {name}",
"map.activeMap.onlineBadge": "Mapa activo (en línea): {name}",
"map.basemapSwitcher.disabledHint": "Mapa base usado cuando el mapa sin conexión está desactivado"
}
1 change: 1 addition & 0 deletions src/i18n/messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,5 +477,6 @@
"theme.light": "Claro",
"theme.system": "Sistema",
"map.activeMap.badge": "Mapa offline ativo: {name}",
"map.activeMap.onlineBadge": "Mapa ativo (online): {name}",
"map.basemapSwitcher.disabledHint": "Mapa base usado quando o mapa offline está desativado"
}
28 changes: 26 additions & 2 deletions src/screens/MapScreen/MapScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,21 @@ export function MapScreen() {
);
useShellSlot(shellSlot);

const hasConfigChanges = useMemo(
() =>
bbox[0] !== DEFAULT_BBOX[0] ||
bbox[1] !== DEFAULT_BBOX[1] ||
bbox[2] !== DEFAULT_BBOX[2] ||
bbox[3] !== DEFAULT_BBOX[3] ||
zoomRange.minZoom !== DEFAULT_ZOOM.minZoom ||
zoomRange.maxZoom !== DEFAULT_ZOOM.maxZoom ||
selectedStyle.id !== DEFAULT_BASEMAP_ID,
[bbox, zoomRange, selectedStyle],
);

function openNameDialog() {
setNameError(null);
setSettingsOpen(false);
setNameDialogOpen(true);
}

Expand Down Expand Up @@ -319,7 +332,11 @@ export function MapScreen() {
<DownloadPanel key={m.id} map={m} />
));
})()}
<Button onClick={openNameDialog} className="w-full">
<Button
onClick={openNameDialog}
className="w-full"
disabled={createMap.isPending || !hasConfigChanges}
>
{intl.formatMessage(mapMessages.saveMap)}
</Button>
</div>
Expand Down Expand Up @@ -424,7 +441,14 @@ export function MapScreen() {
) : null}
{drawMode !== 'draw_rectangle' && (
<div className="absolute bottom-4 right-4 lg:hidden">
<Button size="sm" onClick={openNameDialog}>
{/* Intentionally no !hasConfigChanges guard: this quick action
may save the current/default map view at any time.
Only pending-disable is needed here. */}
<Button
size="sm"
onClick={openNameDialog}
disabled={createMap.isPending}
>
Comment thread
luandro marked this conversation as resolved.
{intl.formatMessage(mapMessages.saveMap)}
</Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,10 @@ describe('MapContainer', () => {
const mapEl = screen.getByTestId('mock-map');
expect(mapEl.dataset.mapStyle).toBe('StyleSpecification');
});
// Should show online active badge
expect(screen.getByTestId('map-online-active-badge')).toBeInTheDocument();
// Should show online active badge with map name
const badge = screen.getByTestId('map-online-active-badge');
expect(badge).toBeInTheDocument();
expect(badge).toHaveTextContent(/Active map.*online.*Draft Map/);
// Should show tooltip on basemap switcher
const trigger = screen.getByTestId('basemap-switcher-trigger');
expect(trigger.getAttribute('title')).toBeTruthy();
Expand Down
Loading
Loading