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';
import { __, n__, sprintf } from '~/locale';
import boardPromotionState from 'ee/boards/components/board_promotion_state';
const Store = gl.issueBoards.BoardsStore;
const base = gl.issueBoards.Board;
gl.issueBoards.Board = base.extend({
data() {
return {
weightFeatureAvailable: Store.weightFeatureAvailable,
};
},
components: {
boardPromotionState,
},
computed: {
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;
return sprintf(__(
`${n__('%d issue', '%d issues', issuesSize)} with %{totalWeight} total weight`),
......
......@@ -5,6 +5,7 @@ import { __ } from '~/locale';
import BoardService from 'ee/boards/services/board_service';
import sidebarEventHub from '~/sidebar/event_hub';
import createFlash from '~/flash';
import { convertPermissionToBoolean } from '~/lib/utils/common_utils';
class BoardsStoreEE {
initEESpecific(boardsStore) {
......@@ -29,6 +30,9 @@ class BoardsStoreEE {
weight: parseInt(this.$boardApp.dataset.boardWeight, 10),
};
this.store.cantEdit = [];
this.store.weightFeatureAvailable = convertPermissionToBoolean(
this.$boardApp.dataset.weightFeatureAvailable,
);
this.initBoardFilters();
}
};
......
......@@ -27,6 +27,7 @@ module EE
labels: board.labels.to_json(only: [:id, :title, :color, :text_color] ),
board_weight: board.weight,
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
}
......
%span.d-inline-flex.ml-2
- if (@group || @project)&.feature_available?(:issue_weights)
%span.d-inline-flex.ml-2
%icon.mr-1{ name: "scale" }
{{ list.totalWeight }}
%weight{ ":fetching" => "issue.isFetching && issue.isFetching.weight",
- if (@project || @group)&.feature_available?(:issue_weights)
%weight{ ":fetching" => "issue.isFetching && issue.isFetching.weight",
":loading" => "issue.isLoading && issue.isLoading.weight",
":weight" => "issue.weight",
":weight-options" => Issue.weight_options,
......
......@@ -124,6 +124,21 @@ describe 'issue boards', :js do
expect(badge(from)).to have_content('3')
expect(badge(to)).to have_content('2')
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
def badge(list)
......
......@@ -232,5 +232,20 @@ describe 'Issue Boards', :js do
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
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