forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Course outline - Content empty (#72)
* feat: [2u-324] add component * feat: [2u-324] add translates * feat: [2u-324] update tests * feat: [2u-324] update branch * fix: [2u-324] fixed empty handler
- Loading branch information
1 parent
ed5da64
commit 5219c3c
Showing
8 changed files
with
135 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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 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
34 changes: 17 additions & 17 deletions
34
src/course-outline/__mocks__/courseOutlineIndexWithoutSections.js
This file contains 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 |
---|---|---|
@@ -1,25 +1,25 @@ | ||
module.exports = { | ||
courseReleaseDate: 'Set Date', | ||
courseStructure: {}, | ||
deprecatedBlocksInfo: { | ||
deprecatedEnabledBlockTypes: [], | ||
course_release_date: 'Set Date', | ||
course_structure: {}, | ||
deprecated_blocks_info: { | ||
deprecated_enabled_block_types: [], | ||
blocks: [], | ||
advanceSettingsUrl: '/settings/advanced/course-v1:edx+101+y76', | ||
advance_settings_url: '/settings/advanced/course-v1:edx+101+y76', | ||
}, | ||
discussionsIncontextFeedbackUrl: '', | ||
discussionsIncontextLearnmoreUrl: '', | ||
initialState: { | ||
expandedLocators: [ | ||
discussions_incontext_feedback_url: '', | ||
discussions_incontext_learnmore_url: '', | ||
initial_state: { | ||
expanded_locators: [ | ||
'block-v1:edx+101+y76+type@chapter+block@03de0adc9d1c4cc097062d80eb04abf6', | ||
'block-v1:edx+101+y76+type@sequential+block@8a85e287e30a47e98d8c1f37f74a6a9d', | ||
], | ||
locatorToShow: 'block-v1:edx+101+y76+type@chapter+block@03de0adc9d1c4cc097062d80eb04abf6', | ||
locator_to_show: 'block-v1:edx+101+y76+type@chapter+block@03de0adc9d1c4cc097062d80eb04abf6', | ||
}, | ||
languageCode: 'en', | ||
lmsLink: '//localhost:18000/courses/course-v1:edx+101+y76/jump_to/block-v1:edx+101+y76+type@course+block@course', | ||
mfeProctoredExamSettingsUrl: '', | ||
notificationDismissUrl: '/course_notifications/course-v1:edx+101+y76/2', | ||
proctoringErrors: [], | ||
reindexLink: '/course/course-v1:edx+101+y76/search_reindex', | ||
rerunNotificationId: 2, | ||
language_code: 'en', | ||
lms_link: '//localhost:18000/courses/course-v1:edx+101+y76/jump_to/block-v1:edx+101+y76+type@course+block@course', | ||
mfe_proctored_exam_settings_url: '', | ||
notification_dismiss_url: '/course_notifications/course-v1:edx+101+y76/2', | ||
proctoring_errors: [], | ||
reindex_link: '/course/course-v1:edx+101+y76/search_reindex', | ||
rerun_notification_id: 2, | ||
}; |
31 changes: 31 additions & 0 deletions
31
src/course-outline/empty-placeholder/EmptyContent.test.jsx
This file contains 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,31 @@ | ||
import React from 'react'; | ||
import { render, fireEvent } from '@testing-library/react'; | ||
import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
|
||
import EmptyPlaceholder from './EmptyPlaceholder'; | ||
import messages from './messages'; | ||
|
||
const onCreateNewSectionMock = jest.fn(); | ||
|
||
const renderComponent = () => render( | ||
<IntlProvider locale="en"> | ||
<EmptyPlaceholder onCreateNewSection={onCreateNewSectionMock} /> | ||
</IntlProvider>, | ||
); | ||
|
||
describe('<EmptyPlaceholder />', () => { | ||
it('renders EmptyPlaceholder component correctly', () => { | ||
const { getByText, getByRole } = renderComponent(); | ||
|
||
expect(getByText(messages.title.defaultMessage)).toBeInTheDocument(); | ||
expect(getByRole('button', { name: messages.button.defaultMessage })).toBeInTheDocument(); | ||
}); | ||
|
||
it('calls the onCreateNewSection function when the button is clicked', () => { | ||
const { getByRole } = renderComponent(); | ||
|
||
const addButton = getByRole('button', { name: messages.button.defaultMessage }); | ||
fireEvent.click(addButton); | ||
expect(onCreateNewSectionMock).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
This file contains 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,39 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import { Add as IconAdd } from '@edx/paragon/icons/es5'; | ||
import { Button, OverlayTrigger, Tooltip } from '@edx/paragon'; | ||
|
||
import messages from './messages'; | ||
|
||
const EmptyPlaceholder = ({ onCreateNewSection }) => { | ||
const intl = useIntl(); | ||
|
||
return ( | ||
<div className="outline-empty-placeholder bg-gray-100" data-testid="empty-placeholder"> | ||
<p className="mb-0 text-gray-500">{intl.formatMessage(messages.title)}</p> | ||
<OverlayTrigger | ||
placement="bottom" | ||
overlay={( | ||
<Tooltip id={intl.formatMessage(messages.tooltip)}> | ||
{intl.formatMessage(messages.tooltip)} | ||
</Tooltip> | ||
)} | ||
> | ||
<Button | ||
variant="outline-success" | ||
iconBefore={IconAdd} | ||
onClick={onCreateNewSection} | ||
> | ||
{intl.formatMessage(messages.button)} | ||
</Button> | ||
</OverlayTrigger> | ||
</div> | ||
); | ||
}; | ||
|
||
EmptyPlaceholder.propTypes = { | ||
onCreateNewSection: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default EmptyPlaceholder; |
10 changes: 10 additions & 0 deletions
10
src/course-outline/empty-placeholder/EmptyPlaceholder.scss
This file contains 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,10 @@ | ||
.outline-empty-placeholder { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 1.25rem; | ||
border: .0625rem solid $gray-200; | ||
border-radius: .375rem; | ||
box-shadow: inset inset 0 1px .125rem 1px $gray-200; | ||
padding: 2.5rem; | ||
} |
This file contains 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,18 @@ | ||
import { defineMessages } from '@edx/frontend-platform/i18n'; | ||
|
||
const messages = defineMessages({ | ||
title: { | ||
id: 'course-authoring.course-outline.empty-placeholder.title', | ||
defaultMessage: 'You haven\'t added any content to this course yet.', | ||
}, | ||
button: { | ||
id: 'course-authoring.course-outline.empty-placeholder.button.new-section', | ||
defaultMessage: 'New section', | ||
}, | ||
tooltip: { | ||
id: 'course-authoring.course-outline.empty-placeholder.button.tooltip', | ||
defaultMessage: 'Click to add a new section', | ||
}, | ||
}); | ||
|
||
export default messages; |