Commit 5ec9feb7 authored by Michael Kozono's avatar Michael Kozono

Merge branch 'lm-refactor-vars' into 'master'

Updates alert status enum values

See merge request gitlab-org/gitlab!32697
parents 6296f558 4354a6b9
......@@ -52,14 +52,14 @@ export default {
sortable: true,
},
{
key: 'startTime',
key: 'startedAt',
label: s__('AlertManagement|Start time'),
thClass: 'js-started-at',
tdClass,
sortable: true,
},
{
key: 'endTime',
key: 'endedAt',
label: s__('AlertManagement|End time'),
tdClass,
sortable: true,
......@@ -72,7 +72,7 @@ export default {
sortable: false,
},
{
key: 'eventsCount',
key: 'eventCount',
label: s__('AlertManagement|Events'),
thClass: 'text-right gl-pr-9 w-3rem',
tdClass: `${tdClass} text-md-right`,
......@@ -164,7 +164,7 @@ export default {
errored: false,
isAlertDismissed: false,
isErrorAlertDismissed: false,
sort: 'START_TIME_ASC',
sort: 'STARTED_AT_ASC',
statusFilter: this.$options.statusTabs[4].filters,
};
},
......@@ -199,7 +199,7 @@ export default {
const sortDirection = sortDesc ? 'DESC' : 'ASC';
const sortColumn = convertToSnakeCase(sortBy).toUpperCase();
if (sortBy !== 'startTime') {
if (sortBy !== 'startedAt') {
findDefaultSortColumn().ariaSort = 'none';
}
this.sort = `${sortColumn}_${sortDirection}`;
......@@ -294,15 +294,15 @@ export default {
</div>
</template>
<template #cell(startTime)="{ item }">
<template #cell(startedAt)="{ item }">
<time-ago v-if="item.startedAt" :time="item.startedAt" />
</template>
<template #cell(endTime)="{ item }">
<template #cell(endedAt)="{ item }">
<time-ago v-if="item.endedAt" :time="item.endedAt" />
</template>
<!-- TODO: Remove after: https://gitlab.com/gitlab-org/gitlab/-/issues/218467 -->
<template #cell(eventsCount)="{ item }">
<template #cell(eventCount)="{ item }">
{{ item.eventCount }}
</template>
......
......@@ -6,16 +6,16 @@ module Types
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 'STARTED_AT_ASC', 'Start time by ascending order', value: :started_at_asc
value 'STARTED_AT_DESC', 'Start time by descending order', value: :started_at_desc
value 'ENDED_AT_ASC', 'End time by ascending order', value: :ended_at_asc
value 'ENDED_AT_DESC', 'End time by descending order', value: :ended_at_desc
value 'CREATED_TIME_ASC', 'Created time by ascending order', value: :created_at_asc
value 'CREATED_TIME_DESC', 'Created time by descending order', value: :created_at_desc
value 'UPDATED_TIME_ASC', 'Created time by ascending order', value: :updated_at_asc
value 'UPDATED_TIME_DESC', 'Created time by descending 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 'EVENT_COUNT_ASC', 'Events count by ascending order', value: :event_count_asc
value 'EVENT_COUNT_DESC', 'Events count by descending order', value: :event_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
......
......@@ -102,7 +102,7 @@ module AlertManagement
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_event_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) }
......@@ -110,12 +110,12 @@ module AlertManagement
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 'started_at_asc' then order_start_time(:asc)
when 'started_at_desc' then order_start_time(:desc)
when 'ended_at_asc' then order_end_time(:asc)
when 'ended_at_desc' then order_end_time(:desc)
when 'event_count_asc' then order_event_count(:asc)
when 'event_count_desc' then order_event_count(:desc)
when 'severity_asc' then order_severity(:asc)
when 'severity_desc' then order_severity(:desc)
when 'status_asc' then order_status(:asc)
......
......@@ -270,22 +270,22 @@ enum AlertManagementAlertSort {
"""
End time by ascending order
"""
END_TIME_ASC
ENDED_AT_ASC
"""
End time by descending order
"""
END_TIME_DESC
ENDED_AT_DESC
"""
Events count by ascending order
"""
EVENTS_COUNT_ASC
EVENT_COUNT_ASC
"""
Events count by descending order
"""
EVENTS_COUNT_DESC
EVENT_COUNT_DESC
"""
Severity by ascending order
......@@ -300,12 +300,12 @@ enum AlertManagementAlertSort {
"""
Start time by ascending order
"""
START_TIME_ASC
STARTED_AT_ASC
"""
Start time by descending order
"""
START_TIME_DESC
STARTED_AT_DESC
"""
Status by ascending order
......
......@@ -769,25 +769,25 @@
"deprecationReason": null
},
{
"name": "START_TIME_ASC",
"name": "STARTED_AT_ASC",
"description": "Start time by ascending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "START_TIME_DESC",
"name": "STARTED_AT_DESC",
"description": "Start time by descending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "END_TIME_ASC",
"name": "ENDED_AT_ASC",
"description": "End time by ascending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "END_TIME_DESC",
"name": "ENDED_AT_DESC",
"description": "End time by descending order",
"isDeprecated": false,
"deprecationReason": null
......@@ -817,13 +817,13 @@
"deprecationReason": null
},
{
"name": "EVENTS_COUNT_ASC",
"name": "EVENT_COUNT_ASC",
"description": "Events count by ascending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "EVENTS_COUNT_DESC",
"name": "EVENT_COUNT_DESC",
"description": "Events count by descending order",
"isDeprecated": false,
"deprecationReason": null
......@@ -100,13 +100,13 @@ describe AlertManagement::AlertsFinder, '#execute' do
context 'when sorting by start time' do
context 'sorts alerts ascending' do
let(:params) { { sort: 'start_time_asc' } }
let(:params) { { sort: 'started_at_asc' } }
it { is_expected.to eq [alert_1, alert_2] }
end
context 'sorts alerts descending' do
let(:params) { { sort: 'start_time_desc' } }
let(:params) { { sort: 'started_at_desc' } }
it { is_expected.to eq [alert_2, alert_1] }
end
......@@ -114,13 +114,13 @@ describe AlertManagement::AlertsFinder, '#execute' do
context 'when sorting by end time' do
context 'sorts alerts ascending' do
let(:params) { { sort: 'end_time_asc' } }
let(:params) { { sort: 'ended_at_asc' } }
it { is_expected.to eq [alert_1, alert_2] }
end
context 'sorts alerts descending' do
let(:params) { { sort: 'end_time_desc' } }
let(:params) { { sort: 'ended_at_desc' } }
it { is_expected.to eq [alert_2, alert_1] }
end
......@@ -131,13 +131,13 @@ describe AlertManagement::AlertsFinder, '#execute' do
let_it_be(:alert_count_3) { create(:alert_management_alert, project: project, events: 3) }
context 'sorts alerts ascending' do
let(:params) { { sort: 'events_count_asc' } }
let(:params) { { sort: 'event_count_asc' } }
it { is_expected.to eq [alert_2, alert_1, alert_count_3, alert_count_6] }
end
context 'sorts alerts descending' do
let(:params) { { sort: 'events_count_desc' } }
let(:params) { { sort: 'event_count_desc' } }
it { is_expected.to eq [alert_count_6, alert_count_3, alert_1, alert_2] }
end
......
......@@ -297,7 +297,7 @@ describe('AlertManagementList', () => {
beforeEach(() => {
mountComponent({
props: { alertManagementEnabled: true, userCanEnableAlertManagement: true },
data: { alerts: mockAlerts, errored: false, sort: 'START_TIME_ASC', alertsCount },
data: { alerts: mockAlerts, errored: false, sort: 'STARTED_AT_ASC', alertsCount },
loading: false,
});
});
......
......@@ -45,11 +45,11 @@ describe Resolvers::AlertManagementAlertResolver do
let_it_be(:alert_count_3) { create(:alert_management_alert, project: project, events: 3) }
it 'sorts alerts ascending' do
expect(resolve_alerts(sort: :events_count_asc)).to eq [alert_2, alert_1, alert_count_3, alert_count_6]
expect(resolve_alerts(sort: :event_count_asc)).to eq [alert_2, alert_1, alert_count_3, alert_count_6]
end
it 'sorts alerts descending' do
expect(resolve_alerts(sort: :events_count_desc)).to eq [alert_count_6, alert_count_3, alert_1, alert_2]
expect(resolve_alerts(sort: :event_count_desc)).to eq [alert_count_6, alert_count_3, alert_1, alert_2]
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment