Skip to content

Commit

Permalink
chore: update with latest master
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald committed Aug 27, 2024
2 parents f36b218 + d99a09e commit 7d73945
Show file tree
Hide file tree
Showing 25 changed files with 377 additions and 181 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ENABLE_UNIT_PAGE=false
ENABLE_ASSETS_PAGE=false
ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN=false
ENABLE_TAGGING_TAXONOMY_PAGES=true
ENABLE_CERTIFICATE_PAGE=true
BBB_LEARN_MORE_URL=''
HOTJAR_APP_ID=''
HOTJAR_VERSION=6
Expand Down
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ENABLE_TEAM_TYPE_SETTING=false
ENABLE_UNIT_PAGE=false
ENABLE_ASSETS_PAGE=false
ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN=true
ENABLE_CERTIFICATE_PAGE=true
ENABLE_NEW_VIDEO_UPLOAD_PAGE=true
ENABLE_TAGGING_TAXONOMY_PAGES=true
BBB_LEARN_MORE_URL=''
Expand Down
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ENABLE_TEAM_TYPE_SETTING=false
ENABLE_UNIT_PAGE=true
ENABLE_ASSETS_PAGE=false
ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN=true
ENABLE_CERTIFICATE_PAGE=true
ENABLE_TAGGING_TAXONOMY_PAGES=true
BBB_LEARN_MORE_URL=''
INVITE_STUDENTS_EMAIL_TO="[email protected]"
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ on:
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
node: [18, 20]
continue-on-error: ${{ matrix.node == 20 }}

