fix(maps): let users and admins enter a CARTO API key (#2060)

CARTO stamps an "API KEY REQUIRED" watermark onto every basemap tile
fetched without a key since 26.08.2026, and both CartoDB presets plus the
built-in fallback are CARTO. The key is free and needs no account, so add
it as a setting rather than dropping the provider.

carto_api_key sits next to mapbox_access_token: per user in Settings/Map,
instance-wide under Admin/User Defaults, encrypted at rest, injected from
CARTO_API_KEY on managed instances. Unlike Mapbox it never switches the
map provider, since a raster key says nothing about the renderer.

The key is appended as ?key= at render time instead of being stored in the
template, so a saved URL stays portable and survives a rotation. That is
also what reaches the four maps that pinned CARTO and ignored the user's
tile setting: atlas, collections, the public trip share and the public
journey. The two share pages read it from their token-gated payload, the
same way baseCurrency already travels.

Also lifts the release notice above page chrome. Its overlay sat at
z-index 50, under the Vacay mode toolbar at 61, so the dialog was neither
on top nor modal. Adds a six-step layer scale to index.css and moves the
three notice shells onto it.

Closes #2054
Closes #2052
This commit is contained in:
Maurice
2026-08-27 12:06:55 +02:00
committed by GitHub
parent 521e52c853
commit 1f66ef1d32
99 changed files with 1258 additions and 67 deletions
@@ -1,4 +1,4 @@
// FE-MOB-MDUS-001 to FE-MOB-MDUS-024
// FE-MOB-MDUS-001 to FE-MOB-MDUS-027
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { render, screen, waitFor, within, fireEvent } from '../../../helpers/render';
import userEvent from '@testing-library/user-event';
@@ -48,6 +48,11 @@ function resetLink(label: string): HTMLElement {
return within(holder).getByRole('button', { name: 'reset' });
}
/** The CARTO key input sits under its label inside the field's own wrapper. */
function cartoInput(): HTMLInputElement {
return within(screen.getByText('Shared CARTO key').parentElement as HTMLElement).getByRole('textbox');
}
describe('MAdminDefaultUserSettings', () => {
beforeEach(() => {
resetAllStores();
@@ -376,4 +381,41 @@ describe('MAdminDefaultUserSettings', () => {
expect(screen.queryByText('Reset to built-in default')).not.toBeInTheDocument();
expect(screen.getByRole('tab', { name: '°C Celsius' })).toHaveAttribute('aria-selected', 'true');
});
it('FE-MOB-MDUS-025: the shared CARTO key is stored on blur and cleared by its reset link', async () => {
const user = userEvent.setup();
const { puts } = stubDefaults({ carto_api_key: 'ck.old' });
render(<MAdminDefaultUserSettings />);
await screen.findByText('Shared CARTO key');
const input = cartoInput();
expect(input).toHaveValue('ck.old');
await user.clear(input);
await user.type(input, 'ck.new');
input.blur();
await waitFor(() => expect(puts).toEqual([{ carto_api_key: 'ck.new' }]));
await user.click(resetLink('Shared CARTO key'));
await waitFor(() => expect(puts).toHaveLength(2));
expect(puts[1]).toEqual({ carto_api_key: null });
await waitFor(() => expect(cartoInput()).toHaveValue(''));
});
it('FE-MOB-MDUS-026: a managed instance brings its own CARTO key and hides the field', async () => {
seedStore(useAuthStore, { isAuthenticated: true, user: buildAdmin(), managed: true });
stubDefaults({ carto_api_key: 'ck.hoster' });
render(<MAdminDefaultUserSettings />);
await screen.findByText('Default User Settings');
expect(screen.queryByText('Shared CARTO key')).not.toBeInTheDocument();
});
it('FE-MOB-MDUS-027: a managed instance hides the shared Mapbox token as well', async () => {
seedStore(useAuthStore, { isAuthenticated: true, user: buildAdmin(), managed: true });
stubDefaults({ map_provider: 'mapbox-gl', mapbox_access_token: 'pk.hoster' });
render(<MAdminDefaultUserSettings />);
await screen.findByText('Map style');
expect(screen.queryByText('Shared Mapbox token')).not.toBeInTheDocument();
});
});