From 09fbd934cfc0377e3cc1328ac4e11fa0b11aa560 Mon Sep 17 00:00:00 2001 From: Joonho Jonathan Oh <149014867+joonhoswe@users.noreply.github.com> Date: Thu, 20 Feb 2025 10:38:45 -0500 Subject: [PATCH 1/2] feat: wrapped endorse button in conditional isAdmin --- nodebb-theme-harmony/templates/partials/post_bar.tpl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nodebb-theme-harmony/templates/partials/post_bar.tpl b/nodebb-theme-harmony/templates/partials/post_bar.tpl index 59326c176a..04cff23877 100644 --- a/nodebb-theme-harmony/templates/partials/post_bar.tpl +++ b/nodebb-theme-harmony/templates/partials/post_bar.tpl @@ -13,6 +13,15 @@ + {{{ if isAdminOrGlobalMod }}} + + {{{ else }}} + status of endorsed or not + {{{ end }}} +
From 59e3053877b670f7acd245ff558e14f58d5a918d Mon Sep 17 00:00:00 2001 From: savannahxunc <56523076+savannahxunc@users.noreply.github.com> Date: Sat, 22 Feb 2025 20:57:55 -0500 Subject: [PATCH 2/2] 2/22 tested endorse code --- .../partials/topic/topic-menu-list.tpl | 10 ++++++++++ public/language/en-GB/topic.json | 2 ++ public/language/en-US/topic.json | 2 ++ public/src/client/topic/threadTools.js | 16 ++++++++++++++++ src/api/topics.js | 17 +++++++++++++++++ 5 files changed, 47 insertions(+) diff --git a/nodebb-theme-harmony/templates/partials/topic/topic-menu-list.tpl b/nodebb-theme-harmony/templates/partials/topic/topic-menu-list.tpl index 8135324a0d..d597a2c5a2 100644 --- a/nodebb-theme-harmony/templates/partials/topic/topic-menu-list.tpl +++ b/nodebb-theme-harmony/templates/partials/topic/topic-menu-list.tpl @@ -1,4 +1,14 @@ {{{ if privileges.editable }}} + +
  • + [[topic:thread-tools.endorse]] +
  • + +
  • + [[topic:thread-tools.unendorse]] +
  • + +
  • [[topic:thread-tools.lock]]
  • diff --git a/public/language/en-GB/topic.json b/public/language/en-GB/topic.json index d14595cd02..222ede8f75 100644 --- a/public/language/en-GB/topic.json +++ b/public/language/en-GB/topic.json @@ -110,6 +110,8 @@ "thread-tools.markAsUnreadForAll": "Mark Unread For All", "thread-tools.pin": "Pin Topic", "thread-tools.unpin": "Unpin Topic", + "thread-tools.endorse": "Endorse Topic", + "thread-tools.unendorse": "Unendorse Topic", "thread-tools.lock": "Lock Topic", "thread-tools.unlock": "Unlock Topic", "thread-tools.move": "Move Topic", diff --git a/public/language/en-US/topic.json b/public/language/en-US/topic.json index 617fbf008f..c83d5eb6e1 100644 --- a/public/language/en-US/topic.json +++ b/public/language/en-US/topic.json @@ -98,6 +98,8 @@ "thread-tools.markAsUnreadForAll": "Mark Unread For All", "thread-tools.pin": "Pin Topic", "thread-tools.unpin": "Unpin Topic", + "thread-tools.endorse": "Endorse Topic", + "thread-tools.unendorse": "Unendorse Topic", "thread-tools.lock": "Lock Topic", "thread-tools.unlock": "Unlock Topic", "thread-tools.move": "Move Topic", diff --git a/public/src/client/topic/threadTools.js b/public/src/client/topic/threadTools.js index db670729d1..c7609b285b 100644 --- a/public/src/client/topic/threadTools.js +++ b/public/src/client/topic/threadTools.js @@ -41,7 +41,22 @@ define('forum/topic/threadTools', [ return false; }); + + topicContainer.on('click', '[component="topic/endorse"]', function () { + console.log('#######endorse executed'); + topicCommand('put', '/endorse', 'endorse'); + return false; + }); + + topicContainer.on('click', '[component="topic/unendorse"]', function () { + console.log('#######unendorse executed'); + topicCommand('del', '/endorse', 'unendorse'); + return false; + }); + topicContainer.on('click', '[component="topic/lock"]', function () { + console.log('#######lock executed'); + topicCommand('put', '/lock', 'lock'); return false; }); @@ -201,6 +216,7 @@ define('forum/topic/threadTools', [ }; function renderMenu(container) { + console.log('####renderMenu executed'); if (!container) { return; } diff --git a/src/api/topics.js b/src/api/topics.js index 7a6cabf966..b5fa1451d6 100644 --- a/src/api/topics.js +++ b/src/api/topics.js @@ -149,6 +149,23 @@ topicsAPI.unpin = async function (caller, data) { }); }; +topicsAPI.endorse = async function (caller, data) { + console.log('****endorse', data); + // await doTopicAction('endorse', 'event:topic_endorse', caller, { + // tids: data.tids, + // }); + await doTopicAction('lock', 'event:topic_locked', caller, { + tids: data.tids, + }); +}; + +topicsAPI.unendorse = async function (caller, data) { + console.log('*****unendorse', data); + // await doTopicAction('unendorse', 'event:topic_unendorse', caller, { + // tids: data.tids, + // }); +}; + topicsAPI.lock = async function (caller, data) { await doTopicAction('lock', 'event:topic_locked', caller, { tids: data.tids,