From 5317afd3d170b465a6830b20f6dc7cc1812516b0 Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Sat, 17 May 2025 09:13:05 +0200 Subject: [PATCH] refactor: apply rev Signed-off-by: Camila Belo --- .changeset/mighty-sites-call.md | 7 ++--- .../User/UserProfileCard/UserProfileCard.tsx | 27 +++++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.changeset/mighty-sites-call.md b/.changeset/mighty-sites-call.md index 33eca1f2e3..77382644b3 100644 --- a/.changeset/mighty-sites-call.md +++ b/.changeset/mighty-sites-call.md @@ -4,7 +4,8 @@ Enhance user profile card configuration: -- Added a new `maxRelations` numerical configuration that controls over how many user groups are shown directly on the profile card: +- Added a new optional `maxRelations` numerical configuration that controls over how many user groups are shown directly on the profile card: + - If the setting is omitted, all relations will be shown. - If `maxRelations` is set to `0`, the list of user groups is not displayed. - If `maxRelations` is set to a positive number, up to that many groups are displayed. - If the user belongs to more groups than the specified limit, a clickable link appears that opens a dialog showing all associated user groups. @@ -16,6 +17,6 @@ Enhance user profile card configuration: extensions: - entity-card:org/user-profile: config: - maxRelations: 5 # Show up to 5 groups on the card - hideIcons: true # Hide the group icons + maxRelations: 5 # (optional) Show up to 5 groups on the card + hideIcons: true # (optional) Hide the group icons ``` diff --git a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx index 0d3d02d0a2..50cb0e1fef 100644 --- a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx +++ b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx @@ -55,7 +55,6 @@ import { LinksGroup } from '../../Meta'; import PersonIcon from '@material-ui/icons/Person'; import { useCallback, useState } from 'react'; -import _ from 'lodash'; const useStyles = makeStyles((theme: any) => ({ closeButton: { @@ -72,6 +71,7 @@ const useStyles = makeStyles((theme: any) => ({ minHeight: 400, }, })); + const CardTitle = (props: { title?: string }) => props.title ? ( @@ -91,16 +91,13 @@ export const UserProfileCard = (props: { const classes = useStyles(); const { entity: user } = useEntity(); - const [isViewAllGroupsDialogOpen, setIsViewAllGroupsDialogOpen] = - useState(false); + const [isAllGroupsDialogOpen, setIsAllGroupsDialogOpen] = useState(false); - const openViewAllGroupsDialog = useCallback( - () => setIsViewAllGroupsDialogOpen(true), - [], - ); - - const closeViewAllGroupsDialog = useCallback( - () => setIsViewAllGroupsDialogOpen(false), + const toggleAllGroupsDialog = useCallback( + () => + setIsAllGroupsDialogOpen( + prevIsViewAllGroupsDialogOpen => !prevIsViewAllGroupsDialogOpen, + ), [], ); @@ -179,7 +176,7 @@ export const UserProfileCard = (props: { , {` ...More (${ @@ -198,8 +195,8 @@ export const UserProfileCard = (props: { @@ -219,7 +216,7 @@ export const UserProfileCard = (props: { - +