summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-30 15:09:15 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-30 15:09:15 +0000
commit536aa3a1f4b96abc4ca34489bf2cbe503afcded7 (patch)
tree88d08f7dfa29a32d6526773c4fe0fefd9f2bc7d1 /app
parent50ae4065530c4eafbeb7c5ff2c462c48c02947ca (diff)
downloadgitlab-ce-536aa3a1f4b96abc4ca34489bf2cbe503afcded7.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/lib/graphql.js13
-rw-r--r--app/assets/javascripts/monitoring/stores/utils.js9
-rw-r--r--app/assets/stylesheets/pages/diff.scss5
-rw-r--r--app/finders/projects/serverless/functions_finder.rb46
-rw-r--r--app/helpers/explore_helper.rb12
-rw-r--r--app/helpers/sorting_helper.rb7
-rw-r--r--app/models/audit_event.rb2
-rw-r--r--app/models/clusters/applications/runner.rb2
-rw-r--r--app/services/akismet_service.rb73
-rw-r--r--app/services/concerns/akismet_methods.rb2
-rw-r--r--app/services/notes/update_service.rb2
-rw-r--r--app/services/spam/akismet_service.rb75
-rw-r--r--app/views/shared/boards/components/_board.html.haml2
13 files changed, 165 insertions, 85 deletions
diff --git a/app/assets/javascripts/lib/graphql.js b/app/assets/javascripts/lib/graphql.js
index 2c5278d16ae..b49fe9362c2 100644
--- a/app/assets/javascripts/lib/graphql.js
+++ b/app/assets/javascripts/lib/graphql.js
@@ -5,6 +5,14 @@ import { ApolloLink } from 'apollo-link';
import { BatchHttpLink } from 'apollo-link-batch-http';
import csrf from '~/lib/utils/csrf';
+export const fetchPolicies = {
+ CACHE_FIRST: 'cache-first',
+ CACHE_AND_NETWORK: 'cache-and-network',
+ NETWORK_ONLY: 'network-only',
+ NO_CACHE: 'no-cache',
+ CACHE_ONLY: 'cache-only',
+};
+
export default (resolvers = {}, config = {}) => {
let uri = `${gon.relative_url_root}/api/graphql`;
@@ -32,5 +40,10 @@ export default (resolvers = {}, config = {}) => {
}),
resolvers,
assumeImmutableResults: config.assumeImmutableResults,
+ defaultOptions: {
+ query: {
+ fetchPolicy: config.fetchPolicy || fetchPolicies.CACHE_FIRST,
+ },
+ },
});
};
diff --git a/app/assets/javascripts/monitoring/stores/utils.js b/app/assets/javascripts/monitoring/stores/utils.js
index 56244a4ca66..cd586c6af3e 100644
--- a/app/assets/javascripts/monitoring/stores/utils.js
+++ b/app/assets/javascripts/monitoring/stores/utils.js
@@ -1,8 +1,13 @@
import { omit } from 'lodash';
-import createGqClient from '~/lib/graphql';
+import createGqClient, { fetchPolicies } from '~/lib/graphql';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
-export const gqClient = createGqClient();
+export const gqClient = createGqClient(
+ {},
+ {
+ fetchPolicy: fetchPolicies.NO_CACHE,
+ },
+);
export const uniqMetricsId = metric => `${metric.metric_id}_${metric.id}`;
diff --git a/app/assets/stylesheets/pages/diff.scss b/app/assets/stylesheets/pages/diff.scss
index f394e4ab58a..d30f113c01f 100644
--- a/app/assets/stylesheets/pages/diff.scss
+++ b/app/assets/stylesheets/pages/diff.scss
@@ -63,11 +63,6 @@
background-color: $gray-normal;
}
- a,
- button {
- color: $gray-700;
- }
-
svg {
vertical-align: middle;
top: -1px;
diff --git a/app/finders/projects/serverless/functions_finder.rb b/app/finders/projects/serverless/functions_finder.rb
index e8c50ef1a88..4e0b69f47e5 100644
--- a/app/finders/projects/serverless/functions_finder.rb
+++ b/app/finders/projects/serverless/functions_finder.rb
@@ -4,9 +4,15 @@ module Projects
module Serverless
class FunctionsFinder
include Gitlab::Utils::StrongMemoize
+ include ReactiveCaching
attr_reader :project
+ self.reactive_cache_key = ->(finder) { finder.cache_key }
+ self.reactive_cache_worker_finder = ->(_id, *args) { from_cache(*args) }
+
+ MAX_CLUSTERS = 10
+
def initialize(project)
@project = project
end
@@ -15,8 +21,9 @@ module Projects
knative_services.flatten.compact
end
- # Possible return values: Clusters::KnativeServicesFinder::KNATIVE_STATE
def knative_installed
+ return knative_installed_from_cluster?(*cache_key) if available_environments.empty?
+
states = services_finders.map do |finder|
finder.knative_detected.tap do |state|
return state if state == ::Clusters::KnativeServicesFinder::KNATIVE_STATES['checking'] # rubocop:disable Cop/AvoidReturnFromBlocks
@@ -45,8 +52,41 @@ module Projects
end
end
+ def self.from_cache(project_id)
+ project = Project.find(project_id)
+
+ new(project)
+ end
+
+ def cache_key(*args)
+ [project.id]
+ end
+
+ def calculate_reactive_cache(*)
+ # rubocop: disable CodeReuse/ActiveRecord
+ project.all_clusters.enabled.take(MAX_CLUSTERS).any? do |cluster|
+ cluster.kubeclient.knative_client.discover
+ rescue Kubeclient::ResourceNotFoundError
+ next
+ end
+ end
+
private
+ def knative_installed_from_cluster?(*cache_key)
+ cached_data = with_reactive_cache_memoized(*cache_key) { |data| data }
+
+ return ::Clusters::KnativeServicesFinder::KNATIVE_STATES['checking'] if cached_data.nil?
+
+ cached_data ? true : false
+ end
+
+ def with_reactive_cache_memoized(*cache_key)
+ strong_memoize(:reactive_cache) do
+ with_reactive_cache(*cache_key) { |data| data }
+ end
+ end
+
def knative_service(environment_scope, name)
finders_for_scope(environment_scope).map do |finder|
services = finder
@@ -95,6 +135,10 @@ module Projects
environment_scope == finder.cluster.environment_scope
end
end
+
+ def id
+ nil
+ end
end
end
end
diff --git a/app/helpers/explore_helper.rb b/app/helpers/explore_helper.rb
index 62be591ec47..1b36f60c316 100644
--- a/app/helpers/explore_helper.rb
+++ b/app/helpers/explore_helper.rb
@@ -19,6 +19,18 @@ module ExploreHelper
request_path_with_options(options)
end
+ def filter_audit_path(options = {})
+ exist_opts = {
+ entity_type: params[:entity_type],
+ entity_id: params[:entity_id],
+ created_before: params[:created_before],
+ created_after: params[:created_after],
+ sort: params[:sort]
+ }
+ options = exist_opts.merge(options).delete_if { |key, value| value.blank? }
+ request_path_with_options(options)
+ end
+
def filter_groups_path(options = {})
request_path_with_options(options)
end
diff --git a/app/helpers/sorting_helper.rb b/app/helpers/sorting_helper.rb
index 33f3bb0b749..3e448087db0 100644
--- a/app/helpers/sorting_helper.rb
+++ b/app/helpers/sorting_helper.rb
@@ -207,6 +207,13 @@ module SortingHelper
}.merge(issuable_sort_option_overrides)
end
+ def audit_logs_sort_order_hash
+ {
+ sort_value_recently_created => sort_title_recently_created,
+ sort_value_oldest_created => sort_title_oldest_created
+ }
+ end
+
def issuable_sort_option_title(sort_value)
sort_value = issuable_sort_option_overrides[sort_value] || sort_value
diff --git a/app/models/audit_event.rb b/app/models/audit_event.rb
index 06a607b75a4..03eb7462ece 100644
--- a/app/models/audit_event.rb
+++ b/app/models/audit_event.rb
@@ -13,6 +13,8 @@ class AuditEvent < ApplicationRecord
scope :by_entity_type, -> (entity_type) { where(entity_type: entity_type) }
scope :by_entity_id, -> (entity_id) { where(entity_id: entity_id) }
+ scope :order_by_id_desc, -> { order(id: :desc) }
+ scope :order_by_id_asc, -> { order(id: :asc) }
after_initialize :initialize_details
diff --git a/app/models/clusters/applications/runner.rb b/app/models/clusters/applications/runner.rb
index 42b63fbef92..6a9cd77d356 100644
--- a/app/models/clusters/applications/runner.rb
+++ b/app/models/clusters/applications/runner.rb
@@ -3,7 +3,7 @@
module Clusters
module Applications
class Runner < ApplicationRecord
- VERSION = '0.13.0'
+ VERSION = '0.13.1'
self.table_name = 'clusters_applications_runners'
diff --git a/app/services/akismet_service.rb b/app/services/akismet_service.rb
deleted file mode 100644
index d8098c4a8f5..00000000000
--- a/app/services/akismet_service.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-# frozen_string_literal: true
-
-class AkismetService
- attr_accessor :text, :options
-
- def initialize(owner_name, owner_email, text, options = {})
- @owner_name = owner_name
- @owner_email = owner_email
- @text = text
- @options = options
- end
-
- def spam?
- return false unless akismet_enabled?
-
- params = {
- type: 'comment',
- text: text,
- created_at: DateTime.now,
- author: owner_name,
- author_email: owner_email,
- referrer: options[:referrer]
- }
-
- begin
- is_spam, is_blatant = akismet_client.check(options[:ip_address], options[:user_agent], params)
- is_spam || is_blatant
- rescue => e
- Rails.logger.error("Unable to connect to Akismet: #{e}, skipping check") # rubocop:disable Gitlab/RailsLogger
- false
- end
- end
-
- def submit_ham
- submit(:ham)
- end
-
- def submit_spam
- submit(:spam)
- end
-
- private
-
- attr_accessor :owner_name, :owner_email
-
- def akismet_client
- @akismet_client ||= ::Akismet::Client.new(Gitlab::CurrentSettings.akismet_api_key,
- Gitlab.config.gitlab.url)
- end
-
- def akismet_enabled?
- Gitlab::CurrentSettings.akismet_enabled
- end
-
- def submit(type)
- return false unless akismet_enabled?
-
- params = {
- type: 'comment',
- text: text,
- author: owner_name,
- author_email: owner_email
- }
-
- begin
- akismet_client.public_send(type, options[:ip_address], options[:user_agent], params) # rubocop:disable GitlabSecurity/PublicSend
- true
- rescue => e
- Rails.logger.error("Unable to connect to Akismet: #{e}, skipping!") # rubocop:disable Gitlab/RailsLogger
- false
- end
- end
-end
diff --git a/app/services/concerns/akismet_methods.rb b/app/services/concerns/akismet_methods.rb
index 508a165b065..48c4e329944 100644
--- a/app/services/concerns/akismet_methods.rb
+++ b/app/services/concerns/akismet_methods.rb
@@ -6,7 +6,7 @@ module AkismetMethods
end
def akismet
- @akismet ||= AkismetService.new(
+ @akismet ||= Spam::AkismetService.new(
spammable_owner.name,
spammable_owner.email,
spammable.spammable_text,
diff --git a/app/services/notes/update_service.rb b/app/services/notes/update_service.rb
index 15c556498ec..c8b0dc30209 100644
--- a/app/services/notes/update_service.rb
+++ b/app/services/notes/update_service.rb
@@ -3,7 +3,7 @@
module Notes
class UpdateService < BaseService
def execute(note)
- return note unless note.editable?
+ return note unless note.editable? && params.present?
old_mentioned_users = note.mentioned_users(current_user).to_a
diff --git a/app/services/spam/akismet_service.rb b/app/services/spam/akismet_service.rb
new file mode 100644
index 00000000000..7d16743b3ed
--- /dev/null
+++ b/app/services/spam/akismet_service.rb
@@ -0,0 +1,75 @@
+# frozen_string_literal: true
+
+module Spam
+ class AkismetService
+ attr_accessor :text, :options
+
+ def initialize(owner_name, owner_email, text, options = {})
+ @owner_name = owner_name
+ @owner_email = owner_email
+ @text = text
+ @options = options
+ end
+
+ def spam?
+ return false unless akismet_enabled?
+
+ params = {
+ type: 'comment',
+ text: text,
+ created_at: DateTime.now,
+ author: owner_name,
+ author_email: owner_email,
+ referrer: options[:referrer]
+ }
+
+ begin
+ is_spam, is_blatant = akismet_client.check(options[:ip_address], options[:user_agent], params)
+ is_spam || is_blatant
+ rescue => e
+ Rails.logger.error("Unable to connect to Akismet: #{e}, skipping check") # rubocop:disable Gitlab/RailsLogger
+ false
+ end
+ end
+
+ def submit_ham
+ submit(:ham)
+ end
+
+ def submit_spam
+ submit(:spam)
+ end
+
+ private
+
+ attr_accessor :owner_name, :owner_email
+
+ def akismet_client
+ @akismet_client ||= ::Akismet::Client.new(Gitlab::CurrentSettings.akismet_api_key,
+ Gitlab.config.gitlab.url)
+ end
+
+ def akismet_enabled?
+ Gitlab::CurrentSettings.akismet_enabled
+ end
+
+ def submit(type)
+ return false unless akismet_enabled?
+
+ params = {
+ type: 'comment',
+ text: text,
+ author: owner_name,
+ author_email: owner_email
+ }
+
+ begin
+ akismet_client.public_send(type, options[:ip_address], options[:user_agent], params) # rubocop:disable GitlabSecurity/PublicSend
+ true
+ rescue => e
+ Rails.logger.error("Unable to connect to Akismet: #{e}, skipping!") # rubocop:disable Gitlab/RailsLogger
+ false
+ end
+ end
+ end
+end
diff --git a/app/views/shared/boards/components/_board.html.haml b/app/views/shared/boards/components/_board.html.haml
index a62c385d711..1c2ba6639cf 100644
--- a/app/views/shared/boards/components/_board.html.haml
+++ b/app/views/shared/boards/components/_board.html.haml
@@ -22,7 +22,7 @@
%span.board-title-main-text.block-truncated{ "v-if": "list.type !== \"label\"",
":title" => '((list.label && list.label.description) || list.title || "")',
data: { container: "body" },
- ":class": "{ 'has-tooltip': !['backlog', 'closed'].includes(list.type) }" }
+ ":class": "{ 'has-tooltip': !['backlog', 'closed'].includes(list.type), 'd-block': list.type === 'milestone' }" }
{{ list.title }}
%span.board-title-sub-text.prepend-left-5.has-tooltip{ "v-if": "list.type === \"assignee\"",