#5201 File history page breadcrumb fixes
Opened 2 years ago by guruprasad. Modified 2 years ago

@@ -63,7 +63,7 @@ 

      <div class="card">

        <div class="card-header">

          <ol class="breadcrumb p-0 bg-transparent mb-0">

-           <li>

+           <li class="breadcrumb-item">

              <a href="{{ url_for('ui_ns.view_tree',

                  repo=repo.name,

                  username=username,
@@ -74,28 +74,22 @@ 

                </span>&nbsp; {{ branchname }}

              </a>

            </li>

-         {% set path = '' %}

          {% for file in filename.split('/') %}

-           {% if loop.first %}

-           {% set path = file %}

+           {% set path = '/'.join(filename.split('/')[:loop.index]) %}

+           {% if loop.last %}

+           {% set path_type = 'file' %}

            {% else %}

-           {% set path = path + '/' + file %}

+           {% set path_type = 'folder' %}

            {% endif %}

-           {% if loop.index != loop.length %}<li><a

-           href="{{ url_for('ui_ns.view_file',

+           <li class="breadcrumb-item">

+             <a href="{{ url_for('ui_ns.view_file',

                  repo=repo.name,

                  username=username,

                  namespace=repo.namespace,

                  identifier=branchname,

                  filename=path | unicode)}}">

-             <span class="fa fa-folder"></span>&nbsp; {{ file }}</a>

+             <span class="fa fa-{{ path_type }}"></span>&nbsp; {{ file }}</a>

            </li>

-           {% elif file %}

-           <li class="active">

-             <span class="fa {% if output_type == 'tree' %}fa-folder{% else %}fa-file{% endif %}">

-             </span>&nbsp; {{ file }}

-           </li>

-           {% endif %}

          {% endfor %}

          </ol>

        </div>

This PR implements the following changes.

  • Fixes the styling of the breadcrumb links in the File history page.
  • Fixes the broken links in the breadcrumb that are more than one level deep. For example, in https://pagure.io/pagure/history/doc/usage/troubleshooting.rst, clicking on the usage link in the breadcrumb opens a page with the Page not found (404) error.
  • Changes the name of the file in the breadcrumb of the File history page to a link to the file. This fixes https://pagure.io/pagure/issue/4793.
  • Simplifies the breadcrumb item generation code since the output_type is hardcoded to "history" in the view that uses the file_history.html template.

Testing instructions:

  • Check out the source branch of this PR in the local Pagure development environment.
  • Open a file that is multiple-levels deep inside a repository.
  • Open the history page of the file.
  • Check and verify that the breadcrumb links properly spaced and separated by /.
  • Verify that the links to the folders and/or files more than one level deep point to the correct pages and that no 404 error is seen when opening those links.
  • Verify that the file name in the breadcrumb of the File history page is a link to the file in the corresponding branch.

rebased onto 236c006976a1d52c1eee06d38cf72a5dc4b93033

2 years ago

rebased onto 61d255f

2 years ago
Metadata