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

fix: adding link to username and email #444

Merged
merged 1 commit into from
Jan 28, 2025
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,14 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
Hyperlink, Icon, IconButton, Stack, Chip,
Chip, Hyperlink, Icon, IconButton, Stack,
} from '@openedx/paragon';
import { Person, Check, Timelapse } from '@openedx/paragon/icons';
import { Check, Person, Timelapse } from '@openedx/paragon/icons';

import ROUTES from '../../../data/constants/routes';

export const EnterpriseCustomerUserDetail = ({
row,
}) => {
export const EnterpriseCustomerUserDetail = ({ row }) => {
const user = row.original.enterpriseCustomerUser;
let memberDetails;
const iconLink = `${ROUTES.SUPPORT_TOOLS_TABS.SUB_DIRECTORY.LEARNER_INFORMATION}/?email=${user?.email}`;
Expand Down Expand Up @@ -48,12 +47,19 @@ export const EnterpriseCustomerUserDetail = ({

if (user?.username) {
memberDetails = (
<div className="mb-n3">
<p className="font-weight-bold mb-0">
{user?.username}
</p>
<p>{user?.email}</p>
</div>
<Hyperlink
destination={iconLink}
key={user?.username}
data-testId="username-email-hyperlink"
target="_blank"
variant="muted"
showLaunchIcon={false}
>
<div className="mb-n3">
<p className="font-weight-bold mb-0">{user?.username}</p>
<p>{user?.email}</p>
</div>
</Hyperlink>
);
} else {
memberDetails = (
Expand All @@ -72,17 +78,13 @@ export const EnterpriseCustomerUserDetail = ({

export const AdministratorCell = ({ row }) => {
if (row.original?.pendingEnterpriseCustomerUser?.isPendingAdmin) {
return (
<Chip
iconBefore={Timelapse}
>
Pending
</Chip>
);
return <Chip iconBefore={Timelapse}>Pending</Chip>;
}
return (
<div>
{row.original?.roleAssignments?.includes('enterprise_admin') ? <Check data-testid="admin check" aria-label="admin check" /> : null}
{row.original?.roleAssignments?.includes('enterprise_admin') ? (
<Check data-testid="admin check" aria-label="admin check" />
) : null}
</div>
);
};
Expand All @@ -91,18 +93,14 @@ export const LearnerCell = ({ row }) => {
if (!row.original?.pendingEnterpriseCustomerUser?.isPendingLearner) {
return (
<div>
{row.original?.roleAssignments?.includes('enterprise_learner') ? <Check data-testid="learner check" aria-label="learner check" /> : null}
{row.original?.roleAssignments?.includes('enterprise_learner') ? (
<Check data-testid="learner check" aria-label="learner check" />
) : null}
</div>
);
}

return (
<Chip
iconBefore={Timelapse}
>
Pending
</Chip>
);
return <Chip iconBefore={Timelapse}>Pending</Chip>;
};

EnterpriseCustomerUserDetail.propTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('EnterpriseCustomerUserDetail', () => {
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');
expect(screen.getByTestId('username-email-hyperlink')).toHaveAttribute('href', '/learner-information/?email=ash@ketchum.org');
});

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

it('renders AdministratorCell there is a pending admin', () => {
Expand Down
Loading