Commit d4accc07 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Only show one board when there are multiple

And show a mention to the users so they know their boards didn't
disappear.
parent c3f43e45
module Boards
class ListService < BaseService
prepend EE::Boards::ListService
def execute
create_board! if project.boards.empty?
project.boards
......
module EE
module Boards
module ListService
def execute
raise NotImplementedError unless defined?(super)
if project.feature_available?(:multiple_issue_boards, current_user)
super
else
super.limit(1)
end
end
end
end
end
......@@ -22,6 +22,9 @@
%li{ "v-for" => "board in boards" }
%a{ ":href" => "'#{project_boards_path(@project)}/' + board.id" }
{{ board.name }}
- if !@project.feature_available?(:multiple_issue_boards) && @project.boards.size > 1
%li.small
Some of your boards are hidden, activate a license to see them again.
.dropdown-loading{ "v-if" => "loading" }
= icon("spin spinner")
- if can?(current_user, :admin_board, @project)
......@@ -47,7 +50,6 @@
%li
%a{ "href" => "#", "@click.stop.prevent" => "showPage('new')" }
Create new board
%li
%a{ "href" => "#", "@click.stop.prevent" => "showPage('edit')" }
Edit board name
......
......@@ -169,19 +169,30 @@ describe 'Multiple Issue Boards', feature: true, js: true do
project.team << [user, :master]
login_as(user)
end
it 'hides the link to create a new board' do
visit project_boards_path(project)
wait_for_requests
end
it 'hides the link to create a new board' do
click_button board.name
page.within('.dropdown-menu') do
expect(page).to have_content('Edit board name')
expect(page).not_to have_content('Create new board')
expect(page).to have_content('Delete board')
expect(page).not_to have_content('Delete board')
end
end
it 'shows a mention that boards are hidden when multiple boards are created' do
create(:board, project: project)
visit project_boards_path(project)
wait_for_requests
click_button board.name
expect(page).to have_content('Some of your boards are hidden, activate a license to see them again.')
end
end
end
require 'spec_helper'
describe Boards::ListService do
let(:project) { create(:empty_project) }
let(:service) { described_class.new(project, double) }
before do
create_list(:board, 2, project: project)
end
describe '#execute' do
it 'returns all issue boards when `multiple_issue_boards` is enabled' do
stub_licensed_features(multiple_issue_boards: true)
expect(service.execute.size).to eq(2)
end
it 'returns the first issue board when `multiple_issue_boards` is disabled' do
stub_licensed_features(multiple_issue_boards: false)
expect(service.execute.size).to eq(1)
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