Skip to content

Commit

Permalink
fix: PR reviews again
Browse files Browse the repository at this point in the history
  • Loading branch information
kiram15 committed Oct 3, 2024
1 parent 341f79f commit a2f86fa
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 48 deletions.
1 change: 0 additions & 1 deletion src/components/EnterpriseApp/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ EnterpriseApp.propTypes = {
enableAnalyticsScreen: PropTypes.bool,
enableReportingConfigurationsScreen: PropTypes.bool,
enablePortalLearnerCreditManagementScreen: PropTypes.bool,
enterpriseGroupsV2: PropTypes.bool,
error: PropTypes.instanceOf(Error),
loading: PropTypes.bool,
};
Expand Down
75 changes: 35 additions & 40 deletions src/components/PeopleManagement/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { useContext } from 'react';
import { Helmet } from 'react-helmet';
import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
import {
ActionRow, Button, Card, Icon, IconButtonWithTooltip, useToggle,
ActionRow, Button, Card, useToggle,
} from '@openedx/paragon';
import { Add, InfoOutline } from '@openedx/paragon/icons';
import { Add } from '@openedx/paragon/icons';

import cardImage from './images/ZeroStateImage.svg';
import Hero from '../Hero';
Expand All @@ -19,60 +19,47 @@ const PeopleManagementPage = () => {
description: 'Title for the people management page.',
});

const {
enterpriseSubsidyTypes,
} = useContext(EnterpriseSubsidiesContext);
const { enterpriseSubsidyTypes } = useContext(EnterpriseSubsidiesContext);

const hasLearnerCredit = enterpriseSubsidyTypes.includes(SUBSIDY_TYPES.budget);
const hasLearnerCredit = enterpriseSubsidyTypes.includes(
SUBSIDY_TYPES.budget,
);
const hasOtherSubsidyTypes = enterpriseSubsidyTypes.includes(SUBSIDY_TYPES.license)
|| enterpriseSubsidyTypes.includes(SUBSIDY_TYPES.coupon);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [isModalOpen, openModal, closeModal] = useToggle(false);

const tooltipContent = (
<FormattedMessage
id="admin.portal.people.management.page.tooltip.content"
defaultMessage="Only available for Learner Credit"
description="Tooltip to say this is only available for Learner Credit (not codes or subscriptions)."
/>
);

return (
<>
<Helmet title={PAGE_TITLE} />
<Hero title={PAGE_TITLE} />
{hasLearnerCredit && (
<div className="mx-3 mt-4">
<ActionRow className="mb-4">
<span className="flex-column">
<span className="d-flex">
<h3 className="mt-2">
<FormattedMessage
id="admin.portal.people.management.page.title"
defaultMessage="Your Learner Credit groups"
defaultMessage="Your organization's groups"
description="Title for people management zero state."
/>
</h3>
{hasLearnerCredit && hasOtherSubsidyTypes && (
<IconButtonWithTooltip
key="primary"
tooltipPlacement="top"
tooltipContent={tooltipContent}
src={InfoOutline}
iconAs={Icon}
alt="Info Popup"
onClick={() => {}}
variant="primary"
className="ml-1"
/>
)}
</span>
<FormattedMessage
id="admin.portal.people.management.page.subtitle"
defaultMessage="Monitor group learning progress, assign more courses, and invite members to new Learner Credit budgets."
description="Subtitle for people management zero state."
/>
{hasLearnerCredit && (
<FormattedMessage
id="admin.portal.people.management.page.subtitle.lc"
defaultMessage="Monitor group learning progress, assign more courses, and invite members to new Learner Credit budgets."
description="Subtitle for people management with learner credit."
/>
)}
{!hasLearnerCredit && hasOtherSubsidyTypes && (
<FormattedMessage
id="admin.portal.people.management.page.subtitle.noLc"
defaultMessage="Monitor group learning progress."
description="Subtitle for people management without learner credit."
/>
)}
</span>
<ActionRow.Spacer />
<Button iconBefore={Add} onClick={openModal}>
Expand All @@ -98,16 +85,24 @@ const PeopleManagementPage = () => {
/>
</h2>
<p className="mx-2">
<FormattedMessage
id="admin.portal.people.management.page.zerostate.card.subtitle"
defaultMessage="Once a group is created, you can track members' progress, assign extra courses, and invite them to additional budgets."
description="Detail message shown to admin benefits of creating a group."
/>
{hasLearnerCredit && (
<FormattedMessage
id="admin.portal.people.management.page.zerostate.card.subtitle.lc"
defaultMessage="Once a group is created, you can track members' progress, assign extra courses, and invite them to additional budgets."
description="Detail message shown to admin benefits of creating a group with learner credit."
/>
)}
{!hasLearnerCredit && hasOtherSubsidyTypes && (
<FormattedMessage
id="admin.portal.people.management.page.zerostate.card.subtitle.noLc"
defaultMessage="Once a group is created, you can track members' progress."
description="Detail message shown to admin benefits of creating a group without learner credit."
/>
)}
</p>
</span>
</Card>
</div>
)}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
render, screen,
} from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import thunk from 'redux-thunk';
import configureMockStore from 'redux-mock-store';
Expand All @@ -11,7 +9,7 @@ import { EnterpriseSubsidiesContext } from '../../EnterpriseSubsidiesContext';
import PeopleManagementPage from '..';

const mockStore = configureMockStore([thunk]);
const getMockStore = store => mockStore(store);
const getMockStore = (store) => mockStore(store);
const enterpriseSlug = 'test-enterprise';
const enterpriseUUID = '1234';
const initialStoreState = {
Expand All @@ -23,7 +21,12 @@ const initialStoreState = {
};

const defaultEnterpriseSubsidiesContextValue = {
enterpriseSubsidyTypes: ['budget', 'license'],
enterpriseSubsidyTypes: ['budget'],
isLoading: false,
};

const subsEnterpriseSubsidiesContextValue = {
enterpriseSubsidyTypes: ['license'],
isLoading: false,
};

Expand All @@ -46,9 +49,27 @@ const PeopleManagementPageWrapper = ({
describe('<PeopleManagementPage >', () => {
it('renders the PeopleManagementPage zero state', () => {
render(<PeopleManagementPageWrapper />);
expect(document.querySelector('h3').textContent).toEqual("Your organization's groups");
expect(screen.getByText("You don't have any groups yet.")).toBeInTheDocument();
expect(screen.getByText(
'Monitor group learning progress, assign more courses, and invite members to new Learner Credit budgets.',
)).toBeInTheDocument();
});
it('renders the PeopleManagementPage zero state without LC', () => {
const store = getMockStore(initialStoreState);
render(
<IntlProvider locale="en">
<Provider store={store}>
<EnterpriseSubsidiesContext.Provider value={subsEnterpriseSubsidiesContextValue}>
<PeopleManagementPage />
</EnterpriseSubsidiesContext.Provider>
</Provider>
</IntlProvider>,
);
expect(document.querySelector('h3').textContent).toEqual(
'Your Learner Credit groups',
"Your organization's groups",
);
expect(screen.getByText('You don\'t have any groups yet.')).toBeInTheDocument();
expect(screen.getByText("You don't have any groups yet.")).toBeInTheDocument();
expect(screen.getByText("Once a group is created, you can track members' progress.")).toBeInTheDocument();
});
});

0 comments on commit a2f86fa

Please sign in to comment.