Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/strapi-admin/ee/admin/containers/Roles/ListPage/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import React, { useCallback } from 'react';
import PropTypes from 'prop-types';
import { useGlobalContext } from 'strapi-helper-plugin';
import { useHistory } from 'react-router-dom';
import { Pencil, Duplicate } from '@buffetjs/icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { RoleRow as RoleRowBase } from '../../../../../admin/src/components/Roles';
import Checkbox from './CustomCheckbox';
const RoleRow = ({
canCreate,
canDelete,
canUpdate,
role,
onRoleToggle,
onRoleDuplicate,
onRoleRemove,
selectedRoles,
}) => {
const { push } = useHistory();
const { settingsBaseURL } = useGlobalContext();
const handleRoleSelection = e => {
e.stopPropagation();
onRoleToggle(role.id);
};
const handleClickDelete = e => {
e.preventDefault();
e.stopPropagation();
if (role.usersCount) {
strapi.notification.toggle({
type: 'info',
message: { id: 'Roles.ListPage.notification.delete-not-allowed' },
});
} else {
onRoleRemove(role.id);
}
};
const handleGoTo = useCallback(() => {
push(`${settingsBaseURL}/roles/${role.id}`);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [role.id, settingsBaseURL]);
const prefix = canDelete ? (
<Checkbox
value={selectedRoles.findIndex(selectedRoleId => selectedRoleId === role.id) !== -1}
onClick={handleRoleSelection}
name="role-checkbox"
/>
) : null;
return (
<RoleRowBase
onClick={handleGoTo}
selectedRoles={selectedRoles}
prefix={prefix}
role={role}
links={[
{
icon: canCreate ? <Duplicate fill="#0e1622" /> : null,
onClick: e => {
e.preventDefault();
e.stopPropagation();
onRoleDuplicate(role.id);
},
},
{
icon: canUpdate ? <Pencil fill="#0e1622" /> : null,
onClick: handleGoTo,
},
{
icon: canDelete ? <FontAwesomeIcon icon="trash-alt" /> : null,
onClick: handleClickDelete,
},
]}
/>
);
};
RoleRow.defaultProps = {
selectedRoles: [],
};
RoleRow.propTypes = {
canCreate: PropTypes.bool.isRequired,
canDelete: PropTypes.bool.isRequired,
canUpdate: PropTypes.bool.isRequired,
onRoleToggle: PropTypes.func.isRequired,
onRoleDuplicate: PropTypes.func.isRequired,
onRoleRemove: PropTypes.func.isRequired,
role: PropTypes.object.isRequired,
selectedRoles: PropTypes.arrayOf(PropTypes.number),
};
export default RoleRow;
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.005 ]-- |