Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit 18514d5

Browse files
committed
Calculate draft index to set for pending status
1 parent a3b2929 commit 18514d5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

js/customize-snapshots.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* global wp, $ */
22
/* eslint consistent-this: [ "error", "snapshot", "control" ] */
3+
/* eslint no-magic-numbers: ["error", { "ignore": [0, 1] }] */
34

45
(function( api ) {
56
'use strict';
@@ -218,15 +219,22 @@
218219
* @return {void}
219220
*/
220221
addPendingToStatusControl: function() {
221-
var snapshot = this, params, coreStatusControl, index = 2;
222+
var snapshot = this, params, coreStatusControl, draftIndex = 0;
222223

223224
coreStatusControl = api.control( 'changeset_status' );
224225

225226
coreStatusControl.deferred.embedded.done( function() {
226227
params = _.extend( {}, coreStatusControl.params );
227228
coreStatusControl.container.remove();
228229
api.control.remove( 'changeset_status' );
229-
params.choices.splice( index, 0, {
230+
231+
_.each( params.choices, function( statusConfig, index ) {
232+
if ( 'draft' === statusConfig.status ) {
233+
draftIndex = index;
234+
}
235+
} );
236+
237+
params.choices.splice( draftIndex + 1, 0, {
230238
label: snapshot.data.i18n.savePending,
231239
status: 'pending'
232240
} );

0 commit comments

Comments
 (0)