Trevor Parscal has uploaded a new change for review.
https://gerrit.wikimedia.org/r/193500
Change subject: Infer rety button action flags from symbolc name
......................................................................
Infer rety button action flags from symbolc name
Rather than storing an action object in this.currentAction, store the symbolic
action name, allowing executeAction to work even if triggered programatically
rather than only when an actual button was clicked and its reference stashed in
this.currentAction.
If an error occurs, instead of assuming currentAction is a button, we lookup
buttons with the same action and copy flags form the first match to the rety
button.
Change-Id: I9d0c6c12c190431f3b0e3c874ce1909fd9c69900
---
M src/Dialog.js
M src/dialogs/ProcessDialog.js
2 files changed, 12 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/00/193500/1
diff --git a/src/Dialog.js b/src/Dialog.js
index dd60ac9..ddf63b9 100644
--- a/src/Dialog.js
+++ b/src/Dialog.js
@@ -143,7 +143,6 @@
*/
OO.ui.Dialog.prototype.onActionClick = function ( action ) {
if ( !this.isPending() ) {
- this.currentAction = action;
this.executeAction( action.getAction() );
}
};
@@ -285,6 +284,7 @@
*/
OO.ui.Dialog.prototype.executeAction = function ( action ) {
this.pushPending();
+ this.currentAction = action;
return this.getActionProcess( action ).execute()
.always( this.popPending.bind( this ) );
};
diff --git a/src/dialogs/ProcessDialog.js b/src/dialogs/ProcessDialog.js
index ee22c7a..28726f1 100644
--- a/src/dialogs/ProcessDialog.js
+++ b/src/dialogs/ProcessDialog.js
@@ -54,7 +54,7 @@
*/
OO.ui.ProcessDialog.prototype.onRetryButtonClick = function () {
this.hideErrors();
- this.executeAction( this.currentAction.getAction() );
+ this.executeAction( this.currentAction );
};
/**
@@ -173,8 +173,9 @@
* @param {OO.ui.Error[]} errors Errors to be handled
*/
OO.ui.ProcessDialog.prototype.showErrors = function ( errors ) {
- var i, len, $item,
+ var i, len, $item, actions,
items = [],
+ abilities = {},
recoverable = true,
warning = false;
@@ -192,9 +193,15 @@
}
this.$errorItems = $( items );
if ( recoverable ) {
- this.retryButton.clearFlags().setFlags(
this.currentAction.getFlags() );
+ abilities[this.currentAction] = true;
+ // Copy the flags from the first matching action
+ actions = this.actions.get( { actions: this.currentAction } );
+ if ( actions.length ) {
+ this.retryButton.clearFlags().setFlags(
actions[0].getFlags() );
+ }
} else {
- this.currentAction.setDisabled( true );
+ abilities[this.currentAction] = false;
+ this.actions.setAbilities( abilities );
}
if ( warning ) {
this.retryButton.setLabel( OO.ui.msg(
'ooui-dialog-process-continue' ) );
--
To view, visit https://gerrit.wikimedia.org/r/193500
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d0c6c12c190431f3b0e3c874ce1909fd9c69900
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Trevor Parscal <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits