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 @@
}
&.status-box-issue-closed,
&.status-box-alert-resolved,
&.status-box-mr-merged {
background-color: $blue-500;
}
......
......@@ -97,11 +97,13 @@ module TodosHelper
'mr'
when Issue
'issue'
when AlertManagement::Alert
'alert'
end
content_tag(:span, nil, class: 'target-status') do
content_tag(:span, nil, class: "status-box status-box-#{type}-#{todo.target.state.dasherize}") do
todo.target.state.capitalize
content_tag(:span, nil, class: "status-box status-box-#{type}-#{todo.target.state.to_s.dasherize}") do
todo.target.state.to_s.capitalize
end
end
end
......@@ -214,7 +216,14 @@ module TodosHelper
end
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
def todo_group_options
......
......@@ -135,6 +135,8 @@ module AlertManagement
scope :counts_by_status, -> { group(:status).count }
scope :counts_by_project_id, -> { group(:project_id).count }
alias_method :state, :status_name
def self.sort_by_attribute(method)
case method.to_s
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
expect(design_option).to include(text: 'Design')
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
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