Commit 997e0f11 authored by Gordon Seto's avatar Gordon Seto Committed by Commit Bot

[CRoS Settings] Rename Routing Prefix label to Subnet mask.

Remove RoutingPrefix property from IPConfigUIProperties and add netmask, update network settings UI text from 'Routing Prefix' to 'Subnet Mask'.

Screenshots:
Before:
https://screenshot.googleplex.com/5Tc47C33Hpkx76Q.png

After:
https://screenshot.googleplex.com/8LNYKXVqGNpZq4L.png

Bug: 1100296
Change-Id: Ib7155a71bd2cc24261a9f4d493162bd9fd0aecd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2443401
Commit-Queue: Gordon Seto <gordonseto@google.com>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarAzeem Arshad <azeemarshad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813460}
parent 0061f4d4
...@@ -1632,8 +1632,8 @@ ...@@ -1632,8 +1632,8 @@
<message name="IDS_ONC_IPV4_GATEWAY" desc="ONC Property label for ipv4-Gateway"> <message name="IDS_ONC_IPV4_GATEWAY" desc="ONC Property label for ipv4-Gateway">
Gateway Gateway
</message> </message>
<message name="IDS_ONC_IPV4_ROUTING_PREFIX" desc="ONC Property label for ipv4-RoutingPrefix"> <message name="IDS_ONC_IPV4_NETMASK" desc="ONC Property label for ipv4-netmask">
Routing prefix Subnet mask
</message> </message>
<message name="IDS_ONC_IPV6_ADDRESS" desc="ONC Property label for ipv6-Address"> <message name="IDS_ONC_IPV6_ADDRESS" desc="ONC Property label for ipv6-Address">
IPv6 address IPv6 address
......
5c3d5df370f0a5cd70f1132063606e3130092d28
\ No newline at end of file
...@@ -201,7 +201,8 @@ void AddOncLocalizedStrings(content::WebUIDataSource* html_source) { ...@@ -201,7 +201,8 @@ void AddOncLocalizedStrings(content::WebUIDataSource* html_source) {
{"OncWiFi-SignalStrength", IDS_ONC_WIFI_SIGNAL_STRENGTH}, {"OncWiFi-SignalStrength", IDS_ONC_WIFI_SIGNAL_STRENGTH},
{"Oncipv4-Gateway", IDS_ONC_IPV4_GATEWAY}, {"Oncipv4-Gateway", IDS_ONC_IPV4_GATEWAY},
{"Oncipv4-IPAddress", IDS_ONC_IPV4_ADDRESS}, {"Oncipv4-IPAddress", IDS_ONC_IPV4_ADDRESS},
{"Oncipv4-RoutingPrefix", IDS_ONC_IPV4_ROUTING_PREFIX}, // We use 'Netmask' in the UI instead of RoutingPrefix.
{"Oncipv4-Netmask", IDS_ONC_IPV4_NETMASK},
{"Oncipv6-IPAddress", IDS_ONC_IPV6_ADDRESS}, {"Oncipv6-IPAddress", IDS_ONC_IPV6_ADDRESS},
}; };
AddLocalizedStringsBulk(html_source, kLocalizedStrings); AddLocalizedStringsBulk(html_source, kLocalizedStrings);
......
...@@ -42,7 +42,7 @@ const getRoutingPrefixAsNetmask = function(prefixLength) { ...@@ -42,7 +42,7 @@ const getRoutingPrefixAsNetmask = function(prefixLength) {
/** /**
* Returns the routing prefix length as a number from the netmask string. * Returns the routing prefix length as a number from the netmask string.
* @param {string} netmask The netmask string, e.g. 255.255.255.0. * @param {string|undefined} netmask The netmask string, e.g. 255.255.255.0.
* @return {number} The corresponding netmask or NO_ROUTING_PREFIX if invalid. * @return {number} The corresponding netmask or NO_ROUTING_PREFIX if invalid.
*/ */
const getRoutingPrefixAsLength = function(netmask) { const getRoutingPrefixAsLength = function(netmask) {
...@@ -128,7 +128,7 @@ Polymer({ ...@@ -128,7 +128,7 @@ Polymer({
value() { value() {
return [ return [
'ipv4.ipAddress', 'ipv4.ipAddress',
'ipv4.routingPrefix', 'ipv4.netmask',
'ipv4.gateway', 'ipv4.gateway',
'ipv6.ipAddress', 'ipv6.ipAddress',
]; ];
...@@ -207,7 +207,7 @@ Polymer({ ...@@ -207,7 +207,7 @@ Polymer({
const defaultIpv4 = { const defaultIpv4 = {
gateway: '192.168.1.1', gateway: '192.168.1.1',
ipAddress: '192.168.1.1', ipAddress: '192.168.1.1',
routingPrefix: '255.255.255.0', netmask: '255.255.255.0',
type: 'IPv4', type: 'IPv4',
}; };
// Ensure that there is a valid IPConfig object. Copy any set properties // Ensure that there is a valid IPConfig object. Copy any set properties
...@@ -235,9 +235,9 @@ Polymer({ ...@@ -235,9 +235,9 @@ Polymer({
* @param {!chromeos.networkConfig.mojom.IPConfigProperties|undefined} * @param {!chromeos.networkConfig.mojom.IPConfigProperties|undefined}
* ipconfig * ipconfig
* @return {!OncMojo.IPConfigUIProperties|undefined} A new * @return {!OncMojo.IPConfigUIProperties|undefined} A new
* IPConfigUIProperties object with routingPrefix expressed as a string * IPConfigUIProperties object with routingPrefix expressed as a netmask
* mask instead of a prefix length. Returns undefined if |ipconfig| is not * string instead of a prefix length. Returns undefined if |ipconfig|
* defined. * is not defined.
* @private * @private
*/ */
getIPConfigUIProperties_(ipconfig) { getIPConfigUIProperties_(ipconfig) {
...@@ -245,39 +245,39 @@ Polymer({ ...@@ -245,39 +245,39 @@ Polymer({
return undefined; return undefined;
} }
// Copy |ipconfig| into a new object, |newIpconfig|. // Copy |ipconfig| properties into |ipconfigUI|.
const newIpconfig = {}; const ipconfigUI = {};
Object.assign(newIpconfig, ipconfig); ipconfigUI.gateway = ipconfig.gateway;
ipconfigUI.ipAddress = ipconfig.ipAddress;
ipconfigUI.nameServers = ipconfig.nameServers;
ipconfigUI.type = ipconfig.type;
ipconfigUI.webProxyAutoDiscoveryUrl = ipconfig.webProxyAutoDiscoveryUrl;
if (ipconfig.routingPrefix !== if (ipconfig.routingPrefix !==
chromeos.networkConfig.mojom.NO_ROUTING_PREFIX) { chromeos.networkConfig.mojom.NO_ROUTING_PREFIX) {
const netmask = getRoutingPrefixAsNetmask(ipconfig.routingPrefix); ipconfigUI.netmask = getRoutingPrefixAsNetmask(ipconfig.routingPrefix);
if (netmask !== undefined) {
newIpconfig.routingPrefix = netmask;
}
} }
return newIpconfig; return ipconfigUI;
}, },
/** /**
* @param {!OncMojo.IPConfigUIProperties} ipconfig * @param {!OncMojo.IPConfigUIProperties} ipconfigUI
* @return {!chromeos.networkConfig.mojom.IPConfigProperties} A new * @return {!chromeos.networkConfig.mojom.IPConfigProperties} A new
* IPConfigProperties object with RoutingPrefix expressed as a a prefix * IPConfigProperties object with netmask expressed as a a prefix
* length. * length.
* @private * @private
*/ */
getIPConfigProperties_(ipconfig) { getIPConfigProperties_(ipconfigUI) {
const result = {}; const ipconfig = {};
for (const key in ipconfig) { ipconfig.gateway = ipconfigUI.gateway;
const value = ipconfig[key]; ipconfig.ipAddress = ipconfigUI.ipAddress;
if (key === 'routingPrefix') { ipconfig.nameServers = ipconfigUI.nameServers;
result.routingPrefix = getRoutingPrefixAsLength(value); ipconfig.routingPrefix = getRoutingPrefixAsLength(ipconfigUI.netmask);
} else { ipconfig.type = ipconfigUI.type;
result[key] = value; ipconfig.webProxyAutoDiscoveryUrl = ipconfigUI.webProxyAutoDiscoveryUrl;
}
} return ipconfig;
return result;
}, },
/** /**
...@@ -291,11 +291,7 @@ Polymer({ ...@@ -291,11 +291,7 @@ Polymer({
for (let i = 0; i < this.ipConfigFields_.length; ++i) { for (let i = 0; i < this.ipConfigFields_.length; ++i) {
const key = this.ipConfigFields_[i]; const key = this.ipConfigFields_[i];
const value = this.get(key, this.ipConfig_); const value = this.get(key, this.ipConfig_);
if (key === 'ipv4.routingPrefix') { if (value !== undefined && value !== '') {
if (value !== chromeos.networkConfig.mojom.NO_ROUTING_PREFIX) {
return true;
}
} else if (value !== undefined && value !== '') {
return true; return true;
} }
} }
...@@ -323,8 +319,10 @@ Polymer({ ...@@ -323,8 +319,10 @@ Polymer({
} }
return { return {
'ipv4.ipAddress': this.getIPFieldEditType_(staticIpConfig.ipAddress), 'ipv4.ipAddress': this.getIPFieldEditType_(staticIpConfig.ipAddress),
'ipv4.routingPrefix': // Use routingPrefix instead of netmask because getIPFieldEditType_
this.getIPFieldEditType_(staticIpConfig.routingPrefix), // expects a ManagedProperty and routingPrefix has the same type as
// netmask.
'ipv4.netmask': this.getIPFieldEditType_(staticIpConfig.routingPrefix),
'ipv4.gateway': this.getIPFieldEditType_(staticIpConfig.gateway) 'ipv4.gateway': this.getIPFieldEditType_(staticIpConfig.gateway)
}; };
}, },
......
...@@ -1152,13 +1152,14 @@ OncMojo.NetworkStateProperties; ...@@ -1152,13 +1152,14 @@ OncMojo.NetworkStateProperties;
OncMojo.ManagedProperty; OncMojo.ManagedProperty;
/** /**
* Modified version of mojom.IPConfigProperties to store routingPrefix as a * Modified version of mojom.IPConfigProperties to store routingPrefix as
* human-readable string instead of as a number. Used in network_ip_config.js. * a human-readable netmask string instead of as a number. Used in
* network_ip_config.js.
* @typedef {{ * @typedef {{
* gateway: (string|undefined), * gateway: (string|undefined),
* ipAddress: (string|undefined), * ipAddress: (string|undefined),
* nameServers: (!Array<string>|undefined), * nameServers: (Array<string>|undefined),
* routingPrefix: (string|undefined), * netmask: (string|undefined),
* type: (string|undefined), * type: (string|undefined),
* webProxyAutoDiscoveryUrl: (string|undefined), * webProxyAutoDiscoveryUrl: (string|undefined),
* }} * }}
......
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