-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44905 from code-dot-org/dtl_candidate_0dbd8797
- Loading branch information
Showing
78 changed files
with
5,658 additions
and
4,168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import {Provider} from 'react-redux'; | ||
import getScriptData from '@cdo/apps/util/getScriptData'; | ||
import CertificateShare from '@cdo/apps/templates/CertificateShare'; | ||
import {getStore} from '@cdo/apps/redux'; | ||
|
||
$(document).ready(function() { | ||
const store = getStore(); | ||
const certificateData = getScriptData('certificate'); | ||
const {imageUrl, printUrl} = certificateData; | ||
const {imageUrl, printUrl, announcement} = certificateData; | ||
ReactDOM.render( | ||
<CertificateShare imageUrl={imageUrl} printUrl={printUrl} />, | ||
<Provider store={store}> | ||
<CertificateShare | ||
imageUrl={imageUrl} | ||
printUrl={printUrl} | ||
announcement={announcement} | ||
/> | ||
</Provider>, | ||
document.getElementById('certificate-share') | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,53 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import i18n from '@cdo/locale'; | ||
import {pegasus} from '@cdo/apps/lib/util/urlHelpers'; | ||
import {TwoColumnActionBlock} from '@cdo/apps/templates/studioHomepages/TwoColumnActionBlock'; | ||
import styleConstants from '../styleConstants'; | ||
|
||
export default function CertificateShare(props) { | ||
export default function CertificateShare({announcement, printUrl, imageUrl}) { | ||
return ( | ||
<a href={props.printUrl}> | ||
<img | ||
src={props.imageUrl} | ||
alt={i18n.certificateForCompletion()} | ||
width="100%" | ||
/> | ||
</a> | ||
<div style={styles.wrapper}> | ||
<a href={printUrl}> | ||
<img | ||
src={imageUrl} | ||
alt={i18n.certificateForCompletion()} | ||
width="100%" | ||
style={styles.certificate} | ||
/> | ||
</a> | ||
{announcement && ( | ||
<TwoColumnActionBlock | ||
imageUrl={pegasus(announcement.image)} | ||
subHeading={announcement.title} | ||
description={announcement.body} | ||
buttons={[ | ||
{ | ||
id: announcement.buttonId, | ||
url: announcement.buttonUrl, | ||
text: announcement.buttonText | ||
} | ||
]} | ||
/> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
const styles = { | ||
wrapper: { | ||
with: '100%', | ||
maxWidth: styleConstants['content-width'], | ||
marginLeft: 'auto', | ||
marginRight: 'auto' | ||
}, | ||
certificate: { | ||
marginBottom: 20 | ||
} | ||
}; | ||
|
||
CertificateShare.propTypes = { | ||
imageUrl: PropTypes.string.isRequired, | ||
printUrl: PropTypes.string.isRequired | ||
printUrl: PropTypes.string.isRequired, | ||
announcement: PropTypes.object | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react'; | ||
import {shallow} from 'enzyme'; | ||
import {expect} from '../../util/reconfiguredChai'; | ||
import CertificateShare from '@cdo/apps/templates/CertificateShare'; | ||
|
||
const defaultProps = { | ||
imageUrl: '/certificate-image', | ||
printUrl: '/certificate-print', | ||
announcement: { | ||
image: '/announcement-image', | ||
title: 'Title Text', | ||
body: 'body text', | ||
buttonId: 'button-id', | ||
buttonUrl: '/button-url', | ||
buttonText: 'button text' | ||
} | ||
}; | ||
|
||
describe('CertificateShare', () => { | ||
let storedWindowDashboard; | ||
|
||
beforeEach(() => { | ||
storedWindowDashboard = window.dashboard; | ||
window.dashboard = { | ||
CODE_ORG_URL: '//code.org' | ||
}; | ||
}); | ||
|
||
afterEach(() => { | ||
window.dashboard = storedWindowDashboard; | ||
}); | ||
|
||
it('renders announcement image url relative to pegasus', () => { | ||
const wrapper = shallow(<CertificateShare {...defaultProps} />); | ||
|
||
const printLink = wrapper.find('a'); | ||
expect(printLink.prop('href')).to.equal('/certificate-print'); | ||
const image = printLink.find('img'); | ||
expect(image.prop('src')).to.equal('/certificate-image'); | ||
|
||
const block = wrapper.find('Connect(UnconnectedTwoColumnActionBlock)'); | ||
expect(block.prop('imageUrl')).to.equal('//code.org/announcement-image'); | ||
}); | ||
|
||
it('renders no announcement without announcement prop', () => { | ||
const props = { | ||
...defaultProps, | ||
announcement: null | ||
}; | ||
const wrapper = shallow(<CertificateShare {...props} />); | ||
|
||
const printLink = wrapper.find('a'); | ||
expect(printLink.length).to.equal(1); | ||
|
||
const block = wrapper.find('Connect(UnconnectedTwoColumnActionBlock)'); | ||
expect(block.length).to.equal(0); | ||
}); | ||
}); |
Oops, something went wrong.