Refactor debug view
Avoid logic in ERB and use helpers
Merge pull request #17873 from kirs/refactor-debug-erb

Refactor debug view