Commit ba7bb7ab authored by Fernando's avatar Fernando

Rework feature flag logic

* Use mixin approach
parent ede39d83
<script>
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { mapState, mapGetters, mapActions } from 'vuex';
import { GlButton, GlLoadingIcon, GlIcon, GlPopover } from '@gitlab/ui';
import { s__ } from '~/locale';
......@@ -11,6 +12,7 @@ import DeleteConfirmationModal from './components/delete_confirmation_modal.vue'
import PaginatedList from '~/vue_shared/components/paginated_list.vue';
import LicenseApprovals from '../../approvals/components/license_compliance/index.vue';
export default {
name: 'LicenseManagement',
components: {
......@@ -49,7 +51,7 @@ export default {
return this.isLoadingManagedLicenses && !this.hasPendingLicenses;
},
isTooltipEnabled() {
return Boolean(gon?.features?.licenseComplianceDeniesMr);
return Boolean(this.glFeatures.licenseComplianceDeniesMr);
},
},
watch: {
......
......@@ -5,8 +5,8 @@ module Projects
before_action :authorize_read_licenses!, only: [:index]
before_action :authorize_admin_software_license_policy!, only: [:create, :update]
before_action do
push_frontend_feature_flag(:license_policy_list, default_enabled: true)
push_frontend_feature_flag(:license_approvals, default_enabled: false)
push_frontend_feature_flag(:license_compliance_denies_mr, default_enabled: false)
end
def index
......
......@@ -30,7 +30,7 @@ const PaginatedListMock = {
const noop = () => {};
const createComponent = ({ state, getters, props, actionMocks, isAdmin, options }) => {
const createComponent = ({ state, getters, props, actionMocks, isAdmin, options, provide }) => {
const fakeStore = new Vuex.Store({
modules: {
licenseManagement: {
......@@ -63,16 +63,16 @@ const createComponent = ({ state, getters, props, actionMocks, isAdmin, options
stubs: {
PaginatedList: PaginatedListMock,
},
provide: {
glFeatures: { licenseComplianceDeniesMr: false },
...provide
},
store: fakeStore,
...options,
});
};
describe('License Management', () => {
beforeEach(() => {
window.gon = { features: { licenseComplianceDeniesMr: false } };
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
......@@ -197,11 +197,12 @@ describe('License Management', () => {
describe('when licenseComplianceDeniesMr feature flag enabled', () => {
it('should not show the developer only tooltip', () => {
window.gon.features.licenseComplianceDeniesMr = true;
createComponent({
state: { isLoadingManagedLicenses: false },
isAdmin: true,
provide: {
glFeatures: { licenseComplianceDeniesMr: true },
},
});
expect(wrapper.find(GlIcon).exists()).toBe(false);
......@@ -211,8 +212,6 @@ describe('License Management', () => {
describe('when licenseComplianceDeniesMr feature flag disabled', () => {
it('should not show the developer only tooltip', () => {
window.gon.features.licenseComplianceDeniesMr = false;
createComponent({
state: { isLoadingManagedLicenses: false },
isAdmin: true,
......@@ -263,11 +262,13 @@ describe('License Management', () => {
describe('when licenseComplianceDeniesMr feature flag enabled', () => {
it('should show the developer only tooltip', () => {
window.gon.features.licenseComplianceDeniesMr = true;
createComponent({
state: { isLoadingManagedLicenses: false },
isAdmin: false,
provide: {
glFeatures: { licenseComplianceDeniesMr: true },
},
});
expect(wrapper.find(GlIcon).exists()).toBe(true);
......@@ -277,8 +278,6 @@ describe('License Management', () => {
describe('when licenseComplianceDeniesMr feature flag disabled', () => {
it('should not show the developer only tooltip', () => {
window.gon.features.licenseComplianceDeniesMr = false;
createComponent({
state: { isLoadingManagedLicenses: false },
isAdmin: false,
......
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