steps:
- uses: actions/checkout@v4
- name: Setup Nodejs Env
run: echo "NODE_VER=`cat .nvmrc`" >> $GITHUB_ENV
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VER }}
node-version: ${{ matrix.node }}
- run: make validate.ci
- name: Upload coverage
uses: codecov/codecov-action@v4
Expand Down
2 changes: 1 addition & 1 deletion src/CourseAuthoringRoutes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const CourseAuthoringRoutes = () => {
/>
<Route
path="certificates"
element={<PageWrap><Certificates courseId={courseId} /></PageWrap>}
element={getConfig().ENABLE_CERTIFICATE_PAGE === 'true' ? <PageWrap><Certificates courseId={courseId} /></PageWrap> : null}
/>
<Route
path="textbooks"
Expand Down
4 changes: 1 addition & 3 deletions src/generic/processing-notification/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { Badge, Icon } from '@openedx/paragon';
import { Settings as IconSettings } from '@openedx/paragon/icons';
import { capitalize } from 'lodash';

import { NOTIFICATION_MESSAGES } from '../../constants';

const ProcessingNotification = ({ isShow, title }) => (
<Badge
className={classNames('processing-notification', {
Expand All @@ -24,7 +22,7 @@ const ProcessingNotification = ({ isShow, title }) => (

ProcessingNotification.propTypes = {
isShow: PropTypes.bool.isRequired,
title: PropTypes.oneOf(Object.values(NOTIFICATION_MESSAGES)).isRequired,
title: PropTypes.string.isRequired,
};

export default ProcessingNotification;
8 changes: 8 additions & 0 deletions src/generic/toast-context/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('<ToastProvider />', () => {
},
});
store = initializeStore();
jest.useFakeTimers();
});

afterEach(() => {
Expand All @@ -61,6 +62,13 @@ describe('<ToastProvider />', () => {
expect(await screen.findByText('This is the toast!')).toBeInTheDocument();
});

it('should close toast after 5000ms', async () => {
render(<RootWrapper><TestComponentToShow /></RootWrapper>);
expect(await screen.findByText('This is the toast!')).toBeInTheDocument();
jest.advanceTimersByTime(6000);
expect(screen.queryByText('This is the toast!')).not.toBeInTheDocument();
});

it('should close toast', async () => {
render(<RootWrapper><TestComponentToClose /></RootWrapper>);
expect(await screen.findByText('Content')).toBeInTheDocument();
Expand Down
15 changes: 10 additions & 5 deletions src/generic/toast-context/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Toast } from '@openedx/paragon';

import ProcessingNotification from '../processing-notification';

export interface ToastContextData {
toastMessage: string | null;
Expand Down Expand Up @@ -35,7 +36,13 @@ export const ToastProvider = (props: ToastProviderProps) => {
setToastMessage(null);
}, []);

const showToast = React.useCallback((message) => setToastMessage(message), [setToastMessage]);
const showToast = React.useCallback((message) => {
setToastMessage(message);
// Close the toast after 5 seconds
setTimeout(() => {
setToastMessage(null);
}, 5000);
}, [setToastMessage]);
const closeToast = React.useCallback(() => setToastMessage(null), [setToastMessage]);

const context = React.useMemo(() => ({
Expand All @@ -48,9 +55,7 @@ export const ToastProvider = (props: ToastProviderProps) => {
<ToastContext.Provider value={context}>
{props.children}
{ toastMessage && (
<Toast show={toastMessage !== null} onClose={closeToast}>
{toastMessage}
</Toast>
<ProcessingNotification isShow={toastMessage !== null} title={toastMessage} />
)}
</ToastContext.Provider>
);
Expand Down
57 changes: 31 additions & 26 deletions src/header/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,37 @@ export const getContentMenuItems = ({ studioBaseUrl, courseId, intl }) => {
return items;
};

export const getSettingMenuItems = ({ studioBaseUrl, courseId, intl }) => ([
{
href: `${studioBaseUrl}/settings/details/${courseId}`,
title: intl.formatMessage(messages['header.links.scheduleAndDetails']),
},
{
href: `${studioBaseUrl}/settings/grading/${courseId}`,
title: intl.formatMessage(messages['header.links.grading']),
},
{
href: `${studioBaseUrl}/course_team/${courseId}`,
title: intl.formatMessage(messages['header.links.courseTeam']),
},
{
href: `${studioBaseUrl}/group_configurations/${courseId}`,
title: intl.formatMessage(messages['header.links.groupConfigurations']),
},
{
href: `${studioBaseUrl}/settings/advanced/${courseId}`,
title: intl.formatMessage(messages['header.links.advancedSettings']),
},
{
href: `${studioBaseUrl}/certificates/${courseId}`,
title: intl.formatMessage(messages['header.links.certificates']),
},
]);
export const getSettingMenuItems = ({ studioBaseUrl, courseId, intl }) => {
const items = [
{
href: `${studioBaseUrl}/settings/details/${courseId}`,
title: intl.formatMessage(messages['header.links.scheduleAndDetails']),
},
{
href: `${studioBaseUrl}/settings/grading/${courseId}`,
title: intl.formatMessage(messages['header.links.grading']),
},
{
href: `${studioBaseUrl}/course_team/${courseId}`,
title: intl.formatMessage(messages['header.links.courseTeam']),
},
{
href: `${studioBaseUrl}/group_configurations/${courseId}`,
title: intl.formatMessage(messages['header.links.groupConfigurations']),
},
{
href: `${studioBaseUrl}/settings/advanced/${courseId}`,
title: intl.formatMessage(messages['header.links.advancedSettings']),
},
];
if (getConfig().ENABLE_CERTIFICATE_PAGE === 'true') {
items.push({
href: `${studioBaseUrl}/certificates/${courseId}`,
title: intl.formatMessage(messages['header.links.certificates']),
});
}
return items;
};

export const getToolsMenuItems = ({ studioBaseUrl, courseId, intl }) => ([
{
Expand Down
21 changes: 20 additions & 1 deletion src/header/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getConfig, setConfig } from '@edx/frontend-platform';
import { getContentMenuItems, getToolsMenuItems } from './utils';
import { getContentMenuItems, getToolsMenuItems, getSettingMenuItems } from './utils';

const props = {
studioBaseUrl: 'UrLSTuiO',
Expand Down Expand Up @@ -29,6 +29,25 @@ describe('header utils', () => {
});
});

describe('getSettingsMenuitems', () => {
it('should include certificates option', () => {
setConfig({
...getConfig(),
ENABLE_CERTIFICATE_PAGE: 'true',
});
const actualItems = getSettingMenuItems(props);
expect(actualItems).toHaveLength(6);
});
it('should not include certificates option', () => {
setConfig({
...getConfig(),
ENABLE_CERTIFICATE_PAGE: 'false',
});
const actualItems = getSettingMenuItems(props);
expect(actualItems).toHaveLength(5);
});
});

describe('getToolsMenuItems', () => {
it('should include export tags option', () => {
setConfig({
Expand Down
1 change: 1 addition & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ initialize({
ENABLE_UNIT_PAGE: process.env.ENABLE_UNIT_PAGE || 'false',
ENABLE_ASSETS_PAGE: process.env.ENABLE_ASSETS_PAGE || 'false',
ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN: process.env.ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN || 'false',
ENABLE_CERTIFICATE_PAGE: process.env.ENABLE_CERTIFICATE_PAGE || 'false',
ENABLE_TAGGING_TAXONOMY_PAGES: process.env.ENABLE_TAGGING_TAXONOMY_PAGES || 'false',
ENABLE_HOME_PAGE_COURSE_API_V2: process.env.ENABLE_HOME_PAGE_COURSE_API_V2 === 'true',
ENABLE_CHECKLIST_QUALITY: process.env.ENABLE_CHECKLIST_QUALITY || 'true',
Expand Down
11 changes: 11 additions & 0 deletions src/library-authoring/LibraryAuthoringPage.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.library-authoring-page {
.header-actions {
.normal-border {
border: 1px solid;
}

.open-border {
border: 2px solid;
}
}
}
Loading

0 comments on commit 7d73945

Please sign in to comment.