From f66e1c173406d2e447d46aab99f51c1277c801bc Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Thu, 6 Apr 2017 00:55:49 +0100 Subject: Destroys pipeline table component when we change tabs in order to stop polling --- app/assets/javascripts/merge_request_tabs.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'app/assets/javascripts/merge_request_tabs.js') diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index 3c4e6102469..7cb42a172af 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -99,9 +99,10 @@ import './flash'; .off('click', this.clickTab); } - destroy() { - this.unbindEvents(); + destroyPipelinesView() { if (this.commitPipelinesTable) { + document.querySelector('#commit-pipeline-table-view') + .removeChild(this.commitPipelinesTable.$el); this.commitPipelinesTable.$destroy(); } } @@ -128,6 +129,7 @@ import './flash'; this.loadCommits($target.attr('href')); this.expandView(); this.resetViewContainer(); + this.destroyPipelinesView(); } else if (this.isDiffAction(action)) { this.loadDiff($target.attr('href')); if (Breakpoints.get().getBreakpointSize() !== 'lg') { @@ -136,12 +138,14 @@ import './flash'; if (this.diffViewType() === 'parallel') { this.expandViewContainer(); } + this.destroyPipelinesView(); } else if (action === 'pipelines') { this.resetViewContainer(); - this.loadPipelines(); + this.mountPipelinesView(); } else { this.expandView(); this.resetViewContainer(); + this.destroyPipelinesView(); } if (this.setUrl) { this.setCurrentAction(action); @@ -227,16 +231,12 @@ import './flash'; }); } - loadPipelines() { - if (this.pipelinesLoaded) { - return; - } - const pipelineTableViewEl = document.querySelector('#commit-pipeline-table-view'); - // Could already be mounted from the `pipelines_bundle` - if (pipelineTableViewEl) { - this.commitPipelinesTable = new CommitPipelinesTable().$mount(pipelineTableViewEl); - } - this.pipelinesLoaded = true; + mountPipelinesView() { + this.commitPipelinesTable = new CommitPipelinesTable().$mount(); + // $mount(el) replaces the el with the new rendered component. We need it in order to mount + // it everytime this tab is clicked - https://vuejs.org/v2/api/#vm-mount + document.querySelector('#commit-pipeline-table-view') + .appendChild(this.commitPipelinesTable.$el); } loadDiff(source) { -- cgit v1.2.1 From ae62fc05e9032329aed279c859f260f1d50e1bbc Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Thu, 6 Apr 2017 23:19:30 -0500 Subject: Fixes failing spec --- app/assets/javascripts/merge_request_tabs.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/assets/javascripts/merge_request_tabs.js') diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index 7cb42a172af..8528e0800ae 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -90,6 +90,7 @@ import './flash'; .on('click', this.clickTab); } + // Used in tests unbindEvents() { $(document) .off('shown.bs.tab', '.merge-request-tabs a[data-toggle="tab"]', this.tabShown) @@ -103,6 +104,7 @@ import './flash'; if (this.commitPipelinesTable) { document.querySelector('#commit-pipeline-table-view') .removeChild(this.commitPipelinesTable.$el); + this.commitPipelinesTable.$destroy(); } } -- cgit v1.2.1 From ac35566403652fc5cea0c42b273169584e5c9ce2 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 7 Apr 2017 13:11:42 +0100 Subject: Fixed duplicate jQuery AJAX spyon --- app/assets/javascripts/merge_request_tabs.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/assets/javascripts/merge_request_tabs.js') diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index 8528e0800ae..7f6c74ce39a 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -102,10 +102,10 @@ import './flash'; destroyPipelinesView() { if (this.commitPipelinesTable) { - document.querySelector('#commit-pipeline-table-view') - .removeChild(this.commitPipelinesTable.$el); - this.commitPipelinesTable.$destroy(); + this.commitPipelinesTable = null; + + document.querySelector('#commit-pipeline-table-view').innerHTML = ''; } } -- cgit v1.2.1 From 4bdbccfc066b3ff1ed3bd29a6266215ed2421df3 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Fri, 7 Apr 2017 19:36:09 +0000 Subject: Remove Vue from main bundle and disable production warnings --- app/assets/javascripts/merge_request_tabs.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'app/assets/javascripts/merge_request_tabs.js') diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index 7f6c74ce39a..f7f6a773036 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -3,9 +3,6 @@ /* global Flash */ import Cookies from 'js-cookie'; - -import CommitPipelinesTable from './commit/pipelines/pipelines_table'; - import './breakpoints'; import './flash'; @@ -234,7 +231,7 @@ import './flash'; } mountPipelinesView() { - this.commitPipelinesTable = new CommitPipelinesTable().$mount(); + this.commitPipelinesTable = new gl.CommitPipelinesTable().$mount(); // $mount(el) replaces the el with the new rendered component. We need it in order to mount // it everytime this tab is clicked - https://vuejs.org/v2/api/#vm-mount document.querySelector('#commit-pipeline-table-view') -- cgit v1.2.1 From a27b59f620ff26c9b358c5a34e175a6a513c9d15 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Sat, 22 Apr 2017 00:54:03 -0500 Subject: Fix diffs with edit-forking needs Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/31276 --- app/assets/javascripts/merge_request_tabs.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/assets/javascripts/merge_request_tabs.js') diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index f7f6a773036..6075157ec31 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -5,6 +5,7 @@ import Cookies from 'js-cookie'; import './breakpoints'; import './flash'; +import BlobForkSuggestion from './blob/blob_fork_suggestion'; /* eslint-disable max-len */ // MergeRequestTabs @@ -266,6 +267,16 @@ import './flash'; new gl.Diff(); this.scrollToElement('#diffs'); + + $('.diff-file').each((i, el) => { + new BlobForkSuggestion({ + openButtons: $(el).find('.js-edit-blob-link-fork-toggler'), + forkButtons: $(el).find('.js-fork-suggestion-button'), + cancelButtons: $(el).find('.js-cancel-fork-suggestion-button'), + suggestionSections: $(el).find('.js-file-fork-suggestion-section'), + actionTextPieces: $(el).find('.js-file-fork-suggestion-section-action'), + }); + }); }, }); } -- cgit v1.2.1 From c6b5ec0fd87a9a7ddea67f6b628fa1a65cdef3c2 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 25 Apr 2017 13:24:27 -0500 Subject: Update MR diff blob_fork_suggestion after jQuery update `.init()` was added in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10858 We need to add it the MR diff instance that was added in a separate MR and of course didn't add a conflict because it is a completely different piece --- app/assets/javascripts/merge_request_tabs.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/assets/javascripts/merge_request_tabs.js') diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index 6075157ec31..93c30c54a8e 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -275,7 +275,8 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion'; cancelButtons: $(el).find('.js-cancel-fork-suggestion-button'), suggestionSections: $(el).find('.js-file-fork-suggestion-section'), actionTextPieces: $(el).find('.js-file-fork-suggestion-section-action'), - }); + }) + .init(); }); }, }); -- cgit v1.2.1 From 5d74fc8a5496423b31eb4dc0daf02b39d0fb51de Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 11 May 2017 11:37:40 +0100 Subject: Use position sticky on merge request tabs Removes the need for Bootstraps affix on browser that support sticky positions. On these browsers, there should be a slight performance improvement as there will be no scrolling events, it will all be handled by the browser --- app/assets/javascripts/merge_request_tabs.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/assets/javascripts/merge_request_tabs.js') diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index 93c30c54a8e..a3dff25c93b 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -358,6 +358,13 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion'; // So we dont affix the tabs on these if (Breakpoints.get().getBreakpointSize() === 'xs' || !$tabs.length) return; + /** + If the browser does not support position sticky, it returns the position as static. + If the browser does support sticky, then we allow the browser to handle it, if not + then we default back to Bootstraps affix + **/ + if ($tabs.css('position') !== 'static') return; + const $diffTabs = $('#diff-notes-app'); $tabs.off('affix.bs.affix affix-top.bs.affix') -- cgit v1.2.1 From 52accce3854df8f6258c1699aacff8d460c8048d Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Gray Date: Mon, 17 Apr 2017 15:54:26 -0500 Subject: Add fixed positioning to top level navbar --- app/assets/javascripts/merge_request_tabs.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/assets/javascripts/merge_request_tabs.js') diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index a3dff25c93b..ebb217ab13a 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -353,6 +353,7 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion'; initAffix() { const $tabs = $('.js-tabs-affix'); + const $fixedNav = $('.navbar-gitlab'); // Screen space on small screens is usually very sparse // So we dont affix the tabs on these @@ -371,7 +372,7 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion'; .affix({ offset: { top: () => ( - $diffTabs.offset().top - $tabs.height() + $diffTabs.offset().top - $tabs.height() - $fixedNav.height() ), }, }) -- cgit v1.2.1 From 16da7f2365fe67c078a2f10766662b93fe8576fc Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 12 May 2017 05:19:32 -0500 Subject: Fix linking to resolved note in diff Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/32125 --- app/assets/javascripts/merge_request_tabs.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'app/assets/javascripts/merge_request_tabs.js') diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index 93c30c54a8e..efbfdbcee0c 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -1,6 +1,7 @@ /* eslint-disable no-new, class-methods-use-this */ /* global Breakpoints */ /* global Flash */ +/* global notes */ import Cookies from 'js-cookie'; import './breakpoints'; @@ -251,7 +252,8 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion'; this.ajaxGet({ url: `${urlPathname}.json${location.search}`, success: (data) => { - $('#diffs').html(data.html); + const $container = $('#diffs'); + $container.html(data.html); if (typeof gl.diffNotesCompileComponents !== 'undefined') { gl.diffNotesCompileComponents(); @@ -278,6 +280,20 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion'; }) .init(); }); + + // Scroll any linked note into view + // Similar to `toggler_behavior` in the discussion tab + const hash = window.gl.utils.getLocationHash(); + const anchor = hash && $container.find(`[id="${hash}"]`); + if (anchor) { + const notesContent = anchor.closest('.notes_content'); + const lineType = notesContent.hasClass('new') ? 'new' : 'old'; + notes.addDiffNote(anchor, lineType, false); + anchor[0].scrollIntoView(); + // We have multiple elements on the page with `#note_xxx` + // (discussion and diff tabs) and `:target` only applies to the first + anchor.addClass('target'); + } }, }); } -- cgit v1.2.1 From 027ad1381e509236b789c58ee7b3d057dd5517b5 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 17 May 2017 14:58:47 -0500 Subject: Fix linking to unresolved/expanded diff note Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/32424 Bug introduced in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11327 --- app/assets/javascripts/merge_request_tabs.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/assets/javascripts/merge_request_tabs.js') diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index 37822dac064..22032d0f914 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -288,7 +288,11 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion'; if (anchor) { const notesContent = anchor.closest('.notes_content'); const lineType = notesContent.hasClass('new') ? 'new' : 'old'; - notes.addDiffNote(anchor, lineType, false); + notes.toggleDiffNote({ + target: anchor, + lineType, + forceShow: true, + }); anchor[0].scrollIntoView(); // We have multiple elements on the page with `#note_xxx` // (discussion and diff tabs) and `:target` only applies to the first -- cgit v1.2.1