nodebb-plugin-discord-onekite 1.1.12 → 1.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # nodebb-plugin-discord-onekite v1.1.4.3
1
+ # nodebb-plugin-discord-onekite v1.1.4.5
2
2
 
3
- Fix: syntax error in library.js (newline in join string).
4
- Keeps v1.1.4-based changes: single clickable link line + excerpt below.
3
+ Fixes ACP save (API route) + floating save button + toast.
4
+
5
+ - Adds API route via `routeHelpers.setupApiRoute` so `api.post('/admin/...')` works.
6
+ - Adds floating save button bottom-right.
7
+ - Shows NodeBB toast on success.
package/library.js CHANGED
@@ -129,7 +129,8 @@ async function getPostExcerpt(pid) {
129
129
  }
130
130
 
131
131
  async function buildPayload({ tid, pid, isReply }) {
132
- const baseUrl = normalizeBaseUrl(meta.config.url);
132
+ let baseUrl = normalizeBaseUrl(meta.config.url || meta.config['url']);
133
+ if (!baseUrl) { baseUrl = 'https://www.onekite.com'; }
133
134
 
134
135
  const topicData = await topics.getTopicFields(tid, ['tid', 'uid', 'cid', 'title', 'slug', 'mainPid']);
135
136
  if (!topicData) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-discord-onekite",
3
- "version": "1.1.12",
3
+ "version": "1.1.14",
4
4
  "description": "Discord webhook notifier for Onekite (NodeBB v4.x only)",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
@@ -10,28 +10,33 @@ define('admin/plugins/discord-onekite', ['api'], function (api) {
10
10
  return Array.from(el.selectedOptions || []).map(o => o.value);
11
11
  }
12
12
 
13
- ACP.init = function () {
14
- const $form = $('.discord-onekite-settings');
15
- if (!$form.length) return;
13
+ function doSave() {
14
+ const payload = {
15
+ webhookUrl: String($('#webhookUrl').val() || '').trim(),
16
+ notifyReplies: $('#notifyReplies').is(':checked'),
17
+ cids: getMultiSelectValues('#cids'),
18
+ };
16
19
 
17
- $('#save').off('click.discordOnekite').on('click.discordOnekite', function () {
18
- const payload = {
19
- webhookUrl: String($('#webhookUrl').val() || '').trim(),
20
- notifyReplies: $('#notifyReplies').is(':checked'),
21
- cids: getMultiSelectValues('#cids'),
22
- };
20
+ // `api.post('/admin/...')` -> `/api/admin/...`
21
+ return api.post('/admin/plugins/discord-onekite/save', payload).then(function () {
22
+ if (window.app && typeof app.alertSuccess === 'function') {
23
+ app.alertSuccess('Paramètres enregistrés !');
24
+ }
25
+ }).catch(function (err) {
26
+ // eslint-disable-next-line no-console
27
+ console.error(err);
28
+ if (window.app && typeof app.alertError === 'function') {
29
+ app.alertError('Erreur lors de l’enregistrement');
30
+ }
31
+ });
32
+ }
33
+
34
+ ACP.init = function () {
35
+ if (!$('.discord-onekite-settings').length) return;
23
36
 
24
- api.post('/admin/plugins/discord-onekite/save', payload).then(function () {
25
- if (window.app && typeof app.alertSuccess === 'function') {
26
- app.alertSuccess('Paramètres enregistrés !');
27
- }
28
- }).catch(function (err) {
29
- // eslint-disable-next-line no-console
30
- console.error(err);
31
- if (window.app && typeof app.alertError === 'function') {
32
- app.alertError('Erreur lors de l’enregistrement');
33
- }
34
- });
37
+ $(document).off('click.discordOnekite', '#save').on('click.discordOnekite', '#save', function (e) {
38
+ e.preventDefault();
39
+ doSave();
35
40
  });
36
41
  };
37
42
 
@@ -1,8 +1,10 @@
1
1
  <div class="acp-page-container">
2
- <h4>Discord Onekite</h4>
3
- <p class="text-muted">
4
- Notifications Discord via webhook.
5
- </p>
2
+ <div class="d-flex justify-content-between align-items-start mb-3">
3
+ <div>
4
+ <h4 class="mb-1">Discord Onekite</h4>
5
+ <p class="text-muted mb-0">Notifications Discord via webhook.</p>
6
+ </div>
7
+ </div>
6
8
 
7
9
  <form role="form" class="discord-onekite-settings">
8
10
  <div class="mb-3">
@@ -28,7 +30,9 @@
28
30
  Si aucune catégorie n’est sélectionnée : <strong>toutes les catégories</strong> seront notifiées.
29
31
  </p>
30
32
  </div>
31
-
32
- <!-- IMPORT admin/partials/save_button.tpl -->
33
33
  </form>
34
+
35
+ <button id="save" class="btn btn-primary" style="position: fixed; right: 2rem; bottom: 2rem; z-index: 1030;">
36
+ <i class="fa fa-save"></i>
37
+ </button>
34
38
  </div>