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
This commit is contained in:
Filipa Lacerda 2018-12-10 12:03:00 +00:00 committed by Alessio Caiazza
parent a30491158a
commit 9004e18e6e
8 changed files with 57 additions and 6 deletions

View file

@ -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'));

View file

@ -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

View file

@ -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
]

View file

@ -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')

View file

@ -0,0 +1,5 @@
- @no_container = true
- page_title _('Releases')
%div{ 'class' => container_class }
#js-releases-page

View file

@ -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]

View file

@ -5506,6 +5506,9 @@ msgstr ""
msgid "Related merge requests"
msgstr ""
msgid "Releases"
msgstr ""
msgid "Remind later"
msgstr ""

View file

@ -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