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 - Section Publish (#61)
* feat: [2u-354] add publish modal, api and update tests * feat: [2u-354] refactor modal * fix: [2u-354] removed comments * fix: [2u-354] fix indents * fix: [2u-354] removed translates duplicates * fix: [2u-354] rename handlers
- Loading branch information
1 parent
f145e6f
commit 928e92e
Showing
13 changed files
with
415 additions
and
17 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* eslint-disable import/named */ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import { | ||
ModalDialog, | ||
Button, | ||
ActionRow, | ||
} from '@edx/paragon'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { getCurrentSection } from '../data/selectors'; | ||
import messages from './messages'; | ||
|
||
const PublishModal = ({ | ||
isOpen, | ||
onClose, | ||
onPublishSubmit, | ||
}) => { | ||
const intl = useIntl(); | ||
const { displayName, childInfo } = useSelector(getCurrentSection); | ||
const subSections = childInfo?.children || []; | ||
|
||
return ( | ||
<ModalDialog | ||
className="publish-modal" | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
hasCloseButton | ||
isFullscreenOnMobile | ||
> | ||
<ModalDialog.Header className="publish-modal__header"> | ||
<ModalDialog.Title> | ||
{intl.formatMessage(messages.title, { title: displayName })} | ||
</ModalDialog.Title> | ||
</ModalDialog.Header> | ||
<ModalDialog.Body> | ||
<p className="small">{intl.formatMessage(messages.description)}</p> | ||
{subSections.length ? subSections.map((subSection) => { | ||
const units = subSection.childInfo.children; | ||
|
||
return units.length ? ( | ||
<React.Fragment key={subSection.id}> | ||
<span className="small text-gray-400">{subSection.displayName}</span> | ||
{units.map((unit) => ( | ||
<div | ||
key={unit.id} | ||
className="small border border-light-400 p-2 publish-modal__subsection" | ||
> | ||
{unit.displayName} | ||
</div> | ||
))} | ||
</React.Fragment> | ||
) : null; | ||
}) : null} | ||
</ModalDialog.Body> | ||
<ModalDialog.Footer className="pt-1"> | ||
<ActionRow> | ||
<ModalDialog.CloseButton variant="tertiary"> | ||
{intl.formatMessage(messages.cancelButton)} | ||
</ModalDialog.CloseButton> | ||
<Button onClick={onPublishSubmit}> | ||
{intl.formatMessage(messages.publishButton)} | ||
</Button> | ||
</ActionRow> | ||
</ModalDialog.Footer> | ||
</ModalDialog> | ||
); | ||
}; | ||
|
||
PublishModal.propTypes = { | ||
isOpen: PropTypes.bool.isRequired, | ||
onClose: PropTypes.func.isRequired, | ||
onPublishSubmit: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default PublishModal; |
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,15 @@ | ||
.publish-modal { | ||
max-width: 33.6875rem; | ||
|
||
.pgn__modal-close-container { | ||
transform: translateY(.5rem); | ||
} | ||
|
||
.publish-modal__header { | ||
padding-top: 1.5rem; | ||
} | ||
|
||
.publish-modal__subsection:not(:last-child) { | ||
margin-bottom: .5rem; | ||
} | ||
} |
Oops, something went wrong.