Fix registrar console to show type-less registrar contacts

RegistrarContacts are allowed to have no "types" specified (they can also have multiple types).  However, the registrar console displays the contacts for the logged-in registrar grouped by type into sections, and contacts with no type were simply being omitted from the listing, which was confusing because you can't even log into the console unless your email is listed as a contact, and yet you might then visit the contact settings page and see (apparently) no configured contacts.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=152302159
This commit is contained in:
nickfelt 2017-04-05 14:03:20 -07:00 committed by Ben McIlwain
parent 09393dc8ce
commit 794743c7bc
3 changed files with 9 additions and 3 deletions

View file

@ -115,7 +115,9 @@ registry.registrar.ContactSettings.prototype.renderItem = function(rspObj) {
var contact = contacts[c]; var contact = contacts[c];
var types = contact.types; var types = contact.types;
if (!types) { if (!types) {
continue; // If the contact has no types, synthesize an "OTHER" type so that it
// still will be displayed in the console.
types = 'OTHER';
} }
types = types.split(','); types = types.split(',');
for (var t in types) { for (var t in types) {

View file

@ -25,7 +25,8 @@
['legal', 'Legal', 'Contact for all legal communications.'], ['legal', 'Legal', 'Contact for all legal communications.'],
['marketing', 'Marketing', 'Contact for registry promotions and campaigns.'], ['marketing', 'Marketing', 'Contact for registry promotions and campaigns.'],
['abuse', 'Abuse', 'Contact for abuse complaints.'], ['abuse', 'Abuse', 'Contact for abuse complaints.'],
['whois', 'WHOIS-Inquiry', 'Contact for inquiries about WHOIS accuracy.']] /} ['whois', 'WHOIS-Inquiry', 'Contact for inquiries about WHOIS accuracy.'],
['other', 'Other', 'Contact that is none of the above types']] /}
<div class="{css set}"> <div class="{css set}">
<h1>Contact settings</h1> <h1>Contact settings</h1>
<table> <table>

View file

@ -73,6 +73,8 @@ function tearDown() {
function testCollectionView() { function testCollectionView() {
testContactWithoutType = createTestContact('notype@example.com');
testContactWithoutType.types = '';
registry.registrar.ConsoleTestUtil.visit(test, { registry.registrar.ConsoleTestUtil.visit(test, {
path: 'contact-settings', path: 'contact-settings',
xsrfToken: test.testXsrfToken, xsrfToken: test.testXsrfToken,
@ -86,11 +88,12 @@ function testCollectionView() {
status: 'SUCCESS', status: 'SUCCESS',
message: 'OK', message: 'OK',
results: [{ results: [{
contacts: [testContact] contacts: [testContact, testContactWithoutType]
}] }]
} }
); );
assertEquals(1, $('admin-contacts').childNodes.length); assertEquals(1, $('admin-contacts').childNodes.length);
assertEquals(1, $('other-contacts').childNodes.length);
// XXX: Needs more field testing. // XXX: Needs more field testing.
} }