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

This commit is contained in:
parthiv-m 2024-10-13 17:45:05 -04:00
parent d69d29f3a9
commit f2b60d3765
4 changed files with 26 additions and 8 deletions

View file

@ -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;
}

View file

@ -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'));

View file

@ -490,9 +490,12 @@ if ($FILEUPLOAD) :
<?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>

View file

@ -353,10 +353,15 @@ 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' : '' ?>">
<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>
<?php echo I18n::encode($ERROR), PHP_EOL; ?>