diff --git a/packages/volto/news/4993.feature b/packages/volto/news/4993.feature new file mode 100644 index 0000000000..f5f831e506 --- /dev/null +++ b/packages/volto/news/4993.feature @@ -0,0 +1 @@ +Refactor ControlPanels/Groups RenderGroups from class components to functional component. @Tishasoumya-02 \ No newline at end of file diff --git a/packages/volto/src/components/manage/Controlpanels/Groups/RenderGroups.jsx b/packages/volto/src/components/manage/Controlpanels/Groups/RenderGroups.jsx index f707003ed1..c1117a59bd 100644 --- a/packages/volto/src/components/manage/Controlpanels/Groups/RenderGroups.jsx +++ b/packages/volto/src/components/manage/Controlpanels/Groups/RenderGroups.jsx @@ -1,134 +1,86 @@ -/** - * Users controlpanel groups. - * @module components/manage/Controlpanels/UsersControlpanelGroups - */ import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { FormattedMessage, injectIntl } from 'react-intl'; +import { FormattedMessage } from 'react-intl'; import { Dropdown, Table, Checkbox } from 'semantic-ui-react'; import trashSVG from '@plone/volto/icons/delete.svg'; import ploneSVG from '@plone/volto/icons/plone.svg'; import { Icon } from '@plone/volto/components'; import { canAssignRole } from '@plone/volto/helpers'; -/** - * UsersControlpanelGroups class. - * @class UsersControlpanelGroups - * @extends Component - */ -class RenderGroups extends Component { - /** - * Property types. - * @property {Object} propTypes Property types. - * @static - */ - static propTypes = { - //single group - group: PropTypes.shape({ - title: PropTypes.string, - description: PropTypes.string, - email: PropTypes.string, - groupname: PropTypes.string, - roles: PropTypes.arrayOf(PropTypes.string), - }).isRequired, - - roles: PropTypes.arrayOf( - PropTypes.shape({ - id: PropTypes.string, - }), - ).isRequired, - inheritedRole: PropTypes.array, - onDelete: PropTypes.func.isRequired, - isUserManager: PropTypes.bool.isRequired, +const RenderGroups = (props) => { + const onChange = (event, { value }) => { + const [group, role] = value.split('.'); + props.updateGroups(group, role); }; - - /** - * Constructor - * @method constructor - * @param {Object} props Component properties - * @constructs Sharing - */ - constructor(props) { - super(props); - this.onChange = this.onChange.bind(this); - } - - /** - * @param {*} event - * @param {*} { value } - * @memberof UsersControlpanelUser - */ - onChange(event, { value }) { - const [group, role] = value.split('&role='); - this.props.updateGroups(group, role); - } - - /** - *@param {*} - *@returns {Boolean} - *@memberof RenderGroups - */ - isAuthGroup = (roleId) => { - return this.props.inheritedRole.includes(roleId); + const isAuthGroup = (roleId) => { + return props.inheritedRole.includes(roleId); }; - - canDeleteGroup() { - if (this.props.isUserManager) return true; - return !this.props.group.roles.includes('Manager'); - } - - /** - * Render method. - * @method render - * @returns {string} Markup for the component. - */ - render() { - return ( -