Merge "Fix support for deleting branches (if you have can_delete)"

This commit is contained in:
Ben Rohlfs
2019-01-18 20:37:00 +00:00
committed by Gerrit Code Review
2 changed files with 16 additions and 4 deletions

View File

@@ -62,7 +62,7 @@
/**
* Because we request one more than the projectsPerPage, _shownProjects
* maybe one less than _projects.
* */
*/
_shownItems: {
type: Array,
computed: 'computeShownItems(_items)',
@@ -90,7 +90,7 @@
_determineIfOwner(repo) {
return this.$.restAPI.getRepoAccess(repo)
.then(access =>
this._isOwner = access && access[repo].is_owner);
this._isOwner = access && !!access[repo].is_owner);
},
_paramsChanged(params) {
@@ -194,6 +194,11 @@
if (res.status < 400) {
this._isEditing = false;
e.model.set('item.revision', ref);
// This is needed to refresh _items property with fresh data,
// specifically can_delete from the json response.
this._getItems(
this._filter, this._repo, this._itemsPerPage,
this._offset, this.detailType);
}
});
},
@@ -240,10 +245,11 @@
this.$.overlay.open();
},
_computeHideDeleteClass(owner, deleteRef) {
if (owner && !deleteRef || owner && deleteRef || deleteRef || owner) {
_computeHideDeleteClass(owner, canDelete) {
if (canDelete || owner) {
return 'show';
}
return '';
},

View File

@@ -549,5 +549,11 @@ limitations under the License.
element._paramsChanged(params);
});
});
test('test _computeHideDeleteClass', () => {
assert.deepEqual(element._computeHideDeleteClass(true, false), 'show');
assert.deepEqual(element._computeHideDeleteClass(false, true), 'show');
assert.deepEqual(element._computeHideDeleteClass(false, false), '');
});
});
</script>