BigW Consortium Gitlab

Commit fc025574 by James Lopez

Merge commit 'e7fdb1aa' into 8-16-stable

# Conflicts: # app/assets/javascripts/vue_pipelines_index/stage.js.es6
parents 8cd7b23c e7fdb1aa
...@@ -219,7 +219,7 @@ gem 'oj', '~> 2.17.4' ...@@ -219,7 +219,7 @@ gem 'oj', '~> 2.17.4'
gem 'chronic', '~> 0.10.2' gem 'chronic', '~> 0.10.2'
gem 'chronic_duration', '~> 0.10.6' gem 'chronic_duration', '~> 0.10.6'
gem 'sass-rails', '~> 5.0.6' gem 'sassc-rails', '~> 1.3.0'
gem 'coffee-rails', '~> 4.1.0' gem 'coffee-rails', '~> 4.1.0'
gem 'uglifier', '~> 2.7.2' gem 'uglifier', '~> 2.7.2'
gem 'gitlab-turbolinks-classic', '~> 2.5', '>= 2.5.6' gem 'gitlab-turbolinks-classic', '~> 2.5', '>= 2.5.6'
......
...@@ -667,12 +667,17 @@ GEM ...@@ -667,12 +667,17 @@ GEM
sanitize (2.1.0) sanitize (2.1.0)
nokogiri (>= 1.4.4) nokogiri (>= 1.4.4)
sass (3.4.22) sass (3.4.22)
sass-rails (5.0.6) sassc (1.11.1)
railties (>= 4.0.0, < 6) bundler
sass (~> 3.1) ffi (~> 1.9.6)
sprockets (>= 2.8, < 4.0) sass (>= 3.3.0)
sprockets-rails (>= 2.0, < 4.0) sassc-rails (1.3.0)
tilt (>= 1.1, < 3) railties (>= 4.0.0)
sass
sassc (~> 1.9)
sprockets (> 2.11)
sprockets-rails
tilt
sawyer (0.8.1) sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6) addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0) faraday (~> 0.8, < 1.0)
...@@ -971,7 +976,7 @@ DEPENDENCIES ...@@ -971,7 +976,7 @@ DEPENDENCIES
ruby-prof (~> 0.16.2) ruby-prof (~> 0.16.2)
rugged (~> 0.24.0) rugged (~> 0.24.0)
sanitize (~> 2.0) sanitize (~> 2.0)
sass-rails (~> 5.0.6) sassc-rails (~> 1.3.0)
scss_lint (~> 0.47.0) scss_lint (~> 0.47.0)
seed-fu (~> 2.3.5) seed-fu (~> 2.3.5)
select2-rails (~> 3.5.9) select2-rails (~> 3.5.9)
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
.on('click', '.js-unfold', this.handleClickUnfold.bind(this)) .on('click', '.js-unfold', this.handleClickUnfold.bind(this))
.on('click', '.diff-line-num a', this.handleClickLineNum.bind(this)); .on('click', '.diff-line-num a', this.handleClickLineNum.bind(this));
this.highlighSelectedLine(); this.openAnchoredDiff();
} }
handleClickUnfold(e) { handleClickUnfold(e) {
...@@ -61,13 +61,22 @@ ...@@ -61,13 +61,22 @@
$.get(link, params, response => $target.parent().replaceWith(response)); $.get(link, params, response => $target.parent().replaceWith(response));
} }
openAnchoredDiff(anchoredDiff, cb) { openAnchoredDiff(cb) {
const diffTitle = $(`#file-path-${anchoredDiff}`); const locationHash = gl.utils.getLocationHash();
const anchoredDiff = locationHash && locationHash.split('_')[0];
if (!anchoredDiff) return;
const diffTitle = $(`#${anchoredDiff}`);
const diffFile = diffTitle.closest('.diff-file'); const diffFile = diffTitle.closest('.diff-file');
const nothingHereBlock = $('.nothing-here-block:visible', diffFile); const nothingHereBlock = $('.nothing-here-block:visible', diffFile);
if (nothingHereBlock.length) { if (nothingHereBlock.length) {
diffFile.singleFileDiff(true, cb); const clickTarget = $('.file-title, .click-to-expand', diffFile);
} else { diffFile.data('singleFileDiff').toggleDiff(clickTarget, () => {
this.highlighSelectedLine();
if (cb) cb();
});
} else if (cb) {
cb(); cb();
} }
} }
......
...@@ -237,13 +237,8 @@ ...@@ -237,13 +237,8 @@
} }
this.diffsLoaded = true; this.diffsLoaded = true;
const diffPage = new gl.Diff(); new gl.Diff();
this.scrollToElement('#diffs');
const locationHash = gl.utils.getLocationHash();
const anchoredDiff = locationHash && locationHash.split('_')[0];
if (anchoredDiff) {
diffPage.openAnchoredDiff(anchoredDiff, () => this.scrollToElement('#diffs'));
}
}, },
}); });
} }
......
/* eslint-disable func-names, space-before-function-paren, no-var, space-before-blocks, prefer-rest-params, wrap-iife, one-var, one-var-declaration-per-line, consistent-return, no-param-reassign, padded-blocks, max-len */ /* eslint-disable func-names, prefer-arrow-callback, space-before-function-paren, no-var, space-before-blocks, prefer-rest-params, wrap-iife, one-var, one-var-declaration-per-line, consistent-return, no-param-reassign, padded-blocks, max-len */
(function() { (function() {
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
COLLAPSED_HTML = '<div class="nothing-here-block diff-collapsed">This diff is collapsed. <a class="click-to-expand">Click to expand it.</a></div>'; COLLAPSED_HTML = '<div class="nothing-here-block diff-collapsed">This diff is collapsed. <a class="click-to-expand">Click to expand it.</a></div>';
function SingleFileDiff(file, forceLoad, cb) { function SingleFileDiff(file) {
var clickTarget;
this.file = file; this.file = file;
this.toggleDiff = bind(this.toggleDiff, this); this.toggleDiff = bind(this.toggleDiff, this);
this.content = $('.diff-content', this.file); this.content = $('.diff-content', this.file);
...@@ -33,14 +32,13 @@ ...@@ -33,14 +32,13 @@
this.content.after(this.collapsedContent); this.content.after(this.collapsedContent);
this.$toggleIcon.addClass('fa-caret-down'); this.$toggleIcon.addClass('fa-caret-down');
} }
clickTarget = $('.file-title, .click-to-expand', this.file).on('click', this.toggleDiff);
if (forceLoad) { $('.file-title, .click-to-expand', this.file).on('click', (function (e) {
this.toggleDiff({ target: clickTarget }, cb); this.toggleDiff($(e.target));
} }).bind(this));
} }
SingleFileDiff.prototype.toggleDiff = function(e, cb) { SingleFileDiff.prototype.toggleDiff = function($target, cb) {
var $target = $(e.target);
if (!$target.hasClass('file-title') && !$target.hasClass('click-to-expand') && !$target.hasClass('diff-toggle-caret')) return; if (!$target.hasClass('file-title') && !$target.hasClass('click-to-expand') && !$target.hasClass('diff-toggle-caret')) return;
this.isOpen = !this.isOpen; this.isOpen = !this.isOpen;
if (!this.isOpen && !this.hasError) { if (!this.isOpen && !this.hasError) {
...@@ -91,10 +89,10 @@ ...@@ -91,10 +89,10 @@
})(); })();
$.fn.singleFileDiff = function(forceLoad, cb) { $.fn.singleFileDiff = function() {
return this.each(function() { return this.each(function() {
if (!$.data(this, 'singleFileDiff') || forceLoad) { if (!$.data(this, 'singleFileDiff')) {
return $.data(this, 'singleFileDiff', new window.SingleFileDiff(this, forceLoad, cb)); return $.data(this, 'singleFileDiff', new window.SingleFileDiff(this));
} }
}); });
}; };
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
- if @project.protected_branch? branch.name - if @project.protected_branch? branch.name
%span.label.label-success %span.label.label-success
%i.fa.fa-lock
protected protected
.controls.hidden-xs .controls.hidden-xs
- if merge_project && create_mr_button?(@repository.root_ref, branch.name) - if merge_project && create_mr_button?(@repository.root_ref, branch.name)
......
.diff-file.file-holder{ id: file_hash, data: diff_file_html_data(project, diff_file.file_path, diff_commit.id) } .diff-file.file-holder{ id: file_hash, data: diff_file_html_data(project, diff_file.file_path, diff_commit.id) }
.file-title{ id: "file-path-#{hexdigest(diff_file.file_path)}" } .file-title
= render "projects/diffs/file_header", diff_file: diff_file, blob: blob, diff_commit: diff_commit, project: project, url: "##{file_hash}" = render "projects/diffs/file_header", diff_file: diff_file, blob: blob, diff_commit: diff_commit, project: project, url: "##{file_hash}"
- unless diff_file.submodule? - unless diff_file.submodule?
......
---
title: Remove Lock Icon on Protected Tag
merge_request: 8513
author: Sergey Nikitin
---
title: Switch to sassc-rails for faster stylesheet compilation
merge_request: 8556
author: Richard Macklin
...@@ -4,10 +4,10 @@ feature 'Expand and collapse diffs', js: true, feature: true do ...@@ -4,10 +4,10 @@ feature 'Expand and collapse diffs', js: true, feature: true do
include WaitForAjax include WaitForAjax
let(:branch) { 'expand-collapse-diffs' } let(:branch) { 'expand-collapse-diffs' }
let(:project) { create(:project) }
before do before do
login_as :admin login_as :admin
project = create(:project)
# Ensure that undiffable.md is in .gitattributes # Ensure that undiffable.md is in .gitattributes
project.repository.copy_gitattributes(branch) project.repository.copy_gitattributes(branch)
...@@ -31,6 +31,33 @@ feature 'Expand and collapse diffs', js: true, feature: true do ...@@ -31,6 +31,33 @@ feature 'Expand and collapse diffs', js: true, feature: true do
define_method(file.split('.').first) { file_container(file) } define_method(file.split('.').first) { file_container(file) }
end end
it 'should show the diff content with a highlighted line when linking to line' do
expect(large_diff).not_to have_selector('.code')
expect(large_diff).to have_selector('.nothing-here-block')
visit namespace_project_commit_path(project.namespace, project, project.commit(branch), anchor: "#{large_diff[:id]}_0_1")
execute_script('window.location.reload()')
wait_for_ajax
expect(large_diff).to have_selector('.code')
expect(large_diff).not_to have_selector('.nothing-here-block')
expect(large_diff).to have_selector('.hll')
end
it 'should show the diff content when linking to file' do
expect(large_diff).not_to have_selector('.code')
expect(large_diff).to have_selector('.nothing-here-block')
visit namespace_project_commit_path(project.namespace, project, project.commit(branch), anchor: large_diff[:id])
execute_script('window.location.reload()')
wait_for_ajax
expect(large_diff).to have_selector('.code')
expect(large_diff).not_to have_selector('.nothing-here-block')
end
context 'visiting a commit with collapsed diffs' do context 'visiting a commit with collapsed diffs' do
it 'shows small diffs immediately' do it 'shows small diffs immediately' do
expect(small_diff).to have_selector('.code') expect(small_diff).to have_selector('.code')
......
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