From 950ce392e97f88dda1871f90e5ac48a1696bd022 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 28 Jun 2022 02:26:51 -0400 Subject: [PATCH] live-branches: Allow for not installing Jetpack (#24843) Jurassic Ninja installs the release version of the Jetpack plugin by default, unless a `nojetpack` option is supplied. Let's add a UI for that to simplify testing of the standalone plugins without Jetpack itself installed. To keep the UI simple, we add "Jetpack" in the existing "Plugins" list, pre-checked to preserve the current behavior as the default. In the JS we invert the sense of this checkbox so `nojetpack` is added to the URL when the checkbox is unchecked. --- .../jetpack-live-branches.user.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/jetpack-live-branches/jetpack-live-branches.user.js b/tools/jetpack-live-branches/jetpack-live-branches.user.js index c607839735287..76b1289b96f95 100644 --- a/tools/jetpack-live-branches/jetpack-live-branches.user.js +++ b/tools/jetpack-live-branches/jetpack-live-branches.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Jetpack Live Branches // @namespace https://wordpress.com/ -// @version 1.21 +// @version 1.22 // @description Adds links to PRs pointing to Jurassic Ninja sites for live-testing a changeset // @grant GM_xmlhttpRequest // @connect jurassic.ninja @@ -136,6 +136,12 @@

Plugins

${ getOptionsList( [ + { + label: 'Jetpack', + name: 'nojetpack', + checked: true, + invert: true, + }, { label: 'WordPress Beta Tester', name: 'wordpress-beta-tester', @@ -277,7 +283,9 @@ */ function getLink() { const query = [ 'jetpack-beta' ]; - $( '#jetpack-live-branches input[type=checkbox]:checked' ).each( ( i, input ) => { + $( + '#jetpack-live-branches input[type=checkbox]:checked:not([data-invert]), #jetpack-live-branches input[type=checkbox][data-invert]:not(:checked)' + ).each( ( i, input ) => { if ( input.value ) { query.push( encodeURIComponent( input.name ) + '=' + encodeURIComponent( input.value ) ); } else { @@ -297,18 +305,19 @@ * @param {string} [opts.value] - Checkbox value, if any. * @param {boolean} [opts.checked] - Whether the checkbox is default checked. * @param {boolean} [opts.disabled] - Whether the checkbox is disabled. + * @param {boolean} [opts.invert] - Whether the sense of the checkbox is inverted. * @param {number} columnWidth - Column width. * @returns {string} HTML. */ function getOption( - { disabled = false, checked = false, value = '', label, name }, + { disabled = false, checked = false, invert = false, value = '', label, name }, columnWidth ) { // prettier-ignore return `