aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorStas Vilchik <stas-vilchik@users.noreply.github.com>2017-05-29 15:12:43 +0200
committerGitHub <noreply@github.com>2017-05-29 15:12:43 +0200
commit864a48b81170cad29c207e67fe855b77ce84e439 (patch)
tree09d01df09d35f87514e3f3959701161a45b5de3b /server/sonar-web
parent115a5fd971e6dcfdbbc502b6dbf8876e744cd0a8 (diff)
downloadsonarqube-864a48b81170cad29c207e67fe855b77ce84e439.tar.gz
sonarqube-864a48b81170cad29c207e67fe855b77ce84e439.zip
drop legacy code from libs/ (#2118)
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/package.json1
-rw-r--r--server/sonar-web/src/main/js/app/index.js6
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/views/measures-overlay.js7
-rw-r--r--server/sonar-web/src/main/js/helpers/isolatedScroll.js (renamed from server/sonar-web/src/main/js/libs/select2-jquery-ui-fix.js)19
-rw-r--r--server/sonar-web/src/main/js/libs/application.js320
-rw-r--r--server/sonar-web/src/main/js/libs/inputs.js130
-rw-r--r--server/sonar-web/src/main/js/libs/jquery-isolated-scroll.js33
-rw-r--r--server/sonar-web/yarn.lock10
8 files changed, 18 insertions, 508 deletions
diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json
index f2b65457ee2..b23ac52b4c8 100644
--- a/server/sonar-web/package.json
+++ b/server/sonar-web/package.json
@@ -97,7 +97,6 @@
"react-transform-hmr": "1.0.4",
"recursive-readdir": "2.1.0",
"rimraf": "2.5.4",
- "script-loader": "0.6.1",
"strip-ansi": "3.0.1",
"style-loader": "0.13.0",
"webpack": "1.13.2",
diff --git a/server/sonar-web/src/main/js/app/index.js b/server/sonar-web/src/main/js/app/index.js
index 7f47d67b34d..dc41bcf0c51 100644
--- a/server/sonar-web/src/main/js/app/index.js
+++ b/server/sonar-web/src/main/js/app/index.js
@@ -22,13 +22,9 @@ import startAjaxMonitoring from './utils/startAjaxMonitoring';
import startReactApp from './utils/startReactApp';
import installExtensionsHandler from './utils/installExtensionsHandler';
import { installGlobal } from '../helpers/l10n';
+import '../helpers/isolatedScroll';
import './styles/index';
-require('script!../libs/select2-jquery-ui-fix.js');
-require('script!../libs/inputs.js');
-require('script!../libs/jquery-isolated-scroll.js');
-require('script!../libs/application.js');
-
startAjaxMonitoring();
installGlobal();
startReactApp();
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/views/measures-overlay.js b/server/sonar-web/src/main/js/components/SourceViewer/views/measures-overlay.js
index 8628d22773a..23190cd383a 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/views/measures-overlay.js
+++ b/server/sonar-web/src/main/js/components/SourceViewer/views/measures-overlay.js
@@ -27,6 +27,11 @@ import { getMeasures } from '../../../api/measures';
import { getMetrics } from '../../../api/metrics';
import { formatMeasure } from '../../../helpers/measures';
+const severityComparator = severity => {
+ const SEVERITIES_ORDER = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'];
+ return SEVERITIES_ORDER.indexOf(severity);
+};
+
export default ModalView.extend({
template: Template,
testsOrder: ['ERROR', 'FAILURE', 'OK', 'SKIPPED'],
@@ -168,7 +173,7 @@ export default ModalView.extend({
const severitiesFacet = data.facets.find(facet => facet.property === 'severities').values;
const sortedSeveritiesFacet = sortBy(severitiesFacet, facet =>
- window.severityComparator(facet.val)
+ severityComparator(facet.val)
);
const tagsFacet = data.facets.find(facet => facet.property === 'tags').values;
diff --git a/server/sonar-web/src/main/js/libs/select2-jquery-ui-fix.js b/server/sonar-web/src/main/js/helpers/isolatedScroll.js
index b23785150f6..2c03768b89e 100644
--- a/server/sonar-web/src/main/js/libs/select2-jquery-ui-fix.js
+++ b/server/sonar-web/src/main/js/helpers/isolatedScroll.js
@@ -17,12 +17,15 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* https://github.com/ivaynberg/select2/issues/1246 */
+import $ from 'jquery';
-(function($) {
-
- $.ui.dialog.prototype._allowInteraction = function(e) {
- return !!$(e.target).closest('.ui-dialog, .ui-datepicker, .select2-drop').length;
- };
-
-})(jQuery);
+$.fn.isolatedScroll = function() {
+ this.on('wheel', function(event) {
+ const delta = -event.originalEvent.deltaY;
+ const bottomOverflow = this.scrollTop + $(this).outerHeight() - this.scrollHeight >= 0;
+ const topOverflow = this.scrollTop <= 0;
+ if ((delta < 0 && bottomOverflow) || (delta > 0 && topOverflow)) {
+ event.preventDefault();
+ }
+ });
+};
diff --git a/server/sonar-web/src/main/js/libs/application.js b/server/sonar-web/src/main/js/libs/application.js
deleted file mode 100644
index 400eb1d5bc4..00000000000
--- a/server/sonar-web/src/main/js/libs/application.js
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-/*
- * Global Messages
- */
-
-(function () {
- /**
- * Show a global message
- * @param {string} id
- * @param {string} message
- */
- window.showMessage = function (id, message) {
- jQuery('#' + id + 'msg').text(message);
- jQuery('#' + id).removeClass('hidden');
- jQuery('#messages-panel').removeClass('hidden');
- };
-
- /**
- * Hide a global message
- * @param {string} id
- * @returns {boolean} always false
- */
- window.hideMessage = function (id) {
- jQuery('#' + id).addClass('hidden');
- var messagePanel = jQuery('#messages-panel'),
- isEmpty = messagePanel.children('*:not(.hidden)').length === 0;
- messagePanel.toggleClass('hidden', isEmpty);
- return false;
- };
-
- /**
- * Show a global error message
- * @param {string} message
- */
- window.error = function (message) {
- window.showMessage('error', message);
- };
-
- /**
- * Show a global warning message
- * @param {string} message
- */
- window.warning = function (message) {
- window.showMessage('warning', message);
- };
-
- /**
- * Show a global info message
- * @param {string} message
- */
- window.info = function (message) {
- window.showMessage('info', message);
- };
-
- /**
- * Hide a global error message
- * @returns {boolean} always false
- */
- window.hideError = function () {
- return window.hideMessage('error');
- };
-
- /**
- * Hide a global warning message
- * @returns {boolean} always false
- */
- window.hideWarning = function () {
- return window.hideMessage('warning');
- };
-
- /**
- * Hide a global info message
- * @returns {boolean} always false
- */
- window.hideInfo = function () {
- return window.hideMessage('info');
- };
-})();
-
-
-
-function toggleFav (resourceId, elt) {
- jQuery.ajax({
- type: 'POST', dataType: 'json', url: window.baseUrl + '/favourites/toggle/' + resourceId,
- success: function (data) {
- var star = jQuery(elt);
- star.removeClass('icon-favorite icon-not-favorite');
- star.addClass(data.css);
- star.attr('title', data.title);
- }
- });
-}
-
-function dashboardParameters (urlHasSomething) {
- var queryString = window.location.search;
- var parameters = [];
-
- var matchDashboard = queryString.match(/did=\d+/);
- if (matchDashboard && jQuery('#is-project-dashboard').length === 1) {
- parameters.push(matchDashboard[0]);
- }
-
- var matchPeriod = queryString.match(/period=\d+/);
- if (matchPeriod) {
- // If we have a match for period, check that it is not project-specific
- var period = parseInt(/period=(\d+)/.exec(queryString)[1], 10);
- if (period <= 3) {
- parameters.push(matchPeriod[0]);
- }
- }
-
- var query = parameters.join('&');
- if (query !== '') {
- query = (urlHasSomething ? '&' : '?') + query;
- }
- return query;
-}
-
-function openModalWindow (url, options) {
- var width = (options && options.width) || 540;
- var $dialog = jQuery('#modal');
- if (!$dialog.length) {
- $dialog = jQuery('<div id="modal" class="ui-widget-overlay ui-front"></div>').appendTo('body');
- }
- jQuery.get(url, function (html) {
- $dialog.removeClass('ui-widget-overlay');
- $dialog.html(html);
- $dialog
- .dialog({
- dialogClass: 'no-close',
- width: width,
- draggable: false,
- autoOpen: false,
- modal: true,
- minHeight: 50,
- resizable: false,
- title: null,
- close: function () {
- jQuery('#modal').remove();
- }
- });
- $dialog.dialog('open');
- }).always(function () {
- $dialog.removeClass('ui-widget-overlay');
- });
- return false;
-}
-
-(function (jQuery) {
- jQuery.fn.extend({
- openModal: function () {
- return this.each(function () {
- var obj = jQuery(this);
- var url = obj.attr('modal-url') || obj.attr('href');
- return openModalWindow(url, { 'width': obj.attr('modal-width') });
- });
- },
- modal: function () {
- return this.each(function () {
- var obj = jQuery(this);
- obj.unbind('click');
- var $link = obj.bind('click', function () {
- $link.openModal();
- return false;
- });
- });
- },
- modalForm: function (ajax_options) {
- return this.each(function () {
- var obj = jQuery(this);
- obj.submit(function () {
- jQuery('input[type=submit], button', this).attr('disabled', 'disabled');
- jQuery.ajax(jQuery.extend({
- type: 'POST',
- url: obj.attr('action'),
- data: obj.serialize(),
- success: function () {
- window.location.reload();
- },
- error: function (xhr) {
- // If the modal window has defined a modal-error element, then returned text must be displayed in it
- var errorElt = obj.find('.modal-error');
- if (errorElt.length) {
- // Hide all loading images
- jQuery('.loading-image').addClass('hidden');
- // Re activate submit button
- jQuery('input[type=submit], button', obj).removeAttr('disabled');
- errorElt.show();
- errorElt.html(jQuery('<div/>').html(xhr.responseText).text());
- } else {
- // otherwise replace modal window by the returned text
- jQuery('#modal').html(xhr.responseText);
- }
- }
- }, ajax_options));
- return false;
- });
- });
- }
- });
-})(jQuery);
-
-function closeModalWindow () {
- jQuery('#modal').dialog('close');
- return false;
-}
-
-
-
-/*
- * Users
- */
-
-(function() {
-
- /**
- * Convert the result of api/users/search to select2 format
- */
- window.usersToSelect2 = function (response) {
- return {
- more: false,
- results: _.map(response.users, function(user) {
- return {
- id: user.login,
- text: user.name + ' (' + user.login + ')'
- };
- })
- };
- };
-
-})();
-
-
-
-/*
- * Misc
- */
-
-(function () {
-
- /**
- * Comparator for _.sortBy()-like functions
- *
- * Fit for natural severities order
- * @param {string} severity
- * @returns {number}
- */
- window.severityComparator = function (severity) {
- var SEVERITIES_ORDER = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'];
- return SEVERITIES_ORDER.indexOf(severity);
- };
-
-
- /**
- * Comparator for _.sortBy()-like functions
- *
- * Fit for facet-like display:
- * BLOCKER MINOR
- * CRITICAL INFO
- * MAJOR
- * @param {string} severity
- * @returns {number}
- */
- window.severityColumnsComparator = function (severity) {
- var SEVERITIES_ORDER = ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR'];
- return SEVERITIES_ORDER.indexOf(severity);
- };
-
-
- /**
- * Return a hash of GET parameters
- * @returns {object}
- */
- window.getQueryParams = function () {
- var qs = window.location.search.split('+').join(' '),
- params = {},
- re = /[?&]?([^=]+)=([^&]*)/g,
- tokens = re.exec(qs);
- while (tokens) {
- params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
- tokens = re.exec(qs);
- }
- return params;
- };
-
-})();
-
-(function () {
- jQuery(function () {
-
- // Process login link in order to add the anchor
- jQuery('#login-link').on('click', function (e) {
- e.preventDefault();
- var href = jQuery(this).prop('href'),
- hash = window.location.hash;
- if (hash.length > 0) {
- href += decodeURIComponent(hash);
- }
- window.location = href;
- });
- });
-})();
diff --git a/server/sonar-web/src/main/js/libs/inputs.js b/server/sonar-web/src/main/js/libs/inputs.js
deleted file mode 100644
index 181a90b73b0..00000000000
--- a/server/sonar-web/src/main/js/libs/inputs.js
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-(function ($) {
-
- function transformPattern (pattern) {
- return pattern.replace(/\{0\}/g, '(\\d+)');
- }
-
- function convertWorkDuration (value) {
- var days, daysPattern, hours, hoursPattern, minutes, minutesPattern;
- if (value === '0') {
- return 0;
- }
- daysPattern = transformPattern(t('work_duration.x_days'));
- hoursPattern = transformPattern(t('work_duration.x_hours'));
- minutesPattern = transformPattern(t('work_duration.x_minutes'));
- days = value.match(daysPattern);
- hours = value.match(hoursPattern);
- minutes = value.match(minutesPattern);
- days = days ? +days[1] : 0;
- hours = hours ? +hours[1] : 0;
- minutes = minutes ? +minutes[1] : 0;
- if (!value) {
- return value;
- } else {
- return (days * window.SS.hoursInDay + hours) * 60 + minutes;
- }
- }
-
- function restoreWorkDuration (value) {
- var days, hours, minutes, result;
- if (value === '0' || value === 0) {
- return '0';
- }
- if (!/^\d+$/.test(value)) {
- return value;
- }
- days = Math.floor(value / (window.SS.hoursInDay * 60));
- hours = Math.floor((value - days * window.SS.hoursInDay * 60) / 60);
- minutes = value % 60;
- result = [];
- if (days > 0) {
- result.push(t('work_duration.x_days').replace('{0}', days));
- }
- if (hours > 0) {
- result.push(t('work_duration.x_hours').replace('{0}', hours));
- }
- if (minutes > 0) {
- result.push(t('work_duration.x_minutes').replace('{0}', minutes));
- }
- return result.join(' ');
- }
-
- function convertRating (value) {
- if (/^[ABCDE]$/.test(value)) {
- return value.charCodeAt(0) - 'A'.charCodeAt(0) + 1;
- } else {
- return value;
- }
- }
-
- function convertValue (value, input) {
- var type;
- type = input.data('type');
- if (type == null) {
- return value;
- }
- switch (type) {
- case 'WORK_DUR':
- return convertWorkDuration(value);
- case 'RATING':
- return convertRating(value);
- default:
- return value;
- }
- }
-
- function restoreRating (value) {
- if (!/^[12345]+$/.test(value)) {
- return value;
- }
- return String.fromCharCode(value - 1 + 'A'.charCodeAt(0));
- }
-
- function restoreValue (value, input) {
- var type;
- type = input.data('type');
- if (type == null) {
- return value;
- }
- switch (type) {
- case 'WORK_DUR':
- return restoreWorkDuration(value);
- case 'RATING':
- return restoreRating(value);
- default:
- return value;
- }
- }
-
- var originalVal = $.fn.val;
-
- $.fn.val = function (value) {
- if (arguments.length) {
- return originalVal.call(this, restoreValue(value, this));
- } else {
- return convertValue(originalVal.call(this), this);
- }
- };
-
- $.fn.originalVal = originalVal;
-
-})(window.jQuery);
diff --git a/server/sonar-web/src/main/js/libs/jquery-isolated-scroll.js b/server/sonar-web/src/main/js/libs/jquery-isolated-scroll.js
deleted file mode 100644
index 2495e0afc96..00000000000
--- a/server/sonar-web/src/main/js/libs/jquery-isolated-scroll.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-(function ($) {
-
- $.fn.isolatedScroll = function () {
- this.on('wheel', function (e) {
- var delta = -e.originalEvent.deltaY;
- var bottomOverflow = this.scrollTop + $(this).outerHeight() - this.scrollHeight >= 0;
- var topOverflow = this.scrollTop <= 0;
- if ((delta < 0 && bottomOverflow) || (delta > 0 && topOverflow)) {
- e.preventDefault();
- }
- });
- };
-
-})(window.jQuery);
diff --git a/server/sonar-web/yarn.lock b/server/sonar-web/yarn.lock
index f424d809212..e914ce35715 100644
--- a/server/sonar-web/yarn.lock
+++ b/server/sonar-web/yarn.lock
@@ -4934,10 +4934,6 @@ raw-body@^1.1.6:
bytes "1.0.0"
iconv-lite "0.4.8"
-raw-loader@~0.5.1:
- version "0.5.1"
- resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-0.5.1.tgz#0c3d0beaed8a01c966d9787bf778281252a979aa"
-
rc-align@2.x:
version "2.3.3"
resolved "https://registry.yarnpkg.com/rc-align/-/rc-align-2.3.3.tgz#15e2fd329fde9c2dec16e4a0e0ec20fba2ffdbc0"
@@ -5416,12 +5412,6 @@ sax@^1.2.1, sax@~1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.1.tgz#7b8e656190b228e81a66aea748480d828cd2d37a"
-script-loader@0.6.1:
- version "0.6.1"
- resolved "https://registry.yarnpkg.com/script-loader/-/script-loader-0.6.1.tgz#183c6103945aaf5134b46f03003b5ee2bad44ceb"
- dependencies:
- raw-loader "~0.5.1"
-
select@^1.0.6:
version "1.1.0"
resolved "https://registry.yarnpkg.com/select/-/select-1.1.0.tgz#a6c520cd9ab919ad81c7d1a273e0452f504dd7a2"