mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-14 19:02:34 +02:00
fix: closes #14041, show specific error message
if config fails to save
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"invalid-data": "Invalid Data",
|
"invalid-data": "Invalid Data",
|
||||||
|
"invalid-config-field-value": "Invalid value for config field \"%1\": %2",
|
||||||
"invalid-json": "Invalid JSON",
|
"invalid-json": "Invalid JSON",
|
||||||
"wrong-parameter-type": "A value of type %3 was expected for property `%1`, but %2 was received instead",
|
"wrong-parameter-type": "A value of type %3 was expected for property `%1`, but %2 was received instead",
|
||||||
"required-parameters-missing": "Required parameters were missing from this API call: %1",
|
"required-parameters-missing": "Required parameters were missing from this API call: %1",
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ define('admin/settings', [
|
|||||||
if (err) {
|
if (err) {
|
||||||
return alerts.alert({
|
return alerts.alert({
|
||||||
alert_id: 'config_status',
|
alert_id: 'config_status',
|
||||||
timeout: 2500,
|
timeout: 5000,
|
||||||
title: '[[admin/admin:changes-not-saved]]',
|
title: '[[admin/admin:changes-not-saved]]',
|
||||||
message: `[[admin/admin:changes-not-saved-message, ${err.message}]]`,
|
message: `[[admin/admin:changes-not-saved-message, ${err.message}]]`,
|
||||||
type: 'danger',
|
type: 'danger',
|
||||||
|
|||||||
@@ -544,7 +544,7 @@ define('settings', ['hooks', 'alerts'], function (hooks, alerts) {
|
|||||||
title: '[[admin/admin:changes-not-saved]]',
|
title: '[[admin/admin:changes-not-saved]]',
|
||||||
message: `[[admin/admin:changes-not-saved-message, ${err.message}]]`,
|
message: `[[admin/admin:changes-not-saved-message, ${err.message}]]`,
|
||||||
type: 'error',
|
type: 'error',
|
||||||
timeout: 2500,
|
timeout: 5000,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const saveBtn = document.getElementById('save');
|
const saveBtn = document.getElementById('save');
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const winston = require('winston');
|
|||||||
const db = require('../database');
|
const db = require('../database');
|
||||||
const pubsub = require('../pubsub');
|
const pubsub = require('../pubsub');
|
||||||
const Meta = require('./index');
|
const Meta = require('./index');
|
||||||
|
const translator = require('../translator');
|
||||||
const cacheBuster = require('./cacheBuster');
|
const cacheBuster = require('./cacheBuster');
|
||||||
const defaults = require('../../install/data/defaults.json');
|
const defaults = require('../../install/data/defaults.json');
|
||||||
|
|
||||||
@@ -190,7 +191,9 @@ function ensureInteger(data, field, min) {
|
|||||||
if (data.hasOwnProperty(field)) {
|
if (data.hasOwnProperty(field)) {
|
||||||
data[field] = parseInt(data[field], 10);
|
data[field] = parseInt(data[field], 10);
|
||||||
if (!(data[field] >= min)) {
|
if (!(data[field] >= min)) {
|
||||||
throw new Error('[[error:invalid-data]]');
|
throw new Error(translator.compile(
|
||||||
|
'error:invalid-config-field-value', field, data[field]
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user