Merge "Show 'Loading actions' in actions bar when loading actions"
This commit is contained in:
commit
222a53c51c
@ -63,7 +63,7 @@ limitations under the License.
|
||||
}
|
||||
</style>
|
||||
<div>
|
||||
<section hidden$="[[!_actionCount(actions.*, _additionalActions.*)]]">
|
||||
<section hidden$="[[_shouldHideActions(actions.*, _additionalActions.*, _loading)]]">
|
||||
<template is="dom-repeat" items="[[_changeActionValues]]" as="action">
|
||||
<gr-button title$="[[action.title]]"
|
||||
hidden$="[[_computeActionHidden(action.__key, _hiddenChangeActions.*)]]"
|
||||
@ -76,7 +76,7 @@ limitations under the License.
|
||||
on-tap="_handleActionTap"></gr-button>
|
||||
</template>
|
||||
</section>
|
||||
<section hidden$="[[!_actionCount(revisionActions.*, _additionalActions.*)]]">
|
||||
<section hidden$="[[_shouldHideActions(revisionActions.*, _additionalActions.*, _loading)]]">
|
||||
<template is="dom-repeat" items="[[_revisionActionValues]]" as="action">
|
||||
<gr-button title$="[[action.title]]"
|
||||
hidden$="[[_computeActionHidden(action.__key, _hiddenRevisionActions.*)]]"
|
||||
@ -89,6 +89,7 @@ limitations under the License.
|
||||
on-tap="_handleActionTap"></gr-button>
|
||||
</template>
|
||||
</section>
|
||||
<gr-button hidden$="[[!_loading]]" disabled>Loading actions...</gr-button>
|
||||
</div>
|
||||
<gr-overlay id="overlay" with-backdrop>
|
||||
<gr-confirm-rebase-dialog id="confirmRebase"
|
||||
|
@ -167,6 +167,7 @@
|
||||
|
||||
ready: function() {
|
||||
this.$.jsAPI.addElement(this.$.jsAPI.Element.CHANGE_ACTIONS, this);
|
||||
this._loading = false;
|
||||
},
|
||||
|
||||
reload: function() {
|
||||
@ -250,10 +251,16 @@
|
||||
this.patchNum);
|
||||
},
|
||||
|
||||
_actionCount: function(actionsChangeRecord, additionalActionsChangeRecord) {
|
||||
var additionalActions = (additionalActionsChangeRecord &&
|
||||
additionalActionsChangeRecord.base) || [];
|
||||
return this._keyCount(actionsChangeRecord) + additionalActions.length;
|
||||
_shouldHideActions: function(actionsRecord, additionalActionsRecord,
|
||||
loading) {
|
||||
if (loading) { return true; }
|
||||
return !this._actionCount(actionsRecord, additionalActionsRecord);
|
||||
},
|
||||
|
||||
_actionCount: function(actionsRecord, additionalActionsRecord) {
|
||||
var additionalActions = (additionalActionsRecord &&
|
||||
additionalActionsRecord.base) || [];
|
||||
return this._keyCount(actionsRecord) + additionalActions.length;
|
||||
},
|
||||
|
||||
_keyCount: function(changeRecord) {
|
||||
@ -284,8 +291,8 @@
|
||||
_computeChangeActionValues: function(actionsChangeRecord,
|
||||
primariesChangeRecord, additionalActionsChangeRecord, change) {
|
||||
var actions = this._getActionValues(
|
||||
actionsChangeRecord, primariesChangeRecord,
|
||||
additionalActionsChangeRecord, ActionType.CHANGE, change);
|
||||
actionsChangeRecord, primariesChangeRecord,
|
||||
additionalActionsChangeRecord, ActionType.CHANGE, change);
|
||||
var quickApprove = this._getQuickApproveAction();
|
||||
if (quickApprove) {
|
||||
actions.unshift(quickApprove);
|
||||
@ -470,7 +477,7 @@
|
||||
return o.key === key;
|
||||
});
|
||||
this._fireAction(
|
||||
this._prependSlash(key), action, true, action.payload);
|
||||
this._prependSlash(key), action, true, action.payload);
|
||||
} else {
|
||||
this._fireAction(this._prependSlash(key), this.actions[key], false);
|
||||
}
|
||||
|
@ -92,12 +92,20 @@ limitations under the License.
|
||||
method: 'DELETE',
|
||||
label: 'Delete',
|
||||
title: 'Delete draft change 42',
|
||||
enabled: true
|
||||
enabled: true,
|
||||
},
|
||||
};
|
||||
return element.reload();
|
||||
});
|
||||
|
||||
test('_shouldHideActions', function() {
|
||||
assert.isTrue(element._shouldHideActions(undefined, undefined, true));
|
||||
assert.isTrue(element._shouldHideActions({base: {}},
|
||||
{base: []}, false));
|
||||
assert.isFalse(element._shouldHideActions({base: { test: 'test' }},
|
||||
{base: ['test']}, false));
|
||||
});
|
||||
|
||||
test('hide revision action', function(done) {
|
||||
flush(function() {
|
||||
var buttonEl = element.$$('[data-action-key="submit"]');
|
||||
@ -156,10 +164,12 @@ limitations under the License.
|
||||
});
|
||||
});
|
||||
|
||||
test('buttons show', function(done) {
|
||||
test('buttons exist', function(done) {
|
||||
element._loading = false;
|
||||
flush(function() {
|
||||
var buttonEls = Polymer.dom(element.root).querySelectorAll('gr-button');
|
||||
assert.equal(buttonEls.length, 5);
|
||||
var buttonEls = Polymer.dom(element.root)
|
||||
.querySelectorAll('gr-button');
|
||||
assert.equal(buttonEls.length, 6);
|
||||
assert.isFalse(element.hidden);
|
||||
done();
|
||||
});
|
||||
@ -335,7 +345,7 @@ limitations under the License.
|
||||
'/cherrypick', action, true, {
|
||||
destination: 'master',
|
||||
message: 'foo message',
|
||||
}
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
@ -379,8 +389,8 @@ limitations under the License.
|
||||
method: 'POST',
|
||||
label: 'Revert',
|
||||
title: 'Revert the change',
|
||||
enabled: true
|
||||
}
|
||||
enabled: true,
|
||||
},
|
||||
};
|
||||
return element.reload();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user