Commit 0bde54c3 authored by Douwe Maan's avatar Douwe Maan

Resolve conflicts related to blob viewers

parent 2db73289
......@@ -6,11 +6,7 @@ export default class BlobViewer {
this.copySourceBtn = document.querySelector('.js-copy-blob-source-btn');
this.simpleViewer = document.querySelector('.blob-viewer[data-type="simple"]');
this.richViewer = document.querySelector('.blob-viewer[data-type="rich"]');
<<<<<<< HEAD
this.$blobContentHolder = $('#blob-content-holder');
=======
this.$fileHolder = $('.file-holder');
>>>>>>> ce-com/master
let initialViewerName = document.querySelector('.blob-viewer:not(.hidden)').getAttribute('data-type');
......@@ -86,11 +82,7 @@ export default class BlobViewer {
viewer.setAttribute('data-loaded', 'true');
<<<<<<< HEAD
this.$blobContentHolder.trigger('highlight:line');
=======
this.$fileHolder.trigger('highlight:line');
>>>>>>> ce-com/master
this.toggleCopyButtonState();
});
......
......@@ -57,15 +57,9 @@ require('vendor/jquery.scrollTo');
}
LineHighlighter.prototype.bindEvents = function() {
<<<<<<< HEAD
const $blobContentHolder = $('#blob-content-holder');
$blobContentHolder.on('click', 'a[data-line-number]', this.clickHandler);
$blobContentHolder.on('highlight:line', this.highlightHash);
=======
const $fileHolder = $('.file-holder');
$fileHolder.on('click', 'a[data-line-number]', this.clickHandler);
$fileHolder.on('highlight:line', this.highlightHash);
>>>>>>> ce-com/master
};
LineHighlighter.prototype.highlightHash = function() {
......
......@@ -14,11 +14,8 @@ module RendersBlob
html: view_to_html_string("projects/blob/_viewer", viewer: viewer, load_asynchronously: false)
}
end
<<<<<<< HEAD
=======
def override_max_blob_size(blob)
blob.override_max_size! if params[:override_max_size] == 'true'
end
>>>>>>> ce-com/master
end
......@@ -35,11 +35,7 @@ class Projects::BlobController < Projects::ApplicationController
end
def show
<<<<<<< HEAD
@blob.override_max_size! if params[:override_max_size] == 'true'
=======
override_max_blob_size(@blob)
>>>>>>> ce-com/master
respond_to do |format|
format.html do
......
......@@ -119,9 +119,6 @@ module BlobHelper
end
def blob_raw_url
<<<<<<< HEAD
namespace_project_raw_path(@project.namespace, @project, @id)
=======
if @snippet
if @snippet.project_id
raw_namespace_project_snippet_path(@project.namespace, @project, @snippet)
......@@ -131,7 +128,6 @@ module BlobHelper
elsif @blob
namespace_project_raw_path(@project.namespace, @project, @id)
end
>>>>>>> ce-com/master
end
# SVGs can contain malicious JavaScript; only include whitelisted
......@@ -221,11 +217,8 @@ module BlobHelper
end
def copy_blob_source_button(blob)
<<<<<<< HEAD
=======
return unless blob.rendered_as_text?(ignore_errors: false)
>>>>>>> ce-com/master
clipboard_button(target: ".blob-content[data-blob-id='#{blob.id}']", class: "btn btn-sm js-copy-blob-source-btn", title: "Copy source to clipboard")
end
......
......@@ -27,11 +27,8 @@ class Blob < SimpleDelegator
BlobViewer::Image,
BlobViewer::Sketch,
<<<<<<< HEAD
=======
BlobViewer::Video,
>>>>>>> ce-com/master
BlobViewer::PDF,
BlobViewer::BinarySTL,
......
......@@ -15,13 +15,8 @@
= render 'projects/blob/viewer_switcher', blob: blob unless blame
.btn-group{ role: "group" }<
<<<<<<< HEAD
= copy_blob_source_button(blob) if !blame && blob.rendered_as_text?(ignore_errors: false)
= open_raw_file_button(namespace_project_raw_path(@project.namespace, @project, @id))
=======
= copy_blob_source_button(blob) unless blame
= open_raw_blob_button(blob)
>>>>>>> ce-com/master
= view_on_environment_button(@commit.sha, @path, @environment) if @environment
.btn-group{ role: "group" }<
......@@ -41,12 +36,9 @@
tree_join(@commit.sha, @path)), class: 'btn btn-sm js-data-file-blob-permalink-url'
.btn-group{ role: "group" }<
<<<<<<< HEAD
- if current_user
= lock_file_link(html_options: {class: 'btn btn-sm path-lock'})
=======
>>>>>>> ce-com/master
= edit_blob_link if blob.readable_text?
- if current_user
= replace_blob_link
......
- blob = viewer.blob
<<<<<<< HEAD
.file-content.wiki
= markup(blob.name, blob.data)
=======
- rendered_markup = blob.rendered_markup if blob.respond_to?(:rendered_markup)
.file-content.wiki
= markup(blob.name, blob.data, rendered: rendered_markup)
>>>>>>> ce-com/master
......@@ -15,13 +15,8 @@
= render 'projects/blob/viewer_switcher', blob: blob
.btn-group{ role: "group" }<
<<<<<<< HEAD
= copy_blob_source_button(@snippet)
= open_raw_file_button(raw_path)
=======
= copy_blob_source_button(blob)
= open_raw_blob_button(blob)
>>>>>>> ce-com/master
- if defined?(download_path) && download_path
= link_to icon('download'), download_path, class: "btn btn-sm has-tooltip", title: 'Download', data: { container: 'body' }
......
require 'spec_helper'
feature 'File blob', :js, feature: true do
<<<<<<< HEAD
include TreeHelper
include WaitForAjax
let(:project) { create(:project, :public) }
def visit_blob(path, fragment = nil)
visit namespace_project_blob_path(project.namespace, project, tree_join('master', path), anchor: fragment)
end
context 'Ruby file' do
before do
visit_blob('files/ruby/popen.rb')
wait_for_ajax
end
it 'displays the blob' do
aggregate_failures do
# shows highlighted Ruby code
expect(page).to have_content("require 'fileutils'")
# does not show a viewer switcher
expect(page).not_to have_selector('.js-blob-viewer-switcher')
# shows an enabled copy button
expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
end
end
end
context 'Markdown file' do
context 'visiting directly' do
before do
visit_blob('files/markdown/ruby-style-guide.md')
wait_for_ajax
end
it 'displays the blob' do
aggregate_failures do
# hides the simple viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]', visible: false)
expect(page).to have_selector('.blob-viewer[data-type="rich"]')
# shows rendered Markdown
expect(page).to have_link("PEP-8")
# shows a viewer switcher
expect(page).to have_selector('.js-blob-viewer-switcher')
# shows a disabled copy button
expect(page).to have_selector('.js-copy-blob-source-btn.disabled')
end
end
context 'switching to the simple viewer' do
before do
find('.js-blob-viewer-switch-btn[data-viewer=simple]').click
wait_for_ajax
end
it 'displays the blob' do
aggregate_failures do
# hides the rich viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]')
expect(page).to have_selector('.blob-viewer[data-type="rich"]', visible: false)
# shows highlighted Markdown code
expect(page).to have_content("[PEP-8](http://www.python.org/dev/peps/pep-0008/)")
# shows an enabled copy button
expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
end
end
context 'switching to the rich viewer again' do
before do
find('.js-blob-viewer-switch-btn[data-viewer=rich]').click
wait_for_ajax
end
it 'displays the blob' do
aggregate_failures do
# hides the simple viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]', visible: false)
expect(page).to have_selector('.blob-viewer[data-type="rich"]')
# shows an enabled copy button
expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
end
end
end
=======
let(:project) { create(:project, :public) }
def visit_blob(path, fragment = nil)
......@@ -639,7 +543,6 @@ feature 'File blob', :js, feature: true do
# shows a download button
expect(page).to have_link('Download')
>>>>>>> ce-com/master
end
end
end
......
......@@ -157,10 +157,7 @@ describe BlobHelper do
describe '#blob_render_error_options' do
before do
assign(:project, project)
<<<<<<< HEAD
=======
assign(:blob, blob)
>>>>>>> ce-com/master
assign(:id, File.join('master', blob.path))
controller.params[:controller] = 'projects/blob'
......
......@@ -21,10 +21,7 @@ describe 'projects/blob/_viewer.html.haml', :view do
before do
assign(:project, project)
<<<<<<< HEAD
=======
assign(:blob, blob)
>>>>>>> ce-com/master
assign(:id, File.join('master', blob.path))
controller.params[:controller] = 'projects/blob'
......
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