[FIX] website: properly warn users of Google API errors

Before this commit, when adding a google map snippet in the DOM, the
user was asked for its API key if not already configured, thanks to an
user-friendly dialog. However, in the case it was misconfigured (while
the editor dialog prevents some misconfiguration, configuration via the
backend allow any random key to be given), the UX was terrible: the
google map is simply removed without any notification.

Misconfiguration can be:
- Invalid API key
- "Maps JavaScript API", "Places API" or "Maps Static API" not enabled
- Billing not enabled

Now notifications/messages warn about those things and reopens the key
configuration dialog, which contains links to the gmap API documentation
and now more information.
Hopefully, this can be improved even further later. Indeed, this is
still not perfect as there is no reliable way to understand google
responses. E.g. even with the three mentioned API and billing enabled,
sometimes the google map API still returns errors indicating "not
enabled APIs" but it cannot be reproduced reliably. During my test it
was systematic for 15min at some point but now there is none, ever. Like
if there was a delay after enabling an API on the google console before
it stops sending errors... although the API works immediately.

Notice that in 15.0, this snippet is shown in debug mode only and we
encourage users to use the new "Map" snippet which does not require any
configuration.

opw-2976261

X-original-commit: d9f86840e27463ccf370a748cafc7c4be32f901f
Part-of: odoo/odoo#106103
This commit is contained in:
qsm-odoo
2022-11-21 21:18:57 +01:00
parent f0ca3f32d2
commit d5ab890f23
3 changed files with 169 additions and 58 deletions
@@ -132,6 +132,25 @@
Enable billing on your Google Project
</a>
</div>
<div class="alert alert-info mb-0 mt-3">
Make sure your settings are properly configured:
<ul class="mb-0">
<li>
Enable the right google map APIs in your google account
<ul>
<li>Maps Static API</li>
<li>Maps JavaScript API</li>
<li>Places API</li>
</ul>
</li>
<li>
Make sure billing is enabled
</li>
<li>
Make sure to wait if errors keep being shown: sometimes enabling an API allows to use it immediately but Google keeps triggering errors for a while
</li>
</ul>
</div>
</div>
</div>
</div>