Skip to content
Snippets Groups Projects
Commit b98fa9ef authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 7e300596
No related branches found
No related tags found
No related merge requests found
Showing
with 87 additions and 53 deletions
import { viewerInformationForPath } from '~/vue_shared/components/content_viewer/lib/viewer_utils';
import { escapeFileUrl } from '~/lib/utils/url_utility';
import { decorateData, sortTree } from '../stores/utils';
 
export const splitParent = path => {
Loading
Loading
@@ -48,7 +47,7 @@ export const decorateFiles = ({
id: path,
name,
path,
url: `/${projectId}/tree/${branchId}/-/${escapeFileUrl(path)}/`,
url: `/${projectId}/tree/${branchId}/-/${path}/`,
type: 'tree',
parentTreeUrl: parentFolder ? parentFolder.url : `/${projectId}/tree/${branchId}/`,
tempFile,
Loading
Loading
@@ -85,7 +84,7 @@ export const decorateFiles = ({
id: path,
name,
path,
url: `/${projectId}/blob/${branchId}/-/${escapeFileUrl(path)}`,
url: `/${projectId}/blob/${branchId}/-/${path}`,
type: 'blob',
parentTreeUrl: fileFolder ? fileFolder.url : `/${projectId}/blob/${branchId}`,
tempFile,
Loading
Loading
import { commitActionTypes, FILE_VIEW_MODE_EDITOR } from '../constants';
import { escapeFileUrl } from '~/lib/utils/url_utility';
 
export const dataStructure = () => ({
id: '',
Loading
Loading
@@ -220,9 +219,7 @@ export const mergeTrees = (fromTree, toTree) => {
 
export const replaceFileUrl = (url, oldPath, newPath) => {
// Add `/-/` so that we don't accidentally replace project path
const result = url.replace(`/-/${escapeFileUrl(oldPath)}`, `/-/${escapeFileUrl(newPath)}`);
return result;
return url.replace(`/-/${oldPath}`, `/-/${newPath}`);
};
 
export const swapInStateArray = (state, arr, key, entryPath) =>
Loading
Loading
<script>
import { omit } from 'underscore';
import { omit } from 'lodash';
import { GlEmptyState, GlPagination, GlSkeletonLoading } from '@gitlab/ui';
import flash from '~/flash';
import axios from '~/lib/utils/axios_utils';
Loading
Loading
<script>
import FileHeader from '~/vue_shared/components/file_row_header.vue';
import FileIcon from '~/vue_shared/components/file_icon.vue';
import { escapeFileUrl } from '~/lib/utils/url_utility';
 
export default {
name: 'FileRow',
Loading
Loading
@@ -94,7 +95,7 @@ export default {
hasUrlAtCurrentRoute() {
if (!this.$router || !this.$router.currentRoute) return true;
 
return this.$router.currentRoute.path === `/project${this.file.url}`;
return this.$router.currentRoute.path === `/project${escapeFileUrl(this.file.url)}`;
},
},
};
Loading
Loading
Loading
Loading
@@ -6,20 +6,18 @@ module SnippetsActions
def edit
end
 
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def raw
disposition = params[:inline] == 'false' ? 'attachment' : 'inline'
 
workhorse_set_content_type!
 
send_data(
convert_line_endings(@snippet.content),
convert_line_endings(blob.data),
type: 'text/plain; charset=utf-8',
disposition: disposition,
filename: @snippet.sanitized_file_name
filename: Snippet.sanitized_file_name(blob.name)
)
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
 
def js_request?
request.format.js?
Loading
Loading
Loading
Loading
@@ -66,7 +66,6 @@ class Projects::SnippetsController < Projects::ApplicationController
end
 
def show
blob = @snippet.blob
conditionally_expand_blob(blob)
 
respond_to do |format|
Loading
Loading
@@ -115,6 +114,16 @@ class Projects::SnippetsController < Projects::ApplicationController
alias_method :awardable, :snippet
alias_method :spammable, :snippet
 
def blob
return unless snippet
@blob ||= if Feature.enabled?(:version_snippets, current_user) && !snippet.repository.empty?
snippet.blobs.first
else
snippet.blob
end
end
def spammable_path
project_snippet_path(@project, @snippet)
end
Loading
Loading
Loading
Loading
@@ -68,17 +68,15 @@ class SnippetsController < ApplicationController
end
 
def show
blob = @snippet.blob
conditionally_expand_blob(blob)
 
@note = Note.new(noteable: @snippet)
@noteable = @snippet
@discussions = @snippet.discussions
@notes = prepare_notes_for_rendering(@discussions.flat_map(&:notes), @noteable)
respond_to do |format|
format.html do
@note = Note.new(noteable: @snippet)
@noteable = @snippet
@discussions = @snippet.discussions
@notes = prepare_notes_for_rendering(@discussions.flat_map(&:notes), @noteable)
render 'show'
end
 
Loading
Loading
@@ -121,6 +119,16 @@ class SnippetsController < ApplicationController
alias_method :awardable, :snippet
alias_method :spammable, :snippet
 
def blob
return unless snippet
@blob ||= if Feature.enabled?(:version_snippets, current_user) && !snippet.repository.empty?
snippet.blobs.first
else
snippet.blob
end
end
def spammable_path
snippet_path(@snippet)
end
Loading
Loading
Loading
Loading
@@ -62,6 +62,7 @@ module Types
 
field :blob, type: Types::Snippets::BlobType,
description: 'Snippet blob',
calls_gitaly: true,
null: false
 
markdown_field :description_html, null: true, method: :description
Loading
Loading
# frozen_string_literal: true
 
# Applicable for blob classes with project attribute
module BlobLanguageFromGitAttributes
extend ActiveSupport::Concern
 
def language_from_gitattributes
return unless project
return unless repository&.exists?
 
repository = project.repository
repository.gitattribute(path, 'gitlab-language')
end
end
Loading
Loading
@@ -197,7 +197,11 @@ class Snippet < ApplicationRecord
end
 
def blob
@blob ||= Blob.decorate(SnippetBlob.new(self), nil)
@blob ||= Blob.decorate(SnippetBlob.new(self), self)
end
def blobs
repository.ls_files(repository.root_ref).map { |file| Blob.lazy(self, repository.root_ref, file) }
end
 
def hook_attrs
Loading
Loading
@@ -208,7 +212,7 @@ class Snippet < ApplicationRecord
super.to_s
end
 
def sanitized_file_name
def self.sanitized_file_name(file_name)
file_name.gsub(/[^a-zA-Z0-9_\-\.]+/, '')
end
 
Loading
Loading
Loading
Loading
@@ -32,7 +32,7 @@ class SnippetBlobPresenter < BlobPresenter
end
 
def snippet
blob.snippet
blob.container
end
 
def language
Loading
Loading
Loading
Loading
@@ -27,6 +27,14 @@ class SnippetPresenter < Gitlab::View::Presenter::Delegated
snippet.submittable_as_spam_by?(current_user)
end
 
def blob
if Feature.enabled?(:version_snippets, current_user) && !snippet.repository.empty?
snippet.blobs.first
else
snippet.blob
end
end
private
 
def can_access_resource?(ability_prefix)
Loading
Loading
Loading
Loading
@@ -3,14 +3,13 @@
class AuditEventService
# Instantiates a new service
#
# @param author [User] the user who authors the change
# @param entity [Object] an instance of either Project/Group/User type. This
# param is also used to determine at which level the audit events are
# shown.
# - Project: events are visible at Project level
# - Group: events are visible at Group level
# @param [User] author the user who authors the change
# @param [User, Project, Group] entity the scope which audit event belongs to
# This param is also used to determine the visibility of the audit event.
# - Project: events are visible at Project and Instance level
# - Group: events are visible at Group and Instance level
# - User: events are visible at Instance level
# @param details [Hash] details to be added to audit event
# @param [Hash] details extra data of audit event
#
# @return [AuditEventService]
def initialize(author, entity, details = {})
Loading
Loading
@@ -21,7 +20,7 @@ class AuditEventService
 
# Builds the @details attribute for authentication
#
# This uses the @author as the target object being changed
# This uses the @author as the target object being audited
#
# @return [AuditEventService]
def for_authentication
Loading
Loading
Loading
Loading
@@ -9,8 +9,7 @@
= render 'shared/snippets/header'
 
.project-snippets
%article.file-holder.snippet-file-content
= render 'shared/snippets/blob'
= render 'shared/snippets/blob', blob: @blob
 
.row-content-block.top-block.content-component-block
= render 'award_emoji/awards_block', awardable: @snippet, inline: true
Loading
Loading
- blob = @snippet.blob
.js-file-title.file-title-flex-parent
= render 'projects/blob/header_content', blob: blob
%article.file-holder.snippet-file-content
.js-file-title.file-title-flex-parent
= render 'projects/blob/header_content', blob: blob
 
.file-actions.d-none.d-sm-block
= render 'projects/blob/viewer_switcher', blob: blob
.file-actions.d-none.d-sm-block
= render 'projects/blob/viewer_switcher', blob: blob
 
.btn-group{ role: "group" }<
= copy_blob_source_button(blob)
= open_raw_blob_button(blob)
= download_raw_snippet_button(@snippet)
.btn-group{ role: "group" }<
= copy_blob_source_button(blob)
= open_raw_blob_button(blob)
= download_raw_snippet_button(@snippet)
 
= render 'projects/blob/content', blob: blob
= render 'projects/blob/content', blob: blob
- blob = @snippet.blob
.gitlab-embed-snippets
.js-file-title.file-title-flex-parent
.file-header-content
Loading
Loading
@@ -6,10 +5,10 @@
 
%strong.file-title-name
%a.gitlab-embedded-snippets-title{ href: url_for(only_path: false, overwrite_params: nil) }
= blob.name
= @blob.name
 
%small
= number_to_human_size(blob.raw_size)
= number_to_human_size(@blob.raw_size)
%a.gitlab-logo-wrapper{ href: url_for(only_path: false, overwrite_params: nil), title: 'view on gitlab' }
%img.gitlab-logo{ src: image_url('ext_snippet_icons/logo.svg'), alt: "GitLab logo" }
 
Loading
Loading
@@ -19,4 +18,4 @@
 
= embedded_snippet_download_button
%article.file-holder.snippet-file-content
= render 'projects/blob/viewer', viewer: @snippet.blob.simple_viewer, load_async: false, external_embed: true
= render 'projects/blob/viewer', viewer: @blob.simple_viewer, load_async: false, external_embed: true
Loading
Loading
@@ -10,8 +10,7 @@
= render 'shared/snippets/header'
 
.personal-snippets
%article.file-holder.snippet-file-content
= render 'shared/snippets/blob'
= render 'shared/snippets/blob', blob: @blob
 
.row-content-block.top-block.content-component-block
= render 'award_emoji/awards_block', awardable: @snippet, inline: true
Loading
Loading
---
title: Fixed regression when URL was encoded in a loop
merge_request: 25849
author:
type: fixed
---
title: 'Fix: tableflip quick action is interpreted even if inside code block'
merge_request:
author: Pavlo Dudchenko
type: fixed
---
title: Render single snippet blob in repository
merge_request: 23848
author:
type: added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment