Fix creating permalink with shortcut key "y"
What does this MR do and why?
- Keep ShortcutsBlob class to minimum and have it only add a shortcut.
-
moveToFilePermalink()andshortcircuitPermalinkButtons()become utility functions - I decided to keep the functions still in
app/assets/javascripts/behaviors/shortcuts/shortcuts_blob.jsfile, because they need to be reused in Vue and JS version of Blob, and still relate toShortcutsBlobclass - Querying of the permalink button and url is done on the spot, inside utility functions to avoid instantiating a shortcuts class with data that becomes outdated after user navigates to a different file
- As a bonus, we don't have to manipulate the url for specific lines, because it query for it, when the line hash is already present in the button's
hrefattribute
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
| Before | After |
|---|---|
| Screen_Recording_2024-05-28_at_14.46.51 | Screen_Recording_2024-05-28_at_14.46.00 |
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Open a project of choice
- Navigate to Repository and select a file to view
- When viewing a file, use
ykey to get the permalink. The url in your browser should update, for example fromhttp://gdk.test:8080/flightjs/Flight/-/blob/master/CONTRIBUTING.md?ref_type=headstohttp://gdk.test:8080/flightjs/Flight/-/blob/67f1ed1d2e7dfc9357cc82e3bc2bde2403264021/CONTRIBUTING.md - Navigate back to the project overview with the browser "Go back" button.
- Select a different file.
- Use
ykey and make sure that the url changed and it contains the name of the file you're currently viewing (not the previous one). - You should be able to repeat these steps and use Permalink button in the top right corner, to get the same urls.
Related to #454667 (closed)
Edited by Paulina Sedlak-Jakubowska