Commit 78a8d475 authored by Jarek Ostrowski's avatar Jarek Ostrowski Committed by Sean McGivern

Move license button to project buttons

Make license_anchor_data a link
Add changelog
Revert schema and add MR number
Revert, accidental changes in previous commit
Move license button to second, adjust CSS class
Adjust styling for different scenarios
Move the license to after the readme in new project
Revert schema
Fix some spec errors
Update add license in user sees set up spec
Regen text
Fix spec
Add license_key to proj presenter spec
Try license_blob
Revert project pres spec string to capitalize
Revert schema changes
Try reverting again
Try reverting schema again
Ok I think this will work revert schema
Remove unreleased changelog file accident
Apply suggestion to spec/presenters/project_presenter_spec.rb
Fix static analysis indent
Fix indent
parent 7c981da1
......@@ -21,7 +21,6 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
def statistics_anchors(show_auto_devops_callout:)
[
license_anchor_data,
commits_anchor_data,
branches_anchor_data,
tags_anchor_data,
......@@ -32,6 +31,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
def statistics_buttons(show_auto_devops_callout:)
[
readme_anchor_data,
license_anchor_data,
changelog_anchor_data,
contribution_guide_anchor_data,
autodevops_anchor_data(show_auto_devops_callout: show_auto_devops_callout),
......@@ -41,15 +41,14 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
end
def empty_repo_statistics_anchors
[
license_anchor_data
].compact.select { |item| item.is_link }
[]
end
def empty_repo_statistics_buttons
[
new_file_anchor_data,
readme_anchor_data,
license_anchor_data,
changelog_anchor_data,
contribution_guide_anchor_data,
gitlab_ci_anchor_data
......@@ -227,17 +226,18 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
icon = statistic_icon('scale')
if repository.license_blob.present?
AnchorData.new(true,
icon + content_tag(:strong, license_short_name, class: 'project-stat-value'),
license_path)
AnchorData.new(false,
icon + content_tag(:span, license_short_name, class: 'project-stat-value'),
license_path,
'default')
else
if current_user && can_current_user_push_to_default_branch?
AnchorData.new(true,
content_tag(:span, icon + _('Add license'), class: 'add-license-link d-flex'),
AnchorData.new(false,
content_tag(:span, statistic_icon + _('Add LICENSE'), class: 'add-license-link d-flex'),
add_license_path)
else
AnchorData.new(true,
icon + content_tag(:strong, _('No license. All rights reserved'), class: 'project-stat-value'),
AnchorData.new(false,
icon + content_tag(:span, _('No license. All rights reserved'), class: 'project-stat-value'),
nil)
end
end
......
---
title: Move add license button to project buttons
merge_request: 19370
author:
type: changed
......@@ -905,6 +905,9 @@ msgstr ""
msgid "Add Kubernetes cluster"
msgstr ""
msgid "Add LICENSE"
msgstr ""
msgid "Add README"
msgstr ""
......
......@@ -39,7 +39,7 @@ describe 'Projects > Files > Project owner creates a license file', :js do
end
it 'project maintainer creates a license file from the "Add license" link' do
click_link 'Add license'
click_link 'Add LICENSE'
expect(page).to have_content('New file')
expect(current_path).to eq(
......
......@@ -12,7 +12,7 @@ describe 'Projects > Files > Project owner sees a link to create a license file
it 'project maintainer creates a license file from a template' do
visit project_path(project)
click_on 'Add license'
click_on 'Add LICENSE'
expect(page).to have_content('New file')
expect(current_path).to eq(
......
......@@ -59,8 +59,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
end
it '"Add license" button linked to new file populated for a license' do
page.within('.project-stats') do
expect(page).to have_link('Add license', href: presenter.add_license_path)
page.within('.project-buttons') do
expect(page).to have_link('Add LICENSE', href: presenter.add_license_path)
end
end
end
......@@ -175,7 +175,7 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
expect(project.repository.license_blob).not_to be_nil
page.within('.project-buttons') do
expect(page).not_to have_link('Add license')
expect(page).not_to have_link('Add LICENSE')
end
end
......
......@@ -312,8 +312,8 @@ describe ProjectPresenter do
project.add_developer(user)
allow(project.repository).to receive(:license_blob).and_return(nil)
expect(presenter.license_anchor_data).to have_attributes(is_link: true,
label: a_string_including('Add license'),
expect(presenter.license_anchor_data).to have_attributes(is_link: false,
label: a_string_including('Add LICENSE'),
link: presenter.add_license_path)
end
end
......@@ -322,7 +322,7 @@ describe ProjectPresenter do
it 'returns anchor data' do
allow(project.repository).to receive(:license_blob).and_return(double(name: 'foo'))
expect(presenter.license_anchor_data).to have_attributes(is_link: true,
expect(presenter.license_anchor_data).to have_attributes(is_link: false,
label: a_string_including(presenter.license_short_name),
link: presenter.license_path)
end
......@@ -420,6 +420,7 @@ describe ProjectPresenter do
it 'orders the items correctly' do
allow(project.repository).to receive(:readme).and_return(double(name: 'readme'))
allow(project.repository).to receive(:license_blob).and_return(nil)
allow(project.repository).to receive(:changelog).and_return(nil)
allow(project.repository).to receive(:contribution_guide).and_return(double(name: 'foo'))
allow(presenter).to receive(:filename_path).and_return('fake/path')
......@@ -433,25 +434,54 @@ describe ProjectPresenter do
end
end
describe '#empty_repo_statistics_buttons' do
let(:project) { create(:project, :repository) }
describe '#repo_statistics_buttons' do
let(:presenter) { described_class.new(project, current_user: user) }
subject(:empty_repo_statistics_buttons) { presenter.empty_repo_statistics_buttons }
before do
project.add_developer(user)
allow(project).to receive(:auto_devops_enabled?).and_return(false)
end
it 'orders the items correctly in an empty project' do
expect(empty_repo_statistics_buttons.map(&:label)).to start_with(
a_string_including('New'),
a_string_including('README'),
a_string_including('CHANGELOG'),
a_string_including('CONTRIBUTING'),
a_string_including('CI/CD')
)
context 'empty repo' do
let(:project) { create(:project, :stubbed_repository)}
context 'for a guest user' do
it 'orders the items correctly' do
expect(empty_repo_statistics_buttons.map(&:label)).to start_with(
a_string_including('No license')
)
end
end
context 'for a developer' do
before do
project.add_developer(user)
end
it 'orders the items correctly' do
expect(empty_repo_statistics_buttons.map(&:label)).to start_with(
a_string_including('New'),
a_string_including('README'),
a_string_including('LICENSE'),
a_string_including('CHANGELOG'),
a_string_including('CONTRIBUTING'),
a_string_including('CI/CD')
)
end
end
end
context 'initialized repo' do
let(:project) { create(:project, :repository) }
it 'orders the items correctly' do
expect(empty_repo_statistics_buttons.map(&:label)).to start_with(
a_string_including('README'),
a_string_including('License'),
a_string_including('CHANGELOG'),
a_string_including('CONTRIBUTING')
)
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