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 () => { ...@@ -87,6 +87,9 @@ export default () => {
groupId: Number($boardApp.dataset.groupId), groupId: Number($boardApp.dataset.groupId),
rootPath: $boardApp.dataset.rootPath, rootPath: $boardApp.dataset.rootPath,
canUpdate: $boardApp.dataset.canUpdate, canUpdate: $boardApp.dataset.canUpdate,
labelsFetchPath: $boardApp.dataset.labelsFetchPath,
labelsManagePath: $boardApp.dataset.labelsManagePath,
labelsFilterBasePath: $boardApp.dataset.labelsFilterBasePath,
}, },
store, store,
apolloProvider, apolloProvider,
......
...@@ -18,7 +18,10 @@ module BoardsHelper ...@@ -18,7 +18,10 @@ module BoardsHelper
time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s, time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s,
recent_boards_endpoint: recent_boards_path, recent_boards_endpoint: recent_boards_path,
parent: current_board_parent.model_name.param_key, 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 end
...@@ -38,6 +41,22 @@ module BoardsHelper ...@@ -38,6 +41,22 @@ module BoardsHelper
end end
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 def board_base_url
if board.group_board? if board.group_board?
group_boards_url(@group) group_boards_url(@group)
......
...@@ -34,28 +34,58 @@ RSpec.describe BoardsHelper do ...@@ -34,28 +34,58 @@ RSpec.describe BoardsHelper do
end end
describe '#board_data' do describe '#board_data' do
let(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:board) { create(:board, project: project) } let_it_be(:board) { create(:board, project: project) }
before do context 'project_board' do
assign(:board, board) before do
assign(:project, project) assign(:project, project)
assign(:board, board)
allow(helper).to receive(:current_user) { user } 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, :create_non_backlog_issues, board).and_return(true)
allow(helper).to receive(:can?).with(user, :admin_issue, board).and_return(true) allow(helper).to receive(:can?).with(user, :admin_issue, board).and_return(true)
end end
it 'returns a board_lists_path as lists_endpoint' do it 'returns a board_lists_path as lists_endpoint' do
expect(helper.board_data[:lists_endpoint]).to eq(board_lists_path(board)) expect(helper.board_data[:lists_endpoint]).to eq(board_lists_path(board))
end end
it 'returns board type as parent' do it 'returns board type as parent' do
expect(helper.board_data[:parent]).to eq('project') expect(helper.board_data[:parent]).to eq('project')
end
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 end
it 'returns can_update for user permissions on the board' do context 'group board' do
expect(helper.board_data[:can_update]).to eq('true') 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
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