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

Add latest changes from gitlab-org/gitlab@master

parent 996f7009
No related branches found
No related tags found
No related merge requests found
Showing
with 67 additions and 237 deletions
Loading
Loading
@@ -10,6 +10,7 @@ class Environment < ApplicationRecord
has_many :successful_deployments, -> { success }, class_name: 'Deployment'
 
has_one :last_deployment, -> { success.order('deployments.id DESC') }, class_name: 'Deployment'
has_one :last_visible_deployment, -> { visible.distinct_on_environment }, class_name: 'Deployment'
 
before_validation :nullify_external_url
before_validation :generate_slug, if: ->(env) { env.slug.blank? }
Loading
Loading
Loading
Loading
@@ -17,13 +17,6 @@ class ProjectWiki
CREATED_AT_ORDER = 'created_at'
DIRECTION_DESC = 'desc'
DIRECTION_ASC = 'asc'
SORT_ORDERS = [TITLE_ORDER, CREATED_AT_ORDER].freeze
SORT_DIRECTIONS = [DIRECTION_ASC, DIRECTION_DESC].freeze
NESTING_FLAT = 'flat'
NESTING_TREE = 'tree'
NESTING_CLOSED = 'hidden'
NESTINGS = [NESTING_TREE, NESTING_CLOSED, NESTING_FLAT].freeze
 
# Returns a string describing what went wrong after
# an operation fails.
Loading
Loading
@@ -65,11 +58,7 @@ class ProjectWiki
end
 
def wiki_base_path
::File.join(project_base_path, 'wikis')
end
def wiki_page_path
::File.join(project_base_path, '-', 'wiki_pages')
[Gitlab.config.gitlab.relative_url_root, '/', @project.full_path, '/wikis'].join('')
end
 
# Returns the Gitlab::Git::Wiki object.
Loading
Loading
@@ -136,23 +125,6 @@ class ProjectWiki
end
end
 
# Finds directory within the repository based on a slug
#
# dir_name - The directory prefix.
#
# Returns an initialized WikiDirectory instance or nil
def find_dir(dir_name, sort = nil, direction = DIRECTION_ASC)
descending = direction == DIRECTION_DESC
# WikiListPagesRequest currently does not support server-side
# filtering. Ideally this logic should be moved to the gitaly
# side.
pages = wiki
.list_pages(sort: sort, direction_desc: descending)
.map { |page| WikiPage.new(self, page, true) }
.select { |wp| wp.directory == dir_name }
WikiDirectory.new(dir_name, pages) if pages.present?
end
def find_sidebar(version = nil)
find_page(SIDEBAR, version)
end
Loading
Loading
@@ -172,12 +144,6 @@ class ProjectWiki
false
end
 
def build_page(attrs)
WikiPage.new(self).tap do |page|
page.update_attributes(attrs) # rubocop:disable Rails/ActiveRecordAliases
end
end
def update_page(page, content:, title: nil, format: :markdown, message: nil)
commit = commit_details(:updated, message, page.title)
 
Loading
Loading
@@ -205,7 +171,7 @@ class ProjectWiki
 
title_array = title.split("/")
title = title_array.pop
[title, ::File.join(title_array)]
[title, title_array.join("/")]
end
 
def repository
Loading
Loading
@@ -232,10 +198,6 @@ class ProjectWiki
 
private
 
def project_base_path
::File.join(Gitlab.config.gitlab.relative_url_root, @project.full_path)
end
def create_repo!(raw_repository)
gitlab_shell.create_wiki_repository(project)
 
Loading
Loading
# frozen_string_literal: true
 
class WikiDirectory
include StaticModel
include ActiveModel::Validations
 
attr_accessor :slug, :pages
 
validates :slug, presence: true
 
# StaticModel overrides and configuration:
def self.primary_key
'slug'
end
def id
"#{slug}@#{last_version&.sha}"
end
def self.model_name
ActiveModel::Name.new(self, nil, 'wiki_dir')
end
alias_method :to_param, :slug
alias_method :title, :slug
# Sorts and groups pages by directory.
#
# pages - an array of WikiPage objects.
#
# Returns an array of WikiPage and WikiDirectory objects.
# The entries are sorted in the order of the input array, where
# directories appear in the position of their first member.
def self.group_by_directory(pages)
grouped = []
dirs = Hash.new do |h, k|
new(k).tap { |dir| grouped << (h[k] = dir) }
end
Array.wrap(pages).each_with_object(grouped) do |page, top_level|
group = page.directory.present? ? dirs[page.directory] : top_level
group << page
end
end
def initialize(slug, pages = [])
@slug = slug
@pages = pages
end
 
