summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaladox none <thomasmulhall410@yahoo.com>2019-01-10 17:37:55 +0000
committerPaladox <thomasmulhall410@yahoo.com>2019-01-22 00:21:39 +0000
commit9631c9a9f36bc27b42dc40dcb3723833864e48b3 (patch)
tree960bdccbd3b28ed08c1034eb3bf280c8d3fc5f86
parent9ce4d2fffc525b3c8a0449583be77d74ddf2544f (diff)
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 cbb792c2cefdf68242f44403b0a08eb615165172)
-rw-r--r--polygerrit-ui/app/elements/admin/gr-project-detail-list/gr-project-detail-list.js14
-rw-r--r--polygerrit-ui/app/elements/admin/gr-project-detail-list/gr-project-detail-list_test.html6
2 files changed, 16 insertions, 4 deletions
diff --git a/polygerrit-ui/app/elements/admin/gr-project-detail-list/gr-project-detail-list.js b/polygerrit-ui/app/elements/admin/gr-project-detail-list/gr-project-detail-list.js
index eec277e58b..abcb593df2 100644
--- a/polygerrit-ui/app/elements/admin/gr-project-detail-list/gr-project-detail-list.js
+++ b/polygerrit-ui/app/elements/admin/gr-project-detail-list/gr-project-detail-list.js
@@ -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 '';
},
diff --git a/polygerrit-ui/app/elements/admin/gr-project-detail-list/gr-project-detail-list_test.html b/polygerrit-ui/app/elements/admin/gr-project-detail-list/gr-project-detail-list_test.html
index 62870dfad6..4663ce962d 100644
--- a/polygerrit-ui/app/elements/admin/gr-project-detail-list/gr-project-detail-list_test.html
+++ b/polygerrit-ui/app/elements/admin/gr-project-detail-list/gr-project-detail-list_test.html
@@ -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>