Commit 80b39e38 authored by Phil Hughes's avatar Phil Hughes

Removed EE specific inline JS

parent aef62b69
......@@ -82,6 +82,8 @@ import initIssuableSidebar from './init_issuable_sidebar';
// EE-only
import ApproversSelect from './approvers_select';
import AuditLogs from './audit_logs';
import initGeoInfoModal from './init_geo_info_modal';
import initGroupAnalytics from './init_group_analytics';
(function() {
var Dispatcher;
......@@ -119,6 +121,19 @@ import AuditLogs from './audit_logs';
});
});
function initBlobEE() {
const dataEl = document.getElementById('js-file-lock');
if (dataEl) {
const {
toggle_path,
path,
} = JSON.parse(dataEl.innerHTML);
PathLocks.init(toggle_path, path);
}
}
function initBlob() {
new LineHighlighter();
......@@ -144,6 +159,8 @@ import AuditLogs from './audit_logs';
actionTextPieces: document.querySelectorAll('.js-file-fork-suggestion-section-action'),
})
.init();
initBlobEE();
}
const filteredSearchEnabled = gl.FilteredSearchManager && document.querySelector('.filtered-search');
......@@ -347,9 +364,6 @@ import AuditLogs from './audit_logs';
shortcut_handler = new ShortcutsNavigation();
GpgBadges.fetch();
break;
case 'projects:edit':
new UsersSelect();
break;
case 'projects:imports:show':
new ProjectImport();
break;
......@@ -362,8 +376,11 @@ import AuditLogs from './audit_logs';
if ($('.blob-viewer').length) {
new BlobViewer();
}
initGeoInfoModal();
break;
case 'projects:edit':
new UsersSelect();
new GroupsSelect();
setupProjectEdit();
break;
case 'projects:pipelines:new':
......@@ -536,6 +553,23 @@ import AuditLogs from './audit_logs';
case 'admin:impersonation_tokens:index':
new gl.DueDateSelectors();
break;
case 'admin:licenses:new':
const $licenseFile = $('.license-file');
const $licenseKey = $('.license-key');
const showLicenseType = () => {
const $checkedFile = $('input[name="license_type"]:checked').val() === 'file';
$licenseFile.toggle($checkedFile);
$licenseKey.toggle(!$checkedFile);
};
$('input[name="license_type"]').on('change', showLicenseType);
showLicenseType();
break;
case 'groups:analytics:show':
initGroupAnalytics();
break;
}
switch (path.first()) {
case 'sessions':
......
export default () => {
const $modal = $('#modal-geo-info');
if (!$modal.length) return;
$modal
.appendTo('body')
.modal({
modal: true,
show: false,
})
.on('show.bs.modal', (e) => {
const {
cloneUrlPrimary,
cloneUrlSecondary,
} = $(e.currentTarget).data();
$('#geo-info-1').text(
`git clone ${(cloneUrlSecondary || '<clone url for secondary repository>')}`,
);
$('#geo-info-2').text(
`git remote set-url --push origin ${(cloneUrlPrimary || '<clone url for primary repository>')}`,
);
});
};
/* global Chart */
export default () => {
const dataEl = document.getElementById('js-analytics-data');
const data = JSON.parse(dataEl.innerHTML);
const labels = data.labels;
const outputElIds = ['push', 'issues_closed', 'merge_requests_created'];
outputElIds.forEach((id) => {
const el = document.getElementById(id);
const ctx = el.getContext('2d');
const chart = new Chart(ctx);
chart.Bar(
{
labels,
datasets: [{
fillColor: 'rgba(220,220,220,0.5)',
strokeColor: 'rgba(220,220,220,1)',
barStrokeWidth: 1,
barValueSpacing: 1,
barDatasetSpacing: 1,
data: data[id].data,
}],
},
{
scaleOverlay: true,
responsive: true,
maintainAspectRatio: false,
},
);
});
$('#event-stats').tablesorter();
};
......@@ -38,21 +38,3 @@
.form-actions
= f.submit 'Upload license', class: 'btn btn-primary'
:javascript
function showLicenseType() {
if ($("input[name='license_type']:checked").val() == "file")
{
$(".license-file").show();
$(".license-key").hide();
}
else
{
$(".license-file").hide();
$(".license-key").show();
}
}
$("input[name='license_type']").click(showLicenseType);
showLicenseType();
......@@ -121,24 +121,10 @@
%td= @stats[:total_events][index]
- [:push, :issues_closed, :merge_requests_created].each do |scope|
:javascript
var data = {
labels : #{@users.map(&:name).to_json},
datasets : [
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
barStrokeWidth: 1,
barValueSpacing: 1,
barDatasetSpacing: 1,
data : #{@stats[scope].to_json}
}
]
}
var ctx = $("##{scope}").get(0).getContext("2d");
new Chart(ctx).Bar(data,{"scaleOverlay": true, responsive: true, maintainAspectRatio: false});
:javascript
$("#event-stats").tablesorter();
%script#js-analytics-data{ type: "application/json" }
- data = {}
- data[:labels] = @users.map(&:name)
- [:push, :issues_closed, :merge_requests_created].each do |scope|
- data[scope] = {}
- data[scope][:data] = @stats[scope]
= data.to_json.html_safe
......@@ -21,8 +21,8 @@
= render 'projects/fork_suggestion'
- if @project.feature_available?(:file_locks)
:javascript
PathLocks.init(
'#{toggle_project_path_locks_path(@project)}',
'#{@path}'
);
%script#js-file-lock{ type: "application/json" }
- data = {}
- data[:path] = @path
- data[:toggle_path] = toggle_project_path_locks_path(@project)
= data.to_json.html_safe
......@@ -49,6 +49,3 @@
Description parsed with #{link_to "GitLab Flavored Markdown", help_page_path('user/markdown'), target: '_blank'}.
= render 'projects/ee/merge_request_approvals_settings', project: project, form: form
:javascript
new GroupsSelect();
......@@ -27,19 +27,3 @@
%p
%strong= 'Done.'
You can now commit and push code as you normally do, but with increased speed.
:javascript
$('#modal-geo-info')
.appendTo('body')
.modal({ modal: true, show: false })
.on('show.bs.modal', function() {
var data = $(this).data();
$('#geo-info-1').text(
'git clone ' +
(data.cloneUrlSecondary || '<clone url for secondary repository>')
);
$('#geo-info-2').text(
'git remote set-url --push origin ' +
(data.cloneUrlPrimary || '<clone url for primary repository>')
);
});
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