Don't show exclusive toggle for 'owner' permissions

In the GWT UI, the checkbox is always disabled. The owner permission
does not allow exclusive to be set. This change only shows the exclusive
toggle if the permission is not 'owner'

Change-Id: I3a3be5aefd661c84e51a84900b3eade6b4b6ef60
This commit is contained in:
Becky Siegel
2018-01-16 10:49:16 -08:00
parent ec7764ac2f
commit 4f33550a21
3 changed files with 21 additions and 6 deletions

View File

@@ -89,11 +89,13 @@ limitations under the License.
<div class="header">
<span class="title">[[name]]</span>
<div class="right">
<paper-toggle-button
id="exclusiveToggle"
checked="{{permission.value.exclusive}}"
on-change="_handleValueChange"
disabled$="[[!editing]]"></paper-toggle-button>Exclusive
<template is=dom-if if="[[!_permissionIsOwner(permission.id)]]">
<paper-toggle-button
id="exclusiveToggle"
checked="{{permission.value.exclusive}}"
on-change="_handleValueChange"
disabled$="[[!editing]]"></paper-toggle-button>Exclusive
</template>
<gr-button
link
id="removeBtn"

View File

@@ -89,6 +89,10 @@
this._setupValues();
},
_permissionIsOwner(permissionId) {
return permissionId === 'owner';
},
_handleEditingChanged(editing, editingOld) {
// Ignore when editing gets set initially.
if (!editingOld) { return; }

View File

@@ -335,7 +335,7 @@ limitations under the License.
assert.isFalse(element._originalExclusiveValue);
assert.isNotOk(element.permission.value.modified);
MockInteractions.tap(element.$.exclusiveToggle);
MockInteractions.tap(element.$$('#exclusiveToggle'));
flushAsynchronousOperations();
assert.isTrue(element.permission.value.exclusive);
assert.isTrue(element.permission.value.modified);
@@ -353,6 +353,15 @@ limitations under the License.
assert.isTrue(element.permission.value.modified);
assert.isTrue(modifiedHandler.called);
});
test('Exclusive hidden for owner permission', () => {
assert.equal(getComputedStyle(element.$$('#exclusiveToggle')).display,
'flex');
element.set(['permission', 'id'], 'owner');
flushAsynchronousOperations();
assert.equal(getComputedStyle(element.$$('#exclusiveToggle')).display,
'none');
});
});
});
</script>