Commit 771fb3b6 authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Network config: nameservers: clear empty

Don't display empty nameservers when switching from custom -> automatic.

Bug: 801087
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Ia4111f044368411773a0cbfb94cf129231f72845
Reviewed-on: https://chromium-review.googlesource.com/896267Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533789}
parent a8363245
......@@ -99,6 +99,7 @@ Polymer({
}
} else {
type = 'automatic';
nameservers = this.clearEmptyNameServers_(nameservers);
}
this.setNameservers_(type, nameservers, false /* send */);
},
......@@ -213,13 +214,14 @@ Polymer({
field: 'NameServers',
value: this.GOOGLE_NAMESERVERS,
});
} else {
// automatic
} else { // type == automatic
// If not connected, properties will clear. Otherwise they may or may not
// change so leave them as-is.
if (this.networkProperties.ConnectionState !=
CrOnc.ConnectionState.CONNECTED) {
this.nameservers_ = [];
} else {
this.nameservers_ = this.clearEmptyNameServers_(this.nameservers_);
}
this.fire('nameservers-change', {
field: 'NameServersConfigType',
......@@ -227,4 +229,13 @@ Polymer({
});
}
},
/**
* @param {!Array<string>} nameservers
* @return {!Array<string>}
* @private
*/
clearEmptyNameServers_: function(nameservers) {
return nameservers.filter((nameserver) => !!nameserver);
},
});
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