Skip to content

Commit 02a1243

Browse files
author
Petr Kachanovsky
committed
fix: change shaIn default to be copy of all or true
1 parent 3e2fd3b commit 02a1243

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

adminforth/modules/configValidator.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -311,24 +311,16 @@ export default class ConfigValidator implements IConfigValidator {
311311
}
312312
}
313313

314-
if (Object.keys(showIn).includes('all')) {
315-
if (Object.keys(showIn).length > 1) {
316-
errors.push(`Resource "${resInput.resourceId || resInput.table}" column "${column.name}" showIn cannot have "all" and other keys at same time: ${Object.keys(showIn).join(', ')}`);
317-
}
318-
for (const key of Object.keys(AdminForthResourcePages)) {
319-
if (key !== 'all') {
320-
showIn[key] = showIn.all;
321-
}
314+
// by default copy from 'all' key if present or show on all pages
315+
for (const key of Object.keys(AdminForthResourcePages)) {
316+
if (!Object.keys(showIn).includes(key)) {
317+
showIn[key] = showIn.all !== undefined ? showIn.all : true;
322318
}
319+
}
320+
if (showIn.all !== undefined) {
323321
delete showIn.all;
324-
} else {
325-
// by default allow all actions
326-
for (const key of Object.keys(AdminForthResourcePages)) {
327-
if (!Object.keys(showIn).includes(key)) {
328-
showIn[key] = true;
329-
}
330-
}
331322
}
323+
332324
return showIn as ShowIn;
333325
}
334326

0 commit comments

Comments
 (0)