Added a button to download SSR to a file. (#38110)
This commit is contained in:
parent
865fcd053c
commit
81b899b55e
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: enhancement
|
||||
|
||||
Added a button to download SSR to a file.
|
|
@ -14,7 +14,8 @@ jQuery( function ( $ ) {
|
|||
.on( 'click', 'a.debug-report', this.generateReport )
|
||||
.on( 'click', '#copy-for-support', this.copyReport )
|
||||
.on( 'aftercopy', '#copy-for-support', this.copySuccess )
|
||||
.on( 'aftercopyfailure', '#copy-for-support', this.copyFail );
|
||||
.on( 'aftercopyfailure', '#copy-for-support', this.copyFail )
|
||||
.on( 'click', '#download-for-support', this.downloadReport );
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -112,6 +113,21 @@ jQuery( function ( $ ) {
|
|||
copyFail: function() {
|
||||
$( '.copy-error' ).removeClass( 'hidden' );
|
||||
$( '#debug-report' ).find( 'textarea' ).trigger( 'focus' ).trigger( 'select' );
|
||||
},
|
||||
|
||||
downloadReport: function() {
|
||||
var ssr_text = new Blob( [ $( '#debug-report' ).find( 'textarea' ).val() ], { type: 'text/plain' } );
|
||||
|
||||
var domain = window.location.hostname;
|
||||
var datetime = new Date().toISOString().slice( 0, 19 ).replace( /:/g, '-' );
|
||||
|
||||
var a = document.createElement( 'a' );
|
||||
a.download = 'SystemStatusReport_' + domain + '_' + datetime + '.txt';
|
||||
a.href = window.URL.createObjectURL( ssr_text );
|
||||
a.textContent = 'Download ready';
|
||||
a.style='display:none';
|
||||
a.click();
|
||||
a.remove();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -38,7 +38,10 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, Cons
|
|||
<div id="debug-report">
|
||||
<textarea readonly="readonly"></textarea>
|
||||
<p class="submit">
|
||||
<button id="copy-for-support" class="button-primary" href="#" data-tip="<?php esc_attr_e( 'Copied!', 'woocommerce' ); ?>">
|
||||
<button id="download-for-support" class="button-primary" href="#">
|
||||
<?php esc_html_e( 'Download for support', 'woocommerce' ); ?>
|
||||
</button>
|
||||
<button id="copy-for-support" class="button" href="#" data-tip="<?php esc_attr_e( 'Copied!', 'woocommerce' ); ?>">
|
||||
<?php esc_html_e( 'Copy for support', 'woocommerce' ); ?>
|
||||
</button>
|
||||
</p>
|
||||
|
|
Loading…
Reference in New Issue