Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-01 12:10:25 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-01 12:10:25 +0300
commit7bc1ee0bcb9cefaf788aa0b93383b7347e9010b0 (patch)
tree4cd125d7c55603ae87b2ca93b8ef89d71c2c5ef8 /app
parent9b646e9297a1d9bcc7397c76010011f56df1579d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/vue_shared/components/tooltip_on_truncate.vue46
-rw-r--r--app/graphql/resolvers/clusters/agent_activity_events_resolver.rb25
-rw-r--r--app/graphql/resolvers/clusters/agents_resolver.rb5
-rw-r--r--app/graphql/types/clusters/agent_activity_event_type.rb38
-rw-r--r--app/graphql/types/clusters/agent_type.rb6
-rw-r--r--app/models/bulk_imports/entity.rb12
-rw-r--r--app/models/user.rb7
-rw-r--r--app/policies/clusters/agents/activity_event_policy.rb11
-rw-r--r--app/services/merge_requests/rebase_service.rb18
9 files changed, 140 insertions, 28 deletions
diff --git a/app/assets/javascripts/vue_shared/components/tooltip_on_truncate.vue b/app/assets/javascripts/vue_shared/components/tooltip_on_truncate.vue
index c5fdb5fc242..09414e679bb 100644
--- a/app/assets/javascripts/vue_shared/components/tooltip_on_truncate.vue
+++ b/app/assets/javascripts/vue_shared/components/tooltip_on_truncate.vue
@@ -1,11 +1,14 @@
<script>
-import { GlTooltipDirective as GlTooltip } from '@gitlab/ui';
-import { isFunction } from 'lodash';
+import { GlTooltipDirective, GlResizeObserverDirective } from '@gitlab/ui';
+import { isFunction, debounce } from 'lodash';
import { hasHorizontalOverflow } from '~/lib/utils/dom_utils';
+const UPDATE_TOOLTIP_DEBOUNCED_WAIT_MS = 300;
+
export default {
directives: {
- GlTooltip,
+ GlTooltip: GlTooltipDirective,
+ GlResizeObserver: GlResizeObserverDirective,
},
props: {
title: {
@@ -26,15 +29,33 @@ export default {
},
data() {
return {
- showTooltip: false,
+ tooltipDisabled: true,
};
},
+ computed: {
+ classes() {
+ if (this.tooltipDisabled) {
+ return '';
+ }
+ return 'js-show-tooltip';
+ },
+ tooltip() {
+ return {
+ title: this.title,
+ placement: this.placement,
+ disabled: this.tooltipDisabled,
+ };
+ },
+ },
watch: {
title() {
- // Wait on $nextTick in case of slot width changes
+ // Wait on $nextTick in case the slot width changes
this.$nextTick(this.updateTooltip);
},
},
+ created() {
+ this.updateTooltipDebounced = debounce(this.updateTooltip, UPDATE_TOOLTIP_DEBOUNCED_WAIT_MS);
+ },
mounted() {
this.updateTooltip();
},
@@ -45,25 +66,20 @@ export default {
} else if (this.truncateTarget === 'child') {
return this.$el.childNodes[0];
}
-
return this.$el;
},
updateTooltip() {
- const target = this.selectTarget();
- this.showTooltip = hasHorizontalOverflow(target);
+ this.tooltipDisabled = !hasHorizontalOverflow(this.selectTarget());
+ },
+ onResize() {
+ this.updateTooltipDebounced();
},
},
};
</script>
<template>
- <span
- v-if="showTooltip"
- v-gl-tooltip="{ placement }"
- :title="title"
- class="js-show-tooltip gl-min-w-0"
- >
+ <span v-gl-tooltip="tooltip" v-gl-resize-observer="onResize" :class="classes" class="gl-min-w-0">
<slot></slot>
</span>
- <span v-else class="gl-min-w-0"> <slot></slot> </span>
</template>
diff --git a/app/graphql/resolvers/clusters/agent_activity_events_resolver.rb b/app/graphql/resolvers/clusters/agent_activity_events_resolver.rb
new file mode 100644
index 00000000000..b6fec3d3772
--- /dev/null
+++ b/app/graphql/resolvers/clusters/agent_activity_events_resolver.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Resolvers
+ module Clusters
+ class AgentActivityEventsResolver < BaseResolver
+ type Types::Clusters::AgentActivityEventType, null: true
+
+ alias_method :agent, :object
+
+ delegate :project, to: :agent
+
+ def resolve(**args)
+ return ::Clusters::Agents::ActivityEvent.none unless can_view_activity_events?
+
+ agent.activity_events
+ end
+
+ private
+
+ def can_view_activity_events?
+ current_user.can?(:admin_cluster, project)
+ end
+ end
+ end
+end
diff --git a/app/graphql/resolvers/clusters/agents_resolver.rb b/app/graphql/resolvers/clusters/agents_resolver.rb
index 9b8cea52e3b..5ad66ed7cdd 100644
--- a/app/graphql/resolvers/clusters/agents_resolver.rb
+++ b/app/graphql/resolvers/clusters/agents_resolver.rb
@@ -28,7 +28,10 @@ module Resolvers
private
def preloads
- { tokens: :last_used_agent_tokens }
+ {
+ activity_events: { activity_events: [:user, agent_token: :agent] },
+ tokens: :last_used_agent_tokens
+ }
end
end
end
diff --git a/app/graphql/types/clusters/agent_activity_event_type.rb b/app/graphql/types/clusters/agent_activity_event_type.rb
new file mode 100644
index 00000000000..79a9fd70505
--- /dev/null
+++ b/app/graphql/types/clusters/agent_activity_event_type.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+module Types
+ module Clusters
+ class AgentActivityEventType < BaseObject
+ graphql_name 'ClusterAgentActivityEvent'
+
+ authorize :admin_cluster
+
+ connection_type_class(Types::CountableConnectionType)
+
+ field :recorded_at,
+ Types::TimeType,
+ null: true,
+ description: 'Timestamp the event was recorded.'
+
+ field :kind,
+ GraphQL::Types::String,
+ null: true,
+ description: 'Type of event.'
+
+ field :level,
+ GraphQL::Types::String,
+ null: true,
+ description: 'Severity of the event.'
+
+ field :user,
+ Types::UserType,
+ null: true,
+ description: 'User associated with the event.'
+
+ field :agent_token,
+ Types::Clusters::AgentTokenType,
+ null: true,
+ description: 'Agent token associated with the event.'
+ end
+ end
+end
diff --git a/app/graphql/types/clusters/agent_type.rb b/app/graphql/types/clusters/agent_type.rb
index ce748f6e8ae..89316ed4728 100644
--- a/app/graphql/types/clusters/agent_type.rb
+++ b/app/graphql/types/clusters/agent_type.rb
@@ -55,6 +55,12 @@ module Types
complexity: 5,
resolver: ::Resolvers::Kas::AgentConnectionsResolver
+ field :activity_events,
+ Types::Clusters::AgentActivityEventType.connection_type,
+ null: true,
+ description: 'Recent activity for the cluster agent.',
+ resolver: Resolvers::Clusters::AgentActivityEventsResolver
+
def project
Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find
end
diff --git a/app/models/bulk_imports/entity.rb b/app/models/bulk_imports/entity.rb
index 159617bc0a9..33ce4686e27 100644
--- a/app/models/bulk_imports/entity.rb
+++ b/app/models/bulk_imports/entity.rb
@@ -20,8 +20,6 @@
class BulkImports::Entity < ApplicationRecord
self.table_name = 'bulk_import_entities'
- EXPORT_RELATIONS_URL = '/%{resource}/%{full_path}/export_relations'
-
belongs_to :bulk_import, optional: false
belongs_to :parent, class_name: 'BulkImports::Entity', optional: true
@@ -112,14 +110,22 @@ class BulkImports::Entity < ApplicationRecord
entity_type.pluralize
end
+ def base_resource_url_path
+ "/#{pluralized_name}/#{encoded_source_full_path}"
+ end
+
def export_relations_url_path
- @export_relations_url_path ||= EXPORT_RELATIONS_URL % { resource: pluralized_name, full_path: encoded_source_full_path }
+ "#{base_resource_url_path}/export_relations"
end
def relation_download_url_path(relation)
"#{export_relations_url_path}/download?relation=#{relation}"
end
+ def wikis_url_path
+ "#{base_resource_url_path}/wikis"
+ end
+
def project?
source_type == 'project_entity'
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 9057fa67e8f..a0209a51131 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -2168,12 +2168,7 @@ class User < ApplicationRecord
project_creation_levels << nil
end
- if Feature.enabled?(:linear_user_groups_with_developer_maintainer_project_access, self, default_enabled: :yaml)
- developer_groups.self_and_descendants.where(project_creation_level: project_creation_levels)
- else
- developer_groups_hierarchy = ::Gitlab::ObjectHierarchy.new(developer_groups).base_and_descendants
- ::Group.where(id: developer_groups_hierarchy.select(:id), project_creation_level: project_creation_levels)
- end
+ developer_groups.self_and_descendants.where(project_creation_level: project_creation_levels)
end
def no_recent_activity?
diff --git a/app/policies/clusters/agents/activity_event_policy.rb b/app/policies/clusters/agents/activity_event_policy.rb
new file mode 100644
index 00000000000..25fe1570b4b
--- /dev/null
+++ b/app/policies/clusters/agents/activity_event_policy.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+module Clusters
+ module Agents
+ class ActivityEventPolicy < BasePolicy
+ alias_method :event, :subject
+
+ delegate { event.agent }
+ end
+ end
+end
diff --git a/app/services/merge_requests/rebase_service.rb b/app/services/merge_requests/rebase_service.rb
index 9423194c01d..d1f45b4b49c 100644
--- a/app/services/merge_requests/rebase_service.rb
+++ b/app/services/merge_requests/rebase_service.rb
@@ -4,7 +4,7 @@ module MergeRequests
class RebaseService < MergeRequests::BaseService
REBASE_ERROR = 'Rebase failed. Please rebase locally'
- attr_reader :merge_request
+ attr_reader :merge_request, :rebase_error
def execute(merge_request, skip_ci: false)
@merge_request = merge_request
@@ -13,7 +13,7 @@ module MergeRequests
if rebase
success
else
- error(REBASE_ERROR)
+ error(rebase_error)
end
end
@@ -22,11 +22,23 @@ module MergeRequests
true
rescue StandardError => e
- log_error(exception: e, message: REBASE_ERROR, save_message_on_model: true)
+ set_rebase_error(e)
+ log_error(exception: e, message: rebase_error, save_message_on_model: true)
false
ensure
merge_request.update_column(:rebase_jid, nil)
end
+
+ private
+
+ def set_rebase_error(exception)
+ @rebase_error =
+ if exception.is_a?(Gitlab::Git::PreReceiveError)
+ "Something went wrong during the rebase pre-receive hook: #{exception.message}."
+ else
+ REBASE_ERROR
+ end
+ end
end
end