Hide 'Embed' button for public snippets but in a non-public project or project's snippets visibility is `Only Project Members`
Summary
Snippets of private/internal projects or projects with Snippets visibility set to Only Project Members are not embeddable; however, the UI still shows the Embed button.
Steps to reproduce
- Create a public snippet inside a private project
- On the snippet page, you will see the Embed button. In the end, you won't be able to embed it (404)
What is the current bug behavior?
The Embed button is shown even though the snippet is not embeddable
What is the expected correct behavior?
The Embed button in the snippet page should be hidden for projects where snippets are not viewable
Relevant logs and/or screenshots
Public Snippet in Private Project:
Visiting the javascript file (used for embedding):
Output of checks
This bug happens on GitLab.com
Results of GitLab environment info
Possible fixes
Improve checks for embeddable()
in https://gitlab.com/gitlab-org/gitlab/-/blob/a8ea55db8badde24e8e0e019c65f0320f5b103fd/app/assets/javascripts/snippets/components/show.vue
Edited by Pham Sy Minh