feat(client,api): add user tokens and route for submitting coderoad tutorials (#43304)

Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>
Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Tom
2021-11-17 08:19:24 -06:00
committed by GitHub
parent 4eb036a2bb
commit f0698aa517
25 changed files with 722 additions and 26 deletions

View File

@@ -7,13 +7,22 @@ import Helmet from 'react-helmet';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import type { Dispatch } from 'redux';
import { createSelector } from 'reselect';
// Local Utilities
import LearnLayout from '../../../components/layouts/learn';
import { webhookTokenSelector } from '../../../redux';
import { ChallengeNode, ChallengeMeta } from '../../../redux/prop-types';
import { updateChallengeMeta, challengeMounted } from '../redux';
// Redux
const mapStateToProps = () => ({});
const mapStateToProps = createSelector(
webhookTokenSelector,
(webhookToken: string | null) => ({
webhookToken
})
);
const mapDispatchToProps = (dispatch: Dispatch) =>
bindActionCreators(
{
@@ -30,6 +39,7 @@ interface ShowCodeAllyProps {
challengeMeta: ChallengeMeta;
};
updateChallengeMeta: (arg0: ChallengeMeta) => void;
webhookToken: string | null;
}
// Component
@@ -48,10 +58,19 @@ class ShowCodeAlly extends Component<ShowCodeAllyProps> {
render() {
const {
title,
fields: { blockName },
url
} = this.props.data.challengeNode;
data: {
challengeNode: {
title,
fields: { blockName },
url
}
},
webhookToken = null
} = this.props;
const envVariables = webhookToken
? `&envVariables=CODEROAD_WEBHOOK_TOKEN=${webhookToken}`
: '';
return (
<LearnLayout>
@@ -60,7 +79,7 @@ class ShowCodeAlly extends Component<ShowCodeAllyProps> {
className='codeally-frame'
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
sandbox='allow-modals allow-forms allow-popups allow-scripts allow-same-origin'
src={`https://codeally.io/embed/?repoUrl=${url}`}
src={`https://codeally.io/embed/?repoUrl=${url}${envVariables}`}
title='Editor'
/>
</LearnLayout>