Skip to content

Commit

Permalink
chore: add staff prompt header
Browse files Browse the repository at this point in the history
  • Loading branch information
leangseu-edx committed Feb 1, 2024
1 parent 2083818 commit 940e7ff
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
20 changes: 14 additions & 6 deletions src/components/Instructions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import React from 'react';

import { useIntl } from '@edx/frontend-platform/i18n';

import { stepStates } from 'constants/index';
import { useStepState } from 'hooks/app';
import { stepNames, stepStates } from 'constants/index';

import { useGlobalState } from 'hooks/app';
import { useViewStep } from 'hooks/routing';
import { isXblockStep } from 'utils';

import useInstructionsMessage from './useInstructionsMessage';

Expand All @@ -12,13 +15,18 @@ import messages from './messages';
const Instructions = () => {
const { formatMessage } = useIntl();
const message = useInstructionsMessage();
const stepState = useStepState({});
if (stepState !== stepStates.inProgress) {
const viewStep = useViewStep();
const { activeStepName, stepState } = useGlobalState();
const stepName = isXblockStep(viewStep) ? activeStepName : viewStep;
if (stepState !== stepStates.inProgress || stepName === stepNames.staff) {
return null;
}
return (
<div className="py-4">
<p className="mb-0"><strong>{formatMessage(messages.instructions)}: </strong>{message}</p>
<div className='py-4'>
<p className='mb-0'>
<strong>{formatMessage(messages.instructions)}: </strong>
{message}
</p>
</div>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/Prompt/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const Prompt = ({
const { formatMessage } = useIntl();
const viewStep = useViewStep();
const activeStepName = useActiveStepName();
const message = messages[viewStep] || messages[activeStepName];
const promptTitle = title || formatMessage(message) || '';
const message = messages[viewStep] || messages[activeStepName] || messages.promptTitle;
const promptTitle = title || formatMessage(message);
const imgRegex = /img src="\/asset-v1([^"]*)?"/g;
const linkRegex = /a href="\/asset-v1([^"]*)?"/g;
const { baseAssetUrl } = useORAConfigData();
Expand Down
5 changes: 5 additions & 0 deletions src/components/Prompt/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ const messages = defineMessages({
description: 'Done step prompt header',
id: 'frontend-app-ora.Prompt.header.done',
},
promptTitle: {
defaultMessage: 'Prompt',
description: 'Prompt title',
id: 'frontend-app-ora.Prompt.promptTitle',
},
});

export default messages;

0 comments on commit 940e7ff

Please sign in to comment.