Skip to content

Commit 3973cf2

Browse files
feat: embedded views
1 parent 87fa67d commit 3973cf2

38 files changed

+518
-1806
lines changed

package-lock.json

Lines changed: 214 additions & 1631 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"url": "https://github.com/edx/frontend-app-ora/issues"
3535
},
3636
"dependencies": {
37-
"@edx/brand": "npm:@edx/brand-openedx@1.2.0",
37+
"@edx/brand": "npm:@edx/brand-edx.org@2.1.2",
3838
"@edx/frontend-component-footer": "12.4.0",
3939
"@edx/frontend-component-header": "4.7.1",
4040
"@edx/frontend-platform": "5.6.1",

src/App.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,21 @@ const RouterRoot = () => {
2424
<Route
2525
path={route}
2626
element={(
27-
<AppContainer Component={Component} />
27+
<AppContainer>
28+
<Component />
29+
</AppContainer>
2830
)}
2931
/>
3032
);
3133
const modalRoute = (route, Component, title) => (
3234
<Route
3335
path={route}
3436
element={(
35-
<ModalContainer title={title}>
36-
<AppContainer Component={Component} />
37-
</ModalContainer>
37+
<AppContainer>
38+
<ModalContainer title={title}>
39+
<Component />
40+
</ModalContainer>
41+
</AppContainer>
3842
)}
3943
/>
4044
);

src/components/AppContainer.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33

4+
import ProgressBar from 'components/ProgressBar';
5+
46
import { useIsPageDataLoaded, useIsORAConfigLoaded } from 'data/services/lms/hooks/selectors';
57

68
/* The purpose of this component is to wrap views with a header/footer for situations
79
* where we need to run non-embedded
810
*/
911

10-
const AppContainer = ({ Component }) => {
12+
const AppContainer = ({ children }) => {
1113
const isConfigLoaded = useIsORAConfigLoaded();
1214
const isPageDataLoaded = useIsPageDataLoaded();
1315
if (!isConfigLoaded || !isPageDataLoaded) {
1416
return null;
1517
}
16-
return <Component />;
18+
return (
19+
<div style={{ width: '100%' }}>
20+
{children}
21+
</div>
22+
);
1723
};
1824
AppContainer.propTypes = {
19-
Component: PropTypes.elementType.isRequired,
25+
children: PropTypes.node.isRequired,
2026
};
2127

2228
export default AppContainer;

src/components/BaseAssessmentView/index.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const BaseAssessmentView = ({
2222
getValues,
2323
}) => (
2424
<AssessmentContextProvider>
25-
<ProgressBar />
2625
<div className="assessment-content-layout mr-auto ml-auto">
2726
<div className="content-wrapper">
2827
<Row className="flex-nowrap m-0">

src/components/Instructions/index.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33

4+
import { stepStates } from 'data/services/lms/constants';
5+
import { useStepState } from 'data/services/lms/hooks/selectors';
6+
47
import useInstructionsMessage from './useInstructionsMessage';
58

69
const Instructions = ({ step }) => {
710
const message = useInstructionsMessage(step);
11+
const stepState = useStepState({ step });
12+
if (stepState !== stepStates.inProgress) {
13+
return null;
14+
}
815
return (
916
<div>
1017
<h2>Instructions</h2>

src/components/Instructions/messages.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ import { stepNames } from 'data/services/lms/constants';
44

55
const messages = defineMessages({
66
[stepNames.submission]: {
7-
defaultMessage: '<Submittion Instructions: TODO>',
7+
defaultMessage: 'Submittion Instructions: TODO',
88
description: 'Submission step instructions',
99
id: 'frontend-app-ora.instructions.submisison',
1010
},
1111
[stepNames.studentTraining]: {
12-
defaultMessage: '<Student Training Instructions: TODO>',
12+
defaultMessage: 'Student Training Instructions: TODO',
1313
description: 'StudentTraining step instructions',
1414
id: 'frontend-app-ora.instructions.studentTraining',
1515
},
1616
[stepNames.self]: {
17-
defaultMessage: '<Self Assessment Instructions: TODO>',
17+
defaultMessage: 'Self Assessment Instructions: TODO',
1818
description: 'Self Assessment step instructions',
1919
id: 'frontend-app-ora.instructions.selfAssessment',
2020
},
2121
[stepNames.peer]: {
22-
defaultMessage: '<Peer Assessment Instructions: TODO>',
22+
defaultMessage: 'Peer Assessment Instructions: TODO',
2323
description: 'Peer Assessment step instructions',
2424
id: 'frontend-app-ora.instructions.peerAssessment',
2525
},

src/components/ModalContainer.jsx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { FullscreenModal } from '@edx/paragon';
4-
import { IntlProvider } from '@edx/frontend-platform/i18n';
54

6-
import AppContainer from 'components/AppContainer';
5+
import ProgressBar from 'components/ProgressBar';
76

87
/* The purpose of this component is to wrap views with a header/footer for situations
98
* where we need to run non-embedded
109
*/
1110

12-
const ModalContainer = ({ title, children }) => {
13-
console.log({ children, title });
14-
return (
15-
<FullscreenModal
16-
isOpen
17-
onClose={null}
18-
hasCloseButton={false}
19-
title={title}
20-
modalBodyClassName="content-body bg-light-300"
21-
>
22-
{children}
23-
</FullscreenModal>
24-
);
25-
};
11+
const ModalContainer = ({ title, children }) => (
12+
<FullscreenModal
13+
isOpen
14+
onClose={null}
15+
hasCloseButton={false}
16+
title={title}
17+
modalBodyClassName="content-body bg-light-300"
18+
beforeBodyNode={<ProgressBar className="px-2" />}
19+
>
20+
{children}
21+
</FullscreenModal>
22+
);
2623
ModalContainer.propTypes = {
2724
children: PropTypes.node.isRequired,
2825
title: PropTypes.string.isRequired,

src/components/ProgressBar/ProgressStep.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@ const ProgressStep = ({
5555
disabled={!isEnabled}
5656
className={classNames(
5757
'ora-progress-nav',
58-
'px-4',
58+
'px-0',
5959
{ 'is-active': isActive },
6060
)}
6161
>
62-
<Icon className={classNames('nav-icon', colorClass)} src={iconSrc} />
62+
<Icon
63+
className={classNames('nav-icon', 'my-auto', colorClass)}
64+
src={iconSrc}
65+
{...subLabel && { style: { position: 'relative', bottom: '0.7rem' } }}
66+
/>
6367
<div className="d-inline-block">
6468
{label}
6569
{subLabel && (
66-
<p className={classNames('x-small', colorClass)}>{subLabel}</p>
70+
<p className={classNames('x-small', 'm-0', colorClass)}>{subLabel}</p>
6771
)}
6872
</div>
6973
</Nav.Link>

src/components/ProgressBar/hooks.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { useParams } from 'react-router-dom';
22
import { useActiveView, useIsEmbedded } from 'hooks';
3-
import { useStepState, useEffectiveGrade } from 'data/services/lms/hooks/selectors';
3+
import {
4+
useStepState,
5+
useEffectiveGrade,
6+
useGlobalState,
7+
} from 'data/services/lms/hooks/selectors';
48
import {
59
routeSteps,
610
stepRoutes,
@@ -12,7 +16,7 @@ export const useProgressStepData = ({ step, canRevisit = false }) => {
1216
const isEmbedded = useIsEmbedded();
1317
const activeView = useActiveView();
1418
const viewStep = routeSteps[activeView];
15-
const stepState = useStepState({ step });
19+
const { activeStepName, stepState } = useGlobalState({ step });
1620

1721
const href = `/${stepRoutes[step]}${isEmbedded ? '/embedded' : ''}/${xblockId}`;
1822
const isActive = viewStep === step;
@@ -22,7 +26,6 @@ export const useProgressStepData = ({ step, canRevisit = false }) => {
2226
|| (canRevisit && stepState === stepStates.completed)
2327
);
2428
const myGrade = useEffectiveGrade()?.stepScore;
25-
2629
return {
2730
href,
2831
isEnabled,
@@ -33,7 +36,6 @@ export const useProgressStepData = ({ step, canRevisit = false }) => {
3336
myGrade,
3437
// myGrade: { earned: 8, possible: 10 },
3538
// isPastDue: step === 'self',
36-
3739
};
3840
};
3941

src/components/ProgressBar/index.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import classNames from 'classnames';
24

35
import { useIntl } from '@edx/frontend-platform/i18n';
46
import { Navbar } from '@edx/paragon';
@@ -30,7 +32,7 @@ export const stepCanRevisit = {
3032
[stepNames.done]: true,
3133
};
3234

33-
export const ProgressBar = () => {
35+
export const ProgressBar = ({ className }) => {
3436
const isLoaded = useIsPageDataLoaded();
3537

3638
const stepOrder = useAssessmentStepOrder();
@@ -53,7 +55,7 @@ export const ProgressBar = () => {
5355
);
5456

5557
return (
56-
<Navbar>
58+
<Navbar className={classNames("px-0", className)}>
5759
<Navbar.Collapse className="ora-progress-nav-group bg-white">
5860
<hr className="ora-progress-divider" />
5961
{stepEl(stepNames.submission)}
@@ -63,5 +65,11 @@ export const ProgressBar = () => {
6365
</Navbar>
6466
);
6567
};
68+
ProgressBar.defaultProps = {
69+
className: '',
70+
};
71+
ProgressBar.propTypes = {
72+
className: PropTypes.string,
73+
};
6674

6775
export default ProgressBar;

src/components/ProgressBar/index.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.ora-progress-nav-group {
2+
width: 100%;
23
display: flex;
34
justify-content: space-between;
45
.ora-progress-divider {
@@ -17,6 +18,9 @@
1718
display: inline-block;
1819
margin-inline-end: 0.5rem;
1920
margin-left: -0.25rem;
21+
svg {
22+
display: inline-block;
23+
}
2024
}
2125
.number-icon {
2226
background-color: black;

src/components/StatusAlert/alertHeadingMessages.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@ import { defineMessages } from '@edx/frontend-platform/i18n';
33
const submission = defineMessages({
44
inProgress: {
55
id: 'ora-grading.StatusAlert.Heading.submission.inProgress',
6-
defaultMessage: 'Submission in progress <TODO>',
6+
defaultMessage: 'Submission in progress: TODO',
77
description: 'Submission in-progress status alert heading',
88
},
99
finished: {
1010
id: 'ora-grading.StatusAlert.Heading.submission.finished',
11-
defaultMessage: 'Submission finished <TODO>',
11+
defaultMessage: 'Submission finished: TODO',
1212
description: 'Submission finished status alert heading',
1313
},
1414
notAvailable: {
1515
id: 'ora-grading.StatusAlert.Heading.submission.notAvailable',
16-
defaultMessage: 'Submission not available <TODO>',
16+
defaultMessage: 'Submission not available: TODO',
1717
description: 'Submission not avilable status alert heading',
1818
},
1919
cancelled: {
2020
id: 'ora-grading.StatusAlert.Heading.submission.cancelled',
21-
defaultMessage: 'Submission cancelled <TODO>',
21+
defaultMessage: 'Submission cancelled: TODO',
2222
description: 'Submission cancelled status alert heading',
2323
},
2424
cancelledBy: {
2525
id: 'ora-grading.StatusAlert.Heading.submission.cancelledBy',
26-
defaultMessage: 'Submission cancelled <TODO>',
26+
defaultMessage: 'Submission cancelled: TODO',
2727
description: 'Submission cancelled by user status alert heading',
2828
},
2929
closed: {
3030
id: 'ora-grading.StatusAlert.Heading.submission.closed',
31-
defaultMessage: 'Submission closed <TODO>',
31+
defaultMessage: 'Submission closed: TODO',
3232
description: 'Submission closed status alert heading',
3333
},
3434
teamAlreadySubmitted: {
@@ -46,51 +46,51 @@ const submission = defineMessages({
4646
const studentTraining = defineMessages({
4747
inProgress: {
4848
id: 'ora-grading.StatusAlert.Heading.studentTraining.inProgress',
49-
defaultMessage: 'Student Training <TODO>',
49+
defaultMessage: 'Student Training: TODO',
5050
description: 'Student Training in progress status alert heading',
5151
},
5252
});
5353

5454
const self = defineMessages({
5555
inProgress: {
5656
id: 'ora-grading.StatusAlert.Heading.self.inProgress',
57-
defaultMessage: 'Self in progress <TODO>',
57+
defaultMessage: 'Self in progress: TODO',
5858
description: 'Student Training in progress status alert heading',
5959
},
6060
closed: {
6161
id: 'ora-grading.StatusAlert.Heading.self.closed',
62-
defaultMessage: 'Self closed <TODO>',
62+
defaultMessage: 'Self closed: TODO',
6363
description: 'Student Training closed status alert heading',
6464
},
6565
});
6666

6767
const peer = defineMessages({
6868
inProgress: {
6969
id: 'ora-grading.StatusAlert.Heading.peer.inProgress',
70-
defaultMessage: 'Peer in progress <TODO>',
70+
defaultMessage: 'Peer in progress: TODO',
7171
description: 'Peer Assessment closed status alert heading',
7272
},
7373
waiting: {
7474
id: 'ora-grading.StatusAlert.Heading.peer.waiting',
75-
defaultMessage: 'Peer waiting <TODO>',
75+
defaultMessage: 'Peer waiting: TODO',
7676
description: 'Peer Assessment waiting status alert heading',
7777
},
7878
finished: {
7979
id: 'ora-grading.StatusAlert.Heading.peer.finished',
80-
defaultMessage: 'Peer finished <TODO>',
80+
defaultMessage: 'Peer finished: TODO',
8181
description: 'Peer Assessment finished status alert heading',
8282
},
8383
closed: {
8484
id: 'ora-grading.StatusAlert.Heading.peer.closed',
85-
defaultMessage: 'Peer closed <TODO>',
85+
defaultMessage: 'Peer closed: TODO',
8686
description: 'Peer Assessment closed status alert heading',
8787
},
8888
});
8989

9090
const done = defineMessages({
9191
status: {
9292
id: 'ora-grading.StatusAlert.Heading.done',
93-
defaultMessage: 'Graded <TODO>',
93+
defaultMessage: 'Graded: TODO',
9494
description: 'Done status alert heading',
9595
},
9696
});

0 commit comments

Comments
 (0)