fix: hide "my profile" from dropdown menu if ALLOW_EDIT_PROFILE=False

This commit is contained in:
Yohan Boniface 2024-10-04 17:54:13 +02:00
parent 6876bb1ba5
commit 21be2e4fd0
3 changed files with 12 additions and 6 deletions

View file

@ -5,10 +5,14 @@ export default class URLs {
this.urls = serverUrls
}
has(urlName) {
return urlName in this.urls
}
get(urlName, params) {
if (typeof this[urlName] === 'function') return this[urlName](params)
if (this.urls.hasOwnProperty(urlName)) {
if (this.has(urlName)) {
return template(this.urls[urlName], params)
}
throw `Unable to find a URL for route ${urlName}`

View file

@ -654,10 +654,6 @@ const ControlsMixin = {
label: L._('New map'),
action: this.urls.get('map_new'),
},
{
label: L._('My profile'),
action: this.urls.get('user_profile'),
},
{
label: L._('My maps'),
action: this.urls.get('user_dashboard'),
@ -667,6 +663,12 @@ const ControlsMixin = {
action: this.urls.get('user_teams'),
},
]
if (this.urls.has('user_profile')) {
actions.push({
label: L._('My profile'),
action: this.urls.get('user_profile'),
})
}
button.addEventListener('click', () => {
const x = button.offsetLeft
const y = button.offsetTop + button.offsetHeight

View file

@ -94,4 +94,4 @@ def test_login_from_map_page(live_server, page, tilelayer, settings, user, conte
# Save should have proceed
assert Map.objects.count() == 1
# Use name should now appear on the header toolbar
expect(page.get_by_text("My Dashboard (Joe)")).to_be_visible()
expect(page.get_by_role("button", name="Joe")).to_be_visible()