mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-25 13:50:47 +01:00
fix: #14112, federation/rules and relays ACP pages not refreshing table properly on changes, basic form validation
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
"relays.state-0": "Pending",
|
||||
"relays.state-1": "Receiving only",
|
||||
"relays.state-2": "Active",
|
||||
"relays.errors.invalid-url": "Please enter a valid URL",
|
||||
|
||||
"server-filtering": "Filtering",
|
||||
"count": "This NodeBB is currently aware of <strong>%1</strong> server(s)",
|
||||
|
||||
@@ -24,7 +24,7 @@ function setupRelays() {
|
||||
case 'relays.remove': {
|
||||
const url = subselector.closest('tr').getAttribute('data-url');
|
||||
del(`/admin/activitypub/relays/${encodeURIComponent(url)}`, {}).then(async (data) => {
|
||||
const html = await app.parseAndTranslate('admin/settings/activitypub', 'relays', { relays: data });
|
||||
const html = await app.parseAndTranslate('admin/federation/relays', 'relays', { relays: data });
|
||||
const tbodyEl = document.querySelector('#relays tbody');
|
||||
if (tbodyEl) {
|
||||
$(tbodyEl).html(html);
|
||||
@@ -41,10 +41,13 @@ function throwModal() {
|
||||
render('admin/partials/activitypub/relays', {}).then(function (html) {
|
||||
const submit = function () {
|
||||
const formEl = modal.find('form').get(0);
|
||||
const payload = Object.fromEntries(new FormData(formEl));
|
||||
if (!formEl.reportValidity()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const payload = Object.fromEntries(new FormData(formEl));
|
||||
post('/admin/activitypub/relays', payload).then(async (data) => {
|
||||
const html = await app.parseAndTranslate('admin/settings/activitypub', 'relays', { relays: data });
|
||||
const html = await app.parseAndTranslate('admin/federation/relays', 'relays', { relays: data });
|
||||
const tbodyEl = document.querySelector('#relays tbody');
|
||||
if (tbodyEl) {
|
||||
$(tbodyEl).html(html);
|
||||
|
||||
@@ -29,7 +29,7 @@ function setupRules() {
|
||||
case 'rules.delete': {
|
||||
const rid = subselector.closest('tr').getAttribute('data-rid');
|
||||
del(`/admin/activitypub/rules/${rid}`, {}).then(async (data) => {
|
||||
const html = await render('admin/settings/activitypub', { rules: data }, 'rules');
|
||||
const html = await render('admin/federation/rules', { rules: data }, 'rules');
|
||||
const tbodyEl = document.querySelector('#rules tbody');
|
||||
if (tbodyEl) {
|
||||
tbodyEl.innerHTML = html;
|
||||
@@ -68,15 +68,21 @@ function throwModal() {
|
||||
render('admin/partials/activitypub/rules', {}).then(function (html) {
|
||||
const submit = function () {
|
||||
const formEl = modal.find('form').get(0);
|
||||
const payload = Object.fromEntries(new FormData(formEl));
|
||||
if (!formEl.reportValidity()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const payload = Object.fromEntries(new FormData(formEl));
|
||||
post('/admin/activitypub/rules', payload).then(async (data) => {
|
||||
const html = await render('admin/settings/activitypub', { rules: data }, 'rules');
|
||||
const html = await render('admin/federation/rules', { rules: data }, 'rules');
|
||||
const tbodyEl = document.querySelector('#rules tbody');
|
||||
if (tbodyEl) {
|
||||
tbodyEl.innerHTML = html;
|
||||
}
|
||||
modal.modal('hide');
|
||||
}).catch(error);
|
||||
|
||||
return false;
|
||||
};
|
||||
const modal = bootbox.dialog({
|
||||
title: '[[admin/settings/activitypub:rules.add]]',
|
||||
|
||||
@@ -110,8 +110,11 @@ Admin.activitypub.reorderRules = async (req, res) => {
|
||||
helpers.formatApiResponse(200, res, await activitypub.rules.list());
|
||||
};
|
||||
|
||||
Admin.activitypub.addRelay = async (req, res) => {
|
||||
Admin.activitypub.addRelay = async (req, res, next) => {
|
||||
const { url } = req.body;
|
||||
if (!url) {
|
||||
return next();
|
||||
}
|
||||
|
||||
await activitypub.relays.add(url);
|
||||
helpers.formatApiResponse(200, res, await activitypub.relays.list());
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
<form role="form">
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="url">Relay URL</label>
|
||||
<input type="text" id="url" name="url" title="Relay URL" class="form-control" placeholder="https://example.org/actor">
|
||||
<input type="url" id="url" name="url" title="Relay URL" class="form-control" placeholder="https://example.org/actor" required>
|
||||
</div>
|
||||
</form>
|
||||
@@ -14,7 +14,7 @@
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="value">Value</label>
|
||||
<input type="text" id="value" name="value" title="Value" class="form-control" placeholder="forum">
|
||||
<input type="text" id="value" name="value" title="Value" class="form-control" placeholder="forum" required>
|
||||
<p class="form-text" id="help-text"></p>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
|
||||
Reference in New Issue
Block a user