Commit af561f52 authored by Markus Koller's avatar Markus Koller

Merge branch '216143-show-resolved-state-in-todos-list' into 'master'

Add AlertManagement Alert state pill

See merge request gitlab-org/gitlab!35579
parents c2bdc29e 7c200ee1
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
} }
&.status-box-issue-closed, &.status-box-issue-closed,
&.status-box-alert-resolved,
&.status-box-mr-merged { &.status-box-mr-merged {
background-color: $blue-500; background-color: $blue-500;
} }
......
...@@ -97,11 +97,13 @@ module TodosHelper ...@@ -97,11 +97,13 @@ module TodosHelper
'mr' 'mr'
when Issue when Issue
'issue' 'issue'
when AlertManagement::Alert
'alert'
end end
content_tag(:span, nil, class: 'target-status') do content_tag(:span, nil, class: 'target-status') do
content_tag(:span, nil, class: "status-box status-box-#{type}-#{todo.target.state.dasherize}") do content_tag(:span, nil, class: "status-box status-box-#{type}-#{todo.target.state.to_s.dasherize}") do
todo.target.state.capitalize todo.target.state.to_s.capitalize
end end
end end
end end
...@@ -214,7 +216,14 @@ module TodosHelper ...@@ -214,7 +216,14 @@ module TodosHelper
end end
def show_todo_state?(todo) def show_todo_state?(todo)
(todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && %w(closed merged).include?(todo.target.state) case todo.target
when MergeRequest, Issue
%w(closed merged).include?(todo.target.state)
when AlertManagement::Alert
%i(resolved).include?(todo.target.state)
else
false
end
end end
def todo_group_options def todo_group_options
......
...@@ -135,6 +135,8 @@ module AlertManagement ...@@ -135,6 +135,8 @@ module AlertManagement
scope :counts_by_status, -> { group(:status).count } scope :counts_by_status, -> { group(:status).count }
scope :counts_by_project_id, -> { group(:project_id).count } scope :counts_by_project_id, -> { group(:project_id).count }
alias_method :state, :status_name
def self.sort_by_attribute(method) def self.sort_by_attribute(method)
case method.to_s case method.to_s
when 'started_at_asc' then order_start_time(:asc) when 'started_at_asc' then order_start_time(:asc)
......
---
title: Add todo pill styling for resolved alert
merge_request: 35579
author:
type: added
...@@ -163,4 +163,63 @@ RSpec.describe TodosHelper do ...@@ -163,4 +163,63 @@ RSpec.describe TodosHelper do
expect(design_option).to include(text: 'Design') expect(design_option).to include(text: 'Design')
end end
end end
describe '#todo_target_state_pill' do
subject { helper.todo_target_state_pill(todo) }
shared_examples 'a rendered state pill' do |attr|
it 'returns expected html' do
aggregate_failures do
expect(subject).to have_css(".status-box-#{attr[:type]}-#{attr[:state].dasherize}")
expect(subject).to have_content(attr[:state].capitalize)
end
end
end
shared_examples 'no state pill' do
specify { expect(subject).to eq(nil) }
end
context 'merge request todo' do
let(:todo) { create(:todo, target: create(:merge_request)) }
it_behaves_like 'no state pill'
context 'merged MR' do
before do
todo.target.update!(state: 'merged')
end
it_behaves_like 'a rendered state pill', type: 'mr', state: 'merged'
end
end
context 'issue todo' do
let(:todo) { create(:todo, target: issue) }
it_behaves_like 'no state pill'
context 'closed issue' do
before do
todo.target.update!(state: 'closed')
end
it_behaves_like 'a rendered state pill', type: 'issue', state: 'closed'
end
end
context 'alert todo' do
let(:todo) { alert_todo }
it_behaves_like 'no state pill'
context 'resolved alert' do
before do
todo.target.resolve!
end
it_behaves_like 'a rendered state pill', type: 'alert', state: 'resolved'
end
end
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