Support for setting max/min value for "Query Limit" and "Batch Changes"

This support was missed when adding gr-repo-access.

Bug: Issue 10309
Change-Id: Ib04f070b61d833de8bf0df187060f72058ea292e
This commit is contained in:
Paladox none 2019-02-02 00:01:28 +00:00
parent 4ab0c351a2
commit c77983dc3c
5 changed files with 42 additions and 1 deletions

View File

@ -109,6 +109,7 @@ limitations under the License.
items="{{_rules}}"
as="rule">
<gr-rule-editor
has-range="[[_computeHasRange(name)]]"
label="[[_label]]"
editing="[[editing]]"
group-id="[[rule.id]]"

View File

@ -19,6 +19,11 @@
const MAX_AUTOCOMPLETE_RESULTS = 20;
const RANGE_NAMES = [
'QUERY LIMIT',
'BATCH CHANGES LIMIT',
];
/**
* Fired when the permission has been modified or removed.
*
@ -269,5 +274,11 @@
this.set(['permission', 'value', 'rules', groupId], value);
this.dispatchEvent(new CustomEvent('access-modified', {bubbles: true}));
},
_computeHasRange(name) {
if (!name) { return false; }
return RANGE_NAMES.includes(name.toUpperCase());
},
});
})();

View File

@ -255,6 +255,14 @@ limitations under the License.
assert.isFalse(element._deleted);
assert.isNotOk(element.permission.value.deleted);
});
test('_computeHasRange', () => {
assert.isTrue(element._computeHasRange('Query Limit'));
assert.isTrue(element._computeHasRange('Batch Changes Limit'));
assert.isFalse(element._computeHasRange('test'));
});
});
suite('interactions', () => {

View File

@ -71,7 +71,11 @@ limitations under the License.
color: var(--deemphasized-text-color);
}
</style>
<style include="gr-form-styles"></style>
<style include="gr-form-styles">
iron-autogrow-textarea {
width: 14em;
}
</style>
<div id="mainContainer"
class$="gr-form-styles [[_computeSectionClass(editing, _deleted)]]">
<div id="options">
@ -106,6 +110,22 @@ limitations under the License.
</select>
</gr-select>
</template>
<template is="dom-if" if="[[hasRange]]">
<iron-autogrow-textarea
id="minInput"
class="min"
autocomplete="on"
placeholder="Min value"
bind-value="{{rule.value.min}}"
disabled$="[[!editing]]"></iron-autogrow-textarea>
<iron-autogrow-textarea
id="maxInput"
class="max"
autocomplete="on"
placeholder="Max value"
bind-value="{{rule.value.max}}"
disabled$="[[!editing]]"></iron-autogrow-textarea>
</template>
<a class="groupPath" href$="[[_computeGroupPath(groupId)]]">
[[groupName]]
</a>

View File

@ -67,6 +67,7 @@
is: 'gr-rule-editor',
properties: {
hasRange: Boolean,
/** @type {?} */
label: Object,
editing: {