Preview new files before committing them
What does this MR do and why?
Implements Add preview for new markup files (#15501), a decade-old feature request.
Add the same Write and Preview tabs the edit page has to the new file page.
The edit page's preview machinery carries over as is:
the renderer is picked from the file name in the editor (Follow mid-edit renames in the preview renderer (!251790 - merged)),
and the live preview follows the Markdown extensions currently loaded (Follow mid-edit renames to Markdown in the "Pre... (!250889 - merged)),
so the frontend (edit_blob.js) needs no changes.
That leaves the view and the controller: add the tabs to the view,
and make the preview action, which assumed a committed blob,
work without one (new files, empty repositories).
Build on
Screen recordings
Manually verified in GDK-in-a-box:
How to set up and validate locally
- Open a directory in a repository and select + > New file, then enter
* Now you see meas the content - Name the file
README.mdand click Preview — the Markdown live preview opens - Rename it to
README.organd click Preview — the content renders as an Org-mode heading - Rename it to
README.txtand click Preview — a diff with every line added
Notes
- Backend engineer, but fairly new to Rails. Feedback on Rails conventions welcome.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.