diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-03 18:08:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-03 18:08:08 +0300 |
commit | 946771d0b016ae92b15a60bc3290a33b94191ffe (patch) | |
tree | 64862c2433989483f5fce45d5539242577a362eb /app | |
parent | f1e2fca19a90a6992c2020cf8c2159cfb0b61bca (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/repository/components/last_commit.vue | 4 | ||||
-rw-r--r-- | app/assets/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer.vue | 1 | ||||
-rw-r--r-- | app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb | 52 | ||||
-rw-r--r-- | app/graphql/types/admin/sidekiq_queues/delete_jobs_response_type.rb | 29 | ||||
-rw-r--r-- | app/graphql/types/mutation_type.rb | 1 | ||||
-rw-r--r-- | app/models/application_setting.rb | 3 | ||||
-rw-r--r-- | app/models/project_wiki.rb | 4 | ||||
-rw-r--r-- | app/models/wiki_page.rb | 50 | ||||
-rw-r--r-- | app/views/layouts/nav/sidebar/_analytics_links.html.haml | 5 | ||||
-rw-r--r-- | app/views/projects/forks/new.html.haml | 6 | ||||
-rw-r--r-- | app/views/projects/wikis/_form.html.haml | 2 |
11 files changed, 118 insertions, 39 deletions
diff --git a/app/assets/javascripts/repository/components/last_commit.vue b/app/assets/javascripts/repository/components/last_commit.vue index 64003630271..71c3e15ba49 100644 --- a/app/assets/javascripts/repository/components/last_commit.vue +++ b/app/assets/javascripts/repository/components/last_commit.vue @@ -71,8 +71,8 @@ export default { }, computed: { statusTitle() { - return sprintf(s__('Commits|Commit: %{commitText}'), { - commitText: this.commit.pipeline.detailedStatus.text, + return sprintf(s__('PipelineStatusTooltip|Pipeline: %{ciStatus}'), { + ciStatus: this.commit.pipeline.detailedStatus.text, }); }, isLoading() { diff --git a/app/assets/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer.vue b/app/assets/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer.vue index e30871b66fc..6f5a133b225 100644 --- a/app/assets/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer.vue +++ b/app/assets/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer.vue @@ -112,6 +112,7 @@ export default { <div class="image"> <image-viewer :path="imagePath" + :file-size="isNew ? newSize : oldSize" :inner-css-classes="[ 'frame', { diff --git a/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb b/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb new file mode 100644 index 00000000000..a3a421f8938 --- /dev/null +++ b/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module Mutations + module Admin + module SidekiqQueues + class DeleteJobs < BaseMutation + graphql_name 'AdminSidekiqQueuesDeleteJobs' + + ADMIN_MESSAGE = 'You must be an admin to use this mutation' + + Labkit::Context::KNOWN_KEYS.each do |key| + argument key, + GraphQL::STRING_TYPE, + required: false, + description: "Delete jobs matching #{key} in the context metadata" + end + + argument :queue_name, + GraphQL::STRING_TYPE, + required: true, + description: 'The name of the queue to delete jobs from' + + field :result, + Types::Admin::SidekiqQueues::DeleteJobsResponseType, + null: true, + description: 'Information about the status of the deletion request' + + def ready?(**args) + unless current_user&.admin? + raise Gitlab::Graphql::Errors::ResourceNotAvailable, ADMIN_MESSAGE + end + + super + end + + def resolve(args) + { + result: Gitlab::SidekiqQueue.new(args[:queue_name]).drop_jobs!(args, timeout: 30), + errors: [] + } + rescue Gitlab::SidekiqQueue::NoMetadataError + { + result: nil, + errors: ['No metadata provided'] + } + rescue Gitlab::SidekiqQueue::InvalidQueueError + raise Gitlab::Graphql::Errors::ResourceNotAvailable, "Queue #{args[:queue_name]} not found" + end + end + end + end +end diff --git a/app/graphql/types/admin/sidekiq_queues/delete_jobs_response_type.rb b/app/graphql/types/admin/sidekiq_queues/delete_jobs_response_type.rb new file mode 100644 index 00000000000..69af9d463bb --- /dev/null +++ b/app/graphql/types/admin/sidekiq_queues/delete_jobs_response_type.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module Types + module Admin + module SidekiqQueues + # We can't authorize against the value passed to this because it's + # a plain hash. + class DeleteJobsResponseType < BaseObject # rubocop:disable Graphql/AuthorizeTypes + graphql_name 'DeleteJobsResponse' + description 'The response from the AdminSidekiqQueuesDeleteJobs mutation.' + + field :completed, + GraphQL::BOOLEAN_TYPE, + null: true, + description: 'Whether or not the entire queue was processed in time; if not, retrying the same request is safe' + + field :deleted_jobs, + GraphQL::INT_TYPE, + null: true, + description: 'The number of matching jobs deleted' + + field :queue_size, + GraphQL::INT_TYPE, + null: true, + description: 'The queue size after processing' + end + end + end +end diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb index 90e9e1ec0b9..d3c0d9732d2 100644 --- a/app/graphql/types/mutation_type.rb +++ b/app/graphql/types/mutation_type.rb @@ -6,6 +6,7 @@ module Types graphql_name 'Mutation' + mount_mutation Mutations::Admin::SidekiqQueues::DeleteJobs mount_mutation Mutations::AwardEmojis::Add mount_mutation Mutations::AwardEmojis::Remove mount_mutation Mutations::AwardEmojis::Toggle diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 2f7d6164b9a..f9d7e8a2b7a 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -172,6 +172,7 @@ class ApplicationSetting < ApplicationRecord validates :gitaly_timeout_default, presence: true, + if: :gitaly_timeout_default_changed?, numericality: { only_integer: true, greater_than_or_equal_to: 0, @@ -180,6 +181,7 @@ class ApplicationSetting < ApplicationRecord validates :gitaly_timeout_medium, presence: true, + if: :gitaly_timeout_medium_changed?, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :gitaly_timeout_medium, numericality: { less_than_or_equal_to: :gitaly_timeout_default }, @@ -190,6 +192,7 @@ class ApplicationSetting < ApplicationRecord validates :gitaly_timeout_fast, presence: true, + if: :gitaly_timeout_fast_changed?, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :gitaly_timeout_fast, numericality: { less_than_or_equal_to: :gitaly_timeout_default }, diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index 7529047a73a..8ed7811b468 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -107,7 +107,7 @@ class ProjectWiki direction_desc: direction == DIRECTION_DESC, load_content: load_content ).map do |page| - WikiPage.new(self, page, true) + WikiPage.new(self, page) end end @@ -122,7 +122,7 @@ class ProjectWiki page_title, page_dir = page_title_and_dir(title) if page = wiki.page(title: page_title, version: version, dir: page_dir) - WikiPage.new(self, page, true) + WikiPage.new(self, page) end end diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index c5db42a40ac..c6481bdbb6c 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -70,10 +70,9 @@ class WikiPage Gitlab::HookData::WikiPageBuilder.new(self).build end - def initialize(wiki, page = nil, persisted = false) + def initialize(wiki, page = nil) @wiki = wiki @page = page - @persisted = persisted @attributes = {}.with_indifferent_access set_attributes if persisted? @@ -94,11 +93,7 @@ class WikiPage # The formatted title of this page. def title - if @attributes[:title] - CGI.unescape_html(self.class.unhyphenize(@attributes[:title])) - else - "" - end + @attributes[:title] || '' end # Sets the title of this page. @@ -176,7 +171,7 @@ class WikiPage # Returns boolean True or False if this instance # has been fully created on disk or not. def persisted? - @persisted == true + @page.present? end # Creates a new Wiki Page. @@ -196,7 +191,7 @@ class WikiPage def create(attrs = {}) update_attributes(attrs) - save(page_details: title) do + save do wiki.create_page(title, content, format, attrs[:message]) end end @@ -222,18 +217,12 @@ class WikiPage update_attributes(attrs) - if title_changed? - page_details = title - - if wiki.find_page(page_details).present? - @attributes[:title] = @page.url_path - raise PageRenameError - end - else - page_details = @page.url_path + if title.present? && title_changed? && wiki.find_page(title).present? + @attributes[:title] = @page.title + raise PageRenameError end - save(page_details: page_details) do + save do wiki.update_page( @page, content: content, @@ -266,7 +255,14 @@ class WikiPage end def title_changed? - title.present? && (@page.nil? || self.class.unhyphenize(@page.url_path) != title) + if persisted? + old_title, old_dir = wiki.page_title_and_dir(self.class.unhyphenize(@page.url_path)) + new_title, new_dir = wiki.page_title_and_dir(title) + + new_title != old_title || (title.include?('/') && new_dir != old_dir) + else + title.present? + end end # Updates the current @attributes hash by merging a hash of params @@ -313,26 +309,24 @@ class WikiPage attributes[:format] = @page.format end - def save(page_details:) - return unless valid? + def save + return false unless valid? unless yield errors.add(:base, wiki.error_message) return false end - page_title, page_dir = wiki.page_title_and_dir(page_details) - gitlab_git_wiki = wiki.wiki - @page = gitlab_git_wiki.page(title: page_title, dir: page_dir) - + @page = wiki.find_page(title).page set_attributes - @persisted = errors.blank? + + true end def validate_path_limits *dirnames, title = @attributes[:title].split('/') - if title.bytesize > MAX_TITLE_BYTES + if title && title.bytesize > MAX_TITLE_BYTES errors.add(:title, _("exceeds the limit of %{bytes} bytes") % { bytes: MAX_TITLE_BYTES }) end diff --git a/app/views/layouts/nav/sidebar/_analytics_links.html.haml b/app/views/layouts/nav/sidebar/_analytics_links.html.haml index e87cf92374a..90f9432af03 100644 --- a/app/views/layouts/nav/sidebar/_analytics_links.html.haml +++ b/app/views/layouts/nav/sidebar/_analytics_links.html.haml @@ -10,6 +10,11 @@ = _('Analytics') %ul.sidebar-sub-level-items{ data: { qa_selector: 'analytics_sidebar_submenu' } } + = nav_link(path: navbar_links.first.path, html_options: { class: "fly-out-top-item" } ) do + = link_to navbar_links.first.link do + %strong.fly-out-top-item-name + = _('Analytics') + %li.divider.fly-out-top-item - navbar_links.each do |menu_item| = nav_link(path: menu_item.path) do = link_to(menu_item.link, menu_item.link_to_options) do diff --git a/app/views/projects/forks/new.html.haml b/app/views/projects/forks/new.html.haml index bf03353a565..8a5b08a19c8 100644 --- a/app/views/projects/forks/new.html.haml +++ b/app/views/projects/forks/new.html.haml @@ -19,9 +19,3 @@ %p.prepend-top-default = _("You must have permission to create a project in a namespace before forking.") - .save-project-loader.hide.js-fork-content - %h2.text-center - = icon('spinner spin') - = _("Forking repository") - %p.text-center - = _("Please wait a moment, this page will automatically refresh when ready.") diff --git a/app/views/projects/wikis/_form.html.haml b/app/views/projects/wikis/_form.html.haml index c66799a1598..bc20635f0c5 100644 --- a/app/views/projects/wikis/_form.html.haml +++ b/app/views/projects/wikis/_form.html.haml @@ -12,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: _('Wiki|Page title') + = f.text_field :title, class: 'form-control qa-wiki-title-textbox', value: @page.title, required: true, autofocus: !@page.persisted?, placeholder: s_('Wiki|Page title') %span.d-inline-block.mw-100.prepend-top-5 = icon('lightbulb-o') - if @page.persisted? |