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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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,52 @@
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">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have this open to a new tab with target="_blank" and 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 +58,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('ash@ketchum.org')).toBeInTheDocument();
expect(screen.getByTestId('icon-hyperlink')).toHaveAttribute('href', '/learner-information/?email=ash@ketchum.org');
});

it('renders pending enterprise customer detail', () => {
Expand All @@ -35,6 +36,7 @@ describe('EnterpriseCustomerUserDetail', () => {
};
render(<EnterpriseCustomerUserDetail row={pendingEnterpriseCustomerUser} />);
expect(screen.getByText('pending@customer.org')).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;
}