diff options
Diffstat (limited to 'app/assets/javascripts/pages/projects')
17 files changed, 86 insertions, 81 deletions
diff --git a/app/assets/javascripts/pages/projects/clusters/new/index.js b/app/assets/javascripts/pages/projects/clusters/new/index.js index 55aa29c9797..14d5ab21555 100644 --- a/app/assets/javascripts/pages/projects/clusters/new/index.js +++ b/app/assets/javascripts/pages/projects/clusters/new/index.js @@ -1,7 +1,13 @@ document.addEventListener('DOMContentLoaded', () => { if (gon.features.createEksClusters) { import(/* webpackChunkName: 'eks_cluster' */ '~/create_cluster/eks_cluster') - .then(({ default: initCreateEKSCluster }) => initCreateEKSCluster()) + .then(({ default: initCreateEKSCluster }) => { + const el = document.querySelector('.js-create-eks-cluster-form-container'); + + if (el) { + initCreateEKSCluster(el); + } + }) .catch(() => {}); } }); diff --git a/app/assets/javascripts/pages/projects/commit/pipelines/index.js b/app/assets/javascripts/pages/projects/commit/pipelines/index.js index 8cc3cb0a57c..9f08260c3d6 100644 --- a/app/assets/javascripts/pages/projects/commit/pipelines/index.js +++ b/app/assets/javascripts/pages/projects/commit/pipelines/index.js @@ -6,6 +6,7 @@ document.addEventListener('DOMContentLoaded', () => { new MiniPipelineGraph({ container: '.js-commit-pipeline-graph', }).bindEvents(); + // eslint-disable-next-line no-jquery/no-load $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath); initPipelines(); }); diff --git a/app/assets/javascripts/pages/projects/commit/show/index.js b/app/assets/javascripts/pages/projects/commit/show/index.js index 6fc982967eb..5aa4734244e 100644 --- a/app/assets/javascripts/pages/projects/commit/show/index.js +++ b/app/assets/javascripts/pages/projects/commit/show/index.js @@ -21,6 +21,7 @@ document.addEventListener('DOMContentLoaded', () => { }).bindEvents(); initNotes(); initChangesDropdown(document.querySelector('.navbar-gitlab').offsetHeight + performanceHeight); + // eslint-disable-next-line no-jquery/no-load $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath); fetchCommitMergeRequests(); initDiffNotes(); diff --git a/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors.js b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors.js index 76613394af6..5b873e6b909 100644 --- a/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors.js +++ b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors.js @@ -1,4 +1,4 @@ -/* eslint-disable func-names, no-var, one-var, camelcase, no-param-reassign, prefer-template, no-return-assign */ +/* eslint-disable func-names, no-var, one-var, camelcase, no-param-reassign, no-return-assign */ import $ from 'jquery'; import _ from 'underscore'; @@ -66,8 +66,8 @@ export default (function() { class: 'person', style: 'display: block;', }); - author_name = $('<h4>' + author.author_name + '</h4>'); - author_email = $('<p class="graph-author-email">' + author.author_email + '</p>'); + author_name = $(`<h4>${author.author_name}</h4>`); + author_email = $(`<p class="graph-author-email">${author.author_email}</p>`); author_commit_info_span = $('<span/>', { class: 'commits', }); diff --git a/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_graph.js b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_graph.js index 506e6075d16..86794800f87 100644 --- a/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_graph.js +++ b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_graph.js @@ -1,4 +1,4 @@ -/* eslint-disable func-names, no-restricted-syntax, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, no-return-assign, prefer-arrow-callback, prefer-template, no-else-return, no-shadow */ +/* eslint-disable func-names, no-restricted-syntax, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, no-return-assign, no-else-return, no-shadow */ import $ from 'jquery'; import _ from 'underscore'; @@ -69,24 +69,18 @@ export const ContributorsGraph = (function() { ContributorsGraph.set_y_domain = function(data) { return (ContributorsGraph.prototype.y_domain = [ 0, - d3.max(data, function(d) { - return (d.commits = d.commits || d.additions || d.deletions); - }), + d3.max(data, d => (d.commits = d.commits || d.additions || d.deletions)), ]); }; ContributorsGraph.init_x_domain = function(data) { - return (ContributorsGraph.prototype.x_domain = d3.extent(data, function(d) { - return d.date; - })); + return (ContributorsGraph.prototype.x_domain = d3.extent(data, d => d.date)); }; ContributorsGraph.init_y_domain = function(data) { return (ContributorsGraph.prototype.y_domain = [ 0, - d3.max(data, function(d) { - return (d.commits = d.commits || d.additions || d.deletions); - }), + d3.max(data, d => (d.commits = d.commits || d.additions || d.deletions)), ]); }; @@ -124,14 +118,11 @@ export const ContributorsGraph = (function() { }; ContributorsGraph.prototype.draw_x_axis = function() { - return ( - this.svg - .append('g') - .attr('class', 'x axis') - /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ - .attr('transform', 'translate(0, ' + this.height + ')') - .call(this.x_axis) - ); + return this.svg + .append('g') + .attr('class', 'x axis') + .attr('transform', `translate(0, ${this.height})`) + .call(this.x_axis); }; ContributorsGraph.prototype.draw_y_axis = function() { @@ -180,9 +171,7 @@ export const ContributorsMasterGraph = (function(superClass) { ContributorsMasterGraph.prototype.parse_dates = function(data) { const parseDate = d3.timeParse('%Y-%m-%d'); - return data.forEach(function(d) { - return (d.date = parseDate(d.date)); - }); + return data.forEach(d => (d.date = parseDate(d.date))); }; ContributorsMasterGraph.prototype.create_scale = function() { @@ -208,19 +197,16 @@ export const ContributorsMasterGraph = (function(superClass) { .attr('height', this.height + this.MARGIN.top + this.MARGIN.bottom) .attr('class', 'tint-box') .append('g') - /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ - .attr('transform', 'translate(' + this.MARGIN.left + ',' + this.MARGIN.top + ')'); + .attr('transform', `translate(${this.MARGIN.left},${this.MARGIN.top})`); return this.svg; }; ContributorsMasterGraph.prototype.create_area = function(x, y) { return (this.area = d3 .area() - .x(function(d) { - return x(d.date); - }) + .x(d => x(d.date)) .y0(this.height) - .y1(function(d) { + .y1(d => { d.commits = d.commits || d.additions || d.deletions; return y(d.commits); })); @@ -330,7 +316,7 @@ export const ContributorsAuthorGraph = (function(superClass) { ContributorsAuthorGraph.prototype.create_area = function(x, y) { return (this.area = d3 .area() - .x(function(d) { + .x(d => { const parseDate = d3.timeParse('%Y-%m-%d'); return x(parseDate(d)); }) @@ -358,8 +344,7 @@ export const ContributorsAuthorGraph = (function(superClass) { .attr('height', this.height + this.MARGIN.top + this.MARGIN.bottom) .attr('class', 'spark') .append('g') - /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ - .attr('transform', 'translate(' + this.MARGIN.left + ',' + this.MARGIN.top + ')'); + .attr('transform', `translate(${this.MARGIN.left},${this.MARGIN.top})`); return this.svg; }; diff --git a/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_util.js b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_util.js index 505ca938f40..a89a13fe37a 100644 --- a/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_util.js +++ b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_util.js @@ -1,4 +1,4 @@ -/* eslint-disable func-names, no-var, one-var, camelcase, no-param-reassign, no-return-assign, prefer-arrow-callback, consistent-return, no-cond-assign, no-else-return */ +/* eslint-disable func-names, no-var, one-var, camelcase, no-param-reassign, no-return-assign, consistent-return, no-cond-assign, no-else-return */ import _ from 'underscore'; export default { @@ -76,16 +76,12 @@ export default { var log, total_data; log = parsed_log.total; total_data = this.pick_field(log, field); - return _.sortBy(total_data, function(d) { - return d.date; - }); + return _.sortBy(total_data, d => d.date); }, pick_field(log, field) { var total_data; total_data = []; - _.each(log, function(d) { - return total_data.push(_.pick(d, [field, 'date'])); - }); + _.each(log, d => total_data.push(_.pick(d, [field, 'date']))); return total_data; }, get_author_data(parsed_log, field, date_range) { @@ -107,9 +103,7 @@ export default { }; })(this), ); - return _.sortBy(author_data, function(d) { - return d[field]; - }).reverse(); + return _.sortBy(author_data, d => d[field]).reverse(); }, parse_log_entry(log_entry, field, date_range) { var parsed_entry; diff --git a/app/assets/javascripts/pages/projects/issues/form.js b/app/assets/javascripts/pages/projects/issues/form.js index 2205a7bafe3..96e47187fed 100644 --- a/app/assets/javascripts/pages/projects/issues/form.js +++ b/app/assets/javascripts/pages/projects/issues/form.js @@ -15,7 +15,9 @@ export default () => { new IssuableForm($('.issue-form')); new LabelsSelect(); new MilestoneSelect(); - new IssuableTemplateSelectors(); + new IssuableTemplateSelectors({ + warnTemplateOverride: true, + }); initSuggestions(); }; diff --git a/app/assets/javascripts/pages/projects/issues/show.js b/app/assets/javascripts/pages/projects/issues/show.js index 0447d1f79fb..28a136a5fa5 100644 --- a/app/assets/javascripts/pages/projects/issues/show.js +++ b/app/assets/javascripts/pages/projects/issues/show.js @@ -5,6 +5,7 @@ import ZenMode from '~/zen_mode'; import '~/notes/index'; import initIssueableApp from '~/issue_show'; import initRelatedMergeRequestsApp from '~/related_merge_requests'; +import initVueIssuableSidebarApp from '~/issuable_sidebar/sidebar_bundle'; export default function() { initIssueableApp(); @@ -12,5 +13,9 @@ export default function() { new Issue(); // eslint-disable-line no-new new ShortcutsIssuable(); // eslint-disable-line no-new new ZenMode(); // eslint-disable-line no-new - initIssuableSidebar(); + if (gon.features && gon.features.vueIssuableSidebar) { + initVueIssuableSidebarApp(); + } else { + initIssuableSidebar(); + } } diff --git a/app/assets/javascripts/pages/projects/issues/show/index.js b/app/assets/javascripts/pages/projects/issues/show/index.js index 7968dfd7a12..ce74a6de11f 100644 --- a/app/assets/javascripts/pages/projects/issues/show/index.js +++ b/app/assets/javascripts/pages/projects/issues/show/index.js @@ -3,5 +3,7 @@ import initShow from '../show'; document.addEventListener('DOMContentLoaded', () => { initShow(); - initSidebarBundle(); + if (gon.features && !gon.features.vueIssuableSidebar) { + initSidebarBundle(); + } }); diff --git a/app/assets/javascripts/pages/projects/labels/components/promote_label_modal.vue b/app/assets/javascripts/pages/projects/labels/components/promote_label_modal.vue index e723cd3fea9..bb95f33c838 100644 --- a/app/assets/javascripts/pages/projects/labels/components/promote_label_modal.vue +++ b/app/assets/javascripts/pages/projects/labels/components/promote_label_modal.vue @@ -2,14 +2,14 @@ import _ from 'underscore'; import axios from '~/lib/utils/axios_utils'; import createFlash from '~/flash'; -import GlModal from '~/vue_shared/components/gl_modal.vue'; +import DeprecatedModal2 from '~/vue_shared/components/deprecated_modal_2.vue'; import { s__, sprintf } from '~/locale'; import { visitUrl } from '~/lib/utils/url_utility'; import eventHub from '../event_hub'; export default { components: { - GlModal, + GlModal: DeprecatedModal2, }, props: { url: { diff --git a/app/assets/javascripts/pages/projects/merge_requests/init_merge_request.js b/app/assets/javascripts/pages/projects/merge_requests/init_merge_request.js index 8f0dc8554e2..e51ab79a51d 100644 --- a/app/assets/javascripts/pages/projects/merge_requests/init_merge_request.js +++ b/app/assets/javascripts/pages/projects/merge_requests/init_merge_request.js @@ -16,5 +16,7 @@ export default () => { new IssuableForm($('.merge-request-form')); new LabelsSelect(); new MilestoneSelect(); - new IssuableTemplateSelectors(); + new IssuableTemplateSelectors({ + warnTemplateOverride: true, + }); }; diff --git a/app/assets/javascripts/pages/projects/merge_requests/init_merge_request_show.js b/app/assets/javascripts/pages/projects/merge_requests/init_merge_request_show.js index 7bfb83a2204..fa1de1f13cb 100644 --- a/app/assets/javascripts/pages/projects/merge_requests/init_merge_request_show.js +++ b/app/assets/javascripts/pages/projects/merge_requests/init_merge_request_show.js @@ -4,11 +4,16 @@ import ShortcutsIssuable from '~/behaviors/shortcuts/shortcuts_issuable'; import { handleLocationHash } from '~/lib/utils/common_utils'; import howToMerge from '~/how_to_merge'; import initPipelines from '~/commit/pipelines/pipelines_bundle'; +import initVueIssuableSidebarApp from '~/issuable_sidebar/sidebar_bundle'; import initWidget from '../../../vue_merge_request_widget'; export default function() { new ZenMode(); // eslint-disable-line no-new - initIssuableSidebar(); + if (gon.features && gon.features.vueIssuableSidebar) { + initVueIssuableSidebarApp(); + } else { + initIssuableSidebar(); + } initPipelines(); new ShortcutsIssuable(true); // eslint-disable-line no-new handleLocationHash(); diff --git a/app/assets/javascripts/pages/projects/merge_requests/show/index.js b/app/assets/javascripts/pages/projects/merge_requests/show/index.js index f61f4db78d5..ddc648702f1 100644 --- a/app/assets/javascripts/pages/projects/merge_requests/show/index.js +++ b/app/assets/javascripts/pages/projects/merge_requests/show/index.js @@ -4,6 +4,8 @@ import initShow from '../init_merge_request_show'; document.addEventListener('DOMContentLoaded', () => { initShow(); - initSidebarBundle(); + if (gon.features && !gon.features.vueIssuableSidebar) { + initSidebarBundle(); + } initMrNotes(); }); diff --git a/app/assets/javascripts/pages/projects/network/network.js b/app/assets/javascripts/pages/projects/network/network.js index 226d63f05c4..43417fa9702 100644 --- a/app/assets/javascripts/pages/projects/network/network.js +++ b/app/assets/javascripts/pages/projects/network/network.js @@ -1,4 +1,4 @@ -/* eslint-disable func-names, no-var, prefer-template */ +/* eslint-disable func-names, no-var */ import $ from 'jquery'; import BranchGraph from '../../../network/branch_graph'; @@ -14,7 +14,7 @@ export default (function() { this.branch_graph = new BranchGraph($('.network-graph'), opts); vph = $(window).height() - 250; $('.network-graph').css({ - height: vph + 'px', + height: `${vph}px`, }); } diff --git a/app/assets/javascripts/pages/projects/project.js b/app/assets/javascripts/pages/projects/project.js index b99408e3609..435e8705803 100644 --- a/app/assets/javascripts/pages/projects/project.js +++ b/app/assets/javascripts/pages/projects/project.js @@ -1,9 +1,9 @@ -/* eslint-disable func-names, no-var, no-return-assign, vars-on-top */ +/* eslint-disable func-names, no-var, no-return-assign */ import $ from 'jquery'; import Cookies from 'js-cookie'; import { __ } from '~/locale'; -import { visitUrl, mergeUrlParams } from '~/lib/utils/url_utility'; +import { mergeUrlParams } from '~/lib/utils/url_utility'; import { serializeForm } from '~/lib/utils/forms'; import axios from '~/lib/utils/axios_utils'; import flash from '~/flash'; @@ -105,6 +105,10 @@ export default class Project { var selected = $dropdown.data('selected'); var fieldName = $dropdown.data('fieldName'); var shouldVisit = Boolean($dropdown.data('visit')); + var $form = $dropdown.closest('form'); + var action = $form.attr('action'); + var linkTarget = mergeUrlParams(serializeForm($form[0]), action); + return $dropdown.glDropdown({ data(term, callback) { axios @@ -126,21 +130,18 @@ export default class Project { renderRow(ref) { var li = refListItem.cloneNode(false); - if (ref.header != null) { - li.className = 'dropdown-header'; - li.textContent = ref.header; - } else { - var link = refLink.cloneNode(false); - - if (ref === selected) { - link.className = 'is-active'; - } - - link.textContent = ref; - link.dataset.ref = ref; + var link = refLink.cloneNode(false); - li.appendChild(link); + if (ref === selected) { + link.className = 'is-active'; } + link.textContent = ref; + link.dataset.ref = ref; + if (ref.length > 0 && shouldVisit) { + link.href = mergeUrlParams({ [fieldName]: ref }, linkTarget); + } + + li.appendChild(link); return li; }, @@ -152,15 +153,11 @@ export default class Project { }, clicked(options) { const { e } = options; - e.preventDefault(); - if ($(`input[name="${fieldName}"]`).length) { - var $form = $dropdown.closest('form'); - var action = $form.attr('action'); - - if (shouldVisit) { - visitUrl(mergeUrlParams(serializeForm($form[0]), action)); - } + if (!shouldVisit) { + e.preventDefault(); } + /* The actual process is removed since `link.href` in `RenderRow` contains the full target. + * It makes the visitable link can be visited when opening on a new tab of browser */ }, }); }); diff --git a/app/assets/javascripts/pages/projects/releases/edit/index.js b/app/assets/javascripts/pages/projects/releases/edit/index.js index c70271b09c4..98ec196fc37 100644 --- a/app/assets/javascripts/pages/projects/releases/edit/index.js +++ b/app/assets/javascripts/pages/projects/releases/edit/index.js @@ -1,4 +1,7 @@ -import $ from 'jquery'; -import initForm from '~/pages/projects/init_form'; +import ZenMode from '~/zen_mode'; +import initEditRelease from '~/releases/detail'; -document.addEventListener('DOMContentLoaded', () => initForm($('.release-form'))); +document.addEventListener('DOMContentLoaded', () => { + new ZenMode(); // eslint-disable-line no-new + initEditRelease(); +}); diff --git a/app/assets/javascripts/pages/projects/releases/index/index.js b/app/assets/javascripts/pages/projects/releases/index/index.js index c183fbb9610..6402023149f 100644 --- a/app/assets/javascripts/pages/projects/releases/index/index.js +++ b/app/assets/javascripts/pages/projects/releases/index/index.js @@ -1,3 +1,3 @@ -import initReleases from '~/releases'; +import initReleases from '~/releases/list'; document.addEventListener('DOMContentLoaded', initReleases); |