Commit 1b313e8d authored by Grzegorz Bizon's avatar Grzegorz Bizon

Make CI/CD detailed status group concept explicit

parent b1120fc3
- status = local_assigns.fetch(:status) - status = local_assigns.fetch(:status)
- css_classes = "ci-status ci-#{status.group}"
- if status.has_details? - if status.has_details?
= link_to status.details_path, class: "ci-status ci-#{status}" do = link_to status.details_path, class: css_classes do
= custom_icon(status.icon) = custom_icon(status.icon)
= status.text = status.text
- else - else
%span{ class: "ci-status ci-#{status}" } %span{ class: css_classes }
= custom_icon(status.icon) = custom_icon(status.icon)
= status.text = status.text
...@@ -17,6 +17,10 @@ module Gitlab ...@@ -17,6 +17,10 @@ module Gitlab
'icon_status_manual' 'icon_status_manual'
end end
def group
'manual'
end
def has_action? def has_action?
can?(user, :update_build, subject) can?(user, :update_build, subject)
end end
......
...@@ -17,6 +17,10 @@ module Gitlab ...@@ -17,6 +17,10 @@ module Gitlab
'icon_status_manual' 'icon_status_manual'
end end
def group
'manual'
end
def has_action? def has_action?
can?(user, :update_build, subject) can?(user, :update_build, subject)
end end
......
...@@ -22,14 +22,7 @@ module Gitlab ...@@ -22,14 +22,7 @@ module Gitlab
raise NotImplementedError raise NotImplementedError
end end
# Deprecation warning: this method is here because we need to maintain def group
# backwards compatibility with legacy statuses. We often do something
# like "ci-status ci-status-#{status}" to set CSS class.
#
# `to_s` method should be renamed to `group` at some point, after
# phasing legacy satuses out.
#
def to_s
self.class.name.demodulize.downcase.underscore self.class.name.demodulize.downcase.underscore
end end
......
...@@ -32,6 +32,14 @@ describe Gitlab::Ci::Status::Build::Cancelable do ...@@ -32,6 +32,14 @@ describe Gitlab::Ci::Status::Build::Cancelable do
end end
end end
describe '#group' do
it 'does not override status group' do
expect(status).to receive(:group)
subject.group
end
end
describe 'action details' do describe 'action details' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:build) { create(:ci_build) } let(:build) { create(:ci_build) }
......
...@@ -18,6 +18,10 @@ describe Gitlab::Ci::Status::Build::Play do ...@@ -18,6 +18,10 @@ describe Gitlab::Ci::Status::Build::Play do
it { expect(subject.icon).to eq 'icon_status_manual' } it { expect(subject.icon).to eq 'icon_status_manual' }
end end
describe '#group' do
it { expect(subject.group).to eq 'manual' }
end
describe 'action details' do describe 'action details' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:build) { create(:ci_build) } let(:build) { create(:ci_build) }
......
...@@ -32,6 +32,14 @@ describe Gitlab::Ci::Status::Build::Retryable do ...@@ -32,6 +32,14 @@ describe Gitlab::Ci::Status::Build::Retryable do
end end
end end
describe '#group' do
it 'does not override status group' do
expect(status).to receive(:group)
subject.group
end
end
describe 'action details' do describe 'action details' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:build) { create(:ci_build) } let(:build) { create(:ci_build) }
......
...@@ -20,6 +20,10 @@ describe Gitlab::Ci::Status::Build::Stop do ...@@ -20,6 +20,10 @@ describe Gitlab::Ci::Status::Build::Stop do
it { expect(subject.icon).to eq 'icon_status_manual' } it { expect(subject.icon).to eq 'icon_status_manual' }
end end
describe '#group' do
it { expect(subject.group).to eq 'manual' }
end
describe 'action details' do describe 'action details' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:build) { create(:ci_build) } let(:build) { create(:ci_build) }
......
...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Canceled do ...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Canceled do
describe '#icon' do describe '#icon' do
it { expect(subject.icon).to eq 'icon_status_canceled' } it { expect(subject.icon).to eq 'icon_status_canceled' }
end end
describe '#group' do
it { expect(subject.group).to eq 'canceled' }
end
end end
...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Created do ...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Created do
describe '#icon' do describe '#icon' do
it { expect(subject.icon).to eq 'icon_status_created' } it { expect(subject.icon).to eq 'icon_status_created' }
end end
describe '#group' do
it { expect(subject.group).to eq 'created' }
end
end end
...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Failed do ...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Failed do
describe '#icon' do describe '#icon' do
it { expect(subject.icon).to eq 'icon_status_failed' } it { expect(subject.icon).to eq 'icon_status_failed' }
end end
describe '#group' do
it { expect(subject.group).to eq 'failed' }
end
end end
...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Pending do ...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Pending do
describe '#icon' do describe '#icon' do
it { expect(subject.icon).to eq 'icon_status_pending' } it { expect(subject.icon).to eq 'icon_status_pending' }
end end
describe '#group' do
it { expect(subject.group).to eq 'pending' }
end
end end
...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Running do ...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Running do
describe '#icon' do describe '#icon' do
it { expect(subject.icon).to eq 'icon_status_running' } it { expect(subject.icon).to eq 'icon_status_running' }
end end
describe '#group' do
it { expect(subject.group).to eq 'running' }
end
end end
...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Skipped do ...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Skipped do
describe '#icon' do describe '#icon' do
it { expect(subject.icon).to eq 'icon_status_skipped' } it { expect(subject.icon).to eq 'icon_status_skipped' }
end end
describe '#group' do
it { expect(subject.group).to eq 'skipped' }
end
end end
...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Success do ...@@ -16,4 +16,8 @@ describe Gitlab::Ci::Status::Success do
describe '#icon' do describe '#icon' do
it { expect(subject.icon).to eq 'icon_status_success' } it { expect(subject.icon).to eq 'icon_status_success' }
end end
describe '#group' do
it { expect(subject.group).to eq 'success' }
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