Commit 7e60a9e2 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Remove epic field for projects not in groups

Also fixes epics field being shown in MRs
parent 1225a6ee
...@@ -373,7 +373,5 @@ module Issuable ...@@ -373,7 +373,5 @@ module Issuable
end end
end end
# We have to prepend into Issuable::ClassMethods, as otherwise the methods Issuable.prepend(EE::Issuable) # rubocop: disable Cop/InjectEnterpriseEditionModule
# defined in EE::Issuable will available on Issuable, and not Issuable::ClassMethods.prepend(EE::Issuable::ClassMethods)
# Issuable::ClassMethods (= what in turn is exposed to classes).
Issuable::ClassMethods.prepend(EE::Issuable)
...@@ -110,9 +110,5 @@ module LicenseHelper ...@@ -110,9 +110,5 @@ module LicenseHelper
!Gitlab::CurrentSettings.should_check_namespace_plan? && show_promotions? && show_callout?('promote_advanced_search_dismissed') && !License.feature_available?(:elastic_search) !Gitlab::CurrentSettings.should_check_namespace_plan? && show_promotions? && show_callout?('promote_advanced_search_dismissed') && !License.feature_available?(:elastic_search)
end end
def promote_feature?(feature_name)
!@project&.group&.feature_available?(feature_name) && show_promotions? && show_callout?(feature_name)
end
extend self extend self
end end
...@@ -4,15 +4,21 @@ module EE ...@@ -4,15 +4,21 @@ module EE
module Issuable module Issuable
extend ActiveSupport::Concern extend ActiveSupport::Concern
def labels_hash class_methods do
issue_labels = Hash.new { |h, k| h[k] = [] } def labels_hash
issue_labels = Hash.new { |h, k| h[k] = [] }
relation = unscoped.where(id: self.select(:id)).eager_load(:labels) relation = unscoped.where(id: self.select(:id)).eager_load(:labels)
relation.pluck(:id, 'labels.title').each do |issue_id, label| relation.pluck(:id, 'labels.title').each do |issue_id, label|
issue_labels[issue_id] << label issue_labels[issue_id] << label
end
issue_labels
end end
end
issue_labels def supports_epic?
is_a?(Issue) && project.group
end end
end end
end end
- if issuable.project.feature_available?(:epics) - if issuable.supports_epic?
- if issuable.is_a?(Issue) - if issuable.project.group.feature_available?(:epics)
.block.epic .block.epic
#js-vue-sidebar-item-epic #js-vue-sidebar-item-epic
.title.hide-collapsed .title.hide-collapsed
Epic Epic
= icon('spinner spin') = icon('spinner spin')
- else - else
= render 'shared/promotions/promote_epics' = render 'shared/promotions/promote_epics'
- promotion_feature = 'promote_epics_sidebar_dismissed' - promotion_feature = 'promote_epics_sidebar_dismissed'
- if promote_feature?(:epic) && show_promotions? && show_callout?(promotion_feature) - if show_promotions? && show_callout?(promotion_feature)
.block.js-epics-sidebar-callout.promotion-issue-sidebar{ data: { uid: promotion_feature } } .block.js-epics-sidebar-callout.promotion-issue-sidebar{ data: { uid: promotion_feature } }
.sidebar-collapsed-icon{ data: { toggle: "dropdown", target: ".js-epics-sidebar-callout" } } .sidebar-collapsed-icon{ data: { toggle: "dropdown", target: ".js-epics-sidebar-callout" } }
%span{ data: { toggle: "tooltip", placement: "left", container: "body" }, title: _('Epic') } %span{ data: { toggle: "tooltip", placement: "left", container: "body" }, title: _('Epic') }
......
---
title: Remove epic field in sidebar for projects without groups
merge_request: 8919
author:
type: fixed
...@@ -8,27 +8,66 @@ describe 'Epic in issue sidebar', :js do ...@@ -8,27 +8,66 @@ describe 'Epic in issue sidebar', :js do
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let!(:epic_issue) { create(:epic_issue, epic: epic, issue: issue) } let!(:epic_issue) { create(:epic_issue, epic: epic, issue: issue) }
shared_examples 'epic in issue sidebar' do
it 'shows epic in issue sidebar for projects with group' do
visit project_issue_path(project, issue)
expect(page.find('.block.epic .value')).to have_content(epic.title)
end
it 'does not show epic in issue sidebar for personal projects' do
personal_project = create(:project, :public)
other_issue = create(:issue, project: personal_project)
visit project_issue_path(personal_project, other_issue)
expect_no_epic
end
end
context 'when epics available' do context 'when epics available' do
before do before do
stub_licensed_features(epics: true) stub_licensed_features(epics: true)
sign_in(user)
visit project_issue_path(project, issue)
end end
it 'shows epic in issue sidebar' do it_behaves_like 'epic in issue sidebar'
expect(page.find('.block.epic .value')).to have_content(epic.title)
context 'with namespaced plans' do
before do
stub_application_setting(check_namespace_plan: true)
end
context 'group has license' do
before do
create(:gitlab_subscription, :gold, namespace: group)
end
it_behaves_like 'epic in issue sidebar'
end
context 'group has no license' do
it 'does not show epic for public projects and groups' do
visit project_issue_path(project, issue)
expect_no_epic
end
end
end end
end end
context 'when epics unavailable' do context 'when epics unavailable' do
before do before do
stub_licensed_features(epics: false) stub_licensed_features(epics: false)
sign_in(user)
visit project_issue_path(project, issue)
end end
it 'does not show epic in issue sidebar' do it 'does not show epic in issue sidebar' do
expect(page).not_to have_selector('.block.epic') visit project_issue_path(project, issue)
expect_no_epic
end end
end end
def expect_no_epic
expect(page).not_to have_selector('.block.epic')
end
end end
# frozen_string_literal: true
require 'spec_helper'
describe 'Merge Request sidebar' do
let(:user) { create(:user) }
let(:group) { create(:group, :public) }
let(:project) { create(:project, :repository, :public, group: group) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
context 'when epics available' do
before do
stub_licensed_features(epics: true)
end
it 'does not show epics in MR sidebar' do
visit project_merge_request_path(project, merge_request)
expect(page).not_to have_selector('.block.epic')
end
end
context 'when epics unavailable' do
before do
stub_licensed_features(epics: false)
end
it 'does not show epics promotion in MR sidebar' do
visit project_merge_request_path(project, merge_request)
expect(page).not_to have_selector('.js-epics-sidebar-callout')
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