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
This commit is contained in:
@@ -62,7 +62,7 @@
|
|||||||
/**
|
/**
|
||||||
* Because we request one more than the projectsPerPage, _shownProjects
|
* Because we request one more than the projectsPerPage, _shownProjects
|
||||||
* maybe one less than _projects.
|
* maybe one less than _projects.
|
||||||
* */
|
*/
|
||||||
_shownItems: {
|
_shownItems: {
|
||||||
type: Array,
|
type: Array,
|
||||||
computed: 'computeShownItems(_items)',
|
computed: 'computeShownItems(_items)',
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
_determineIfOwner(repo) {
|
_determineIfOwner(repo) {
|
||||||
return this.$.restAPI.getRepoAccess(repo)
|
return this.$.restAPI.getRepoAccess(repo)
|
||||||
.then(access =>
|
.then(access =>
|
||||||
this._isOwner = access && access[repo].is_owner);
|
this._isOwner = access && !!access[repo].is_owner);
|
||||||
},
|
},
|
||||||
|
|
||||||
_paramsChanged(params) {
|
_paramsChanged(params) {
|
||||||
@@ -194,6 +194,11 @@
|
|||||||
if (res.status < 400) {
|
if (res.status < 400) {
|
||||||
this._isEditing = false;
|
this._isEditing = false;
|
||||||
e.model.set('item.revision', ref);
|
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();
|
this.$.overlay.open();
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeHideDeleteClass(owner, deleteRef) {
|
_computeHideDeleteClass(owner, canDelete) {
|
||||||
if (owner && !deleteRef || owner && deleteRef || deleteRef || owner) {
|
if (canDelete || owner) {
|
||||||
return 'show';
|
return 'show';
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -549,5 +549,11 @@ limitations under the License.
|
|||||||
element._paramsChanged(params);
|
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>
|
</script>
|
||||||
|
Reference in New Issue
Block a user