Skip to content

Commit

Permalink
fix: some navigation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Oct 11, 2024
1 parent 08a7e48 commit be2765d
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 25 deletions.
22 changes: 21 additions & 1 deletion src/library-authoring/LibraryAuthoringPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { StudioFooter } from '@edx/frontend-component-footer';
import { useIntl } from '@edx/frontend-platform/i18n';
import {
Badge,
Breadcrumb,
Button,
Container,
Stack,
Expand All @@ -13,6 +14,7 @@ import {
} from '@openedx/paragon';
import { Add, InfoOutline } from '@openedx/paragon/icons';
import {
Link,
useLocation,
useNavigate,
useSearchParams,
Expand Down Expand Up @@ -186,6 +188,23 @@ const LibraryAuthoringPage = () => {
}
};

const breadcumbs = componentPickerMode ? (
<Breadcrumb
links={[
{
label: intl.formatMessage(messages.returnToLibrarySelection),
onClick: () => {
navigate({

Check warning on line 197 in src/library-authoring/LibraryAuthoringPage.tsx

View check run for this annotation

Codecov / codecov/patch

src/library-authoring/LibraryAuthoringPage.tsx#L196-L197

Added lines #L196 - L197 were not covered by tests
pathname: '/component-picker',
search: searchParams.toString(),
});
},
},
]}
linkAs={Link}
/>
) : undefined;

return (
<div className="d-flex">
<div className="flex-grow-1">
Expand All @@ -208,7 +227,8 @@ const LibraryAuthoringPage = () => {
>
<SubHeader
title={<SubHeaderTitle title={libraryData.title} />}
subtitle={intl.formatMessage(messages.headingSubtitle)}
subtitle={!componentPickerMode ? intl.formatMessage(messages.headingSubtitle) : undefined}
breadcrumbs={breadcumbs}
headerActions={<HeaderActions />}
/>
<SearchKeywordsField className="w-50" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const LibraryCollectionPage = () => {
ariaLabel={intl.formatMessage(messages.breadcrumbsAriaLabel)}
links={[
{
label: intl.formatMessage(messages.returnToLibrarySelection),
label: intl.formatMessage(messages.returnToLibrary),
onClick: () => { setCollectionId(undefined); },

Check warning on line 166 in src/library-authoring/collections/LibraryCollectionPage.tsx

View check run for this annotation

Codecov / codecov/patch

src/library-authoring/collections/LibraryCollectionPage.tsx#L166

Added line #L166 was not covered by tests
},
]}
Expand Down
8 changes: 4 additions & 4 deletions src/library-authoring/collections/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ const messages = defineMessages({
defaultMessage: 'Edit collection title',
description: 'Alt text for edit collection title icon button',
},
returnToLibrarySelection: {
id: 'course-authoring.library-authoring.collection.component-picker.return-to-library-selection',
defaultMessage: '← Change Library',
description: 'Breadcrumbs link to return to library selection',
returnToLibrary: {
id: 'course-authoring.library-authoring.collection.component-picker.return-to-library',
defaultMessage: '← Back to Library',
description: 'Breadcrumbs link to return to library',
},
});

Expand Down
16 changes: 8 additions & 8 deletions src/library-authoring/component-picker/ComponentPicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('<ComponentPicker />', () => {
fireEvent.click(screen.getByText('Next'));

// Wait for the content library to load
expect(await screen.findByText('Content library')).toBeInTheDocument();
await screen.findByText(/← Change Library/i);
expect(await screen.findByText('Test Library 1')).toBeInTheDocument();

// Click the add component from the component card
Expand All @@ -87,7 +87,7 @@ describe('<ComponentPicker />', () => {
fireEvent.click(screen.getByText('Next'));

// Wait for the content library to load
expect(await screen.findByText('Content library')).toBeInTheDocument();
await screen.findByText(/← Change Library/i);
expect(await screen.findByText('Test Library 1')).toBeInTheDocument();

// Click the add component from the component card
Expand All @@ -113,7 +113,7 @@ describe('<ComponentPicker />', () => {
fireEvent.click(screen.getByText('Next'));

// Wait for the content library to load
expect(await screen.findByText('Content library')).toBeInTheDocument();
await screen.findByText(/← Change Library/i);
expect(await screen.findByText('Test Library 1')).toBeInTheDocument();

// Click on the component card to open the sidebar
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('<ComponentPicker />', () => {
fireEvent.click(screen.getByText('Next'));

// Wait for the content library to load
expect(await screen.findByText('Content library')).toBeInTheDocument();
await screen.findByText(/← Change Library/i);
expect(await screen.findByText('Test Library 1')).toBeInTheDocument();

// Click on the component card to open the sidebar
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('<ComponentPicker />', () => {
fireEvent.click(screen.getByText('Next'));

// Wait for the content library to load
expect(await screen.findByText('Content library')).toBeInTheDocument();
await screen.findByText(/← Change Library/i);
expect(await screen.findByText('Test Library 1')).toBeInTheDocument();

// Click on the collection card to open the sidebar
Expand All @@ -190,7 +190,7 @@ describe('<ComponentPicker />', () => {
fireEvent.click(within(sidebar).getByRole('button', { name: 'Open' }));

// Wait for the collection to load
await screen.findByText(/Change Library/i);
await screen.findByText(/Back to Library/i);
await screen.findByText('Introduction to Testing');

// Click the add component from the component card
Expand All @@ -215,7 +215,7 @@ describe('<ComponentPicker />', () => {
fireEvent.click(screen.getByText('Next'));

// Wait for the content library to load
expect(await screen.findByText('Content library')).toBeInTheDocument();
await screen.findByText(/← Change Library/i);
expect(await screen.findByText('Test Library 1')).toBeInTheDocument();

// Click on the collection card to open the sidebar
Expand All @@ -230,7 +230,7 @@ describe('<ComponentPicker />', () => {
fireEvent.click(within(sidebar).getByRole('button', { name: 'Open' }));

// Wait for the collection to load
await screen.findByText(/Change Library/i);
await screen.findByText(/Back to Library/i);
await screen.findByText('Introduction to Testing');

// Click on the collection card to open the sidebar
Expand Down
6 changes: 0 additions & 6 deletions src/library-authoring/component-picker/ComponentPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ export const ComponentPicker = () => {
{intl.formatMessage(messages.selectLibraryNextButton)}
</Button>
</Stepper.ActionRow>

<Stepper.ActionRow eventKey="pick-components">
<Button variant="outline-primary" onClick={() => setCurrentStep('select-library')}>
{intl.formatMessage(messages.pickComponentPreviousButton)}
</Button>
</Stepper.ActionRow>
</div>
</Stepper>
);
Expand Down
5 changes: 0 additions & 5 deletions src/library-authoring/component-picker/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ const messages = defineMessages({
defaultMessage: 'Next',
description: 'The text for the next button in the select library component',
},
pickComponentPreviousButton: {
id: 'course-authoring.library-authoring.pick-components.previous-button',
defaultMessage: 'Previous',
description: 'The text for the previous button in the pick component component',
},
});

export default messages;
5 changes: 5 additions & 0 deletions src/library-authoring/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ const messages = defineMessages({
defaultMessage: 'Read Only',
description: 'Text in badge when the user has read only access',
},
returnToLibrarySelection: {
id: 'course-authoring.library-authoring.pick-components.return-to-library-selection',
defaultMessage: '← Change Library',
description: 'Breadcrumbs link to return to library selection',
},
});

export default messages;

0 comments on commit be2765d

Please sign in to comment.