Skip to content

Commit

Permalink
refactor: rebase upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Sep 30, 2024
1 parent d7444ef commit 5088ef4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/library-authoring/components/CollectionCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('<CollectionCard />', () => {
const openMenuItem = screen.getByRole('link', { name: 'Open' });
expect(openMenuItem).toBeInTheDocument();

expect(openMenuItem).toHaveAttribute('href', '/library/lb:org1:Demo_Course/collection/collection1/');
expect(openMenuItem).toHaveAttribute('href', '/library/lb:org1:Demo_Course/collection/collection-display-name/');
});

it('should show confirmation box, delete collection and show toast to undo deletion', async () => {
Expand All @@ -72,7 +72,7 @@ describe('<CollectionCard />', () => {

expect(screen.queryByText('Collection Display Formated Name')).toBeInTheDocument();
// Open menu
let menuBtn = await screen.findByRole('button', { name: messages.componentCardMenuAlt.defaultMessage });
let menuBtn = await screen.findByRole('button', { name: messages.collectionCardMenuAlt.defaultMessage });
userEvent.click(menuBtn);
// find and click delete menu option.
expect(screen.queryByText('Delete')).toBeInTheDocument();
Expand All @@ -87,7 +87,7 @@ describe('<CollectionCard />', () => {
expect(cancelBtn).not.toBeInTheDocument();

// Open menu
menuBtn = await screen.findByRole('button', { name: messages.componentCardMenuAlt.defaultMessage });
menuBtn = await screen.findByRole('button', { name: messages.collectionCardMenuAlt.defaultMessage });
userEvent.click(menuBtn);
// click on confirm button to delete
deleteBtn = await screen.findByRole('button', { name: 'Delete' });
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('<CollectionCard />', () => {

expect(screen.queryByText('Collection Display Formated Name')).toBeInTheDocument();
// Open menu
const menuBtn = await screen.findByRole('button', { name: messages.componentCardMenuAlt.defaultMessage });
const menuBtn = await screen.findByRole('button', { name: messages.collectionCardMenuAlt.defaultMessage });
userEvent.click(menuBtn);
// find and click delete menu option.
const deleteBtn = await screen.findByRole('button', { name: 'Delete' });
Expand Down
17 changes: 13 additions & 4 deletions src/library-authoring/components/CollectionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
useToggle,
} from '@openedx/paragon';
import { MoreVert } from '@openedx/paragon/icons';
import { useContext } from 'react';
import { Link } from 'react-router-dom';

import { type CollectionHit } from '../../search-manager';
Expand All @@ -19,11 +18,11 @@ import { useDeleteCollection, useRestoreCollection } from '../data/apiHooks';
import DeleteModal from '../../generic/delete-modal/DeleteModal';
import messages from './messages';

type CollectionCardProps = {
type CollectionMenuProps = {
collectionHit: CollectionHit,
};

const CollectionMenu = ({ collectionHit } : CollectionCardProps) => {
const CollectionMenu = ({ collectionHit } : CollectionMenuProps) => {
const intl = useIntl();
const { showToast } = useContext(ToastContext);
const [isDeleteModalOpen, openDeleteModal, closeDeleteModal] = useToggle(false);
Expand Down Expand Up @@ -68,10 +67,16 @@ const CollectionMenu = ({ collectionHit } : CollectionCardProps) => {
src={MoreVert}
iconAs={Icon}
variant="primary"
alt={intl.formatMessage(messages.componentCardMenuAlt)}
alt={intl.formatMessage(messages.collectionCardMenuAlt)}
data-testid="collection-card-menu-toggle"
/>
<Dropdown.Menu>
<Dropdown.Item
as={Link}
to={`/library/${collectionHit.contextKey}/collection/${collectionHit.blockId}/`}
>
<FormattedMessage {...messages.menuOpen} />
</Dropdown.Item>
<Dropdown.Item onClick={openDeleteModal}>
<FormattedMessage {...messages.deleteCollection} />
</Dropdown.Item>
Expand All @@ -92,6 +97,10 @@ const CollectionMenu = ({ collectionHit } : CollectionCardProps) => {
);
};

type CollectionCardProps = {
collectionHit: CollectionHit,
};

const CollectionCard = ({ collectionHit } : CollectionCardProps) => {
const intl = useIntl();
const {
Expand Down
1 change: 0 additions & 1 deletion src/search-manager/data/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ interface BaseContentHit {
displayName: string;
usageKey: string;
blockId: string;
usageKey: string;
/** The course or library ID */
contextKey: string;
org: string;
Expand Down

0 comments on commit 5088ef4

Please sign in to comment.