Commit 77b5fbe7 authored by Axel García's avatar Axel García

Provide required data for board labels

parent c914239d
......@@ -87,6 +87,9 @@ export default () => {
groupId: Number($boardApp.dataset.groupId),
rootPath: $boardApp.dataset.rootPath,
canUpdate: $boardApp.dataset.canUpdate,
labelsFetchPath: $boardApp.dataset.labelsFetchPath,
labelsManagePath: $boardApp.dataset.labelsManagePath,
labelsFilterBasePath: $boardApp.dataset.labelsFilterBasePath,
},
store,
apolloProvider,
......
......@@ -18,7 +18,10 @@ module BoardsHelper
time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s,
recent_boards_endpoint: recent_boards_path,
parent: current_board_parent.model_name.param_key,
group_id: @group&.id
group_id: @group&.id,
labels_filter_base_path: build_issue_link_base,
labels_fetch_path: labels_fetch_path,
labels_manage_path: labels_manage_path
}
end
......@@ -38,6 +41,22 @@ module BoardsHelper
end
end
def labels_fetch_path
if board.group_board?
group_labels_path(@group, format: :json, only_group_labels: true, include_ancestor_groups: true)
else
project_labels_path(@project, format: :json, include_ancestor_groups: true)
end
end
def labels_manage_path
if board.group_board?
group_labels_path(@group)
else
project_labels_path(@project)
end
end
def board_base_url
if board.group_board?
group_boards_url(@group)
......
......@@ -34,12 +34,13 @@ RSpec.describe BoardsHelper do
end
describe '#board_data' do
let(:user) { create(:user) }
let(:board) { create(:board, project: project) }
let_it_be(:user) { create(:user) }
let_it_be(:board) { create(:board, project: project) }
context 'project_board' do
before do
assign(:board, board)
assign(:project, project)
assign(:board, board)
allow(helper).to receive(:current_user) { user }
allow(helper).to receive(:can?).with(user, :create_non_backlog_issues, board).and_return(true)
......@@ -57,6 +58,35 @@ RSpec.describe BoardsHelper do
it 'returns can_update for user permissions on the board' do
expect(helper.board_data[:can_update]).to eq('true')
end
it 'returns required label endpoints' do
expect(helper.board_data[:labels_fetch_path]).to eq("/#{project.full_path}/-/labels.json?include_ancestor_groups=true")
expect(helper.board_data[:labels_manage_path]).to eq("/#{project.full_path}/-/labels")
end
end
context 'group board' do
let_it_be(:group) { create(:group, path: 'base') }
let_it_be(:board) { create(:board, group: group) }
before do
assign(:group, group)
assign(:board, board)
allow(helper).to receive(:current_user) { user }
allow(helper).to receive(:can?).with(user, :create_non_backlog_issues, board).and_return(true)
allow(helper).to receive(:can?).with(user, :admin_issue, board).and_return(true)
end
it 'returns correct path for base group' do
expect(helper.build_issue_link_base).to eq('/base/:project_path/issues')
end
it 'returns required label endpoints' do
expect(helper.board_data[:labels_fetch_path]).to eq("/groups/base/-/labels.json?include_ancestor_groups=true&only_group_labels=true")
expect(helper.board_data[:labels_manage_path]).to eq("/groups/base/-/labels")
end
end
end
describe '#current_board_json' do
......
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