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-07 09:09:38 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-07 09:09:38 +0300
commitb6a92c969b16549683ef276f1db7ba9a41dc85bb (patch)
treeccfb1fb03227e567495bdc9aa078afc57ed66f3a /app
parent2e26679b96b5621de70b00bc44f0d3893f1954df (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/alert_management/components/alert_management_list.vue15
-rw-r--r--app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue3
-rw-r--r--app/assets/javascripts/main.js2
-rw-r--r--app/assets/javascripts/pages/projects/blob/new/index.js11
-rw-r--r--app/assets/stylesheets/pages/alerts_list.scss21
-rw-r--r--app/finders/alert_management/alerts_finder.rb7
-rw-r--r--app/graphql/resolvers/alert_management_alert_resolver.rb4
-rw-r--r--app/graphql/types/alert_management/alert_sort_enum.rb25
-rw-r--r--app/models/alert_management/alert.rb24
9 files changed, 95 insertions, 17 deletions
diff --git a/app/assets/javascripts/alert_management/components/alert_management_list.vue b/app/assets/javascripts/alert_management/components/alert_management_list.vue
index 2c3674b9b96..29d632ef3d5 100644
--- a/app/assets/javascripts/alert_management/components/alert_management_list.vue
+++ b/app/assets/javascripts/alert_management/components/alert_management_list.vue
@@ -13,6 +13,8 @@ import { s__ } from '~/locale';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import getAlerts from '../graphql/queries/getAlerts.query.graphql';
+const tdClass = 'table-col d-flex d-md-table-cell align-items-center';
+
export default {
i18n: {
noAlertsMsg: s__(
@@ -26,29 +28,34 @@ export default {
{
key: 'severity',
label: s__('AlertManagement|Severity'),
+ tdClass: `${tdClass} rounded-top text-capitalize`,
},
{
key: 'startedAt',
label: s__('AlertManagement|Start time'),
+ tdClass,
},
{
key: 'endedAt',
label: s__('AlertManagement|End time'),
+ tdClass,
},
{
key: 'title',
label: s__('AlertManagement|Alert'),
thClass: 'w-30p',
+ tdClass,
},
{
key: 'eventCount',
label: s__('AlertManagement|Events'),
thClass: 'text-right event-count',
- tdClass: 'text-right event-count',
+ tdClass: `${tdClass} text-md-right event-count`,
},
{
key: 'status',
label: s__('AlertManagement|Status'),
+ tdClass: `${tdClass} rounded-bottom text-capitalize`,
},
],
statuses: {
@@ -137,8 +144,11 @@ export default {
{{ $options.i18n.errorMsg }}
</gl-alert>
+ <h4 class="d-block d-md-none my-3">
+ {{ s__('AlertManagement|Alerts') }}
+ </h4>
<gl-table
- class="mt-3"
+ class="alert-management-table mt-3"
:items="alerts"
:fields="$options.fields"
:show-empty="true"
@@ -169,6 +179,7 @@ export default {
<template #cell(title)="{ item }">
<div class="gl-max-w-full text-truncate">{{ item.title }}</div>
</template>
+
<template #cell(status)="{ item }">
<gl-new-dropdown class="w-100" :text="item.status">
<gl-new-dropdown-item v-for="(label, field) in $options.statuses" :key="field">
diff --git a/app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue b/app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue
index 5023496e2c3..1e9e36feecc 100644
--- a/app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue
+++ b/app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue
@@ -72,9 +72,6 @@ export default {
dismissCookieName() {
return `${this.trackLabel}_${this.dismissKey}`;
},
- commitCookieName() {
- return `suggest_gitlab_ci_yml_commit_${this.dismissKey}`;
- },
},
mounted() {
if (
diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js
index 6c8f6372795..05869b483c8 100644
--- a/app/assets/javascripts/main.js
+++ b/app/assets/javascripts/main.js
@@ -106,7 +106,6 @@ function deferredInitialisation() {
initLogoAnimation();
initUsagePingConsent();
initUserPopovers();
- initUserTracking();
initBroadcastNotifications();
const recoverySettingsCallout = document.querySelector('.js-recovery-settings-callout');
@@ -187,6 +186,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (document.querySelector('#js-peek')) initPerformanceBar({ container: '#js-peek' });
+ initUserTracking();
initLayoutNav();
// Set the default path for all cookies to GitLab's root directory
diff --git a/app/assets/javascripts/pages/projects/blob/new/index.js b/app/assets/javascripts/pages/projects/blob/new/index.js
index 720cb249052..189053f3ed7 100644
--- a/app/assets/javascripts/pages/projects/blob/new/index.js
+++ b/app/assets/javascripts/pages/projects/blob/new/index.js
@@ -1,12 +1,3 @@
import initBlobBundle from '~/blob_edit/blob_bundle';
-import initPopover from '~/blob/suggest_gitlab_ci_yml';
-document.addEventListener('DOMContentLoaded', () => {
- initBlobBundle();
-
- const suggestEl = document.querySelector('.js-suggest-gitlab-ci-yml');
-
- if (suggestEl) {
- initPopover(suggestEl);
- }
-});
+document.addEventListener('DOMContentLoaded', initBlobBundle);
diff --git a/app/assets/stylesheets/pages/alerts_list.scss b/app/assets/stylesheets/pages/alerts_list.scss
index 7c27237a52a..0d0db0ea6fe 100644
--- a/app/assets/stylesheets/pages/alerts_list.scss
+++ b/app/assets/stylesheets/pages/alerts_list.scss
@@ -53,4 +53,25 @@
}
}
}
+
+ @include media-breakpoint-down(sm) {
+ .alert-management-table {
+ .table-col {
+ min-height: 68px;
+
+ &:last-child {
+ background-color: $gray-normal;
+
+ &::before {
+ content: none !important;
+ }
+
+ div {
+ width: 100% !important;
+ padding: 0 !important;
+ }
+ }
+ }
+ }
+ }
}
diff --git a/app/finders/alert_management/alerts_finder.rb b/app/finders/alert_management/alerts_finder.rb
index b2961329821..061cfb1fde1 100644
--- a/app/finders/alert_management/alerts_finder.rb
+++ b/app/finders/alert_management/alerts_finder.rb
@@ -12,7 +12,8 @@ module AlertManagement
return AlertManagement::Alert.none unless authorized?
collection = project.alert_management_alerts
- by_iid(collection)
+ collection = by_iid(collection)
+ sort(collection)
end
private
@@ -25,6 +26,10 @@ module AlertManagement
collection.for_iid(params[:iid])
end
+ def sort(collection)
+ params[:sort] ? collection.sort_by_attribute(params[:sort]) : collection
+ end
+
def authorized?
Ability.allowed?(current_user, :read_alert_management_alerts, project)
end
diff --git a/app/graphql/resolvers/alert_management_alert_resolver.rb b/app/graphql/resolvers/alert_management_alert_resolver.rb
index 77a20763c58..6c8f64cc62b 100644
--- a/app/graphql/resolvers/alert_management_alert_resolver.rb
+++ b/app/graphql/resolvers/alert_management_alert_resolver.rb
@@ -6,6 +6,10 @@ module Resolvers
required: false,
description: 'IID of the alert. For example, "1"'
+ argument :sort, Types::AlertManagement::AlertSortEnum,
+ description: 'Sort alerts by this criteria',
+ required: false
+
type Types::AlertManagement::AlertType, null: true
def resolve(**args)
diff --git a/app/graphql/types/alert_management/alert_sort_enum.rb b/app/graphql/types/alert_management/alert_sort_enum.rb
new file mode 100644
index 00000000000..76ef43d9dcf
--- /dev/null
+++ b/app/graphql/types/alert_management/alert_sort_enum.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Types
+ module AlertManagement
+ class AlertSortEnum < SortEnum
+ graphql_name 'AlertManagementAlertSort'
+ description 'Values for sorting alerts'
+
+ value 'START_TIME_ASC', 'Start time by ascending order', value: :start_time_asc
+ value 'START_TIME_DESC', 'Start time by descending order', value: :start_time_desc
+ value 'END_TIME_ASC', 'End time by ascending order', value: :end_time_asc
+ value 'END_TIME_DESC', 'End time by descending order', value: :end_time_desc
+ value 'CREATED_TIME_ASC', 'Created time by ascending order', value: :created_at_asc
+ value 'CREATED_TIME_DESC', 'Created time by ascending order', value: :created_at_desc
+ value 'UPDATED_TIME_ASC', 'Created time by ascending order', value: :updated_at_desc
+ value 'UPDATED_TIME_DESC', 'Created time by ascending order', value: :updated_at_desc
+ value 'EVENTS_COUNT_ASC', 'Events count by ascending order', value: :events_count_asc
+ value 'EVENTS_COUNT_DESC', 'Events count by descending order', value: :events_count_desc
+ value 'SEVERITY_ASC', 'Severity by ascending order', value: :severity_asc
+ value 'SEVERITY_DESC', 'Severity by descending order', value: :severity_desc
+ value 'STATUS_ASC', 'Status by ascending order', value: :status_asc
+ value 'STATUS_DESC', 'Status by descending order', value: :status_desc
+ end
+ end
+end
diff --git a/app/models/alert_management/alert.rb b/app/models/alert_management/alert.rb
index 1263423e1c4..6522d52690d 100644
--- a/app/models/alert_management/alert.rb
+++ b/app/models/alert_management/alert.rb
@@ -4,6 +4,7 @@ module AlertManagement
class Alert < ApplicationRecord
include AtomicInternalId
include ShaAttribute
+ include Sortable
belongs_to :project
belongs_to :issue, optional: true
@@ -45,6 +46,29 @@ module AlertManagement
scope :for_iid, -> (iid) { where(iid: iid) }
+ scope :order_start_time, -> (sort_order) { order(started_at: sort_order) }
+ scope :order_end_time, -> (sort_order) { order(ended_at: sort_order) }
+ scope :order_events_count, -> (sort_order) { order(events: sort_order) }
+ scope :order_severity, -> (sort_order) { order(severity: sort_order) }
+ scope :order_status, -> (sort_order) { order(status: sort_order) }
+
+ def self.sort_by_attribute(method)
+ case method.to_s
+ when 'start_time_asc' then order_start_time(:asc)
+ when 'start_time_desc' then order_start_time(:desc)
+ when 'end_time_asc' then order_end_time(:asc)
+ when 'end_time_desc' then order_end_time(:desc)
+ when 'events_count_asc' then order_events_count(:asc)
+ when 'events_count_desc' then order_events_count(:desc)
+ when 'severity_asc' then order_severity(:asc)
+ when 'severity_desc' then order_severity(:desc)
+ when 'status_asc' then order_status(:asc)
+ when 'status_desc' then order_status(:desc)
+ else
+ order_by(method)
+ end
+ end
+
def fingerprint=(value)
if value.blank?
super(nil)