Commit 873fae30 authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

Revert "Fix incorrect behaviour of settings UI for IP address and name servers."

This reverts commit 6d16ec71.

Reason for revert: Suspect causing failure to the net_unittests here:
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/Mac10.10%20Tests/38075

Original change's description:
> Fix incorrect behaviour of settings UI for IP address and name servers.
> 
> * Block IP address and name servers checkboxes and input fields when
> corresponding settings are enforced by policy and not recommended.
> * Correctly show policy indicators for these settings.
> 
> Bug: 847429
> Change-Id: I3db8ad751ebe44dff487cc01721019738f72c4e5
> Reviewed-on: https://chromium-review.googlesource.com/c/1335487
> Commit-Queue: Zakhar Voit <voit@google.com>
> Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
> Reviewed-by: Alexander Hendrich <hendrich@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#619929}

TBR=stevenjb@chromium.org,hendrich@chromium.org,voit@google.com

Change-Id: I986daf88eb60ac7e1e5113ef9c857b473a7f8d0e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 847429
Reviewed-on: https://chromium-review.googlesource.com/c/1396219Reviewed-by: default avatarXida Chen <xidachen@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619947}
parent e7225fb1
......@@ -2,28 +2,18 @@
<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_types.html">
<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_network_behavior.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="network_property_list.html">
<link rel="import" href="network_shared_css.html">
<dom-module id="network-ip-config">
<template>
<style include="network-shared iron-flex">
cr-toggle {
margin-inline-start: var(--settings-control-label-spacing);
}
</style>
<style include="network-shared iron-flex"></style>
<div class="property-box">
<div id="autoIPConfigLabel" class="start">
[[i18n('networkIPConfigAuto')]]
</div>
<cr-policy-indicator indicator-type="[[getPolicyIndicatorType_(
networkProperties, 'IPAddressConfigType')]]">
</cr-policy-indicator>
<cr-toggle checked="{{automatic_}}"
disabled="[[!canChangeIPConfigType_(editable, networkProperties)]]"
<cr-toggle checked="{{automatic_}}" disabled="[[!editable]]"
on-change="onAutomaticChange_"
aria-labelledby="autoIPConfigLabel">
</cr-toggle>
......
......@@ -10,7 +10,7 @@
Polymer({
is: 'network-ip-config',
behaviors: [I18nBehavior, CrPolicyNetworkBehavior],
behaviors: [I18nBehavior],
properties: {
/**
......@@ -110,28 +110,6 @@ Polymer({
}
},
/**
* Checks whether IP address config type can be changed.
* @param {boolean} editable
* @param {!CrOnc.NetworkProperties} networkProperties
* @return {boolean} true only if 'IPAddressConfigType' as well as all other
* IP address config related fields are editable.
* @private
*/
canChangeIPConfigType_: function(editable, networkProperties) {
if (!editable) {
return false;
}
const controlledProps = [
'IPAddressConfigType', 'StaticIPConfig.IPAddress',
'StaticIPConfig.RoutingPrefix', 'StaticIPConfig.Gateway'
];
return controlledProps.every(
setting =>
!this.isNetworkPolicyPathEnforced(networkProperties, setting));
},
/** @private */
onAutomaticChange_: function() {
if (!this.automatic_) {
......
......@@ -4,8 +4,6 @@
<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html">
<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_radio_group/cr_radio_group.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_network_behavior.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/html/md_select_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
......@@ -34,10 +32,6 @@
margin-inline-start: 38px;
}
.nameservers:not([changeable]) {
opacity: var(--cr-disabled-opacity);
}
#radioGroupDiv {
align-items: center;
display: block;
......@@ -45,38 +39,28 @@
padding-inline-start: var(--cr-section-padding);
}
cr-policy-indicator {
/* Aligns with the other policy indicators. */
margin-inline-end: calc(var(--settings-control-label-spacing) + 34px);
}
</style>
<div class="property-box">
<div class="start">
[[i18n('networkNameservers')]]
</div>
<cr-policy-indicator indicator-type="[[getPolicyIndicatorType_(
networkProperties, 'NameServersConfigType')]]">
</cr-policy-indicator>
[[i18n('networkNameservers')]]
</div>
<div id="radioGroupDiv">
<cr-radio-group id="nameserverType" class="layout vertical"
selected="[[nameserversType_]]"
on-selected-changed="onTypeChange_"
aria-label="[[i18n('networkNameservers')]]">
<!-- Automatic nameservers -->
<cr-radio-button name="automatic" disabled="[[!canChangeConfigType_]]">
<cr-radio-button name="automatic">
[[i18n('networkNameserversAutomatic')]]
</cr-radio-button>
<template is="dom-if" if="[[showNameservers_(nameserversType_,
'automatic', nameservers_)]]">
<div class="nameservers" changeable$="[[canChangeConfigType_]]">
[[getNameserversString_(nameservers_)]]
</div>
<div class="nameservers">[[getNameserversString_(nameservers_)]]</div>
</template>
<!-- Google nameservers -->
<cr-radio-button name="google" disabled="[[!canChangeConfigType_]]">
<cr-radio-button name="google">
[[i18n('networkNameserversGoogle')]]
<template is="dom-if"
if="[[i18nExists('networkGoogleNameserversLearnMoreUrl')]]">
......@@ -88,13 +72,11 @@
</cr-radio-button>
<template is="dom-if" if="[[showNameservers_(nameserversType_,
'google', nameservers_)]]">
<div class$="nameservers">
[[getNameserversString_(nameservers_)]]
</div>
<div class="nameservers">[[getNameserversString_(nameservers_)]]</div>
</template>
<!-- Custom nameservers -->
<cr-radio-button name="custom" disabled="[[!canChangeConfigType_]]">
<cr-radio-button name="custom">
[[i18n('networkNameserversCustom')]]
</cr-radio-button>
<template is="dom-if" if="[[showNameservers_(nameserversType_,
......@@ -103,8 +85,7 @@
<template is="dom-repeat" items="[[nameservers_]]">
<cr-input id="nameserver[[index]]" value="[[item]]"
on-change="onValueChange_"
disabled="[[!canEditCustomNameServers_(editable,
nameserversType_, networkProperties)]]">
disabled="[[!canEdit_(editable, nameserversType_)]]">
</cr-input>
</template>
</div>
......
......@@ -8,7 +8,7 @@
Polymer({
is: 'network-nameservers',
behaviors: [I18nBehavior, CrPolicyNetworkBehavior],
behaviors: [I18nBehavior],
properties: {
/**
......@@ -54,12 +54,6 @@ Polymer({
return this.i18nAdvanced(
'networkNameserversGoogle', {substitutions: [], tags: ['a']});
}
},
/** @private */
canChangeConfigType_: {
type: Boolean,
computed: 'computeCanChangeConfigType_(editable, networkProperties)',
}
},
......@@ -138,38 +132,14 @@ Polymer({
});
},
/**
* @param {boolean} editable
* @param {!CrOnc.NetworkProperties} networkProperties
* @return {boolean} True if the nameservers config type type can be changed.
* @private
*/
computeCanChangeConfigType_: function(editable, networkProperties) {
if (!editable) {
return false;
}
return !this.isNetworkPolicyPathEnforced(
networkProperties, 'NameServersConfigType') &&
!this.isNetworkPolicyPathEnforced(
networkProperties, 'StaticIPConfig.NameServers');
},
/**
* @param {boolean} editable
* @param {string} nameserversType
* @param {!CrOnc.NetworkProperties} networkProperties
* @return {boolean} True if the nameservers are editable.
* @private
*/
canEditCustomNameServers_: function(
editable, nameserversType, networkProperties) {
return editable && nameserversType == 'custom' &&
!this.isNetworkPolicyEnforced(
networkProperties.NameServersConfigType) &&
!!networkProperties.StaticIPConfig &&
!this.isNetworkPolicyEnforced(
networkProperties.StaticIPConfig.NameServers);
canEdit_: function(editable, nameserversType) {
return editable && nameserversType == 'custom';
},
/**
......
......@@ -121,88 +121,4 @@ const CrPolicyNetworkBehavior = {
}
return CrPolicyIndicatorType.NONE;
},
/**
* @param {Object} dict A managed ONC dictionary.
* @param {string} path A path to a setting inside |dict|.
* @return {!CrOnc.ManagedProperty|undefined} The value of the setting at
* |path|.
* @private
*/
getSettingAtPath_: function(dict, path) {
const keys = path.split('.');
for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
if (typeof dict !== 'object' || !(key in dict)) {
return undefined;
}
dict = dict[key];
}
return dict;
},
/**
* Get managed property at the given path. If the property is not policy
* managed, return 'undefined'. If the property's value is 'undefined' return
* a non-editable policy managed 'CrOnc.ManagedProperty' object.
* @param {!CrOnc.NetworkProperties} networkProperties
* @param {string} path
* @return {!CrOnc.ManagedProperty|undefined}
* @private
*/
getManagedSettingAtPath_: function(networkProperties, path) {
if (!this.isPolicySource(networkProperties.Source)) {
return undefined;
}
const setting = this.getSettingAtPath_(networkProperties, path);
if (setting) {
return setting;
}
// If setting is not defined, return a non-editable managed property with
// 'undefined' value enforced by 'networkProperties.Source'.
return {
'Effective': networkProperties.Source,
'DeviceEditable': false,
'UserEditable': false,
'UserPolicy': undefined,
'DevicePolicy': undefined
};
},
/**
* @param {!CrOnc.NetworkProperties} networkProperties
* @param {string} path A path to a setting inside |networkProperties|.
* @return {boolean} True if the setting at |path| is managed by policy (e.g.
* 'StaticIPConfig.NameServers').
*/
isNetworkPolicyPathManaged: function(networkProperties, path) {
return this.isNetworkPolicyControlled(
this.getManagedSettingAtPath_(networkProperties, path));
},
/**
* @param {!CrOnc.NetworkProperties} networkProperties
* @param {string} path A path to a setting inside |networkProperties|.
* @return {boolean} True if the setting at |path| is enforced by policy (e.g.
* 'StaticIPConfig.NameServers').
*/
isNetworkPolicyPathEnforced: function(networkProperties, path) {
return this.isNetworkPolicyEnforced(
this.getManagedSettingAtPath_(networkProperties, path));
},
/**
* Get policy indicator type for the setting at |path|.
* @param {CrOnc.NetworkProperties} networkProperties
* @param {string} path
* @return {CrPolicyIndicatorType}
*/
getPolicyIndicatorType_: function(networkProperties, path) {
if (!this.isNetworkPolicyPathManaged(networkProperties, path)) {
return CrPolicyIndicatorType.NONE;
}
return networkProperties.Source == CrOnc.Source.DEVICE_POLICY ?
CrPolicyIndicatorType.DEVICE_POLICY :
CrPolicyIndicatorType.USER_POLICY;
},
};
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