diff options
author | Vasilii Iakliushin <viakliushin@gitlab.com> | 2021-01-12 18:52:03 +0300 |
---|---|---|
committer | Vasilii Iakliushin <viakliushin@gitlab.com> | 2021-01-12 18:52:03 +0300 |
commit | fd7ff36b13975408591f24c3e85ceab2969582e3 (patch) | |
tree | 30382d14c621589b3b9ef08bed351f4cd2bdb8f6 /layouts | |
parent | a75621454ed1df6425afa7ff7a08d44b350e92a6 (diff) |
Remove previous versions from dropdown for omnibus packages
We discovered that dropdown displays previous versions when deployed
in Omnibus.
Changes:
* Extract common functionality into a partial or a helper
* Add `display_previous_versions?` method to hide previous versions
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/versions_list.html | 20 | ||||
-rw-r--r-- | layouts/versions_dropdown.html | 88 |
2 files changed, 38 insertions, 70 deletions
diff --git a/layouts/partials/versions_list.html b/layouts/partials/versions_list.html new file mode 100644 index 00000000..549f1d13 --- /dev/null +++ b/layouts/partials/versions_list.html @@ -0,0 +1,20 @@ +<!-- + If we are on the archives page, the link here is hardcoded to always + point to `/archives/`. If you visit https://docs.gitlab.com/archives/ + and select a version from the dropdown, that version's archives page + will be shown. We want to always show the latest archives page as it + contains all current versions and offline archives. +--> +<% if archives? %> +<li> + <a href='/archives/'> + <%= version %> + </a> +</li> +<% else %> +<li> + <a<%= active_dropdown(version) %> href='/<%= version %><%= @item.identifier.without_ext + '.html' %>'> + <%= version %> + </a> +</li> +<% end %> diff --git a/layouts/versions_dropdown.html b/layouts/versions_dropdown.html index d6a47c8c..74fac920 100644 --- a/layouts/versions_dropdown.html +++ b/layouts/versions_dropdown.html @@ -1,14 +1,6 @@ -<% -latest_stable = @items['/_data/versions.yaml'][:online].first -next_major = latest_stable.split('.').first -next_minor = "#{latest_stable.split('.').last.to_i + 1}" -next_version = "#{next_major}.#{next_minor}" -dotcom = "GitLab.com (#{next_version}-pre)" -%> <!-- versions dropdown--> -<div class="choose-version"> -Version -</div> +<div class="choose-version">Version</div> + <div class="dropdown"> <a role="button" class="btn btn-versions dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="versions" href="#"> <!-- @@ -21,19 +13,8 @@ Version - The branch name otherwise. For local development and review apps, show "Versions". --> - <% if archives? %> - Archives - <% else %> - <% if production? %> - <% if ENV['CI_COMMIT_REF_NAME'] == ENV['CI_DEFAULT_BRANCH'] %> - <%= dotcom %> - <% else %> - <%= ENV['CI_COMMIT_REF_NAME'] %> - <% end %> - <% else %> - Versions - <% end %> - <% end %> + <%= version_dropdown_title %> + <span class="caret"></span> </a> <ul class="dropdown-menu versions-menu" aria-labelledby="versions"> @@ -42,56 +23,23 @@ Version <i class="fa fa-question-circle-o" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Latest pre-release version of GitLab, with features available or about to become available on GitLab.com. For self-managed GitLab installations, select your version number as listed at your GitLab instance's /help URL."></i> </a> </li> - <!-- Start of online versions --> - <li class="dropdown-divider"></li> - <% @items['/_data/versions.yaml'][:online].each do |version| %> - <!-- - If we are on the archives page, the link here is hardcoded to always - point to `/archives/`. If you visit https://docs.gitlab.com/archives/ - and select a version from the dropdown, that version's archives page - will be shown. We want to always show the latest archives page as it - contains all current versions and offline archives. - --> - <% if archives? %> - <li> - <a href='/archives/'> - <%= version %> - </a> - </li> - <% else %> - <li> - <a<%= active_dropdown(version) %> href='/<%= version %><%= @item.identifier.without_ext + '.html' %>'> - <%= version %> - </a> - </li> + + <% if display_previous_versions? %> + <!-- Start of online versions --> + <li class="dropdown-divider"></li> + <% data_versions[:online].each do |version| %> + <%= render '/partials/versions_list.*', version: version %> <% end %> - <% end %> - <!-- End of online versions --> - <!-- Start of last major versions --> - <li class="dropdown-divider"></li> - <% @items['/_data/versions.yaml'][:previous_majors].each do |version| %> - <!-- - If we are on the archives page, the link here is hardcoded to always - point to `/archives/`. If you visit https://docs.gitlab.com/archives/ - and select a version from the dropdown, that version's archives page - will be shown. We want to always show the latest archives page as it - contains all current versions and offline archives. - --> - <% if archives? %> - <li> - <a href='/archives/'> - <%= version %> - </a> - </li> - <% else %> - <li> - <a<%= active_dropdown(version) %> href='/<%= version %><%= @item.identifier.without_ext + '.html' %>'> - <%= version %> - </a> - </li> + <!-- End of online versions --> + + <!-- Start of last major versions --> + <li class="dropdown-divider"></li> + <% data_versions[:previous_majors].each do |version| %> + <%= render '/partials/versions_list.*', version: version %> <% end %> + <!-- End of last major versions --> <% end %> - <!-- End of last major versions --> + <li class="dropdown-divider"></li> <li><a<%= active_dropdown('archives') %> href='/archives/'>Archives</a></li> </ul> |