Skip to content

Commit

Permalink
fix(ui): supported to see all personas in the user profile dropdown (#…
Browse files Browse the repository at this point in the history
…13915)

* supported to see all persona in user profile dropdown

* fix dropdown closing on more click for persona

* minor changes
  • Loading branch information
Ashish8689 authored Nov 9, 2023
1 parent 149be22 commit 5f9f7ae
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* limitations under the License.
*/
.profile-dropdown {
a.more-teams-pill {
.more-teams-pill {
background: #dde3ea;
border: 1px solid #dde3ea;
border-radius: 4px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const renderLimitedListMenuItem = ({
sizeLimit = 2,
readMoreKey,
}: ListMenuItemProps) => {
const remaningCount =
const remainingCount =
listItems.length ?? 0 > sizeLimit
? (listItems.length ?? sizeLimit) - sizeLimit
: 0;
Expand All @@ -69,9 +69,9 @@ const renderLimitedListMenuItem = ({
key: item.id,
})) ?? []),
...[
remaningCount > 0
remainingCount > 0
? {
label: readMoreLabelRenderer(remaningCount),
label: readMoreLabelRenderer(remainingCount),
key: readMoreKey ?? 'more-item',
}
: null,
Expand All @@ -89,6 +89,7 @@ export const UserProfileIcon = () => {
() => currentUser?.profile?.images?.image512,
[currentUser]
);
const [showAllPersona, setShowAllPersona] = useState<boolean>(false);

const handleOnImageError = useCallback(() => {
setIsImgUrlValid(false);
Expand Down Expand Up @@ -151,13 +152,23 @@ export const UserProfileIcon = () => {
);

const readMoreTeamRenderer = useCallback(
(count) => (
<Link
className="more-teams-pill"
to={getUserPath(currentUser?.name as string)}>
{count} {t('label.more')}
</Link>
),
(count: number, isPersona?: boolean) =>
isPersona ? (
<Typography.Text
className="more-teams-pill"
onClick={(e) => {
e.stopPropagation();
setShowAllPersona(true);
}}>
{count} {t('label.more')}
</Typography.Text>
) : (
<Link
className="more-teams-pill"
to={getUserPath(currentUser?.name as string)}>
{count} {t('label.more')}
</Link>
),
[currentUser]
);

Expand Down Expand Up @@ -226,8 +237,9 @@ export const UserProfileIcon = () => {
children: renderLimitedListMenuItem({
listItems: personas ?? [],
readMoreKey: 'more-persona',
sizeLimit: showAllPersona ? personas?.length : 2,
labelRenderer: personaLabelRenderer,
readMoreLabelRenderer: readMoreTeamRenderer,
readMoreLabelRenderer: (count) => readMoreTeamRenderer(count, true),
}),
label: (
<span className="text-grey-muted text-xs">
Expand Down Expand Up @@ -271,7 +283,15 @@ export const UserProfileIcon = () => {
type: 'group',
},
],
[currentUser, userName, selectedPersona, teams, roles, personas]
[
currentUser,
userName,
selectedPersona,
teams,
roles,
personas,
showAllPersona,
]
);

useEffect(() => {
Expand Down

0 comments on commit 5f9f7ae

Please sign in to comment.