Skip to content

Commit

Permalink
feat: lms live link
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Nov 22, 2023
1 parent 689bf21 commit af5061d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import messages from './messages';
const handleNewSectionMock = jest.fn();
const handleReIndexMock = jest.fn();
const handleExpandAllMock = jest.fn();
const handleViewLiveMock = jest.fn();

const headerNavigationsActions = {
handleNewSection: handleNewSectionMock,
handleReIndex: handleReIndexMock,
handleExpandAll: handleExpandAllMock,
handleViewLive: handleViewLiveMock,
lmsLink: '',
};

const renderComponent = (props) => render(
Expand Down Expand Up @@ -62,10 +61,6 @@ describe('<HeaderNavigations />', () => {
const expandAllButton = getByRole('button', { name: messages.expandAllButton.defaultMessage });
fireEvent.click(expandAllButton);
expect(handleExpandAllMock).toHaveBeenCalledTimes(1);

const viewLiveButton = getByRole('button', { name: messages.viewLiveButton.defaultMessage });
fireEvent.click(viewLiveButton);
expect(handleViewLiveMock).toHaveBeenCalledTimes(1);
});

it('render collapse button correctly', () => {
Expand Down
7 changes: 4 additions & 3 deletions src/course-outline/header-navigations/HeaderNavigations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const HeaderNavigations = ({
}) => {
const intl = useIntl();
const {
handleNewSection, handleReIndex, handleExpandAll, handleViewLive,
handleNewSection, handleReIndex, handleExpandAll, lmsLink,
} = headerNavigationsActions;

return (
Expand Down Expand Up @@ -74,7 +74,8 @@ const HeaderNavigations = ({
)}
>
<Button
onClick={handleViewLive}
href={lmsLink}
target="_blank"
variant="outline-primary"
>
{intl.formatMessage(messages.viewLiveButton)}
Expand All @@ -92,7 +93,7 @@ HeaderNavigations.propTypes = {
handleNewSection: PropTypes.func.isRequired,
handleReIndex: PropTypes.func.isRequired,
handleExpandAll: PropTypes.func.isRequired,
handleViewLive: PropTypes.func.isRequired,
lmsLink: PropTypes.string.isRequired,
}).isRequired,
};

Expand Down
6 changes: 2 additions & 4 deletions src/course-outline/hooks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
const useCourseOutline = ({ courseId }) => {
const dispatch = useDispatch();

const { reindexLink } = useSelector(getOutlineIndexData);
const { reindexLink, lmsLink } = useSelector(getOutlineIndexData);
const { outlineIndexLoadingStatus, reIndexLoadingStatus } = useSelector(getLoadingStatus);
const statusBarData = useSelector(getStatusBarData);
const savingStatus = useSelector(getSavingStatus);
Expand All @@ -48,9 +48,7 @@ const useCourseOutline = ({ courseId }) => {
handleExpandAll: () => {
setSectionsExpanded((prevState) => !prevState);
},
handleViewLive: () => {
// TODO add handler
},
lmsLink,
};

const handleEnableHighlightsSubmit = () => {
Expand Down

0 comments on commit af5061d

Please sign in to comment.