mirror of
https://github.com/strapi/strapi.git
synced 2025-08-05 15:29:04 +00:00
31 lines
809 B
JavaScript
31 lines
809 B
JavaScript
![]() |
const formatActionsBySections = actions =>
|
||
|
actions.reduce((result, p) => {
|
||
|
const checkboxItem = {
|
||
|
displayName: p.displayName,
|
||
|
action: p.actionId,
|
||
|
};
|
||
|
|
||
|
switch (p.section) {
|
||
|
case 'contentTypes':
|
||
|
checkboxItem.subjects = p.subjects;
|
||
|
break;
|
||
|
case 'plugins':
|
||
|
checkboxItem.subCategory = p.subCategory;
|
||
|
checkboxItem.plugin = `plugin::${p.pluginName}`;
|
||
|
break;
|
||
|
case 'settings':
|
||
|
checkboxItem.category = p.category;
|
||
|
checkboxItem.subCategory = p.subCategory;
|
||
|
break;
|
||
|
case 'default':
|
||
|
throw new Error(`Unknown section ${p.section}`);
|
||
|
}
|
||
|
|
||
|
result[p.section] = result[p.section] || [];
|
||
|
result[p.section].push(checkboxItem);
|
||
|
|
||
|
return result;
|
||
|
}, {});
|
||
|
|
||
|
module.exports = formatActionsBySections;
|