-
Notifications
You must be signed in to change notification settings - Fork 196
feat: add course import page [FC-0112] #2580
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
Merged
ChrisChV
merged 14 commits into
openedx:master
from
open-craft:rpenido/FAL-4265/import-home
Nov 7, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ca3c068
feat: add course import page
rpenido 868084d
fix: change loading placeholder
rpenido 9a97f25
refactor: renaming migration > import
rpenido 262754c
test: move `initializeMocks` to `beforeEach`
rpenido 42a31b0
test: replace `query..` by `get..`
rpenido 85834d1
test: add `await` to `userEvent.click` and remove `waitFor`
rpenido f17820b
fix: pass `readOnly` flag to `Header`
rpenido b843763
fix: add intl to `Previous Imports` title
rpenido 0878749
test: removing unused import
rpenido cab000a
fix: remove custom css for help sidebar
rpenido ab24e7c
fix: remove unused class and padding
rpenido 73948ab
fix: style on `ImportedCourseCard`
rpenido fc79cb1
fix: task_status string for `In Progress`
rpenido 6b3827b
fix: open course in new page
rpenido File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/library-authoring/import-course/CourseImportHomePage.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { | ||
| initializeMocks, | ||
| render as testRender, | ||
| screen, | ||
| } from '@src/testUtils'; | ||
|
|
||
| import { LibraryProvider } from '../common/context/LibraryContext'; | ||
| import { | ||
| mockContentLibrary, | ||
| mockGetCourseImports, | ||
| } from '../data/api.mocks'; | ||
| import { CourseImportHomePage } from './CourseImportHomePage'; | ||
|
|
||
| mockContentLibrary.applyMock(); | ||
| mockGetCourseImports.applyMock(); | ||
|
|
||
| const mockNavigate = jest.fn(); | ||
| jest.mock('react-router-dom', () => ({ | ||
| ...jest.requireActual('react-router-dom'), | ||
| useNavigate: () => mockNavigate, | ||
| })); | ||
|
|
||
| const render = (libraryId: string) => ( | ||
| testRender( | ||
| <CourseImportHomePage />, | ||
| { | ||
| extraWrapper: ({ children }: { children: React.ReactNode }) => ( | ||
| <LibraryProvider libraryId={libraryId}> | ||
| {children} | ||
| </LibraryProvider> | ||
| ), | ||
| path: '/libraries/:libraryId/import-course', | ||
| params: { libraryId }, | ||
| }, | ||
| ) | ||
| ); | ||
|
|
||
| describe('<CourseImportHomePage>', () => { | ||
| beforeEach(() => { | ||
| initializeMocks(); | ||
| }); | ||
|
|
||
| it('should render the library course import home page', async () => { | ||
| render(mockGetCourseImports.libraryId); | ||
| expect(await screen.findByRole('heading', { name: /Tools.*Import/ })).toBeInTheDocument(); // Header | ||
| expect(screen.getByRole('heading', { name: 'Previous Imports' })).toBeInTheDocument(); | ||
| expect(screen.getAllByRole('link', { name: /DemoX 2025 T[0-5]/ })).toHaveLength(4); | ||
| }); | ||
|
|
||
| it('should render the empty state', async () => { | ||
| render(mockGetCourseImports.emptyLibraryId); | ||
| expect(await screen.findByRole('heading', { name: /Tools.*Import/ })).toBeInTheDocument(); // Header | ||
| expect(screen.queryByRole('heading', { name: 'Previous Imports' })).not.toBeInTheDocument(); | ||
| expect(screen.getByText('You have not imported any courses into this library.')).toBeInTheDocument(); | ||
| }); | ||
| }); |
93 changes: 93 additions & 0 deletions
93
src/library-authoring/import-course/CourseImportHomePage.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import { | ||
| Button, | ||
| Card, | ||
| Container, | ||
| Layout, | ||
| Stack, | ||
| } from '@openedx/paragon'; | ||
| import { Add } from '@openedx/paragon/icons'; | ||
| import { Helmet } from 'react-helmet'; | ||
|
|
||
| import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n'; | ||
| import Loading from '@src/generic/Loading'; | ||
| import SubHeader from '@src/generic/sub-header/SubHeader'; | ||
| import Header from '@src/header'; | ||
|
|
||
| import { useLibraryContext } from '../common/context/LibraryContext'; | ||
| import { useCourseImports } from '../data/apiHooks'; | ||
| import { HelpSidebar } from './HelpSidebar'; | ||
| import { ImportedCourseCard } from './ImportedCourseCard'; | ||
| import messages from './messages'; | ||
|
|
||
| const EmptyState = () => ( | ||
| <Container size="md" className="py-6"> | ||
| <Card> | ||
| <Stack direction="horizontal" gap={3} className="my-6 justify-content-center"> | ||
| <FormattedMessage {...messages.emptyStateText} /> | ||
| <Button iconBefore={Add} disabled> | ||
| <FormattedMessage {...messages.emptyStateButtonText} /> | ||
| </Button> | ||
| </Stack> | ||
| </Card> | ||
| </Container> | ||
| ); | ||
|
|
||
| export const CourseImportHomePage = () => { | ||
| const intl = useIntl(); | ||
| const { libraryId, libraryData, readOnly } = useLibraryContext(); | ||
| const { data: courseImports } = useCourseImports(libraryId); | ||
|
|
||
| if (!courseImports || !libraryData) { | ||
| return <Loading />; | ||
| } | ||
|
|
||
| return ( | ||
| <div className="d-flex"> | ||
| <div className="flex-grow-1"> | ||
| <Helmet> | ||
| <title>{libraryData.title} | {process.env.SITE_NAME}</title> | ||
| </Helmet> | ||
| <Header | ||
| number={libraryData.slug} | ||
| title={libraryData.title} | ||
| org={libraryData.org} | ||
| contextId={libraryId} | ||
| isLibrary | ||
| readOnly={readOnly} | ||
| containerProps={{ | ||
| size: undefined, | ||
| }} | ||
| /> | ||
| <Container className="mt-4 mb-5"> | ||
| <div className="px-4 bg-light-200 border-bottom"> | ||
| <SubHeader | ||
| title={intl.formatMessage(messages.pageTitle)} | ||
| subtitle={intl.formatMessage(messages.pageSubtitle)} | ||
| hideBorder | ||
| /> | ||
| </div> | ||
| <Layout xs={[{ span: 9 }, { span: 3 }]}> | ||
| <Layout.Element> | ||
| {courseImports.length ? ( | ||
| <Stack gap={3} className="pl-4 mt-4"> | ||
| <h3> | ||
| <FormattedMessage {...messages.courseImportPreviousImports} /> | ||
| </h3> | ||
| {courseImports.map((courseImport) => ( | ||
| <ImportedCourseCard | ||
| key={courseImport.source.key} | ||
| courseImport={courseImport} | ||
| /> | ||
| ))} | ||
| </Stack> | ||
| ) : (<EmptyState />)} | ||
| </Layout.Element> | ||
| <Layout.Element> | ||
| <HelpSidebar /> | ||
| </Layout.Element> | ||
| </Layout> | ||
| </Container> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { FormattedMessage } from '@edx/frontend-platform/i18n'; | ||
| import { Icon, Stack } from '@openedx/paragon'; | ||
| import { Question } from '@openedx/paragon/icons'; | ||
| import { Paragraph } from '@src/utils'; | ||
|
|
||
| import messages from './messages'; | ||
|
|
||
| export const HelpSidebar = () => ( | ||
| <div className="pt-3 border-left h-100"> | ||
| <Stack gap={1} direction="horizontal" className="pl-4 h4 text-primary-700"> | ||
| <Icon src={Question} /> | ||
| <span> | ||
| <FormattedMessage {...messages.helpAndSupportTitle} /> | ||
| </span> | ||
| </Stack> | ||
| <hr /> | ||
| <Stack className="pl-4 pr-4"> | ||
| <Stack> | ||
| <span className="h5"> | ||
| <FormattedMessage {...messages.helpAndSupportFirstQuestionTitle} /> | ||
| </span> | ||
| <span className="x-small"> | ||
| <FormattedMessage | ||
| {...messages.helpAndSupportFirstQuestionBody} | ||
| values={{ p: Paragraph }} | ||
| /> | ||
| </span> | ||
| </Stack> | ||
| <hr /> | ||
| <Stack> | ||
| <span className="h5"> | ||
| <FormattedMessage {...messages.helpAndSupportSecondQuestionTitle} /> | ||
| </span> | ||
| <span className="x-small"> | ||
| <FormattedMessage | ||
| {...messages.helpAndSupportSecondQuestionBody} | ||
| values={{ p: Paragraph }} | ||
| /> | ||
| </span> | ||
| </Stack> | ||
| </Stack> | ||
| <hr className="w-100" /> | ||
| </div> | ||
| ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass
readOnlyfrom library context here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fixed here: f17820b