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: delete collection [FC-0062] #1333

Merged
merged 19 commits into from
Oct 8, 2024
Merged
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
Prev Previous commit
Next Next commit
refactor: rebase upstream
navinkarkera committed Oct 8, 2024
commit ed6b0db77e8e146b056359cc7c540c5f2794a146
8 changes: 4 additions & 4 deletions src/library-authoring/components/CollectionCard.test.tsx
Original file line number Diff line number Diff line change
@@ -61,7 +61,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 () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for testing this feature so thoroughly!

@@ -71,7 +71,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();
@@ -86,7 +86,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' });
@@ -120,7 +120,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' });
16 changes: 13 additions & 3 deletions src/library-authoring/components/CollectionCard.tsx
Original file line number Diff line number Diff line change
@@ -18,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);
@@ -67,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>
@@ -91,6 +97,10 @@ const CollectionMenu = ({ collectionHit } : CollectionCardProps) => {
);
};

type CollectionCardProps = {
collectionHit: CollectionHit,
};

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