From 9004e18e6e0bca3deb7115b16e345f9755c012f3 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Mon, 10 Dec 2018 12:03:00 +0000 Subject: [PATCH] Adds releases index route Renders empty index page Adds Releases entry to the navigation bar behind a feature flag Renders 404 when feature flag for releases is not enabled --- .../shortcuts/shortcuts_navigation.js | 1 + .../projects/releases_controller.rb | 16 +++++++++--- app/helpers/projects_helper.rb | 4 +-- .../layouts/nav/sidebar/_project.html.haml | 7 ++++- app/views/projects/releases/index.html.haml | 5 ++++ config/routes/project.rb | 1 + locale/gitlab.pot | 3 +++ .../nav/sidebar/_project.html.haml_spec.rb | 26 +++++++++++++++++++ 8 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 app/views/projects/releases/index.html.haml diff --git a/app/assets/javascripts/behaviors/shortcuts/shortcuts_navigation.js b/app/assets/javascripts/behaviors/shortcuts/shortcuts_navigation.js index fa9b2c9f755..bef1553703b 100644 --- a/app/assets/javascripts/behaviors/shortcuts/shortcuts_navigation.js +++ b/app/assets/javascripts/behaviors/shortcuts/shortcuts_navigation.js @@ -8,6 +8,7 @@ export default class ShortcutsNavigation extends Shortcuts { Mousetrap.bind('g p', () => findAndFollowLink('.shortcuts-project')); Mousetrap.bind('g v', () => findAndFollowLink('.shortcuts-project-activity')); + Mousetrap.bind('g r', () => findAndFollowLink('.shortcuts-project-releases')); Mousetrap.bind('g f', () => findAndFollowLink('.shortcuts-tree')); Mousetrap.bind('g c', () => findAndFollowLink('.shortcuts-commits')); Mousetrap.bind('g j', () => findAndFollowLink('.shortcuts-builds')); diff --git a/app/controllers/projects/releases_controller.rb b/app/controllers/projects/releases_controller.rb index 55827075896..c3d8f8a8d75 100644 --- a/app/controllers/projects/releases_controller.rb +++ b/app/controllers/projects/releases_controller.rb @@ -4,9 +4,13 @@ class Projects::ReleasesController < Projects::ApplicationController # Authorize before_action :require_non_empty_project before_action :authorize_download_code! - before_action :authorize_push_code! - before_action :tag - before_action :release + before_action :authorize_push_code!, except: [:index] + before_action :tag, except: [:index] + before_action :release, except: [:index] + before_action :check_releases_page_feature_flag, only: [:index] + + def index + end def edit end @@ -26,6 +30,12 @@ class Projects::ReleasesController < Projects::ApplicationController private + def check_releases_page_feature_flag + return render_404 unless Feature.enabled?(:releases_page) + + push_frontend_feature_flag(:releases_page) + end + def tag @tag ||= @repository.find_tag(params[:tag_id]) end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 1186eb3ddcc..aa54172e108 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -277,7 +277,7 @@ module ProjectsHelper nav_tabs = [:home] if !project.empty_repo? && can?(current_user, :download_code, project) - nav_tabs << [:files, :commits, :network, :graphs, :forks] + nav_tabs << [:files, :commits, :network, :graphs, :forks, :releases] end if project.repo_exists? && can?(current_user, :read_merge_request, project) @@ -533,6 +533,7 @@ module ProjectsHelper %w[ projects#show projects#activity + releases#index cycle_analytics#show ] end @@ -564,7 +565,6 @@ module ProjectsHelper projects/repositories tags branches - releases graphs network ] diff --git a/app/views/layouts/nav/sidebar/_project.html.haml b/app/views/layouts/nav/sidebar/_project.html.haml index bdd0108db0d..59557c70904 100644 --- a/app/views/layouts/nav/sidebar/_project.html.haml +++ b/app/views/layouts/nav/sidebar/_project.html.haml @@ -29,6 +29,11 @@ = link_to activity_project_path(@project), title: _('Activity'), class: 'shortcuts-project-activity' do %span= _('Activity') + - if project_nav_tab?(:releases) && Feature.enabled?(:releases_page) + = nav_link(controller: :releases) do + = link_to project_releases_path(@project), title: _('Releases'), class: 'shortcuts-project-releases' do + %span= _('Releases') + = render_if_exists 'projects/sidebar/security_dashboard' - if can?(current_user, :read_cycle_analytics, @project) @@ -62,7 +67,7 @@ = link_to project_branches_path(@project) do = _('Branches') - = nav_link(controller: [:tags, :releases]) do + = nav_link(controller: [:tags]) do = link_to project_tags_path(@project) do = _('Tags') diff --git a/app/views/projects/releases/index.html.haml b/app/views/projects/releases/index.html.haml new file mode 100644 index 00000000000..7bc942a3c3c --- /dev/null +++ b/app/views/projects/releases/index.html.haml @@ -0,0 +1,5 @@ +- @no_container = true +- page_title _('Releases') + +%div{ 'class' => container_class } + #js-releases-page diff --git a/config/routes/project.rb b/config/routes/project.rb index 7d0623cb904..03c95b61e51 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -95,6 +95,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do end end + resources :releases, only: [:index] resources :forks, only: [:index, :new, :create] resource :import, only: [:new, :create, :show] diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 8a7db438add..9f9844e2140 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -5506,6 +5506,9 @@ msgstr "" msgid "Related merge requests" msgstr "" +msgid "Releases" +msgstr "" + msgid "Remind later" msgstr "" diff --git a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb index 98d4456b277..ec20c346234 100644 --- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb +++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb @@ -49,4 +49,30 @@ describe 'layouts/nav/sidebar/_project' do expect(rendered).to have_css('.sidebar-top-level-items > li.active', text: 'Registry') end end + + describe 'releases entry' do + describe 'when releases feature flag is disabled' do + before do + stub_feature_flags(releases_page: false) + end + + it 'does not render releases link' do + render + + expect(rendered).not_to have_link('Releases', href: project_releases_path(project)) + end + end + + describe 'when releases feature flags is enabled' do + before do + stub_feature_flags(releases_page: true) + end + + it 'renders releases link' do + render + + expect(rendered).to have_link('Releases', href: project_releases_path(project)) + end + end + end end