mirror of
https://github.com/strapi/strapi.git
synced 2025-08-13 19:27:34 +00:00
Fix batch-delete
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
ca5f97aa5d
commit
fa7d906494
@ -14,11 +14,7 @@ const RoleRow = ({ role, onRoleToggle, onRoleDuplicate, onRoleRemove, selectedRo
|
|||||||
const handleRoleSelection = e => {
|
const handleRoleSelection = e => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
if (role.usersCount) {
|
|
||||||
strapi.notification.info('Roles.ListPage.notification.delete-not-allowed');
|
|
||||||
} else {
|
|
||||||
onRoleToggle(role.id);
|
onRoleToggle(role.id);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClickDelete = () => {
|
const handleClickDelete = () => {
|
||||||
|
@ -53,10 +53,20 @@ const RoleListPage = () => {
|
|||||||
|
|
||||||
const handleConfirmDeleteData = async () => {
|
const handleConfirmDeleteData = async () => {
|
||||||
try {
|
try {
|
||||||
|
const filteredRoles = selectedRoles.filter(currentId => {
|
||||||
|
const currentRole = roles.find(role => role.id === currentId);
|
||||||
|
|
||||||
|
return currentRole.usersCount === 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (selectedRoles.length !== filteredRoles.length) {
|
||||||
|
strapi.notification.info('Roles.ListPage.notification.delete-all-not-allowed');
|
||||||
|
}
|
||||||
|
|
||||||
await request('/admin/roles/batch-delete', {
|
await request('/admin/roles/batch-delete', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: {
|
body: {
|
||||||
ids: selectedRoles,
|
ids: filteredRoles,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -345,6 +345,7 @@
|
|||||||
"app.containers.AuthPage.ForgotPasswordSuccess.text.contact-admin": "If you do not receive this link, please contact your administrator.",
|
"app.containers.AuthPage.ForgotPasswordSuccess.text.contact-admin": "If you do not receive this link, please contact your administrator.",
|
||||||
"app.containers.AuthPage.ForgotPasswordSuccess.title": "Email sent",
|
"app.containers.AuthPage.ForgotPasswordSuccess.title": "Email sent",
|
||||||
"Roles.ListPage.notification.delete-not-allowed": "A role cannot be deleted if associated with users",
|
"Roles.ListPage.notification.delete-not-allowed": "A role cannot be deleted if associated with users",
|
||||||
|
"Roles.ListPage.notification.delete-all-not-allowed": "Some roles could not be deleted since they are associated with users",
|
||||||
"Roles.RoleRow.user-count.plural": "{number} users",
|
"Roles.RoleRow.user-count.plural": "{number} users",
|
||||||
"Roles.RoleRow.user-count.singular": "{number} user",
|
"Roles.RoleRow.user-count.singular": "{number} user",
|
||||||
"Roles.components.List.empty.withSearch": "There is no role corresponding to the search ({search})..."
|
"Roles.components.List.empty.withSearch": "There is no role corresponding to the search ({search})..."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user