diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 348d849a..f11054bb 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -1023,11 +1023,7 @@ U.Map = L.Map.extend({ this.options.umap_id = data.id this.permissions.setOptions(data.permissions) this.permissions.commit() - if ( - data.permissions && - data.permissions.anonymous_edit_url && - this.options.urls.map_send_edit_link - ) { + if (data.permissions && data.permissions.anonymous_edit_url) { alert.duration = Infinity alert.content = L._( @@ -1035,12 +1031,6 @@ U.Map = L.Map.extend({ ) + `
${data.permissions.anonymous_edit_url}` alert.actions = [ - { - label: L._('Send me the link'), - input: L._('Email'), - callback: this.sendEditLink, - callbackContext: this, - }, { label: L._('Copy link'), callback: () => { @@ -1053,6 +1043,14 @@ U.Map = L.Map.extend({ callbackContext: this, }, ] + if (this.options.urls.map_send_edit_link) { + alert.actions.push({ + label: L._('Send me the link'), + input: L._('Email'), + callback: this.sendEditLink, + callbackContext: this, + }) + } } } else if (!this.permissions.isDirty) { // Do not override local changes to permissions, diff --git a/umap/tests/integration/test_anonymous_owned_map.py b/umap/tests/integration/test_anonymous_owned_map.py index 74f3f0e7..0a92e523 100644 --- a/umap/tests/integration/test_anonymous_owned_map.py +++ b/umap/tests/integration/test_anonymous_owned_map.py @@ -203,3 +203,23 @@ def test_email_sending_error_are_catched(tilelayer, page, live_server): alert.get_by_role("button", name="Send me the link").click() assert patched.called expect(alert.get_by_text("Can't send email to foo@bar.com")).to_be_visible() + + +def test_alert_message_after_create_show_link_even_without_mail( + tilelayer, live_server, page, monkeypatch, settings +): + # Disable email + settings.DEFAULT_FROM_EMAIL = None + page.goto(f"{live_server.url}/en/map/new") + with page.expect_response(re.compile(r".*/map/create/")): + page.get_by_role("button", name="Save").click() + alert = page.locator(".umap-alert") + expect(alert).to_be_visible() + expect( + alert.get_by_text( + "Your map has been created! As you are not logged in, here is your secret " + "link to edit the map, please keep it safe:" + ) + ).to_be_visible() + expect(alert.get_by_role("button", name="Copy")).to_be_visible() + expect(alert.get_by_role("button", name="Send me the link")).to_be_hidden()