Просмотр исходного кода

Add _is_deleted status message to Controller and prompt for button click after paste delete

parthiv-m 1 год назад
Родитель
Сommit
f2b60d3765
4 измененных файлов с 26 добавлено и 8 удалено
  1. 3 3
      js/privatebin.js
  2. 10 0
      lib/Controller.php
  3. 5 2
      tpl/bootstrap.php
  4. 8 3
      tpl/bootstrap5.php

+ 3 - 3
js/privatebin.js

@@ -5626,11 +5626,11 @@ jQuery.PrivateBin = (function($, RawDeflate) {
             me.initZ();
 
             // if delete token is passed (i.e. paste has been deleted by this
-            // access), redirect to baseurl after 5 seconds
+            // access), add an event listener for the 'new' paste button in the alert
             if (Model.hasDeleteToken()) {
-                setTimeout(() => {
+                $("#new-from-alert").on("click", function () {
                     UiHelper.reloadHome();
-                }, 5000);
+                });
                 return;
             }
 

+ 10 - 0
lib/Controller.php

@@ -67,6 +67,14 @@ class Controller
      */
     private $_status = '';
 
+    /**
+     * status message
+     *
+     * @access private
+     * @var    boolean
+     */
+    private $_is_deleted = false;
+
     /**
      * JSON message
      *
@@ -309,6 +317,7 @@ class Controller
                     // Paste exists and deletion token is valid: Delete the paste.
                     $paste->delete();
                     $this->_status = 'Paste was properly deleted.';
+                    $this->_is_deleted = true;
                 } else {
                     $this->_error = 'Wrong deletion token. Paste was not deleted.';
                 }
@@ -412,6 +421,7 @@ class Controller
         }
         $page->assign('BASEPATH', I18n::_($this->_conf->getKey('basepath')));
         $page->assign('STATUS', I18n::_($this->_status));
+        $page->assign('ISDELETED', I18n::_(json_encode($this->_is_deleted)));
         $page->assign('VERSION', self::VERSION);
         $page->assign('DISCUSSION', $this->_conf->getKey('discussion'));
         $page->assign('OPENDISCUSSION', $this->_conf->getKey('opendiscussion'));

+ 5 - 2
tpl/bootstrap.php

@@ -489,10 +489,13 @@ if ($FILEUPLOAD) :
 				</div>
 <?php
 endif;
-?>
-				<div id="status" role="alert" class="alert alert-<?php echo $STATUS === 'Paste was properly deleted.' ? 'success' : 'info' ?><?php echo empty($STATUS) ? ' hidden' : '' ?>">
+?>					
+				<div id="status" role="alert" class="clearfix alert alert-<?php echo (bool)$ISDELETED ? 'success' : 'info'; echo empty($STATUS) ? ' hidden' : '' ?>">
 					<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
 					<?php echo I18n::encode($STATUS), PHP_EOL; ?>
+					<button type="button" class="btn btn-default pull-right" id="new-from-alert">
+						<span class="glyphicon glyphicon-file"></span> <?php echo I18n::_('New'), PHP_EOL; ?>
+					</button>
 				</div>
 				<div id="errormessage" role="alert" class="<?php echo empty($ERROR) ? 'hidden' : '' ?> alert alert-danger">
 					<span class="glyphicon glyphicon-alert" aria-hidden="true"></span>

+ 8 - 3
tpl/bootstrap5.php

@@ -353,9 +353,14 @@ if ($FILEUPLOAD) :
 <?php
 endif;
 ?>
-				<div id="status" role="alert" class="alert alert-<?php $STATUS == 'Paste was properly deleted.' ? 'success' : 'info' ?><?php echo empty($STATUS) ? ' hidden' : '' ?>">
-					<svg width="16" height="16" fill="currentColor" aria-hidden="true"><use href="img/bootstrap-icons.svg#info-circle" /></svg>
-					<?php echo I18n::encode($STATUS), PHP_EOL; ?>
+				<div id="status" role="alert" class="d-flex justify-content-between align-items-center alert alert-<?php echo (bool)$ISDELETED ? 'success' : 'info'; echo empty($STATUS) ? ' hidden' : '' ?>">
+					<div>
+						<svg width="16" height="16" fill="currentColor" aria-hidden="true"><use href="img/bootstrap-icons.svg#info-circle" /></svg>
+						<?php echo I18n::encode($STATUS), PHP_EOL; ?>
+					</div>
+					<button type="button" class="btn btn-secondary" id="new-from-alert">
+						<svg width="16" height="16" fill="currentColor" aria-hidden="true"><use href="img/bootstrap-icons.svg#file-earmark" /></svg> <?php echo I18n::_('New'), PHP_EOL; ?>
+					</button>
 				</div>
 				<div id="errormessage" role="alert" class="<?php echo empty($ERROR) ? 'hidden' : '' ?> alert alert-danger">
 					<svg width="16" height="16" fill="currentColor" aria-hidden="true"><use href="img/bootstrap-icons.svg#exclamation-triangle" /></svg>