Fix support for deleting branches (if you have can_delete)
* This fixes _determineIfOwner so that the check inside it "access && !!access[repo].is_owner"
forces a boolean value.
* This fixes a issue where you change the head to point to a different branch,
but it did not correctly update the delete branch button, without needing
to refresh the page.
Bug: Issue 10151
Bug: Issue 10019
Change-Id: I8a500a02865d88986b710e552b0c6d81576e301f
(cherry picked from commit cbb792c2ce
)
This commit is contained in:
parent
9ce4d2fffc
commit
9631c9a9f3
@ -57,7 +57,7 @@
|
||||
/**
|
||||
* Because we request one more than the projectsPerPage, _shownProjects
|
||||
* maybe one less than _projects.
|
||||
* */
|
||||
*/
|
||||
_shownItems: {
|
||||
type: Array,
|
||||
computed: 'computeShownItems(_items)',
|
||||
@ -85,7 +85,7 @@
|
||||
_determineIfOwner(project) {
|
||||
return this.$.restAPI.getProjectAccess(project)
|
||||
.then(access =>
|
||||
this._isOwner = access && access[project].is_owner);
|
||||
this._isOwner = access && !!access[project].is_owner);
|
||||
},
|
||||
|
||||
_paramsChanged(params) {
|
||||
@ -180,6 +180,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._project, this._itemsPerPage,
|
||||
this._offset, this.detailType);
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -228,10 +233,11 @@
|
||||
this.$.overlay.open();
|
||||
},
|
||||
|
||||
_computeHideDeleteClass(owner, deleteRef) {
|
||||
if (owner && !deleteRef || owner && deleteRef || deleteRef || owner) {
|
||||
_computeHideDeleteClass(owner, canDelete) {
|
||||
if (canDelete || owner) {
|
||||
return 'show';
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
|
||||
|
@ -435,5 +435,11 @@ limitations under the License.
|
||||
assert.isTrue(element._handleCloseCreate.called);
|
||||
});
|
||||
});
|
||||
|
||||
test('test _computeHideDeleteClass', () => {
|
||||
assert.deepEqual(element._computeHideDeleteClass(true, false), 'show');
|
||||
assert.deepEqual(element._computeHideDeleteClass(false, true), 'show');
|
||||
assert.deepEqual(element._computeHideDeleteClass(false, false), '');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user