Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding link to user page to icon #431

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,33 +1,58 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
Icon, IconButton, Stack, Chip,
Hyperlink, Icon, IconButton, Stack, Chip,
} from '@openedx/paragon';
import { Person, Check, Timelapse } from '@openedx/paragon/icons';
import ROUTES from '../../../data/constants/routes';

export const EnterpriseCustomerUserDetail = ({
row,
}) => {
const user = row.original.enterpriseCustomerUser;
let memberDetails;
const memberDetailIcon = (
<IconButton
isActive
invertColors
src={Person}
iconAs={Icon}
className="border rounded-circle mr-3"
alt="members detail column icon"
style={{ opacity: 1, flexShrink: 0 }}
/>
);
const iconLink = `${ROUTES.SUPPORT_TOOLS_TABS.SUB_DIRECTORY.LEARNER_INFORMATION}/?email=${user?.email}`;
const memberDetailIcon = () => {
if (user) {
return (
<Hyperlink
destination={iconLink}
key={user?.email}
data-testId="icon-hyperlink"
target="_blank"
showLaunchIcon={false}
>
<IconButton
isActive
invertColors
src={Person}
iconAs={Icon}
className="border rounded-circle mr-3"
alt="members detail column icon"
style={{ opacity: 1, flexShrink: 0 }}
/>
</Hyperlink>
);
}
return (
<IconButton
isActive
invertColors
src={Person}
iconAs={Icon}
className="icon-button border rounded-circle mr-3"
alt="members detail column icon"
/>
);
};

if (row.original.enterpriseCustomerUser?.username) {
if (user?.username) {
memberDetails = (
<div className="mb-n3">
<p className="font-weight-bold mb-0">
{row.original.enterpriseCustomerUser?.username}
{user?.username}
</p>
<p>{row.original.enterpriseCustomerUser?.email}</p>
<p>{user?.email}</p>
</div>
);
} else {
Expand All @@ -39,7 +64,7 @@ export const EnterpriseCustomerUserDetail = ({
}
return (
<Stack gap={0} direction="horizontal">
{memberDetailIcon}
{memberDetailIcon()}
{memberDetails}
</Stack>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('EnterpriseCustomerUserDetail', () => {
render(<EnterpriseCustomerUserDetail row={enterpriseCustomerUser} />);
expect(screen.getByText('ash ketchum')).toBeInTheDocument();
expect(screen.getByText('[email protected]')).toBeInTheDocument();
expect(screen.getByTestId('icon-hyperlink')).toHaveAttribute('href', '/learner-information/[email protected]');
});

it('renders pending enterprise customer detail', () => {
Expand All @@ -35,6 +36,7 @@ describe('EnterpriseCustomerUserDetail', () => {
};
render(<EnterpriseCustomerUserDetail row={pendingEnterpriseCustomerUser} />);
expect(screen.getByText('[email protected]')).toBeInTheDocument();
expect(screen.queryByTestId('icon-hyperlink')).not.toBeInTheDocument();
});

it('renders AdministratorCell there is a pending admin', () => {
Expand Down
6 changes: 6 additions & 0 deletions src/Configuration/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@
color: black !important;
font-weight: bold;
}

.icon-button {
opacity: 1;
flex-shrink: 0;
pointer-events: none;
}