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.
- Loading branch information
Showing
15 changed files
with
518 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Stack } from '@edx/paragon'; | ||
import { FormattedMessage, injectIntl, useIntl } from '@edx/frontend-platform/i18n'; | ||
import messages from './messages'; | ||
import { DatepickerControl, DATEPICKER_TYPES } from '../../generic/datepicker-control'; | ||
|
||
const BasicTab = ({ releaseDate, setReleaseDate }) => { | ||
const intl = useIntl(); | ||
const onChange = (value) => { | ||
setReleaseDate(value); | ||
}; | ||
|
||
return ( | ||
<> | ||
<h3 className="mt-3"><FormattedMessage {...messages.releaseDateAndTime} /></h3> | ||
<hr /> | ||
<Stack direction="horizontal" gap={5}> | ||
<DatepickerControl | ||
type={DATEPICKER_TYPES.date} | ||
value={releaseDate} | ||
label={intl.formatMessage(messages.releaseDate)} | ||
controlName="state-date" | ||
onChange={(date) => onChange(date)} | ||
/> | ||
<DatepickerControl | ||
type={DATEPICKER_TYPES.time} | ||
value={releaseDate} | ||
label={intl.formatMessage(messages.releaseTimeUTC)} | ||
controlName="start-time" | ||
onChange={(date) => onChange(date)} | ||
/> | ||
</Stack> | ||
</> | ||
); | ||
}; | ||
|
||
BasicTab.propTypes = { | ||
releaseDate: PropTypes.string.isRequired, | ||
setReleaseDate: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default injectIntl(BasicTab); |
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,95 @@ | ||
/* eslint-disable import/named */ | ||
import React, { useEffect, useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import { | ||
ModalDialog, | ||
Button, | ||
ActionRow, | ||
Tab, | ||
Tabs, | ||
} from '@edx/paragon'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { VisibilityTypes } from '../../data/constants'; | ||
import { getCurrentSection } from '../data/selectors'; | ||
import messages from './messages'; | ||
import BasicTab from './BasicTab'; | ||
import VisibilityTab from './VisibilityTab'; | ||
|
||
const ConfigureModal = ({ | ||
isOpen, | ||
onClose, | ||
onConfigureSubmit, | ||
}) => { | ||
const intl = useIntl(); | ||
const { displayName, start: sectionStartDate, visibilityState } = useSelector(getCurrentSection); | ||
const [releaseDate, setReleaseDate] = useState(sectionStartDate); | ||
const [isVisibleToStaffOnly, setIsVisibleToStaffOnly] = useState(visibilityState === VisibilityTypes.STAFF_ONLY); | ||
const [saveButtonDisabled, setSaveButtonDisabled] = useState(true); | ||
|
||
useEffect(() => { | ||
setReleaseDate(sectionStartDate); | ||
}, [sectionStartDate]); | ||
|
||
useEffect(() => { | ||
setIsVisibleToStaffOnly(visibilityState === VisibilityTypes.STAFF_ONLY); | ||
}, [visibilityState]); | ||
|
||
useEffect(() => { | ||
const visibilityUnchanged = isVisibleToStaffOnly === (visibilityState === VisibilityTypes.STAFF_ONLY); | ||
setSaveButtonDisabled(visibilityUnchanged && releaseDate === sectionStartDate); | ||
}, [releaseDate, isVisibleToStaffOnly]); | ||
|
||
const handleSave = () => { | ||
onConfigureSubmit(isVisibleToStaffOnly, releaseDate); | ||
}; | ||
|
||
return ( | ||
<ModalDialog | ||
className="configure-modal" | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
hasCloseButton | ||
isFullscreenOnMobile | ||
> | ||
<ModalDialog.Header className="configure-modal__header"> | ||
<ModalDialog.Title> | ||
{intl.formatMessage(messages.title, { title: displayName })} | ||
</ModalDialog.Title> | ||
</ModalDialog.Header> | ||
<ModalDialog.Body className="configure-modal__body"> | ||
<Tabs> | ||
<Tab eventKey="basic" title={intl.formatMessage(messages.basicTabTitle)}> | ||
<BasicTab releaseDate={releaseDate} setReleaseDate={setReleaseDate} /> | ||
</Tab> | ||
<Tab eventKey="visibility" title={intl.formatMessage(messages.visibilityTabTitle)}> | ||
<VisibilityTab | ||
isVisibleToStaffOnly={isVisibleToStaffOnly} | ||
setIsVisibleToStaffOnly={setIsVisibleToStaffOnly} | ||
showWarning={visibilityState === VisibilityTypes.STAFF_ONLY} | ||
/> | ||
</Tab> | ||
</Tabs> | ||
</ModalDialog.Body> | ||
<ModalDialog.Footer className="pt-1"> | ||
<ActionRow> | ||
<ModalDialog.CloseButton variant="tertiary"> | ||
{intl.formatMessage(messages.cancelButton)} | ||
</ModalDialog.CloseButton> | ||
<Button onClick={handleSave} disabled={saveButtonDisabled}> | ||
{intl.formatMessage(messages.saveButton)} | ||
</Button> | ||
</ActionRow> | ||
</ModalDialog.Footer> | ||
</ModalDialog> | ||
); | ||
}; | ||
|
||
ConfigureModal.propTypes = { | ||
isOpen: PropTypes.bool.isRequired, | ||
onClose: PropTypes.func.isRequired, | ||
onConfigureSubmit: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default ConfigureModal; |
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,12 @@ | ||
.configure-modal { | ||
max-width: 33.6875rem; | ||
overflow: visible; | ||
|
||
.configure-modal__header { | ||
padding-top: 1.5rem; | ||
} | ||
|
||
.configure-modal__body { | ||
overflow: visible; | ||
} | ||
} |
Oops, something went wrong.