Skip to content

Commit 2d814c0

Browse files
authored
chore: add xblock studio view (#178)
* chore: add xblock studio view * chore: linting * chore: add preview route * chore: fix url
1 parent 34935db commit 2d814c0

36 files changed

+853
-35
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CSRF_TOKEN_API_PATH=''
66
ECOMMERCE_BASE_URL=''
77
LANGUAGE_PREFERENCE_COOKIE_NAME=''
88
LMS_BASE_URL=''
9+
STUDIO_BASE_URL=''
910
LOGIN_URL=''
1011
LOGOUT_URL=''
1112
LOGO_URL=''

.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CSRF_TOKEN_API_PATH='/csrf/api/v1/token'
77
ECOMMERCE_BASE_URL='http://localhost:18130'
88
LANGUAGE_PREFERENCE_COOKIE_NAME='openedx-language-preference'
99
LMS_BASE_URL='http://localhost:18000'
10+
STUDIO_BASE_URL='http://localhost:18010'
1011
LOGIN_URL='http://localhost:18000/login'
1112
LOGOUT_URL='http://localhost:18000/logout'
1213
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg

.env.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CSRF_TOKEN_API_PATH='/csrf/api/v1/token'
55
ECOMMERCE_BASE_URL='http://localhost:18130'
66
LANGUAGE_PREFERENCE_COOKIE_NAME='openedx-language-preference'
77
LMS_BASE_URL='http://localhost:18000'
8+
STUDIO_BASE_URL='http://localhost:18010'
89
LOGIN_URL='http://localhost:18000/login'
910
LOGOUT_URL='http://localhost:18000/logout'
1011
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg

src/App.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { SkeletonTheme } from '@edx/paragon';
1010
import AssessmentView from 'views/AssessmentView';
1111
import SubmissionView from 'views/SubmissionView';
1212
import XBlockView from 'views/XBlockView';
13+
import XBlockStudioView from 'views/XBlockStudioView';
1314
import GradeView from 'views/GradeView';
1415

1516
import AppContainer from 'components/AppContainer';
@@ -67,6 +68,8 @@ const App = () => {
6768
/*
6869
const embeddedRoutes = [
6970
<Route key="embedXblock" path={routes.xblockEmbed} element={<XBlockView />} />,
71+
<Route key="embedXblockStudio" path={routes.xblockStudioEmbed} element={<XBlockStudioView />} />,
72+
<Route key="embedXblockPreview" path={routes.xblockPreviewEmbed} element={<XBlockView />} />,
7073
modalRoute(routes.peerAssessmentEmbed, PeerAssessmentView, 'ORA Peer Assessment'),
7174
modalRoute(routes.selfAssessmentEmbed, SelfAssessmentView, 'ORA Self Assessment'),
7275
modalRoute(routes.studentTrainingEmbed, StudentTrainingView, 'ORA Student Training'),
@@ -81,6 +84,8 @@ const App = () => {
8184
*/
8285
const baseRoutes = [
8386
appRoute(routes.xblock, XBlockView),
87+
appRoute(routes.xblockStudio, XBlockStudioView),
88+
appRoute(routes.xblockPreview, XBlockView),
8489
modalRoute(routes.peerAssessment, AssessmentView),
8590
modalRoute(routes.selfAssessment, AssessmentView),
8691
modalRoute(routes.studentTraining, AssessmentView),

src/components/Instructions/useInstructionsMessage.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { stepNames, stepStates } from 'constants/index';
44

55
import { useGlobalState } from 'hooks/app';
66
import { useViewStep } from 'hooks/routing';
7+
import { isXblockStep } from 'utils';
78

89
import messages from './messages';
910

@@ -15,7 +16,7 @@ const useInstructionsMessage = () => {
1516
effectiveGrade,
1617
stepState,
1718
} = useGlobalState();
18-
const stepName = (viewStep === stepNames.xblock) ? activeStepName : viewStep;
19+
const stepName = isXblockStep(viewStep) ? activeStepName : viewStep;
1920
if (stepState !== stepStates.inProgress || stepName === stepNames.staff) {
2021
return null;
2122
}

src/components/ProgressBar/hooks.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useViewStep } from 'hooks/routing';
44
import { useGlobalState, useStepInfo } from 'hooks/app';
55
import { useOpenModal } from 'hooks/modal';
66
import { stepRoutes, stepStates, stepNames } from 'constants/index';
7+
import { isXblockStep } from 'utils';
78

89
export const useProgressStepData = ({ step, canRevisit = false }) => {
910
const { xblockId, courseId } = useParams();
@@ -15,10 +16,11 @@ export const useProgressStepData = ({ step, canRevisit = false }) => {
1516
} = useGlobalState({ step });
1617
const stepInfo = useStepInfo();
1718
const openModal = useOpenModal();
19+
const isXblock = isXblockStep(viewStep);
1820

1921
const href = `/${stepRoutes[step]}/${courseId}/${xblockId}`;
2022
const onClick = () => openModal({ view: step, title: step });
21-
const isActive = viewStep === stepNames.xblock
23+
const isActive = isXblock
2224
? activeStepName === step
2325
: viewStep === step;
2426
let isEnabled = isActive
@@ -31,7 +33,7 @@ export const useProgressStepData = ({ step, canRevisit = false }) => {
3133
isEnabled = !isWaitingForSubmissions && (isEnabled || isPeerComplete);
3234
}
3335
return {
34-
...(viewStep === stepNames.xblock ? { onClick } : { href }),
36+
...(isXblock ? { onClick } : { href }),
3537
isEnabled,
3638
isActive,
3739
isComplete: stepState === stepStates.done,

src/components/ProgressBar/index.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {
1515
import { stepNames } from 'constants/index';
1616

1717
import { useViewStep } from 'hooks/routing';
18+
import { isXblockStep } from 'utils';
19+
1820
import ProgressStep from './ProgressStep';
1921

2022
import messages from './messages';
@@ -42,6 +44,7 @@ export const ProgressBar = ({ className }) => {
4244

4345
const activeStep = useViewStep();
4446
const { activeStepName } = useGlobalState();
47+
const isXblock = isXblockStep(activeStep);
4548

4649
const stepOrders = [
4750
stepNames.submission,
@@ -66,7 +69,7 @@ export const ProgressBar = ({ className }) => {
6669
/>
6770
);
6871

69-
let activeStepTitle = activeStep === stepNames.xblock ? activeStepName : activeStep;
72+
let activeStepTitle = isXblock ? activeStepName : activeStep;
7073
if (activeStepTitle === stepNames.staff) {
7174
activeStepTitle = stepNames.submission;
7275
}

src/components/Prompt/hooks.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/components/Prompt/index.jsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ import { useActiveStepName, useORAConfigData } from 'hooks/app';
88
import { useViewStep } from 'hooks/routing';
99

1010
import messages from './messages';
11-
import usePromptHooks from './hooks';
1211

1312
import './index.scss';
1413

15-
const Prompt = ({ prompt, defaultOpen }) => {
16-
const { open, toggleOpen } = usePromptHooks({ defaultOpen });
14+
const Prompt = ({
15+
prompt, title, open, onToggle,
16+
}) => {
1717
const { formatMessage } = useIntl();
1818
const viewStep = useViewStep();
1919
const activeStepName = useActiveStepName();
2020
const message = messages[viewStep] || messages[activeStepName];
21-
const title = message ? formatMessage(message) : '';
21+
const promptTitle = title || formatMessage(message) || '';
2222
const imgRegex = /img src="\/asset-v1([^"]*)?"/g;
2323
const linkRegex = /a href="\/asset-v1([^"]*)?"/g;
2424
const { baseAssetUrl } = useORAConfigData();
@@ -33,20 +33,32 @@ const Prompt = ({ prompt, defaultOpen }) => {
3333
const promptWithStaticAssets = promptWithAssets
3434
.replaceAll(staticRegex.img, `img src="${process.env.LMS_BASE_URL}/${baseAssetUrl}$1"`)
3535
.replaceAll(staticRegex.link, `a href="${process.env.LMS_BASE_URL}/${baseAssetUrl}$1"`);
36+
37+
const collapsibleProps = open !== null && onToggle !== null ? {
38+
open,
39+
onToggle,
40+
} : {
41+
defaultOpen: true,
42+
};
43+
3644
return (
37-
<Collapsible title={(<h3 className="py-3">{title}</h3>)} open={open} onToggle={toggleOpen}>
45+
<Collapsible title={(<h3 className="py-3">{promptTitle}</h3>)} {...collapsibleProps}>
3846
<div className="prompt" dangerouslySetInnerHTML={{ __html: promptWithStaticAssets }} />
3947
</Collapsible>
4048
);
4149
};
4250

4351
Prompt.defaultProps = {
44-
defaultOpen: true,
52+
open: null,
53+
onToggle: null,
54+
title: null,
4555
};
4656

4757
Prompt.propTypes = {
48-
defaultOpen: PropTypes.bool,
4958
prompt: PropTypes.string.isRequired,
59+
open: PropTypes.bool,
60+
onToggle: PropTypes.func,
61+
title: PropTypes.string,
5062
};
5163

5264
export default Prompt;

src/components/StatusAlert/hooks/simpleAlerts.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ import { useExitAction, useStartStepAction } from 'hooks/actions';
44

55
import { stepNames, stepStates } from 'constants/index';
66

7+
import { isXblockStep } from 'utils';
78
import useCreateAlert from './useCreateAlert';
89
import messages from '../messages';
910

1011
export const useGradedAlerts = ({ step }) => {
1112
const viewStep = useViewStep();
1213
const startAction = useStartStepAction();
14+
const isXblock = isXblockStep(viewStep);
1315
const alert = {
1416
message: messages.alerts.done.status,
1517
heading: messages.headings.done.status,
1618
};
17-
if (startAction && viewStep !== stepNames.xblock) {
19+
if (startAction && !isXblock) {
1820
alert.actions = [startAction.action];
1921
}
2022
return [useCreateAlert({ step })(alert)];

0 commit comments

Comments
 (0)