Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add default prompt header #180

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 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>
<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 { 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 All @@ -43,7 +43,7 @@

return (
<Collapsible title={(<h3 className="py-3">{promptTitle}</h3>)} {...collapsibleProps}>
<div className="prompt" dangerouslySetInnerHTML={{ __html: promptWithStaticAssets }} />

Check warning on line 46 in src/components/Prompt/index.jsx

View workflow job for this annotation

GitHub Actions / test

Dangerous property 'dangerouslySetInnerHTML' found
</Collapsible>
);
};
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: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what I think about this as a default value but I also don't think it really matters

defaultMessage: 'Prompt',
description: 'Prompt title',
id: 'frontend-app-ora.Prompt.promptTitle',
},
});

export default messages;
Loading