From a7e0291241117c7ff6130a575e23eae2c8eb5a06 Mon Sep 17 00:00:00 2001 From: Tishasoumya-02 Date: Mon, 17 Jul 2023 10:26:21 +0530 Subject: [PATCH 1/6] refactor --- .../Controlpanels/Groups/RenderGroups.jsx | 175 +++++++----------- 1 file changed, 64 insertions(+), 111 deletions(-) diff --git a/src/components/manage/Controlpanels/Groups/RenderGroups.jsx b/src/components/manage/Controlpanels/Groups/RenderGroups.jsx index 86af8486b6..770ade6b8c 100644 --- a/src/components/manage/Controlpanels/Groups/RenderGroups.jsx +++ b/src/components/manage/Controlpanels/Groups/RenderGroups.jsx @@ -1,123 +1,76 @@ -/** - * 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 { 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'; -/** - * 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, - }; - - /** - * 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 RenderGroups = (props) => { + const onChange = (event, { value }) => { const [group, role] = value.split('.'); - this.props.updateGroups(group, role); - } - - /** - *@param {*} - *@returns {Boolean} - *@memberof RenderGroups - */ - isAuthGroup = (roleId) => { - return this.props.inheritedRole.includes(roleId); + props.updateGroups(group, role); + }; + const isAuthGroup = (roleId) => { + return props.inheritedRole.includes(roleId); }; - /** - * Render method. - * @method render - * @returns {string} Markup for the component. - */ - render() { - return ( - - {this.props.group.groupname} - {this.props.roles.map((role) => ( - - {this.props.inheritedRole && - this.props.inheritedRole.includes(role.id) && - this.props.group.roles.includes('Authenticated') ? ( - - ) : ( - - )} - - ))} - - - - - - - - - + + return ( + + {props.group.groupname} + {props.roles.map((role) => ( + + {props.inheritedRole && + props.inheritedRole.includes(role.id) && + props.group.roles.includes('Authenticated') ? ( + + ) : ( + + )} - - ); - } -} + ))} + + + + + + + + + + + + ); +}; + +RenderGroups.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, +}; export default injectIntl(RenderGroups); From 6b29d33f6a2242962fdcabf24cd87a3cd21c01fd Mon Sep 17 00:00:00 2001 From: Tishasoumya-02 Date: Thu, 20 Jul 2023 10:52:31 +0530 Subject: [PATCH 2/6] refactor --- news/4988.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/4988.feature diff --git a/news/4988.feature b/news/4988.feature new file mode 100644 index 0000000000..5281f7b576 --- /dev/null +++ b/news/4988.feature @@ -0,0 +1 @@ +Refactor ControlPanels/Groups RenderGroups-@Tishasoumya-02 \ No newline at end of file From 57744c3f6603c3f731850385acaa246493e05244 Mon Sep 17 00:00:00 2001 From: Tishasoumya-02 Date: Thu, 20 Jul 2023 12:08:36 +0530 Subject: [PATCH 3/6] /news --- news/{4988.feature => 4993.feature} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename news/{4988.feature => 4993.feature} (100%) diff --git a/news/4988.feature b/news/4993.feature similarity index 100% rename from news/4988.feature rename to news/4993.feature From 98192177c2c29b70c26547a39f9015ed5c5d2bbf Mon Sep 17 00:00:00 2001 From: Tishasoumya-02 Date: Thu, 8 Aug 2024 11:55:04 +0530 Subject: [PATCH 4/6] update snapshot test --- .../__snapshots__/RenderGroups.test.jsx.snap | 72 +++++++++++++++---- 1 file changed, 57 insertions(+), 15 deletions(-) diff --git a/packages/volto/src/components/manage/Controlpanels/Groups/__snapshots__/RenderGroups.test.jsx.snap b/packages/volto/src/components/manage/Controlpanels/Groups/__snapshots__/RenderGroups.test.jsx.snap index bb19f13b4d..9bc5db1313 100644 --- a/packages/volto/src/components/manage/Controlpanels/Groups/__snapshots__/RenderGroups.test.jsx.snap +++ b/packages/volto/src/components/manage/Controlpanels/Groups/__snapshots__/RenderGroups.test.jsx.snap @@ -22,11 +22,10 @@ exports[`UsersControlpanelGroups renders a UsersControlpanelGroups component 1`]