Buttons on new Geo Nodes don't work when GitLab uses a relative path
This is a regression coming from https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/3902/diffs.
In ee/app/assets/javascripts/geo_nodes/constants.js
, we hard code NODE_ACTION_BASE_PATH = '/admin/geo_nodes/'
, and we use this value in ee/app/assets/javascripts/geo_nodes/components/geo_node_actions.vue
inside an a
tag href
attribute.
These buttons will not work as intended when GitLab is configured to run at a relative path, like company.com/gitlab/
instead of gitlab.company.com/
, in which case the correct href
would be /<relative root>/admin/geo_nodes
, not /admin/geo_nodes
.
I wonder why we decided to hard code paths in JS. I think we should use the Rails-provided URL/path helpers, and pass the values to the frontend inside the GeoNode
JSON, or using data-attributes in the view.
We could also use gon.relative_url_root
, but I'd generally like to recommend against hard coded paths, to simplify changing things down the line. A bug like the one fixed in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4186 also wouldn't have appeared in the first place if we had used URL/path helpres!
/cc @timzallmann @kushalpandya @jramsay
/cc @digitalmoksha