Commit f4e4a9ad authored by Simon Knox's avatar Simon Knox Committed by Phil Hughes

Resolve "Weight Feature in Community Edition buggy in board view"

parent cbf5b26d
...@@ -2,14 +2,25 @@ import '~/boards/components/board'; ...@@ -2,14 +2,25 @@ import '~/boards/components/board';
import { __, n__, sprintf } from '~/locale'; import { __, n__, sprintf } from '~/locale';
import boardPromotionState from 'ee/boards/components/board_promotion_state'; import boardPromotionState from 'ee/boards/components/board_promotion_state';
const Store = gl.issueBoards.BoardsStore;
const base = gl.issueBoards.Board; const base = gl.issueBoards.Board;
gl.issueBoards.Board = base.extend({ gl.issueBoards.Board = base.extend({
data() {
return {
weightFeatureAvailable: Store.weightFeatureAvailable,
};
},
components: { components: {
boardPromotionState, boardPromotionState,
}, },
computed: { computed: {
counterTooltip() { counterTooltip() {
if (!this.weightFeatureAvailable) {
// call computed property from base component (CE board.js)
return base.options.computed.counterTooltip.call(this);
}
const { issuesSize, totalWeight } = this.list; const { issuesSize, totalWeight } = this.list;
return sprintf(__( return sprintf(__(
`${n__('%d issue', '%d issues', issuesSize)} with %{totalWeight} total weight`), `${n__('%d issue', '%d issues', issuesSize)} with %{totalWeight} total weight`),
......
...@@ -5,6 +5,7 @@ import { __ } from '~/locale'; ...@@ -5,6 +5,7 @@ import { __ } from '~/locale';
import BoardService from 'ee/boards/services/board_service'; import BoardService from 'ee/boards/services/board_service';
import sidebarEventHub from '~/sidebar/event_hub'; import sidebarEventHub from '~/sidebar/event_hub';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { convertPermissionToBoolean } from '~/lib/utils/common_utils';
class BoardsStoreEE { class BoardsStoreEE {
initEESpecific(boardsStore) { initEESpecific(boardsStore) {
...@@ -29,6 +30,9 @@ class BoardsStoreEE { ...@@ -29,6 +30,9 @@ class BoardsStoreEE {
weight: parseInt(this.$boardApp.dataset.boardWeight, 10), weight: parseInt(this.$boardApp.dataset.boardWeight, 10),
}; };
this.store.cantEdit = []; this.store.cantEdit = [];
this.store.weightFeatureAvailable = convertPermissionToBoolean(
this.$boardApp.dataset.weightFeatureAvailable,
);
this.initBoardFilters(); this.initBoardFilters();
} }
}; };
......
...@@ -27,6 +27,7 @@ module EE ...@@ -27,6 +27,7 @@ module EE
labels: board.labels.to_json(only: [:id, :title, :color, :text_color] ), labels: board.labels.to_json(only: [:id, :title, :color, :text_color] ),
board_weight: board.weight, board_weight: board.weight,
focus_mode_available: parent.feature_available?(:issue_board_focus_mode), focus_mode_available: parent.feature_available?(:issue_board_focus_mode),
weight_feature_available: parent.feature_available?(:issue_weights).to_s,
show_promotion: show_feature_promotion show_promotion: show_feature_promotion
} }
......
%span.d-inline-flex.ml-2 - if (@group || @project)&.feature_available?(:issue_weights)
%icon.mr-1{ name: "scale" } %span.d-inline-flex.ml-2
{{ list.totalWeight }} %icon.mr-1{ name: "scale" }
{{ list.totalWeight }}
%weight{ ":fetching" => "issue.isFetching && issue.isFetching.weight", - if (@project || @group)&.feature_available?(:issue_weights)
":loading" => "issue.isLoading && issue.isLoading.weight", %weight{ ":fetching" => "issue.isFetching && issue.isFetching.weight",
":weight" => "issue.weight", ":loading" => "issue.isLoading && issue.isLoading.weight",
":weight-options" => Issue.weight_options, ":weight" => "issue.weight",
"weight-none-value" => Issue::WEIGHT_NONE, ":weight-options" => Issue.weight_options,
":editable" => can_admin_issue?, "weight-none-value" => Issue::WEIGHT_NONE,
":id" => "issue.id" } ":editable" => can_admin_issue?,
":id" => "issue.id" }
...@@ -124,6 +124,21 @@ describe 'issue boards', :js do ...@@ -124,6 +124,21 @@ describe 'issue boards', :js do
expect(badge(from)).to have_content('3') expect(badge(from)).to have_content('3')
expect(badge(to)).to have_content('2') expect(badge(to)).to have_content('2')
end end
context 'unlicensed' do
before do
stub_licensed_features(issue_weights: false)
visit_board_page
end
it 'hides weight' do
backlog = board.lists.first
badge(backlog).hover
tooltip = find("##{badge(backlog)['aria-describedby']}")
expect(tooltip.text).to eq('2 issues')
end
end
end end
def badge(list) def badge(list)
......
...@@ -232,5 +232,20 @@ describe 'Issue Boards', :js do ...@@ -232,5 +232,20 @@ describe 'Issue Boards', :js do
end end
end end
end end
context 'unlicensed' do
before do
stub_licensed_features(issue_weights: false)
visit project_board_path(project, board)
wait_for_requests
end
it 'hides weight' do
click_card(card1)
wait_for_requests
expect(page).not_to have_selector('.js-weight-weight-label')
end
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