Commit 14334f00 authored by Fernando's avatar Fernando

Add license list to nav

* Add feature flag and permissions check
* Add controller, route, and nav entries

Fix typo

Refactor routes and feature flag

* Change from license_list to licenses_list
* Change from /security/license-list to /licenses

Fix pipeline errors

* remove controller file whitesspace
* regenerate pot file

Fix specs and linter

Update project_nav_tab? call

Add missing new line

Fix haml linter

Code review changes

Update to License Compliance

Update page header

Remove unecessary before action

Remove database.yml.example

Remove license list QA action
parent 8fa09d27
import Vue from 'vue';
import { __ } from '~/locale';
if (gon.features && gon.features.licensesList) {
document.addEventListener(
'DOMContentLoaded',
() =>
new Vue({
el: '#js-licenses-app',
render(createElement) {
return createElement('h1', __('License Compliance'));
},
}),
);
}
# frozen_string_literal: true
module Projects
class LicensesController < Projects::ApplicationController
before_action :authorize_read_licenses_list!
before_action do
push_frontend_feature_flag(:licenses_list)
end
end
end
......@@ -44,6 +44,10 @@ module EE
nav_tabs << :dependencies
end
if can?(current_user, :read_licenses_list, project)
nav_tabs << :licenses
end
if ::Gitlab.config.packages.enabled &&
project.feature_available?(:packages) &&
can?(current_user, :read_package, project)
......@@ -138,6 +142,7 @@ module EE
%w[
projects/security/dashboard#show
projects/dependencies#show
projects/licenses#show
]
end
......@@ -220,6 +225,10 @@ module EE
end
end
def any_project_nav_tab?(tabs)
tabs.any? { |tab| project_nav_tab?(tab) }
end
def settings_operations_available?
return true if super
......
- return unless project_nav_tab?(:security) || project_nav_tab?(:dependencies)
- return unless any_project_nav_tab?([:security, :dependencies, :licenses])
- top_level_link = project_nav_tab?(:security) ? project_security_dashboard_path(@project) : project_dependencies_path(@project)
- top_level_qa_selector = project_nav_tab?(:security) ? 'security_dashboard_link' : 'dependency_list_link'
......@@ -28,3 +28,7 @@
= link_to project_dependencies_path(@project), title: _('Dependency List'), data: { qa_selector: 'dependency_list_link' } do
%span= _('Dependency List')
- if project_nav_tab?(:licenses)
= nav_link(path: 'projects/licenses#show') do
= link_to project_licenses_path(@project), title: _('License Compliance'), data: { qa_selector: 'licenses_list_link' } do
%span= _('License Compliance')
- breadcrumb_title _('License Compliance')
- page_title _('License Compliance')
#js-licenses-app
......@@ -84,6 +84,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
resource :dependencies, only: [:show]
resource :licenses, only: [:show]
namespace :security do
resources :dependencies, only: [:index]
......
# frozen_string_literal: true
require 'spec_helper'
describe Projects::LicensesController do
set(:project) { create(:project, :repository, :private) }
set(:user) { create(:user) }
subject { get :show, params: { namespace_id: project.namespace, project_id: project } }
describe 'GET show' do
context 'with authorized user' do
before do
project.add_developer(user)
sign_in(user)
end
context 'when feature is available' do
before do
stub_licensed_features(licenses_list: true, license_management: true)
end
it 'renders the show template' do
subject
expect(response).to have_gitlab_http_status(200)
expect(response).to render_template(:show)
end
end
context 'when feature is not available' do
it 'returns 404' do
subject
expect(response).to have_gitlab_http_status(404)
end
end
end
context 'with unauthorized user' do
before do
sign_in(user)
end
context 'when feature is available' do
before do
stub_licensed_features(licenses_list: true, license_management: true)
end
it 'returns 404' do
subject
expect(response).to have_gitlab_http_status(404)
end
end
end
context 'with anonymous user' do
it 'returns 302' do
subject
expect(response).to have_gitlab_http_status(302)
expect(response).to redirect_to(new_user_session_path)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment