Commit ee09ba59 authored by Chris Garrity's avatar Chris Garrity

Add handling for parameters passed in the query from scratchr2

Scratchr2 has links to contact us from the report (profile|studio) dialogs. Looking at the scratchr2 source, there’s also one for confirmations, so this change handles the additional details in the same way - in the subject and description. In the future we could consider pre-filling specific form fields that we define.
parent f0bcd9f5
...@@ -9,6 +9,8 @@ const HelpForm = props => { ...@@ -9,6 +9,8 @@ const HelpForm = props => {
const username = `helpdesk_ticket[custom_field][cf_scratch_name_40167]=${props.user.username || ''}`; const username = `helpdesk_ticket[custom_field][cf_scratch_name_40167]=${props.user.username || ''}`;
const agentText = encodeURI(window.navigator.userAgent.replace(';', ' -')); const agentText = encodeURI(window.navigator.userAgent.replace(';', ' -'));
const browser = `helpdesk_ticket[custom_field][cf_browser_40167]=${agentText}`; const browser = `helpdesk_ticket[custom_field][cf_browser_40167]=${agentText}`;
const formSubject = `helpdesk_ticket[subject]=${props.subject}`;
const formDescription = `helpdesk_ticket[description]=${props.body}`;
return ( return (
<div> <div>
<script <script
...@@ -27,7 +29,7 @@ const HelpForm = props => { ...@@ -27,7 +29,7 @@ const HelpForm = props => {
height="505px" height="505px"
id="freshwidget-embedded-form" id="freshwidget-embedded-form"
scrolling="no" scrolling="no"
src={`${prefix}&${title}&${username}&${browser}`} src={`${prefix}&${title}&${username}&${browser}&${formSubject}&${formDescription}`}
title={<FormattedMessage id="contactUs.questionsForum" />} title={<FormattedMessage id="contactUs.questionsForum" />}
width="100%" width="100%"
/> />
...@@ -37,6 +39,8 @@ const HelpForm = props => { ...@@ -37,6 +39,8 @@ const HelpForm = props => {
HelpForm.propTypes = { HelpForm.propTypes = {
body: PropTypes.string,
subject: PropTypes.string,
title: PropTypes.string.isRequired, title: PropTypes.string.isRequired,
user: PropTypes.shape({ user: PropTypes.shape({
classroomId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), classroomId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
...@@ -46,6 +50,8 @@ HelpForm.propTypes = { ...@@ -46,6 +50,8 @@ HelpForm.propTypes = {
}; };
HelpForm.defaultProps = { HelpForm.defaultProps = {
body: '',
subject: '',
title: '', title: '',
user: {username: ''} user: {username: ''}
}; };
......
...@@ -10,6 +10,21 @@ const HelpForm = require('../../components/helpform/helpform.jsx'); ...@@ -10,6 +10,21 @@ const HelpForm = require('../../components/helpform/helpform.jsx');
const InformationPage = require('../../components/informationpage/informationpage.jsx'); const InformationPage = require('../../components/informationpage/informationpage.jsx');
let subject = '';
let body = '';
const url = (window.location && window.location.search) || '';
// assumes that scratchr2 will only ever send one parameter
const params = url.split('?')[1];
if (typeof (params) !== 'undefined' && params.indexOf('studio') !== -1) {
subject = `Inappropriate content reported in studio ${params.split('=')[1]}`;
body = `https://scratch.mit.edu/studios/${params.split('=')[1]}`;
} else if (typeof (params) !== 'undefined' && params.indexOf('profile') !== -1) {
subject = `Inappropriate content reported in profile ${params.split('=')[1]}`;
body = `https://scratch.mit.edu/users/${params.split('=')[1]}`;
} else if (typeof (params) !== 'undefined' && params.indexOf('confirmation') !== -1) {
subject = 'Problem with email confirmation';
}
const ContactUs = injectIntl(props => ( const ContactUs = injectIntl(props => (
<InformationPage title={props.intl.formatMessage({id: 'contactUs.title'})}> <InformationPage title={props.intl.formatMessage({id: 'contactUs.title'})}>
<div className="inner info-inner"> <div className="inner info-inner">
...@@ -45,7 +60,11 @@ const ContactUs = injectIntl(props => ( ...@@ -45,7 +60,11 @@ const ContactUs = injectIntl(props => (
<p><FormattedMessage id="contactUs.formIntro" /></p> <p><FormattedMessage id="contactUs.formIntro" /></p>
</section> </section>
</div> </div>
<HelpForm title={props.intl.formatMessage({id: 'contactUs.contactScratch'})} /> <HelpForm
body={body}
subject={subject}
title={props.intl.formatMessage({id: 'contactUs.contactScratch'})}
/>
</InformationPage> </InformationPage>
)); ));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment