From 05cc7ccb6041017e3a629651167e09245eebd0c1 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 7 Jun 2021 14:44:12 -0400 Subject: [PATCH] feat: make undoTimeout configurable, closes #9599 --- install/data/defaults.json | 1 + .../en-GB/admin/settings/general.json | 5 ++- public/src/client/topic/move.js | 32 +++++++++++-------- src/controllers/api.js | 1 + src/views/admin/settings/general.tpl | 12 +++++++ 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/install/data/defaults.json b/install/data/defaults.json index 47765eb796..2ea9833d79 100644 --- a/install/data/defaults.json +++ b/install/data/defaults.json @@ -30,6 +30,7 @@ "maximumTagsPerTopic": 5, "minimumTagLength": 3, "maximumTagLength": 15, + "undoTimeout": 10000, "allowTopicsThumbnail": 1, "registrationType": "normal", "registrationApprovalType": "normal", diff --git a/public/language/en-GB/admin/settings/general.json b/public/language/en-GB/admin/settings/general.json index af76ee19b7..147384d94b 100644 --- a/public/language/en-GB/admin/settings/general.json +++ b/public/language/en-GB/admin/settings/general.json @@ -40,5 +40,8 @@ "site-colors": "Site Color Metadata", "theme-color": "Theme Color", "background-color": "Background Color", - "background-color-help": "Color used for splash screen background when website is installed as a PWA" + "background-color-help": "Color used for splash screen background when website is installed as a PWA", + "undo-timeout": "Undo Timeout", + "undo-timeout-help": "Some operations such as moving topics will allow for the moderator to undo their action within a certain timeframe. Set to 0 to disable undo completely.", + "topic-tools": "Topic Tools" } \ No newline at end of file diff --git a/public/src/client/topic/move.js b/public/src/client/topic/move.js index c7d8c22fb0..624c7aeb28 100644 --- a/public/src/client/topic/move.js +++ b/public/src/client/topic/move.js @@ -63,20 +63,24 @@ define('forum/topic/move', ['categorySelector', 'alerts'], function (categorySel currentCid: Move.currentCid, onComplete: Move.onComplete, }; - alerts.alert({ - alert_id: 'tids_move_' + (Move.tids ? Move.tids.join('-') : 'all'), - title: '[[topic:thread_tools.move]]', - message: message, - type: 'success', - timeout: 10000, - timeoutfn: function () { - moveTopics(data); - }, - clickfn: function (alert, params) { - delete params.timeoutfn; - app.alertSuccess('[[topic:topic_move_undone]]'); - }, - }); + if (config.undoTimeout > 0) { + return alerts.alert({ + alert_id: 'tids_move_' + (Move.tids ? Move.tids.join('-') : 'all'), + title: '[[topic:thread_tools.move]]', + message: message, + type: 'success', + timeout: config.undoTimeout, + timeoutfn: function () { + moveTopics(data); + }, + clickfn: function (alert, params) { + delete params.timeoutfn; + app.alertSuccess('[[topic:topic_move_undone]]'); + }, + }); + } + + moveTopics(data); } } diff --git a/src/controllers/api.js b/src/controllers/api.js index 48e667c26a..5419bbbe01 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -36,6 +36,7 @@ apiController.loadConfig = async function (req) { maximumTagsPerTopic: meta.config.maximumTagsPerTopic || 5, minimumTagLength: meta.config.minimumTagLength || 3, maximumTagLength: meta.config.maximumTagLength || 15, + undoTimeout: meta.config.undoTimeout || 0, useOutgoingLinksPage: meta.config.useOutgoingLinksPage === 1, outgoingLinksWhitelist: meta.config.useOutgoingLinksPage === 1 ? meta.config['outgoingLinks:whitelist'] : undefined, allowGuestHandles: meta.config.allowGuestHandles === 1, diff --git a/src/views/admin/settings/general.tpl b/src/views/admin/settings/general.tpl index dba582b609..a792e48142 100644 --- a/src/views/admin/settings/general.tpl +++ b/src/views/admin/settings/general.tpl @@ -189,4 +189,16 @@ +
+
[[admin/settings/general:topic-tools]]
+
+
+ + +

+ [[admin/settings/general:undo-timeout-help]] +

+
+
+
\ No newline at end of file