1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-30 10:36:35 +02:00

Server: Remove dangerous "Delete all" button for now

This commit is contained in:
Laurent Cozic 2021-07-03 16:30:40 +01:00
parent 3d18514c3c
commit 125af75b93
2 changed files with 1 additions and 31 deletions

View File

@ -1,8 +1,7 @@
import { SubPath, redirect, respondWithItemContent } from '../../utils/routeUtils';
import { SubPath, respondWithItemContent } from '../../utils/routeUtils';
import Router from '../../utils/Router';
import { RouteType } from '../../utils/types';
import { AppContext } from '../../utils/types';
import { formParse } from '../../utils/requestUtils';
import { ErrorNotFound } from '../../utils/errors';
import config, { showItemUrls } from '../../config';
import { formatDateTime } from '../../utils/time';
@ -78,18 +77,4 @@ router.get('items/:id/content', async (path: SubPath, ctx: AppContext) => {
return respondWithItemContent(ctx.response, item, item.content);
}, RouteType.UserContent);
router.post('items', async (_path: SubPath, ctx: AppContext) => {
const body = await formParse(ctx.req);
const fields = body.fields;
if (fields.delete_all_button) {
const itemModel = ctx.joplin.models.item();
await itemModel.deleteAll(ctx.joplin.owner.id);
} else {
throw new Error('Invalid form button');
}
return redirect(ctx, await ctx.joplin.models.item().itemUrl());
});
export default router;

View File

@ -1,18 +1,3 @@
{{#itemTable}}
{{>table}}
{{/itemTable}}
<form id="item_form" action="{{{postUrl}}}" method="POST" class="block">
<input type="submit" name="delete_all_button" class="button is-danger" value="Delete all" />
</form>
<script>
onDocumentReady(function() {
document.getElementById("item_form").addEventListener('submit', function(event) {
if (event.submitter.getAttribute('name') === 'delete_all_button') {
const response = prompt('This will DELETE all your notes, and it cannot be undone. If you wish to continue, please type "confirm".');
if (response !== 'confirm') event.preventDefault();
}
});
});
</script>