Merge "Add a Process to the save workflow"

This commit is contained in:
jenkins-bot 2023-08-16 15:32:54 +00:00 committed by Gerrit Code Review
commit 79d0fcb585

View file

@ -1975,73 +1975,80 @@ ve.init.mw.ArticleTarget.prototype.showSaveDialog = function ( action, checkboxN
this.saveDialogIsOpening = true; this.saveDialogIsOpening = true;
this.emit( 'saveWorkflowBegin' ); var saveProcess = new OO.ui.Process();
mw.hook( 've.preSaveProcess' ).fire( saveProcess, target );
// Preload the serialization saveProcess.execute().done( function () {
this.prepareCacheKey( this.getDocToSave() ); target.emit( 'saveWorkflowBegin' );
// Get the save dialog // Preload the serialization
this.getSurface().getDialogs().getWindow( 'mwSave' ).done( function ( win ) { target.prepareCacheKey( target.getDocToSave() );
var windowAction = ve.ui.actionFactory.create( 'window', target.getSurface() );
if ( !target.saveDialog ) { // Get the save dialog
target.saveDialog = win; target.getSurface().getDialogs().getWindow( 'mwSave' ).done( function ( win ) {
firstLoad = true; var windowAction = ve.ui.actionFactory.create( 'window', target.getSurface() );
// Connect to save dialog if ( !target.saveDialog ) {
target.saveDialog.connect( target, { target.saveDialog = win;
save: 'onSaveDialogSave', firstLoad = true;
review: 'onSaveDialogReview',
preview: 'onSaveDialogPreview',
resolve: 'onSaveDialogResolveConflict',
retry: 'onSaveDialogRetry',
// The array syntax is a way to call `this.emit( 'saveWorkflowEnd' )`.
close: [ 'emit', 'saveWorkflowEnd' ]
} );
// Attach custom overlay // Connect to save dialog
target.saveDialog.$element.append( target.$saveDialogOverlay ); target.saveDialog.connect( target, {
} save: 'onSaveDialogSave',
review: 'onSaveDialogReview',
preview: 'onSaveDialogPreview',
resolve: 'onSaveDialogResolveConflict',
retry: 'onSaveDialogRetry',
// The array syntax is a way to call `this.emit( 'saveWorkflowEnd' )`.
close: [ 'emit', 'saveWorkflowEnd' ]
} );
var data = target.getSaveDialogOpeningData(); // Attach custom overlay
target.saveDialog.$element.append( target.$saveDialogOverlay );
}
if ( var data = target.getSaveDialogOpeningData();
( action === 'review' && !data.canReview ) ||
( action === 'preview' && !data.canPreview )
) {
target.saveDialogIsOpening = false;
return;
}
if ( firstLoad ) { if (
for ( var name in target.checkboxesByName ) { ( action === 'review' && !data.canReview ) ||
if ( target.initialCheckboxes[ name ] !== undefined ) { ( action === 'preview' && !data.canPreview )
target.checkboxesByName[ name ].setSelected( target.initialCheckboxes[ name ] ); ) {
target.saveDialogIsOpening = false;
return;
}
if ( firstLoad ) {
for ( var name in target.checkboxesByName ) {
if ( target.initialCheckboxes[ name ] !== undefined ) {
target.checkboxesByName[ name ].setSelected( target.initialCheckboxes[ name ] );
}
} }
} }
}
var checkbox; var checkbox;
if ( checkboxName && ( checkbox = target.checkboxesByName[ checkboxName ] ) ) { if ( checkboxName && ( checkbox = target.checkboxesByName[ checkboxName ] ) ) {
var isSelected = !checkbox.isSelected(); var isSelected = !checkbox.isSelected();
// Wait for native access key change to happen // Wait for native access key change to happen
setTimeout( function () { setTimeout( function () {
checkbox.setSelected( isSelected ); checkbox.setSelected( isSelected );
} ); } );
} }
// When calling review/preview action, switch to those panels immediately // When calling review/preview action, switch to those panels immediately
if ( action === 'review' || action === 'preview' ) { if ( action === 'review' || action === 'preview' ) {
data.initialPanel = action; data.initialPanel = action;
} }
// Open the dialog // Open the dialog
var openPromise = windowAction.open( 'mwSave', data, action ); var openPromise = windowAction.open( 'mwSave', data, action );
if ( openPromise ) { if ( openPromise ) {
openPromise.always( function () { openPromise.always( function () {
target.saveDialogIsOpening = false; target.saveDialogIsOpening = false;
} ); } );
} }
} );
} ).fail( function () {
target.saveDialogIsOpening = false;
} ); } );
}; };