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>2020-05-19 15:08:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-19 15:08:21 +0300
commit553a22402b0c176b0486cac0009af085122c00f3 (patch)
tree06602864e1778180f3db5d43c56e89882861bc27 /app
parent57d1bb82549c6713f87f87d5f35eec3d867c83db (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/alert_management/components/alert_details.vue41
-rw-r--r--app/assets/javascripts/ide/components/ide_tree.vue2
-rw-r--r--app/assets/stylesheets/pages/alert_management/details.scss42
-rw-r--r--app/assets/stylesheets/pages/alert_management/list.scss (renamed from app/assets/stylesheets/pages/alerts_list.scss)35
-rw-r--r--app/assets/stylesheets/pages/alert_management/severity-icons.scss26
-rw-r--r--app/graphql/mutations/metrics/dashboard/annotations/create.rb106
-rw-r--r--app/graphql/types/mutation_type.rb1
-rw-r--r--app/models/project_authorization.rb3
-rw-r--r--app/models/project_services/chat_message/merge_message.rb4
-rw-r--r--app/models/snippet.rb7
-rw-r--r--app/services/alert_management/create_alert_issue_service.rb2
-rw-r--r--app/workers/concerns/application_worker.rb17
12 files changed, 229 insertions, 57 deletions
diff --git a/app/assets/javascripts/alert_management/components/alert_details.vue b/app/assets/javascripts/alert_management/components/alert_details.vue
index 272caa11e03..89db7db77d5 100644
--- a/app/assets/javascripts/alert_management/components/alert_details.vue
+++ b/app/assets/javascripts/alert_management/components/alert_details.vue
@@ -10,6 +10,7 @@ import {
GlTabs,
GlTab,
GlButton,
+ GlTable,
} from '@gitlab/ui';
import createFlash from '~/flash';
import { s__ } from '~/locale';
@@ -30,7 +31,7 @@ export default {
errorMsg: s__(
'AlertManagement|There was an error displaying the alert. Please refresh the page to try again.',
),
- fullAlertDetailsTitle: s__('AlertManagement|Full alert details'),
+ fullAlertDetailsTitle: s__('AlertManagement|Alert details'),
overviewTitle: s__('AlertManagement|Overview'),
reportedAt: s__('AlertManagement|Reported %{when}'),
reportedAtWithTool: s__('AlertManagement|Reported %{when} by %{tool}'),
@@ -46,6 +47,7 @@ export default {
GlTab,
GlTabs,
GlButton,
+ GlTable,
TimeAgoTooltip,
},
mixins: [glFeatureFlagsMixin()],
@@ -149,18 +151,16 @@ export default {
<strong>{{ $options.severityLabels[alert.severity] }}</strong>
</div>
<span class="mx-2">&bull;</span>
- <span>
- <gl-sprintf :message="reportedAtMessage">
- <template #when>
- <time-ago-tooltip :time="alert.createdAt" />
- </template>
- <template #tool>{{ alert.monitoringTool }}</template>
- </gl-sprintf>
- </span>
+ <gl-sprintf :message="reportedAtMessage">
+ <template #when>
+ <time-ago-tooltip :time="alert.createdAt" class="gl-ml-3" />
+ </template>
+ <template #tool>{{ alert.monitoringTool }}</template>
+ </gl-sprintf>
</div>
<gl-button
v-if="glFeatures.createIssueFromAlertEnabled"
- class="gl-mt-3 mt-sm-0 align-self-center align-self-sm-baseline"
+ class="gl-mt-3 mt-sm-0 align-self-center align-self-sm-baseline alert-details-create-issue-button"
data-testid="createIssueBtn"
:href="newIssuePath"
category="primary"
@@ -215,13 +215,20 @@ export default {
</ul>
</gl-tab>
<gl-tab data-testid="fullDetailsTab" :title="$options.i18n.fullAlertDetailsTitle">
- <ul class="list-unstyled">
- <li v-for="(value, key) in alert" v-if="key !== '__typename'" :key="key">
- <p class="py-1 my-1 gl-font-base">
- <strong>{{ key }}: </strong> {{ value }}
- </p>
- </li>
- </ul>
+ <gl-table
+ class="alert-management-details-table"
+ :items="[{ key: 'Value', ...alert }]"
+ :show-empty="true"
+ :busy="loading"
+ stacked
+ >
+ <template #empty>
+ {{ s__('AlertManagement|No alert data to display.') }}
+ </template>
+ <template #table-busy>
+ <gl-loading-icon size="lg" color="dark" class="mt-3" />
+ </template>
+ </gl-table>
</gl-tab>
</gl-tabs>
</div>
diff --git a/app/assets/javascripts/ide/components/ide_tree.vue b/app/assets/javascripts/ide/components/ide_tree.vue
index d78cddc0953..647f4d4be85 100644
--- a/app/assets/javascripts/ide/components/ide_tree.vue
+++ b/app/assets/javascripts/ide/components/ide_tree.vue
@@ -42,7 +42,7 @@ export default {
<template>
<ide-tree-list viewer-type="editor">
- <template slot="header">
+ <template #header>
{{ __('Edit') }}
<div class="ide-tree-actions ml-auto d-flex">
<new-entry-button
diff --git a/app/assets/stylesheets/pages/alert_management/details.scss b/app/assets/stylesheets/pages/alert_management/details.scss
new file mode 100644
index 00000000000..89219e41644
--- /dev/null
+++ b/app/assets/stylesheets/pages/alert_management/details.scss
@@ -0,0 +1,42 @@
+.alert-management-details {
+ // these styles need to be deleted once GlTable component looks in GitLab same as in @gitlab/ui
+ table {
+ tr {
+ td {
+ @include gl-border-0;
+ @include gl-p-5;
+ border-color: transparent;
+ border-bottom: 1px solid $table-border-color;
+
+ &:first-child {
+ div {
+ font-weight: bold;
+ }
+ }
+
+ &:not(:first-child) {
+ &::before {
+ color: $gray-700;
+ font-weight: normal !important;
+ }
+
+ div {
+ color: $gray-700;
+ }
+ }
+
+ @include media-breakpoint-up(sm) {
+ div {
+ text-align: left !important;
+ }
+ }
+ }
+ }
+ }
+
+ @include media-breakpoint-down(xs) {
+ .alert-details-create-issue-button {
+ width: 100%;
+ }
+ }
+}
diff --git a/app/assets/stylesheets/pages/alerts_list.scss b/app/assets/stylesheets/pages/alert_management/list.scss
index 8eae2b3da1c..3fda66adc87 100644
--- a/app/assets/stylesheets/pages/alerts_list.scss
+++ b/app/assets/stylesheets/pages/alert_management/list.scss
@@ -1,30 +1,4 @@
-.alert-management-list,
-.alert-management-details {
- .icon-critical {
- color: $red-800;
- }
-
- .icon-high {
- color: $red-600;
- }
-
- .icon-medium {
- color: $orange-400;
- }
-
- .icon-low {
- color: $orange-300;
- }
-
- .icon-info {
- color: $blue-400;
- }
-
- .icon-unknown {
- color: $gray-400;
- }
-
-
+.alert-management-list {
// consider adding these stateful variants to @gitlab-ui
// https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/1178
.hover-bg-blue-50:hover {
@@ -97,13 +71,6 @@
}
}
- @include media-breakpoint-down(xs) {
- // TODO Remove in favour of a details CSS page
- [data-testid='createIssueBtn'] {
- width: 100%;
- }
- }
-
.gl-tab-nav-item {
color: $gl-gray-600;
diff --git a/app/assets/stylesheets/pages/alert_management/severity-icons.scss b/app/assets/stylesheets/pages/alert_management/severity-icons.scss
new file mode 100644
index 00000000000..b400e80d5c5
--- /dev/null
+++ b/app/assets/stylesheets/pages/alert_management/severity-icons.scss
@@ -0,0 +1,26 @@
+.alert-management-list,
+.alert-management-details {
+ .icon-critical {
+ color: $red-800;
+ }
+
+ .icon-high {
+ color: $red-600;
+ }
+
+ .icon-medium {
+ color: $orange-400;
+ }
+
+ .icon-low {
+ color: $orange-300;
+ }
+
+ .icon-info {
+ color: $blue-400;
+ }
+
+ .icon-unknown {
+ color: $gray-400;
+ }
+}
diff --git a/app/graphql/mutations/metrics/dashboard/annotations/create.rb b/app/graphql/mutations/metrics/dashboard/annotations/create.rb
new file mode 100644
index 00000000000..f99688aeac6
--- /dev/null
+++ b/app/graphql/mutations/metrics/dashboard/annotations/create.rb
@@ -0,0 +1,106 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Metrics
+ module Dashboard
+ module Annotations
+ class Create < BaseMutation
+ graphql_name 'CreateAnnotation'
+
+ ANNOTATION_SOURCE_ARGUMENT_ERROR = 'Either a cluster or environment global id is required'
+ INVALID_ANNOTATION_SOURCE_ERROR = 'Invalid cluster or environment id'
+
+ authorize :create_metrics_dashboard_annotation
+
+ field :annotation,
+ Types::Metrics::Dashboards::AnnotationType,
+ null: true,
+ description: 'The created annotation'
+
+ argument :environment_id,
+ GraphQL::ID_TYPE,
+ required: false,
+ description: 'The global id of the environment to add an annotation to'
+
+ argument :cluster_id,
+ GraphQL::ID_TYPE,
+ required: false,
+ description: 'The global id of the cluster to add an annotation to'
+
+ argument :starting_at, Types::TimeType,
+ required: true,
+ description: 'Timestamp indicating starting moment to which the annotation relates'
+
+ argument :ending_at, Types::TimeType,
+ required: false,
+ description: 'Timestamp indicating ending moment to which the annotation relates'
+
+ argument :dashboard_path,
+ GraphQL::STRING_TYPE,
+ required: true,
+ description: 'The path to a file defining the dashboard on which the annotation should be added'
+
+ argument :description,
+ GraphQL::STRING_TYPE,
+ required: true,
+ description: 'The description of the annotation'
+
+ AnnotationSource = Struct.new(:object, keyword_init: true) do
+ def type_keys
+ { 'Clusters::Cluster' => :cluster, 'Environment' => :environment }
+ end
+
+ def klass
+ object.class.name
+ end
+
+ def type
+ raise Gitlab::Graphql::Errors::ArgumentError, INVALID_ANNOTATION_SOURCE_ERROR unless type_keys[klass]
+
+ type_keys[klass]
+ end
+ end
+
+ def resolve(args)
+ annotation_response = ::Metrics::Dashboard::Annotations::CreateService.new(context[:current_user], annotation_create_params(args)).execute
+
+ annotation = annotation_response[:annotation]
+
+ {
+ annotation: annotation.valid? ? annotation : nil,
+ errors: errors_on_object(annotation)
+ }
+ end
+
+ private
+
+ def ready?(**args)
+ # Raise error if both cluster_id and environment_id are present or neither is present
+ unless args[:cluster_id].present? ^ args[:environment_id].present?
+ raise Gitlab::Graphql::Errors::ArgumentError, ANNOTATION_SOURCE_ARGUMENT_ERROR
+ end
+
+ super(args)
+ end
+
+ def find_object(id:)
+ GitlabSchema.object_from_id(id)
+ end
+
+ def annotation_create_params(args)
+ annotation_source = AnnotationSource.new(object: annotation_source(args))
+
+ args[annotation_source.type] = annotation_source.object
+
+ args
+ end
+
+ def annotation_source(args)
+ annotation_source_id = args[:cluster_id] || args[:environment_id]
+ authorized_find!(id: annotation_source_id)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb
index 309864c83be..aeff84b83b8 100644
--- a/app/graphql/types/mutation_type.rb
+++ b/app/graphql/types/mutation_type.rb
@@ -22,6 +22,7 @@ module Types
mount_mutation Mutations::MergeRequests::SetSubscription
mount_mutation Mutations::MergeRequests::SetWip, calls_gitaly: true
mount_mutation Mutations::MergeRequests::SetAssignees
+ mount_mutation Mutations::Metrics::Dashboard::Annotations::Create
mount_mutation Mutations::Notes::Create::Note, calls_gitaly: true
mount_mutation Mutations::Notes::Create::DiffNote, calls_gitaly: true
mount_mutation Mutations::Notes::Create::ImageDiffNote, calls_gitaly: true
diff --git a/app/models/project_authorization.rb b/app/models/project_authorization.rb
index e81d9d0f5fe..366852d93bf 100644
--- a/app/models/project_authorization.rb
+++ b/app/models/project_authorization.rb
@@ -2,7 +2,6 @@
class ProjectAuthorization < ApplicationRecord
include FromUnion
- prepend_if_ee('::EE::ProjectAuthorization') # rubocop: disable Cop/InjectEnterpriseEditionModule
belongs_to :user
belongs_to :project
@@ -30,3 +29,5 @@ class ProjectAuthorization < ApplicationRecord
end
end
end
+
+ProjectAuthorization.prepend_if_ee('::EE::ProjectAuthorization')
diff --git a/app/models/project_services/chat_message/merge_message.rb b/app/models/project_services/chat_message/merge_message.rb
index dc62a4c8908..0a2d9120adc 100644
--- a/app/models/project_services/chat_message/merge_message.rb
+++ b/app/models/project_services/chat_message/merge_message.rb
@@ -2,8 +2,6 @@
module ChatMessage
class MergeMessage < BaseMessage
- prepend_if_ee('::EE::ChatMessage::MergeMessage') # rubocop: disable Cop/InjectEnterpriseEditionModule
-
attr_reader :merge_request_iid
attr_reader :source_branch
attr_reader :target_branch
@@ -71,3 +69,5 @@ module ChatMessage
end
end
end
+
+ChatMessage::MergeMessage.prepend_if_ee('::EE::ChatMessage::MergeMessage')
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 37bbf3bbb9a..72ebdf61787 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -18,7 +18,8 @@ class Snippet < ApplicationRecord
include AfterCommitQueue
extend ::Gitlab::Utils::Override
- MAX_FILE_COUNT = 1
+ MAX_FILE_COUNT = 10
+ MAX_SINGLE_FILE_COUNT = 1
cache_markdown_field :title, pipeline: :single_line
cache_markdown_field :description
@@ -169,6 +170,10 @@ class Snippet < ApplicationRecord
Snippet.find_by(id: id, project: project)
end
+ def self.max_file_limit(user)
+ Feature.enabled?(:snippet_multiple_files, user) ? MAX_FILE_COUNT : MAX_SINGLE_FILE_COUNT
+ end
+
def initialize(attributes = {})
# We can't use default_value_for because the database has a default
# value of 0 for visibility_level. If someone attempts to create a
diff --git a/app/services/alert_management/create_alert_issue_service.rb b/app/services/alert_management/create_alert_issue_service.rb
index 9fb6c21ad45..0197f29145d 100644
--- a/app/services/alert_management/create_alert_issue_service.rb
+++ b/app/services/alert_management/create_alert_issue_service.rb
@@ -30,7 +30,7 @@ module AlertManagement
def allowed?
Feature.enabled?(:alert_management_create_alert_issue, project) &&
- user.can?(:update_alert_management_alert, project)
+ user.can?(:create_issue, project)
end
def create_issue(alert, user, alert_payload)
diff --git a/app/workers/concerns/application_worker.rb b/app/workers/concerns/application_worker.rb
index c0062780688..7ab9a0c2a02 100644
--- a/app/workers/concerns/application_worker.rb
+++ b/app/workers/concerns/application_worker.rb
@@ -11,6 +11,8 @@ module ApplicationWorker
include WorkerAttributes
include WorkerContext
+ LOGGING_EXTRA_KEY = 'extra'
+
included do
set_queue
@@ -24,6 +26,21 @@ module ApplicationWorker
payload.stringify_keys.merge(context)
end
+
+ def log_extra_metadata_on_done(key, value)
+ @done_log_extra_metadata ||= {}
+ @done_log_extra_metadata[key] = value
+ end
+
+ def logging_extras
+ return {} unless @done_log_extra_metadata
+
+ # Prefix keys with class name to avoid conflicts in Elasticsearch types.
+ # Also prefix with "extra." so that we know to log these new fields.
+ @done_log_extra_metadata.transform_keys do |k|
+ "#{LOGGING_EXTRA_KEY}.#{self.class.name.gsub("::", "_").underscore}.#{k}"
+ end
+ end
end
class_methods do