def <<(page)
@pages << page
@last_version = nil
end
def last_version
@last_version ||= @pages.map(&:last_version).max_by(&:authored_date)
end
def page_count
@pages.size
end
def empty?
page_count.zero?
end
def to_partial_path(context = nil)
name = [context, 'wiki_directory'].compact.join('_')
"projects/wiki_directories/#{name}"
# Relative path to the partial to be used when rendering collections
# of this object.
def to_partial_path
'projects/wikis/wiki_directory'
end
end
Loading
Loading
@@ -15,7 +15,30 @@ class WikiPage
end
 
def self.model_name
ActiveModel::Name.new(self, nil, 'wiki_page')
ActiveModel::Name.new(self, nil, 'wiki')
end
# Sorts and groups pages by directory.
#
# pages - an array of WikiPage objects.
#
# Returns an array of WikiPage and WikiDirectory objects. The entries are
# sorted by alphabetical order (directories and pages inside each directory).
# Pages at the root level come before everything.
def self.group_by_directory(pages)
return [] if pages.blank?
pages.each_with_object([]) do |page, grouped_pages|
next grouped_pages << page unless page.directory.present?
directory = grouped_pages.find do |obj|
obj.is_a?(WikiDirectory) && obj.slug == page.directory
end
next directory.pages << page if directory
grouped_pages << WikiDirectory.new(page.directory, [page])
end
end
 
def self.unhyphenize(name)
Loading
Loading
@@ -43,16 +66,6 @@ class WikiPage
Gitlab::HookData::WikiPageBuilder.new(self).build
end
 
# Create a new WikiPage
#
# == Parameters:
# wiki::
# A `ProjectWiki` model object
# page::
# A `Gitlab::Git::WikiPage` business object, to which this class provides a facade
# persisted::
# Is this page fully saved on disk?
#
def initialize(wiki, page = nil, persisted = false)
@wiki = wiki
@page = page
Loading
Loading
@@ -243,10 +256,10 @@ class WikiPage
end
end
 
def to_partial_path(context = nil)
name = [context, 'wiki_page'].compact.join('_')
"projects/wiki_pages/#{name}"
# Relative path to the partial to be used when rendering collections
# of this object.
def to_partial_path
'projects/wikis/wiki_page'
end
 
def id
Loading
Loading
Loading
Loading
@@ -42,6 +42,10 @@ module Notes
clear_noteable_diffs_cache(note)
Suggestions::CreateService.new(note).execute
increment_usage_counter(note)
if Feature.enabled?(:notes_create_service_tracking, project)
Gitlab::Tracking.event('Notes::CreateService', 'execute', tracking_data_for(note))
end
end
 
if quick_actions_service.commands_executed_count.to_i > 0
Loading
Loading
@@ -59,5 +63,16 @@ module Notes
 
note
end
private
def tracking_data_for(note)
label = Gitlab.ee? && note.author == User.visual_review_bot ? 'anonymous_visual_review_note' : 'note'
{
label: label,
value: note.id
}
end
end
end
Loading
Loading
@@ -26,5 +26,8 @@
.form-group
= f.label :snowplow_cookie_domain, _('Cookie domain'), class: 'label-light'
= f.text_field :snowplow_cookie_domain, class: 'form-control'
.form-group
= f.label :snowplow_iglu_registry_url, _('Iglu registry URL (optional)'), class: 'label-light'
= f.text_field :snowplow_iglu_registry_url, class: 'form-control'
 
= f.submit _('Save changes'), class: 'btn btn-success'
Loading
Loading
@@ -264,7 +264,7 @@
dismiss_endpoint: user_callouts_path } }
- if show_cluster_hint
.feature-highlight-popover-content
= image_tag 'illustrations/cluster_popover.svg', class: 'feature-highlight-illustration'
= image_tag 'illustrations/cluster_popover.svg', class: 'feature-highlight-illustration', lazy: false, alt: _('Kubernetes popover')
.feature-highlight-popover-sub-content
%p= _('Allows you to add and manage Kubernetes clusters.')
%p
Loading
Loading
@@ -282,14 +282,14 @@
 
