Commit 0c0dbb85 authored by Vitali Tatarintev's avatar Vitali Tatarintev Committed by Bob Van Landuyt

Remove `type: :licensed`

Removes `type: :licensed` from feature flags
parent f0acac26
......@@ -351,7 +351,7 @@ export default () => {
toggleFocusMode(ModalStore, boardsStore);
toggleLabels();
if (gon.features?.swimlanes) {
if (gon.licensed_features?.swimlanes) {
toggleEpicsSwimlanes();
}
......
......@@ -61,9 +61,6 @@ export default {
this.customState.integrationLevel === integrationLevels.GROUP
);
},
showJiraIssuesFields() {
return this.isJira && this.glFeatures.jiraIssuesIntegration;
},
showReset() {
return this.isInstanceOrGroupLevel && this.propsSource.resetPath;
},
......@@ -129,7 +126,7 @@ export default {
v-bind="field"
/>
<jira-issues-fields
v-if="showJiraIssuesFields"
v-if="isJira"
:key="`${currentKey}-jira-issues-fields`"
v-bind="propsSource.jiraIssuesProps"
/>
......
......@@ -36,7 +36,7 @@ function mountJiraIssuesListApp() {
}
function mountIssuablesListApp() {
if (!gon.features?.vueIssuablesList && !gon.features?.jiraIssuesIntegration) {
if (!gon.features?.vueIssuablesList) {
return;
}
......
export default (Vue) => {
Vue.mixin({
provide: {
glFeatures: { ...((window.gon && window.gon.features) || {}) },
glFeatures:
{
...window.gon?.features,
// TODO: extract into glLicensedFeatures https://gitlab.com/gitlab-org/gitlab/-/issues/322460
...window.gon?.licensed_features,
} || {},
},
});
};
......@@ -12,8 +12,6 @@ class Projects::ServicesController < Projects::ApplicationController
before_action :set_deprecation_notice_for_prometheus_service, only: [:edit, :update]
before_action :redirect_deprecated_prometheus_service, only: [:update]
before_action only: :edit do
push_frontend_feature_flag(:jira_issues_integration, @project, type: :licensed, default_enabled: true)
push_frontend_feature_flag(:jira_vulnerabilities_integration, @project, type: :licensed, default_enabled: true)
push_frontend_feature_flag(:jira_for_vulnerabilities, @project, type: :development, default_enabled: :yaml)
end
......
......@@ -6,10 +6,6 @@ module Clusters
Clusters::Cluster.instance_type
end
def feature_available?(feature)
::Feature.enabled?(feature, type: :licensed, default_enabled: true)
end
def flipper_id
self.class.to_s
end
......
......@@ -5,7 +5,7 @@ export default {
...gettersCE,
isSwimlanesOn: (state) => {
return Boolean(gon?.features?.swimlanes && state.isShowingEpicsSwimlanes);
return Boolean(gon?.licensed_features?.swimlanes && state.isShowingEpicsSwimlanes);
},
getIssuesByEpic: (state, getters) => (listId, epicId) => {
return getters
......
......@@ -12,9 +12,9 @@ module EE
def push_licensed_features
# This is pushing a licensed Feature to the frontend.
push_frontend_feature_flag(:wip_limits, type: :licensed, default_enabled: true) if parent.feature_available?(:wip_limits)
push_frontend_feature_flag(:swimlanes, type: :licensed, default_enabled: true) if parent.feature_available?(:swimlanes)
push_frontend_feature_flag(:issue_weights, type: :licensed, default_enabled: true) if parent.feature_available?(:issue_weights)
push_licensed_feature(:wip_limits) if parent.feature_available?(:wip_limits)
push_licensed_feature(:swimlanes) if parent.feature_available?(:swimlanes)
push_licensed_feature(:issue_weights) if parent.feature_available?(:issue_weights)
end
end
end
......@@ -16,7 +16,6 @@ module Projects
before_action :check_issues_show_enabled!, only: :show
before_action do
push_frontend_feature_flag(:jira_issues_integration, project, type: :licensed, default_enabled: true)
push_frontend_feature_flag(:jira_issues_list, project, type: :development)
end
......
......@@ -143,9 +143,6 @@ module EE
# being licensed.
override :feature_available?
def feature_available?(feature)
# This feature might not be behind a feature flag at all, so default to true
return false unless ::Feature.enabled?(feature, type: :licensed, default_enabled: true)
available_features = strong_memoize(:feature_available) do
Hash.new do |h, f|
h[f] = load_feature_available(f)
......
......@@ -784,9 +784,6 @@ module EE
end
def licensed_feature_available?(feature, user = nil)
# This feature might not be behind a feature flag at all, so default to true
return false unless ::Feature.enabled?(feature, user, type: :licensed, default_enabled: true)
available_features = strong_memoize(:licensed_feature_available) do
Hash.new do |h, f|
h[f] = load_licensed_feature_available(f)
......
......@@ -427,9 +427,6 @@ class License < ApplicationRecord
def feature_available?(feature)
return false if trial? && expired?
# This feature might not be behind a feature flag at all, so default to true
return false unless ::Feature.enabled?(feature, type: :licensed, default_enabled: true)
features.include?(feature)
end
......
......@@ -8,7 +8,8 @@ module PersonalAccessTokens
end
def execute
return unless ::Feature.enabled?(:personal_access_token_expiration_policy, type: :licensed, default_enabled: true)
# TODO: Change to `project.feature_available?` https://gitlab.com/gitlab-org/gitlab/-/issues/323908
return unless ::License.feature_available?(:personal_access_token_expiration_policy)
return unless PersonalAccessToken.expiration_enforced?
return unless expiration_date && user_affected?
......
......@@ -117,7 +117,7 @@ RSpec.describe Boards::ListsController do
context 'without licensed wip limits' do
before do
stub_feature_flags(wip_limits: false)
stub_licensed_features(wip_limits: false)
end
it 'ignores max issue count' do
......@@ -141,7 +141,7 @@ RSpec.describe Boards::ListsController do
context 'without licensed wip limits' do
before do
stub_feature_flags(wip_limits: false)
stub_licensed_features(wip_limits: false)
end
it 'ignores max issue count' do
......@@ -193,7 +193,7 @@ RSpec.describe Boards::ListsController do
context 'without licensed wip limits' do
before do
stub_feature_flags(wip_limits: false)
stub_licensed_features(wip_limits: false)
end
it 'ignores limit metric setting' do
......@@ -467,7 +467,7 @@ RSpec.describe Boards::ListsController do
context 'when wip limits are not licensed' do
before do
stub_feature_flags(wip_limits: false)
stub_licensed_features(wip_limits: false)
end
it 'fails to update max issue count with expected status' do
......
......@@ -215,7 +215,7 @@ RSpec.describe 'issue boards', :js do
login_as(user)
end
context 'When license is available' do
context 'when license is available' do
let!(:label) { create(:label, project: project, name: 'Brount') }
let!(:list) { create(:list, board: board, label: label, position: 1) }
......@@ -346,7 +346,7 @@ RSpec.describe 'issue boards', :js do
end
end
context 'When license is not available' do
context 'when license is not available' do
before do
stub_licensed_features(wip_limits: false)
visit project_boards_path(project)
......
......@@ -6,7 +6,7 @@ import { createStore } from '~/boards/stores';
describe('ee/BoardContent', () => {
let wrapper;
let store;
window.gon = { features: {} };
window.gon = { licensed_features: {} };
const createComponent = () => {
wrapper = shallowMount(BoardContent, {
......@@ -30,19 +30,19 @@ describe('ee/BoardContent', () => {
});
afterEach(() => {
window.gon.features = {};
window.gon.licensed_features = {};
wrapper.destroy();
});
describe.each`
featureFlag | state | result
${true} | ${{ isShowingEpicsSwimlanes: true }} | ${true}
${true} | ${{ isShowingEpicsSwimlanes: false }} | ${false}
${false} | ${{ isShowingEpicsSwimlanes: true }} | ${false}
${false} | ${{ isShowingEpicsSwimlanes: false }} | ${false}
`('with featureFlag=$featureFlag and state=$state', ({ featureFlag, state, result }) => {
licenseEnabled | state | result
${true} | ${{ isShowingEpicsSwimlanes: true }} | ${true}
${true} | ${{ isShowingEpicsSwimlanes: false }} | ${false}
${false} | ${{ isShowingEpicsSwimlanes: true }} | ${false}
${false} | ${{ isShowingEpicsSwimlanes: false }} | ${false}
`('with licenseEnabled=$licenseEnabled and state=$state', ({ licenseEnabled, state, result }) => {
beforeEach(() => {
gon.features.swimlanes = featureFlag;
gon.licensed_features.swimlanes = licenseEnabled;
Object.assign(store.state, state);
createComponent();
});
......
......@@ -18,12 +18,12 @@ describe('EE Boards Store Getters', () => {
describe('isSwimlanesOn', () => {
afterEach(() => {
window.gon = { features: {} };
window.gon = { licensed_features: {} };
});
describe('when swimlanes feature is true', () => {
beforeEach(() => {
window.gon = { features: { swimlanes: true } };
window.gon = { licensed_features: { swimlanes: true } };
});
describe('when isShowingEpicsSwimlanes is true', () => {
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Gitlab::TreeSummary do
let_it_be(:project) { create(:project, :custom_repo, files: { 'a.txt' => '' }) }
let_it_be_with_refind(:project) { create(:project, :custom_repo, files: { 'a.txt' => '' }) }
let_it_be(:path_lock) { create(:path_lock, project: project, path: 'a.txt') }
let_it_be(:user) { create(:user) }
......@@ -21,7 +21,7 @@ RSpec.describe Gitlab::TreeSummary do
context 'when file_locks feature is unavailable' do
before do
stub_feature_flags(file_locks: false)
stub_licensed_features(file_locks: false)
end
it 'does not fill lock labels' do
......
......@@ -101,6 +101,10 @@ RSpec.describe List do
let!(:list2) { create(:list, board: board2) }
context 'with enabled wip_limits' do
before do
stub_licensed_features(wip_limits: true)
end
it 'returns the expected values' do
expect(list1.wip_limits_available?).to be_truthy
expect(list2.wip_limits_available?).to be_truthy
......@@ -109,7 +113,7 @@ RSpec.describe List do
context 'with disabled wip_limits' do
before do
stub_feature_flags(wip_limits: false)
stub_licensed_features(wip_limits: false)
end
it 'returns the expected values' do
......
......@@ -501,22 +501,6 @@ RSpec.describe Namespace do
end
end
end
context 'when feature is disabled by a feature flag' do
it 'returns false' do
stub_feature_flags(feature => false)
is_expected.to eq(false)
end
end
context 'when feature is enabled by a feature flag' do
it 'returns true' do
stub_feature_flags(feature => true)
is_expected.to eq(true)
end
end
end
describe '#feature_available?' do
......
......@@ -254,7 +254,7 @@ RSpec.describe GroupMember do
end
context 'group member webhooks', :sidekiq_inline do
let_it_be(:group) { create(:group_with_plan, plan: :ultimate_plan) }
let_it_be_with_refind(:group) { create(:group_with_plan, plan: :ultimate_plan) }
let_it_be(:group_hook) { create(:group_hook, group: group, member_events: true) }
let_it_be(:user) { create(:user) }
......@@ -350,8 +350,8 @@ RSpec.describe GroupMember do
expect(WebMock).not_to have_requested(:post, group_hook.url)
end
it 'does not execute webhooks if feature flag is disabled' do
stub_feature_flags(group_webhooks: false)
it 'does not execute webhooks if license is disabled' do
stub_licensed_features(group_webhooks: false)
group.add_guest(user)
......
......@@ -874,26 +874,6 @@ RSpec.describe License do
end
end
end
context 'when feature is disabled by a feature flag' do
it 'returns false' do
feature = license.features.first
stub_feature_flags(feature => false)
expect(license.features).not_to receive(:include?)
expect(license.feature_available?(feature)).to eq(false)
end
end
context 'when feature is enabled by a feature flag' do
it 'returns true' do
feature = license.features.first
stub_feature_flags(feature => true)
expect(license.feature_available?(feature)).to eq(true)
end
end
end
def build_license_with_add_ons(add_ons, plan: nil)
......
......@@ -883,14 +883,6 @@ RSpec.describe Project do
it 'returns true' do
is_expected.to eq(true)
end
context 'when feature is disabled by a feature flag' do
it 'returns false' do
stub_feature_flags(feature => false)
is_expected.to eq(false)
end
end
end
context 'not allowed by Plan License but project and namespace are public' do
......
......@@ -1084,7 +1084,6 @@ RSpec.describe ProjectPolicy do
let(:current_user) { public_send(role) if role }
before do
stub_feature_flags(feature => true)
stub_licensed_features(feature => true)
enable_admin_mode!(current_user) if admin_mode
end
......@@ -1098,14 +1097,6 @@ RSpec.describe ProjectPolicy do
it { is_expected.to be_disallowed(policy) }
end
context 'when feature flag is disabled' do
before do
stub_feature_flags(feature => false)
end
it { is_expected.to be_disallowed(policy) }
end
end
end
end
......
......@@ -74,7 +74,7 @@ RSpec.describe API::Boards do
context 'without WIP limits license' do
before do
stub_feature_flags(wip_limits: false)
stub_licensed_features(wip_limits: false)
get api(url, user)
end
......
......@@ -154,7 +154,7 @@ RSpec.describe 'EE::Boards::Lists::UpdateService' do
context 'without licensed wip limits' do
before do
stub_feature_flags(wip_limits: false)
stub_licensed_features(wip_limits: false)
end
it 'does not update the list even if max_issue_count is given' do
......
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Boards::Lists::CreateService do
describe '#execute' do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be_with_refind(:project) { create(:project, group: group) }
let_it_be(:board, refind: true) { create(:board, project: project) }
let_it_be(:user) { create(:user) }
......@@ -106,7 +106,7 @@ RSpec.describe Boards::Lists::CreateService do
describe '#create_list_attributes' do
shared_examples 'attribute provider for list creation' do
before do
stub_feature_flags(wip_limits: wip_limits_enabled)
stub_licensed_features(wip_limits: wip_limits_enabled)
end
where(:params, :expected_max_issue_count, :expected_max_issue_weight, :expected_limit_metric) do
......
......@@ -13,6 +13,10 @@ RSpec.describe PersonalAccessTokens::RevokeInvalidTokens do
let_it_be(:invalid_pat1) { create(:personal_access_token, expires_at: nil, user: user) }
let_it_be(:invalid_pat2) { create(:personal_access_token, expires_at: 20.days.from_now, user: user) }
before do
stub_licensed_features(personal_access_token_expiration_policy: true)
end
shared_examples 'user does not receive revoke notification email' do
it 'does not send any notification to user' do
expect(Notify).not_to receive(:policy_revoked_personal_access_tokens_email).and_call_original
......@@ -103,9 +107,9 @@ RSpec.describe PersonalAccessTokens::RevokeInvalidTokens do
end
end
context 'when the feature flag for personal access token policy is disabled' do
context 'when the licensed feature for personal access token policy is disabled' do
before do
stub_feature_flags(personal_access_token_expiration_policy: false)
stub_licensed_features(personal_access_token_expiration_policy: false)
end
it_behaves_like 'user does not receive revoke notification email'
......
......@@ -64,23 +64,10 @@ RSpec.shared_examples 'Insights page' do
end
end
end
context 'when the feature flag is disabled globally' do
before do
stub_feature_flags(insights: false)
end
it 'returns 404' do
visit route
expect(page).to have_gitlab_http_status(:not_found)
end
end
end
context 'without correct license' do
before do
stub_feature_flags(insights: false)
stub_licensed_features(insights: false)
end
......
......@@ -21,6 +21,10 @@ RSpec.describe PersonalAccessTokens::Groups::PolicyWorker, type: :worker do
described_class.new.perform(group.id)
end
before do
stub_licensed_features(personal_access_token_expiration_policy: true)
end
it_behaves_like 'an idempotent worker' do
let(:job_args) { [group.id] }
......
......@@ -9,6 +9,7 @@ RSpec.describe PersonalAccessTokens::Instance::PolicyWorker, type: :worker do
before do
stub_application_setting(max_personal_access_token_lifetime: instance_limit)
stub_licensed_features(personal_access_token_expiration_policy: true)
end
context 'when a token is valid' do
......
......@@ -37,18 +37,6 @@ class Feature
push_frontend_feature_flag(:my_ops_flag, project, type: :ops)
EOS
},
licensed: {
description: 'Permanent feature flags used to temporarily disable licensed features.',
deprecated: true,
optional: true,
rollout_issue: false,
ee_only: true,
default_enabled: true,
example: <<-EOS
project.feature_available?(:my_licensed_feature)
namespace.feature_available?(:my_licensed_feature)
EOS
},
experiment: {
description: 'Short lived, used specifically to run A/B/n experiments.',
optional: true,
......
......@@ -265,16 +265,9 @@ RSpec.describe 'bin/feature-flag' do
end
describe '.read_ee_only' do
where(:type, :is_ee_only) do
:development | false
:licensed | true
end
with_them do
let(:options) { OpenStruct.new(name: 'foo', type: type) }
let(:options) { OpenStruct.new(name: 'foo', type: :development) }
it { expect(described_class.read_ee_only(options)).to eq(is_ee_only) }
end
it { expect(described_class.read_ee_only(options)).to eq(false) }
end
end
end
......@@ -207,27 +207,6 @@ describe('IntegrationForm', () => {
expect(findJiraTriggerFields().exists()).toBe(true);
});
describe('featureFlag jiraIssuesIntegration is false', () => {
it('does not render JiraIssuesFields', () => {
createComponent({
customStateProps: { type: 'jira' },
featureFlags: { jiraIssuesIntegration: false },
});
expect(findJiraIssuesFields().exists()).toBe(false);
});
});
describe('featureFlag jiraIssuesIntegration is true', () => {
it('renders JiraIssuesFields', () => {
createComponent({
customStateProps: { type: 'jira' },
featureFlags: { jiraIssuesIntegration: true },
});
expect(findJiraIssuesFields().exists()).toBe(true);
});
});
});
describe('triggerEvents is present', () => {
......
......@@ -11,6 +11,10 @@ describe('GitLab Feature Flags Plugin', () => {
aFeature: true,
bFeature: false,
},
licensed_features: {
cFeature: true,
dFeature: false,
},
};
localVue.use(GlFeatureFlags);
......@@ -25,6 +29,8 @@ describe('GitLab Feature Flags Plugin', () => {
expect(wrapper.vm.glFeatures).toEqual({
aFeature: true,
bFeature: false,
cFeature: true,
dFeature: false,
});
});
......@@ -37,6 +43,8 @@ describe('GitLab Feature Flags Plugin', () => {
expect(wrapper.vm.glFeatures).toEqual({
aFeature: true,
bFeature: false,
cFeature: true,
dFeature: false,
});
});
});
......@@ -269,7 +269,7 @@ RSpec.describe Feature, stub_feature_flags: false do
end
it 'when invalid type is used' do
expect { described_class.enabled?(:my_feature_flag, type: :licensed) }
expect { described_class.enabled?(:my_feature_flag, type: :ops) }
.to raise_error(/The `type:` of/)
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