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
 | 
			
		||||
       * 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 '';
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user