- if project_nav_tab? :wiki
- wiki_url = project_wiki_path(@project, :home)
= nav_link(controller: [:wikis, :wiki_pages, :wiki_directories]) do
= nav_link(controller: :wikis) do
= link_to wiki_url, class: 'shortcuts-wiki', data: { qa_selector: 'wiki_link' } do
.nav-icon-container
= sprite_icon('book')
%span.nav-item-name
= _('Wiki')
%ul.sidebar-sub-level-items.is-fly-out-only
= nav_link(controller: [:wikis, :wiki_pages, :wiki_directories], html_options: { class: "fly-out-top-item" } ) do
= nav_link(controller: :wikis, html_options: { class: "fly-out-top-item" } ) do
= link_to wiki_url do
%strong.fly-out-top-item-name
= _('Wiki')
Loading
Loading
%li
%span.text-secondary-500.svg-icon.svg-baseline
- if @show_children
= sprite_icon('folder-open', size: 16)
- else
= sprite_icon('folder-o', size: 16)
= link_to wiki_dir.slug, project_wiki_dir_path(@project, wiki_dir)
- unless @show_children
%span.badge.badge-pill.wiki-dir-page-count= wiki_dir.page_count
.float-right
%small= (s_("Last edited %{date}") % { date: time_ago_with_tooltip(wiki_dir.last_version.authored_date) }).html_safe
- if @show_children
%ul
= render wiki_dir.pages, context: context
%li
%span.text-secondary-300.svg-icon.svg-baseline
= sprite_icon('folder-open', size: 16)
= link_to wiki_dir.slug, project_wiki_dir_path(@project, wiki_dir)
%ul= render wiki_dir.pages, context: context
= render wiki_directory.to_partial_path(context), wiki_dir: wiki_directory, context: context
- layout_path = 'shared/empty_states/wikis_layout'
- add_to_breadcrumbs _("Wiki"), project_wiki_path(@project, :home)
- add_to_breadcrumbs s_("Wiki|Pages"), project_wikis_pages_path(@project)
- breadcrumb_title s_(@wiki_dir.slug)
- page_title @wiki_dir.slug
- if can?(current_user, :create_wiki, @project)
- create_path = project_wiki_path(@project, params[:id], { view: 'create', params: { title: "#{params[:id]}/" } })
- create_link = link_to s_('WikiDirEmpty|Create a page in this directory'), create_path, class: 'btn btn-success qa-create-first-page-link', title: s_('WikiDirEmpty|Create a page')
= render layout: layout_path, locals: { image_path: 'illustrations/wiki_login_empty.svg' } do
%h4.text-left
= s_('WikiDirEmpty|This directory has no wiki pages')
%p.text-left
= s_("WikiDirEmpty|A wiki is where you can store all the details about your project. This can include why you've created it, its principles, how to use it, and so on.")
= create_link
- elsif can?(current_user, :read_issue, @project)
- issues_link = link_to s_('WikiEmptyIssueMessage|issue tracker'), project_issues_path(@project)
- new_issue_link = link_to s_('WikiEmpty|Suggest wiki improvement'), new_project_issue_path(@project), class: 'btn btn-success', title: s_('WikiEmptyIssueMessage|Suggest wiki improvement')
= render layout: layout_path, locals: { image_path: 'illustrations/wiki_logout_empty.svg' } do
%h4
= s_('WikiDirEmpty|This directory has no wiki pages')
%p.text-left
= s_('WikiEmptyIssueMessage|You must be a project member in order to add wiki pages. If you have suggestions for how to improve the wiki for this project, consider opening an issue in the %{issues_link}.').html_safe % { issues_link: issues_link }
= new_issue_link
- else
= render layout: layout_path, locals: { image_path: 'illustrations/wiki_logout_empty.svg' } do
%h4
= s_('WikiDirEmpty|This directory has no wiki pages')
%p
= s_('WikiEmpty|You must be a project member in order to add wiki pages.')
- add_to_breadcrumbs _("Wiki"), project_wiki_path(@project, :home)
- add_to_breadcrumbs s_("Wiki|Pages"), project_wikis_pages_path(@project)
- breadcrumb_title s_(@wiki_dir.slug)
- page_title @wiki_dir.slug
= render 'page_listing', { allow_change_nesting: false, wiki_page_title: page_title, page_path: ->(opts) { project_wiki_dir_path(@project, @wiki_dir, opts) } }
= link_to @page.human_title, project_wiki_path(@project, @page)
%span.light
= _('&middot;').html_safe
= subtitle
- is_active = params[:id] == wiki_page.slug
- icon_active_class = is_active ? 'text-secondary-800' : 'text-secondary-300'
%li{ class: active_when(is_active) }
%span.svg-icon.svg-baseline{ class: icon_active_class }
= sprite_icon('book', size: 16)
- if is_active
= wiki_page.human_title
- else
= link_to project_wiki_path(@project, wiki_page) do
= wiki_page.human_title
= render wiki_page.to_partial_path(context), wiki_page: wiki_page
- @content_class = 'wiki-page' + (fluid_layout ? '' : ' limit-container-width')
- breadcrumb_title @page.human_title
- page_title @page.human_title, _("Wiki")
- add_to_breadcrumbs _("Wiki"), project_wiki_path(@project, :home)
- add_to_breadcrumbs s_("Wiki|Pages"), project_wikis_pages_path(@project)
- if @page_dir.present?
- add_to_breadcrumbs _(@page_dir.slug), project_wiki_dir_path(@project, @page_dir)
.wiki-page-header.top-area.has-sidebar-toggle.flex-column.flex-lg-row
%button.btn.btn-default.sidebar-toggle.js-sidebar-wiki-toggle{ role: "button", type: "button" }
= icon('angle-double-left')
.nav-text.flex-fill
%h2.wiki-page-title= @page.human_title
%span.wiki-last-edit-by
- if @page.last_version
= (_("Last edited by %{name}") % { name: "<strong>#{@page.last_version.author_name}</strong>" }).html_safe
#{time_ago_with_tooltip(@page.last_version.authored_date)}
.nav-controls.pb-md-3.pb-lg-0
= render 'main_links'
- if @page.historical?
.warning_message
= s_("WikiHistoricalPage|This is an old version of this page.")
- most_recent_link = link_to s_("WikiHistoricalPage|most recent version"), project_wiki_path(@project, @page)
- history_link = link_to s_("WikiHistoricalPage|history"), project_wiki_history_path(@project, @page)
= (s_("WikiHistoricalPage|You can view the %{most_recent_link} or browse the %{history_link}.") % { most_recent_link: most_recent_link, history_link: history_link }).html_safe
.prepend-top-default.append-bottom-default
.md.md-file.qa-wiki-page-content
= render_wiki_content(@page)
= render 'sidebar'
- form_classes = 'wiki-form common-note-form prepend-top-default js-quick-submit'
- form_classes += ' js-new-wiki-page' unless @page.persisted?
 
