Skip to content

Commit

Permalink
impr(funbox): improve error message when funbox cannot be set with cu…
Browse files Browse the repository at this point in the history
…rrent config

Closes #4617
  • Loading branch information
Miodec committed Sep 13, 2023
1 parent 963f512 commit 6d7c3fe
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions frontend/src/ts/test/funbox/funbox-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export function canSetFunboxWithConfig(
} else {
funboxToCheck += "#" + funbox;
}
let errorCount = 0;
const errors = [];
for (const [configKey, configValue] of Object.entries(config)) {
if (
!canSetConfigWithCurrentFunboxes(
Expand All @@ -171,18 +171,29 @@ export function canSetFunboxWithConfig(
true
)
) {
errorCount += 1;
errors.push({
key: configKey,
value: configValue,
});
}
}
if (errorCount > 0) {
if (errors.length > 0) {
const errorStrings = [];
for (const error of errors) {
errorStrings.push(
`${Misc.capitalizeFirstLetter(
Misc.camelCaseToWords(error.key)
)} cannot be set to ${error.value}.`
);
}
Notifications.add(
`You can't enable ${funbox.replace(
/_/g,
" "
)} with currently active config.`,
`You can't enable ${funbox.replace(/_/g, " ")}:<br>${errorStrings.join(
"<br>"
)}`,
0,
{
duration: 5,
allowHTML: true,
}
);
return false;
Expand Down

0 comments on commit 6d7c3fe

Please sign in to comment.