When content within a sequence was shorter than the height of the browser viewport, the `.sequence-container > .outline-sidebar-wrapper` element does not expand appropriately. This caused the course outline sidebar to be partially or completely hidden from view.
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import { useEffect, useState } from 'react';
|
|
import { getConfig } from '@edx/frontend-platform';
|
|
import PropTypes from 'prop-types';
|
|
import { getNotices } from './api';
|
|
/**
|
|
* This component uses the platform-plugin-notices plugin to function.
|
|
* If the user has an unacknowledged notice, they will be rerouted off
|
|
* course home and onto a full-screen notice page. If the plugin is not
|
|
* installed, or there are no notices, we just passthrough this component.
|
|
*/
|
|
const NoticesProvider = ({ children }) => {
|
|
const [isRedirected, setIsRedirected] = useState();
|
|
|
|
useEffect(() => {
|
|
async function getData() {
|
|
if (getConfig().ENABLE_NOTICES) {
|
|
const data = await getNotices();
|
|
if (data && data.results && data.results.length > 0) {
|
|
const { results } = data;
|
|
setIsRedirected(true);
|
|
window.location.replace(`${results[0]}?next=${window.location.href}`);
|
|
}
|
|
}
|
|
}
|
|
getData();
|
|
}, []);
|
|
|
|
return isRedirected === true ? null : children;
|
|
};
|
|
|
|
NoticesProvider.propTypes = {
|
|
children: PropTypes.node.isRequired,
|
|
};
|
|
|
|
export default NoticesProvider;
|