= form_for [@project.namespace.becomes(Namespace), @project, @page],
method: @page.persisted? ? 'put' : 'post',
url: { controller: 'wiki_pages', action: @page.persisted? ? :update : :create },
html: { class: form_classes },
data: { uploads_path: uploads_path } do |f|
= form_for [@project.namespace.becomes(Namespace), @project, @page], method: @page.persisted? ? :put : :post,
html: { class: form_classes },
data: { uploads_path: uploads_path } do |f|
= form_errors(@page)
 
- if @page.persisted?
Loading
Loading
@@ -14,7 +12,7 @@
.form-group.row
.col-sm-12= f.label :title, class: 'control-label-full-width'
.col-sm-12
= f.text_field :title, class: 'form-control qa-wiki-title-textbox', value: @page.title, required: true, autofocus: !@page.persisted?, placeholder: s_('Wiki|Page title')
= f.text_field :title, class: 'form-control qa-wiki-title-textbox', value: @page.title, required: true, autofocus: !@page.persisted?, placeholder: _('Wiki|Page title')
%span.d-inline-block.mw-100.prepend-top-5
= icon('lightbulb-o')
- if @page.persisted?
Loading
Loading
- if (@page && @page.persisted?)
- if can?(current_user, :create_wiki, @project)
= link_to project_wiki_pages_new_path(@project), class: "add-new-wiki btn btn-success", role: "button" do
= link_to project_wikis_new_path(@project), class: "add-new-wiki btn btn-success", role: "button" do
= s_("Wiki|New page")
= link_to project_wiki_history_path(@project, @page), class: "btn", role: "button" do
= s_("Wiki|Page history")
Loading
Loading
%li
%span.text-secondary-500.svg-icon.svg-baseline= sprite_icon('book', size: 16)
= wiki_page_link(wiki_page, @nesting, @project)
= link_to wiki_page.title, project_wiki_path(@project, wiki_page)
%small (#{wiki_page.format})
.float-right
%span.badge.badge-pill.wiki-page-format= _(wiki_page.format)
- if wiki_page.last_version
= '/'
%small= (s_("Last edited %{date}") % { date: time_ago_with_tooltip(wiki_page.last_version.authored_date) }).html_safe
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