diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/pages/projects/wikis/wikis.js | 16 | ||||
-rw-r--r-- | app/controllers/application_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/import/gitea_controller.rb | 23 | ||||
-rw-r--r-- | app/models/deployment.rb | 4 | ||||
-rw-r--r-- | app/models/repository.rb | 6 | ||||
-rw-r--r-- | app/models/service.rb | 1 | ||||
-rw-r--r-- | app/services/ci/find_exposed_artifacts_service.rb | 6 | ||||
-rw-r--r-- | app/views/projects/wikis/_form.html.haml | 12 |
8 files changed, 56 insertions, 16 deletions
diff --git a/app/assets/javascripts/pages/projects/wikis/wikis.js b/app/assets/javascripts/pages/projects/wikis/wikis.js index 6b02a074abf..93afdc54ce1 100644 --- a/app/assets/javascripts/pages/projects/wikis/wikis.js +++ b/app/assets/javascripts/pages/projects/wikis/wikis.js @@ -1,6 +1,13 @@ import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; import { s__, sprintf } from '~/locale'; +const MARKDOWN_LINK_TEXT = { + markdown: '[Link Title](page-slug)', + rdoc: '{Link title}[link:page-slug]', + asciidoc: 'link:page-slug[Link title]', + org: '[[page-slug]]', +}; + export default class Wikis { constructor() { this.sidebarEl = document.querySelector('.js-wiki-sidebar'); @@ -28,6 +35,15 @@ export default class Wikis { window.addEventListener('resize', () => this.renderSidebar()); this.renderSidebar(); + + const changeFormatSelect = document.querySelector('#wiki_format'); + const linkExample = document.querySelector('.js-markup-link-example'); + + if (changeFormatSelect) { + changeFormatSelect.addEventListener('change', e => { + linkExample.innerHTML = MARKDOWN_LINK_TEXT[e.target.value]; + }); + } } handleWikiTitleChange(e) { diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 484e86964f6..8cb8fd6dd4c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -149,10 +149,6 @@ class ApplicationController < ActionController::Base payload[:username] = logged_user.try(:username) end - if response.status == 422 && response.body.present? && response.content_type == 'application/json' - payload[:response] = response.body - end - payload[:queue_duration] = request.env[::Gitlab::Middleware::RailsQueueDuration::GITLAB_RAILS_QUEUE_DURATION_KEY] end diff --git a/app/controllers/import/gitea_controller.rb b/app/controllers/import/gitea_controller.rb index a23b2f8139e..f0888e08622 100644 --- a/app/controllers/import/gitea_controller.rb +++ b/app/controllers/import/gitea_controller.rb @@ -16,7 +16,13 @@ class Import::GiteaController < Import::GithubController # Must be defined or it will 404 def status - super + if blocked_url? + session[access_token_key] = nil + + redirect_to new_import_url, alert: _('Specified URL cannot be used.') + else + super + end end private @@ -54,4 +60,19 @@ class Import::GiteaController < Import::GithubController def client_options { host: provider_url, api_version: 'v1' } end + + def blocked_url? + Gitlab::UrlBlocker.blocked_url?( + provider_url, + { + allow_localhost: allow_local_requests?, + allow_local_network: allow_local_requests?, + schemes: %w(http https) + } + ) + end + + def allow_local_requests? + Gitlab::CurrentSettings.allow_local_requests_from_web_hooks_and_services? + end end diff --git a/app/models/deployment.rb b/app/models/deployment.rb index b118404b916..707c4e8157d 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -280,12 +280,12 @@ class Deployment < ApplicationRecord errors.add(:ref, _('The branch or tag does not exist')) end + private + def ref_path File.join(environment.ref_path, 'deployments', iid.to_s) end - private - def legacy_finished_at self.created_at if success? && !read_attribute(:finished_at) end diff --git a/app/models/repository.rb b/app/models/repository.rb index beb65ff26fd..534c62ec467 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -911,10 +911,8 @@ class Repository def merged_branch_names(branch_names = []) # Currently we should skip caching if requesting all branch names # This is only used in a few places, notably app/services/branches/delete_merged_service.rb, - # and it could potentially result in a very large cache/performance issues with the current - # implementation. - skip_cache = branch_names.empty? || Feature.disabled?(:merged_branch_names_redis_caching, default_enabled: true) - return raw_repository.merged_branch_names(branch_names) if skip_cache + # and it could potentially result in a very large cache. + return raw_repository.merged_branch_names(branch_names) if branch_names.empty? cache = redis_hash_cache diff --git a/app/models/service.rb b/app/models/service.rb index 41ae197f432..e6b32db7eef 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -34,6 +34,7 @@ class Service < ApplicationRecord validates :project_id, presence: true, unless: -> { template? } validates :type, presence: true + validates :template, uniqueness: { scope: :type }, if: -> { template? } scope :visible, -> { where.not(type: 'GitlabIssueTrackerService') } scope :issue_trackers, -> { where(category: 'issue_tracker') } diff --git a/app/services/ci/find_exposed_artifacts_service.rb b/app/services/ci/find_exposed_artifacts_service.rb index d268252577f..abbeb101be2 100644 --- a/app/services/ci/find_exposed_artifacts_service.rb +++ b/app/services/ci/find_exposed_artifacts_service.rb @@ -35,7 +35,7 @@ module Ci { text: job.artifacts_expose_as, url: path_for_entries(metadata_entries, job), - job_path: project_job_path(project, job), + job_path: project_job_path(job.project, job), job_name: job.name } end @@ -59,9 +59,9 @@ module Ci return if entries.empty? if single_artifact?(entries) - file_project_job_artifacts_path(project, job, entries.first.path) + file_project_job_artifacts_path(job.project, job, entries.first.path) else - browse_project_job_artifacts_path(project, job) + browse_project_job_artifacts_path(job.project, job) end end diff --git a/app/views/projects/wikis/_form.html.haml b/app/views/projects/wikis/_form.html.haml index bc20635f0c5..d29abfa937d 100644 --- a/app/views/projects/wikis/_form.html.haml +++ b/app/views/projects/wikis/_form.html.haml @@ -43,8 +43,16 @@ .form-text.text-muted = succeed '.' do - = (s_("WikiMarkdownTip|To link to a (new) page, simply type %{link_example}") % { link_example: '<code>[Link Title](page-slug)</code>' }).html_safe - + - case @page.format.to_s + - when 'rdoc' + - link_example = '{Link title}[link:page-slug]' + - when 'asciidoc' + - link_example = 'link:page-slug[Link title]' + - when 'org' + - link_example = '[[page-slug]]' + - else + - link_example = '[Link Title](page-slug)' + = (s_('WikiMarkdownTip|To link to a (new) page, simply type <code class="js-markup-link-example">%{link_example}</code>') % { link_example: link_example }).html_safe = succeed '.' do - markdown_link = link_to s_("WikiMarkdownDocs|documentation"), help_page_path('user/markdown', anchor: 'wiki-specific-markdown') = (s_("WikiMarkdownDocs|More examples are in the %{docs_link}") % { docs_link: markdown_link }).html_safe |