Commit 902525ab authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch '60213-fix-is-ee-webpack-checks' into 'master'

Replace runtime isEE check with compile time one

Closes #60213

See merge request gitlab-org/gitlab-ce!30351
parents 6a4cc804 7ca77203
...@@ -5,6 +5,7 @@ globals: ...@@ -5,6 +5,7 @@ globals:
gl: false gl: false
gon: false gon: false
localStorage: false localStorage: false
IS_EE: false
plugins: plugins:
- import - import
- html - html
......
...@@ -2,7 +2,6 @@ import IssuableFilteredSearchTokenKeys from 'ee_else_ce/filtered_search/issuable ...@@ -2,7 +2,6 @@ import IssuableFilteredSearchTokenKeys from 'ee_else_ce/filtered_search/issuable
import FilteredSearchContainer from '../filtered_search/container'; import FilteredSearchContainer from '../filtered_search/container';
import FilteredSearchManager from '../filtered_search/filtered_search_manager'; import FilteredSearchManager from '../filtered_search/filtered_search_manager';
import boardsStore from './stores/boards_store'; import boardsStore from './stores/boards_store';
import { isEE } from '~/lib/utils/common_utils';
export default class FilteredSearchBoards extends FilteredSearchManager { export default class FilteredSearchBoards extends FilteredSearchManager {
constructor(store, updateUrl = false, cantEdit = []) { constructor(store, updateUrl = false, cantEdit = []) {
...@@ -10,7 +9,7 @@ export default class FilteredSearchBoards extends FilteredSearchManager { ...@@ -10,7 +9,7 @@ export default class FilteredSearchBoards extends FilteredSearchManager {
page: 'boards', page: 'boards',
isGroupDecendent: true, isGroupDecendent: true,
stateFiltersSelector: '.issues-state-filters', stateFiltersSelector: '.issues-state-filters',
isGroup: isEE(), isGroup: IS_EE,
filteredSearchTokenKeys: IssuableFilteredSearchTokenKeys, filteredSearchTokenKeys: IssuableFilteredSearchTokenKeys,
}); });
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import Vue from 'vue'; import Vue from 'vue';
import './label'; import './label';
import { isEE, convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import IssueProject from './project'; import IssueProject from './project';
import boardsStore from '../stores/boards_store'; import boardsStore from '../stores/boards_store';
...@@ -91,13 +91,13 @@ class ListIssue { ...@@ -91,13 +91,13 @@ class ListIssue {
addMilestone(milestone) { addMilestone(milestone) {
const miletoneId = this.milestone ? this.milestone.id : null; const miletoneId = this.milestone ? this.milestone.id : null;
if (isEE && milestone.id !== miletoneId) { if (IS_EE && milestone.id !== miletoneId) {
this.milestone = new ListMilestone(milestone); this.milestone = new ListMilestone(milestone);
} }
} }
removeMilestone(removeMilestone) { removeMilestone(removeMilestone) {
if (isEE && removeMilestone && removeMilestone.id === this.milestone.id) { if (IS_EE && removeMilestone && removeMilestone.id === this.milestone.id) {
this.milestone = {}; this.milestone = {};
} }
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import { __ } from '~/locale'; import { __ } from '~/locale';
import ListLabel from './label'; import ListLabel from './label';
import ListAssignee from './assignee'; import ListAssignee from './assignee';
import { isEE, urlParamsToObject } from '~/lib/utils/common_utils'; import { urlParamsToObject } from '~/lib/utils/common_utils';
import boardsStore from '../stores/boards_store'; import boardsStore from '../stores/boards_store';
import ListMilestone from './milestone'; import ListMilestone from './milestone';
...@@ -58,7 +58,7 @@ class List { ...@@ -58,7 +58,7 @@ class List {
} else if (obj.user) { } else if (obj.user) {
this.assignee = new ListAssignee(obj.user); this.assignee = new ListAssignee(obj.user);
this.title = this.assignee.name; this.title = this.assignee.name;
} else if (isEE && obj.milestone) { } else if (IS_EE && obj.milestone) {
this.milestone = new ListMilestone(obj.milestone); this.milestone = new ListMilestone(obj.milestone);
this.title = this.milestone.title; this.title = this.milestone.title;
} }
...@@ -85,7 +85,7 @@ class List { ...@@ -85,7 +85,7 @@ class List {
entityType = 'label_id'; entityType = 'label_id';
} else if (this.assignee) { } else if (this.assignee) {
entityType = 'assignee_id'; entityType = 'assignee_id';
} else if (isEE && this.milestone) { } else if (IS_EE && this.milestone) {
entityType = 'milestone_id'; entityType = 'milestone_id';
} }
...@@ -205,7 +205,7 @@ class List { ...@@ -205,7 +205,7 @@ class List {
issue.addAssignee(this.assignee); issue.addAssignee(this.assignee);
} }
if (isEE && this.milestone) { if (IS_EE && this.milestone) {
if (listFrom && listFrom.type === 'milestone') { if (listFrom && listFrom.type === 'milestone') {
issue.removeMilestone(listFrom.milestone); issue.removeMilestone(listFrom.milestone);
} }
......
import { isEE } from '~/lib/utils/common_utils';
export default class ListMilestone { export default class ListMilestone {
constructor(obj) { constructor(obj) {
this.id = obj.id; this.id = obj.id;
this.title = obj.title; this.title = obj.title;
if (isEE) { if (IS_EE) {
this.path = obj.path; this.path = obj.path;
this.state = obj.state; this.state = obj.state;
this.webUrl = obj.web_url || obj.webUrl; this.webUrl = obj.web_url || obj.webUrl;
......
// Noop function which has a EE counter-part
export default () => {}; export default () => {};
...@@ -11,7 +11,7 @@ import CreateLabelDropdown from './create_label'; ...@@ -11,7 +11,7 @@ import CreateLabelDropdown from './create_label';
import flash from './flash'; import flash from './flash';
import ModalStore from './boards/stores/modal_store'; import ModalStore from './boards/stores/modal_store';
import boardsStore from './boards/stores/boards_store'; import boardsStore from './boards/stores/boards_store';
import { isEE, isScopedLabel } from '~/lib/utils/common_utils'; import { isScopedLabel } from '~/lib/utils/common_utils';
export default class LabelsSelect { export default class LabelsSelect {
constructor(els, options = {}) { constructor(els, options = {}) {
...@@ -140,7 +140,7 @@ export default class LabelsSelect { ...@@ -140,7 +140,7 @@ export default class LabelsSelect {
labelCount = data.labels.length; labelCount = data.labels.length;
// EE Specific // EE Specific
if (isEE) { if (IS_EE) {
/** /**
* For Scoped labels, the last label selected with the * For Scoped labels, the last label selected with the
* same key will be applied to the current issueable. * same key will be applied to the current issueable.
......
...@@ -726,14 +726,6 @@ export const NavigationType = { ...@@ -726,14 +726,6 @@ export const NavigationType = {
TYPE_RESERVED: 255, TYPE_RESERVED: 255,
}; };
/**
* Returns the value of `gon.ee`
* Used to check if it's the EE codebase or the CE one.
*
* @returns Boolean
*/
export const isEE = () => window.gon && window.gon.ee;
/** /**
* Checks if the given Label has a special syntax `::` in * Checks if the given Label has a special syntax `::` in
* it's title. * it's title.
......
...@@ -4,7 +4,6 @@ import _ from 'underscore'; ...@@ -4,7 +4,6 @@ import _ from 'underscore';
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import '~/vue_shared/mixins/is_ee';
import { getParameterValues } from '~/lib/utils/url_utility'; import { getParameterValues } from '~/lib/utils/url_utility';
import invalidUrl from '~/lib/utils/invalid_url'; import invalidUrl from '~/lib/utils/invalid_url';
import MonitorAreaChart from './charts/area.vue'; import MonitorAreaChart from './charts/area.vue';
...@@ -160,6 +159,12 @@ export default { ...@@ -160,6 +159,12 @@ export default {
selectedDashboardText() { selectedDashboardText() {
return this.currentDashboard || (this.allDashboards[0] && this.allDashboards[0].display_name); return this.currentDashboard || (this.allDashboards[0] && this.allDashboards[0].display_name);
}, },
addingMetricsAvailable() {
return IS_EE && this.canAddMetrics && !this.showEmptyState;
},
alertWidgetAvailable() {
return IS_EE && this.prometheusAlertsAvailable && this.alertsEndpoint;
},
}, },
created() { created() {
this.setEndpoints({ this.setEndpoints({
...@@ -313,7 +318,7 @@ export default { ...@@ -313,7 +318,7 @@ export default {
</div> </div>
</div> </div>
<div class="d-flex"> <div class="d-flex">
<div v-if="isEE && canAddMetrics && !showEmptyState"> <div v-if="addingMetricsAvailable">
<gl-button <gl-button
v-gl-modal-directive="$options.addMetric.modalId" v-gl-modal-directive="$options.addMetric.modalId"
class="js-add-metric-button text-success border-success" class="js-add-metric-button text-success border-success"
...@@ -372,7 +377,7 @@ export default { ...@@ -372,7 +377,7 @@ export default {
group-id="monitor-area-chart" group-id="monitor-area-chart"
> >
<alert-widget <alert-widget
v-if="isEE && prometheusAlertsAvailable && alertsEndpoint && graphData" v-if="alertWidgetAvailable && graphData"
:alerts-endpoint="alertsEndpoint" :alerts-endpoint="alertsEndpoint"
:relevant-queries="graphData.queries" :relevant-queries="graphData.queries"
:alerts-to-manage="getGraphAlerts(graphData.queries)" :alerts-to-manage="getGraphAlerts(graphData.queries)"
......
import Vue from 'vue'; import Vue from 'vue';
import { isEE } from '~/lib/utils/common_utils';
import initNoteStats from 'ee_else_ce/event_tracking/notes'; import initNoteStats from 'ee_else_ce/event_tracking/notes';
import notesApp from './components/notes_app.vue'; import notesApp from './components/notes_app.vue';
import initDiscussionFilters from './discussion_filters'; import initDiscussionFilters from './discussion_filters';
...@@ -41,9 +40,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -41,9 +40,7 @@ document.addEventListener('DOMContentLoaded', () => {
}; };
}, },
mounted() { mounted() {
if (isEE) { initNoteStats();
initNoteStats();
}
}, },
render(createElement) { render(createElement) {
return createElement('notes-app', { return createElement('notes-app', {
......
import Vue from 'vue';
import { isEE } from '~/lib/utils/common_utils';
Vue.mixin({
computed: {
isEE() {
return isEE();
},
},
});
...@@ -322,7 +322,10 @@ module.exports = { ...@@ -322,7 +322,10 @@ module.exports = {
}), }),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
// This one is used to define window.gon.ee and other things properly in tests:
'process.env.IS_GITLAB_EE': JSON.stringify(IS_EE), 'process.env.IS_GITLAB_EE': JSON.stringify(IS_EE),
// This one is used to check against "EE" properly in application code
IS_EE: IS_EE ? 'window.gon && window.gon.ee' : JSON.stringify(false),
}), }),
].filter(Boolean), ].filter(Boolean),
......
...@@ -8,7 +8,6 @@ import '~/commons'; ...@@ -8,7 +8,6 @@ import '~/commons';
import Vue from 'vue'; import Vue from 'vue';
import VueResource from 'vue-resource'; import VueResource from 'vue-resource';
import Translate from '~/vue_shared/translate'; import Translate from '~/vue_shared/translate';
import CheckEE from '~/vue_shared/mixins/is_ee';
import jasmineDiff from 'jasmine-diff'; import jasmineDiff from 'jasmine-diff';
import { config as testUtilsConfig } from '@vue/test-utils'; import { config as testUtilsConfig } from '@vue/test-utils';
...@@ -48,7 +47,6 @@ Vue.config.errorHandler = function(err) { ...@@ -48,7 +47,6 @@ Vue.config.errorHandler = function(err) {
Vue.use(VueResource); Vue.use(VueResource);
Vue.use(Translate); Vue.use(Translate);
Vue.use(CheckEE);
// enable test fixtures // enable test fixtures
jasmine.getFixtures().fixturesPath = FIXTURES_PATH; jasmine.getFixtures().fixturesPath = FIXTURES_PATH;
......
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