Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name the tags on the topology screens based on its classifications #3034

Merged
merged 1 commit into from
Dec 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/assets/javascripts/services/topology_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ ManageIQ.angular.app.service('topologyService', function() {
__('Status: ') + d.item.status,
];

if (d.item.kind === 'Tag') {
status = [
d.item.name,
__('Type: ') + d.item.display_kind,
];
}

if (d.item.kind === 'Host' || d.item.kind === 'Vm') {
status.push(__('Provider: ') + d.item.provider);
}

return status;
};


this.showHideNames = function($scope) {
return function() {
$scope.checkboxModel.value = $('input#box_display_names')[0].checked;
Expand Down
11 changes: 10 additions & 1 deletion app/services/topology_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,18 @@ def entity_id(entity)
entity_type(entity) + entity.compressed_id.to_s
end

def entity_name(entity)
if entity.kind_of?(Tag)
cls = entity.classification
[cls.parent, cls].map(&:description).join(': ')
else
entity.name
end
end

def build_base_entity_data(entity)
{
:name => entity.name,
:name => entity_name(entity),
:kind => entity_type(entity),
:model => entity.class.to_s,
:miq_id => entity.id,
Expand Down
22 changes: 22 additions & 0 deletions spec/services/topology_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,26 @@
end
end
end

describe '#entity_name' do
let(:name) { subject.send(:entity_name, entity) }

context 'entity is not a tag' do
let(:entity) { FactoryGirl.create(:vm_vmware) }

it 'returns with the name of the entity' do
expect(name).to eq(entity.name)
end
end

context 'entity is a tag' do
let(:parent_cls) { FactoryGirl.create(:classification, :description => 'foo') }
let(:cls) { FactoryGirl.create(:classification, :parent => parent_cls, :description => 'bar') }
let(:entity) { FactoryGirl.create(:tag, :classification => cls) }

it 'returns with the parent and the child classification description' do
expect(name).to eq('foo: bar')
end
end
end
end