fix(client): add relevant placeholder to link submission (#38411)
This commit is contained in:
@@ -5,13 +5,14 @@ import { Form } from '../../../components/formHelpers';
|
|||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
isFrontEnd: PropTypes.bool,
|
isFrontEnd: PropTypes.bool,
|
||||||
|
isProject: PropTypes.bool,
|
||||||
isSubmitting: PropTypes.bool,
|
isSubmitting: PropTypes.bool,
|
||||||
onSubmit: PropTypes.func.isRequired,
|
onSubmit: PropTypes.func.isRequired,
|
||||||
updateProjectForm: PropTypes.func.isRequired
|
updateSolutionForm: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
const frontEndFields = ['solution'];
|
const challengeFields = ['solution'];
|
||||||
const backEndFields = ['solution', 'githubLink'];
|
const backEndProjectFields = ['solution', 'githubLink'];
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
types: {
|
types: {
|
||||||
@@ -21,38 +22,39 @@ const options = {
|
|||||||
required: ['solution']
|
required: ['solution']
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ProjectForm extends Component {
|
export class SolutionForm extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.updateProjectForm({});
|
this.props.updateSolutionForm({});
|
||||||
}
|
}
|
||||||
handleSubmit(values) {
|
handleSubmit(values) {
|
||||||
this.props.updateProjectForm(values);
|
this.props.updateSolutionForm(values);
|
||||||
this.props.onSubmit();
|
this.props.onSubmit();
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
const { isSubmitting, isFrontEnd } = this.props;
|
const { isSubmitting, isFrontEnd, isProject } = this.props;
|
||||||
const buttonCopy = isSubmitting
|
const buttonCopy = isSubmitting
|
||||||
? 'Submit and go to my next challenge'
|
? 'Submit and go to my next challenge'
|
||||||
: "I've completed this challenge";
|
: "I've completed this challenge";
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
buttonText={`${buttonCopy}`}
|
buttonText={`${buttonCopy}`}
|
||||||
formFields={isFrontEnd ? frontEndFields : backEndFields}
|
formFields={
|
||||||
|
isProject && !isFrontEnd ? backEndProjectFields : challengeFields
|
||||||
|
}
|
||||||
id={isFrontEnd ? 'front-end-form' : 'back-end-form'}
|
id={isFrontEnd ? 'front-end-form' : 'back-end-form'}
|
||||||
options={{
|
options={{
|
||||||
...options,
|
...options,
|
||||||
placeholders: {
|
placeholders: {
|
||||||
solution:
|
solution:
|
||||||
'Link to solution, ex: ' +
|
'Link, ex: ' +
|
||||||
(isFrontEnd
|
(isFrontEnd
|
||||||
? 'https://codepen.io/camperbot/full/oNvPqqo'
|
? 'https://codepen.io/camperbot/full/oNvPqqo'
|
||||||
: 'https://camperbot.glitch.me'),
|
: 'https://camperbot.glitch.me'),
|
||||||
githubLink:
|
githubLink: 'ex: https://github.com/camperbot/hello'
|
||||||
'Link to GitHub repo, ex: https://github.com/camperbot/hello'
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
submit={this.handleSubmit}
|
submit={this.handleSubmit}
|
||||||
@@ -61,6 +63,6 @@ export class ProjectForm extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectForm.propTypes = propTypes;
|
SolutionForm.propTypes = propTypes;
|
||||||
|
|
||||||
export default ProjectForm;
|
export default SolutionForm;
|
@@ -15,8 +15,7 @@ import {
|
|||||||
initTests,
|
initTests,
|
||||||
updateBackendFormValues,
|
updateBackendFormValues,
|
||||||
updateChallengeMeta,
|
updateChallengeMeta,
|
||||||
updateProjectFormValues,
|
updateSolutionFormValues
|
||||||
backendNS
|
|
||||||
} from '../../redux';
|
} from '../../redux';
|
||||||
import { getGuideUrl } from '../../utils';
|
import { getGuideUrl } from '../../utils';
|
||||||
|
|
||||||
@@ -28,16 +27,14 @@ import Output from '../../components/Output';
|
|||||||
import CompletionModal from '../../components/CompletionModal';
|
import CompletionModal from '../../components/CompletionModal';
|
||||||
import HelpModal from '../../components/HelpModal';
|
import HelpModal from '../../components/HelpModal';
|
||||||
import ProjectToolPanel from '../Tool-Panel';
|
import ProjectToolPanel from '../Tool-Panel';
|
||||||
import ProjectForm from '../ProjectForm';
|
import SolutionForm from '../SolutionForm';
|
||||||
import { Form } from '../../../../components/formHelpers';
|
|
||||||
import Spacer from '../../../../components/helpers/Spacer';
|
import Spacer from '../../../../components/helpers/Spacer';
|
||||||
import { ChallengeNode } from '../../../../redux/propTypes';
|
import { ChallengeNode } from '../../../../redux/propTypes';
|
||||||
import { isSignedInSelector } from '../../../../redux';
|
import { isSignedInSelector } from '../../../../redux';
|
||||||
import Hotkeys from '../../components/Hotkeys';
|
import Hotkeys from '../../components/Hotkeys';
|
||||||
|
|
||||||
import { backend } from '../../../../../utils/challengeTypes';
|
|
||||||
|
|
||||||
import '../../components/test-frame.css';
|
import '../../components/test-frame.css';
|
||||||
|
import { backEndProject } from '../../../../../utils/challengeTypes';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
challengeMounted: PropTypes.func.isRequired,
|
challengeMounted: PropTypes.func.isRequired,
|
||||||
@@ -59,7 +56,7 @@ const propTypes = {
|
|||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
updateBackendFormValues: PropTypes.func.isRequired,
|
updateBackendFormValues: PropTypes.func.isRequired,
|
||||||
updateChallengeMeta: PropTypes.func.isRequired,
|
updateChallengeMeta: PropTypes.func.isRequired,
|
||||||
updateProjectFormValues: PropTypes.func.isRequired
|
updateSolutionFormValues: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = createSelector(
|
const mapStateToProps = createSelector(
|
||||||
@@ -80,18 +77,7 @@ const mapDispatchToActions = {
|
|||||||
initTests,
|
initTests,
|
||||||
updateBackendFormValues,
|
updateBackendFormValues,
|
||||||
updateChallengeMeta,
|
updateChallengeMeta,
|
||||||
updateProjectFormValues
|
updateSolutionFormValues
|
||||||
};
|
|
||||||
|
|
||||||
const formFields = ['solution'];
|
|
||||||
const options = {
|
|
||||||
required: ['solution'],
|
|
||||||
types: {
|
|
||||||
solution: 'url'
|
|
||||||
},
|
|
||||||
placeholders: {
|
|
||||||
solution: 'Link to solution, ex: https://codepen.io/camperbot/full/oNvPqqo'
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export class BackEnd extends Component {
|
export class BackEnd extends Component {
|
||||||
@@ -99,7 +85,6 @@ export class BackEnd extends Component {
|
|||||||
super(props);
|
super(props);
|
||||||
this.state = {};
|
this.state = {};
|
||||||
this.updateDimensions = this.updateDimensions.bind(this);
|
this.updateDimensions = this.updateDimensions.bind(this);
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@@ -152,12 +137,6 @@ export class BackEnd extends Component {
|
|||||||
challengeMounted(challengeMeta.id);
|
challengeMounted(challengeMeta.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSubmit(values) {
|
|
||||||
const { updateBackendFormValues, executeChallenge } = this.props;
|
|
||||||
updateBackendFormValues(values);
|
|
||||||
executeChallenge();
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
data: {
|
data: {
|
||||||
@@ -175,15 +154,13 @@ export class BackEnd extends Component {
|
|||||||
challengeMeta: { introPath, nextChallengePath, prevChallengePath }
|
challengeMeta: { introPath, nextChallengePath, prevChallengePath }
|
||||||
},
|
},
|
||||||
tests,
|
tests,
|
||||||
isSignedIn,
|
|
||||||
executeChallenge,
|
executeChallenge,
|
||||||
updateProjectFormValues
|
updateSolutionFormValues,
|
||||||
|
updateBackendFormValues
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const buttonCopy = isSignedIn
|
|
||||||
? 'Submit and go to my next challenge'
|
|
||||||
: "I've completed this challenge";
|
|
||||||
const blockNameTitle = `${blockName} - ${title}`;
|
const blockNameTitle = `${blockName} - ${title}`;
|
||||||
|
const isBackEndProject = challengeType === backEndProject;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Hotkeys
|
<Hotkeys
|
||||||
@@ -203,21 +180,16 @@ export class BackEnd extends Component {
|
|||||||
description={description}
|
description={description}
|
||||||
instructions={instructions}
|
instructions={instructions}
|
||||||
/>
|
/>
|
||||||
{challengeType === backend ? (
|
<SolutionForm
|
||||||
<Form
|
|
||||||
buttonText={`${buttonCopy}`}
|
|
||||||
formFields={formFields}
|
|
||||||
id={backendNS}
|
|
||||||
options={options}
|
|
||||||
submit={this.handleSubmit}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<ProjectForm
|
|
||||||
isFrontEnd={false}
|
isFrontEnd={false}
|
||||||
|
isProject={isBackEndProject}
|
||||||
onSubmit={executeChallenge}
|
onSubmit={executeChallenge}
|
||||||
updateProjectForm={updateProjectFormValues}
|
updateSolutionForm={values =>
|
||||||
|
isBackEndProject
|
||||||
|
? updateSolutionFormValues(values)
|
||||||
|
: updateBackendFormValues(values)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
<ProjectToolPanel
|
<ProjectToolPanel
|
||||||
guideUrl={getGuideUrl({ forumTopicId, title })}
|
guideUrl={getGuideUrl({ forumTopicId, title })}
|
||||||
/>
|
/>
|
||||||
|
@@ -11,7 +11,7 @@ import {
|
|||||||
challengeMounted,
|
challengeMounted,
|
||||||
updateChallengeMeta,
|
updateChallengeMeta,
|
||||||
openModal,
|
openModal,
|
||||||
updateProjectFormValues
|
updateSolutionFormValues
|
||||||
} from '../../redux';
|
} from '../../redux';
|
||||||
import { frontEndProject } from '../../../../../utils/challengeTypes';
|
import { frontEndProject } from '../../../../../utils/challengeTypes';
|
||||||
import { getGuideUrl } from '../../utils';
|
import { getGuideUrl } from '../../utils';
|
||||||
@@ -20,7 +20,7 @@ import LearnLayout from '../../../../components/layouts/Learn';
|
|||||||
import ChallengeTitle from '../../components/Challenge-Title';
|
import ChallengeTitle from '../../components/Challenge-Title';
|
||||||
import ChallengeDescription from '../../components/Challenge-Description';
|
import ChallengeDescription from '../../components/Challenge-Description';
|
||||||
import Spacer from '../../../../components/helpers/Spacer';
|
import Spacer from '../../../../components/helpers/Spacer';
|
||||||
import ProjectForm from '../ProjectForm';
|
import SolutionForm from '../SolutionForm';
|
||||||
import ProjectToolPanel from '../Tool-Panel';
|
import ProjectToolPanel from '../Tool-Panel';
|
||||||
import CompletionModal from '../../components/CompletionModal';
|
import CompletionModal from '../../components/CompletionModal';
|
||||||
import HelpModal from '../../components/HelpModal';
|
import HelpModal from '../../components/HelpModal';
|
||||||
@@ -32,7 +32,7 @@ const mapDispatchToProps = dispatch =>
|
|||||||
{
|
{
|
||||||
updateChallengeMeta,
|
updateChallengeMeta,
|
||||||
challengeMounted,
|
challengeMounted,
|
||||||
updateProjectFormValues,
|
updateSolutionFormValues,
|
||||||
openCompletionModal: () => openModal('completion')
|
openCompletionModal: () => openModal('completion')
|
||||||
},
|
},
|
||||||
dispatch
|
dispatch
|
||||||
@@ -48,7 +48,7 @@ const propTypes = {
|
|||||||
challengeMeta: PropTypes.object
|
challengeMeta: PropTypes.object
|
||||||
}),
|
}),
|
||||||
updateChallengeMeta: PropTypes.func.isRequired,
|
updateChallengeMeta: PropTypes.func.isRequired,
|
||||||
updateProjectFormValues: PropTypes.func.isRequired
|
updateSolutionFormValues: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
export class Project extends Component {
|
export class Project extends Component {
|
||||||
@@ -105,11 +105,12 @@ export class Project extends Component {
|
|||||||
pageContext: {
|
pageContext: {
|
||||||
challengeMeta: { introPath, nextChallengePath, prevChallengePath }
|
challengeMeta: { introPath, nextChallengePath, prevChallengePath }
|
||||||
},
|
},
|
||||||
updateProjectFormValues
|
updateSolutionFormValues
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const isFrontEnd = challengeType === frontEndProject;
|
|
||||||
|
|
||||||
|
const isFrontEndProject = challengeType === frontEndProject;
|
||||||
const blockNameTitle = `${blockName} - ${title}`;
|
const blockNameTitle = `${blockName} - ${title}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Hotkeys
|
<Hotkeys
|
||||||
innerRef={c => (this._container = c)}
|
innerRef={c => (this._container = c)}
|
||||||
@@ -125,10 +126,11 @@ export class Project extends Component {
|
|||||||
<Spacer />
|
<Spacer />
|
||||||
<ChallengeTitle>{blockNameTitle}</ChallengeTitle>
|
<ChallengeTitle>{blockNameTitle}</ChallengeTitle>
|
||||||
<ChallengeDescription description={description} />
|
<ChallengeDescription description={description} />
|
||||||
<ProjectForm
|
<SolutionForm
|
||||||
isFrontEnd={isFrontEnd}
|
isFrontEnd={true}
|
||||||
|
isProject={isFrontEndProject}
|
||||||
onSubmit={openCompletionModal}
|
onSubmit={openCompletionModal}
|
||||||
updateProjectForm={updateProjectFormValues}
|
updateSolutionForm={updateSolutionFormValues}
|
||||||
/>
|
/>
|
||||||
<ProjectToolPanel
|
<ProjectToolPanel
|
||||||
guideUrl={getGuideUrl({ forumTopicId, title })}
|
guideUrl={getGuideUrl({ forumTopicId, title })}
|
||||||
|
@@ -18,7 +18,7 @@ import {
|
|||||||
challengeTestsSelector,
|
challengeTestsSelector,
|
||||||
closeModal,
|
closeModal,
|
||||||
challengeFilesSelector,
|
challengeFilesSelector,
|
||||||
updateProjectFormValues
|
updateSolutionFormValues
|
||||||
} from './';
|
} from './';
|
||||||
import {
|
import {
|
||||||
userSelector,
|
userSelector,
|
||||||
@@ -92,7 +92,7 @@ function submitProject(type, state) {
|
|||||||
payload: challengeInfo
|
payload: challengeInfo
|
||||||
};
|
};
|
||||||
return postChallenge(update, username).pipe(
|
return postChallenge(update, username).pipe(
|
||||||
concat(of(updateProjectFormValues({})))
|
concat(of(updateSolutionFormValues({})))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,7 +57,7 @@ export const types = createTypes(
|
|||||||
'updateChallengeMeta',
|
'updateChallengeMeta',
|
||||||
'updateFile',
|
'updateFile',
|
||||||
'updateJSEnabled',
|
'updateJSEnabled',
|
||||||
'updateProjectFormValues',
|
'updateSolutionFormValues',
|
||||||
'updateSuccessMessage',
|
'updateSuccessMessage',
|
||||||
'updateTests',
|
'updateTests',
|
||||||
'updateLogs',
|
'updateLogs',
|
||||||
@@ -136,8 +136,8 @@ export const updateFile = createAction(types.updateFile);
|
|||||||
export const updateConsole = createAction(types.updateConsole);
|
export const updateConsole = createAction(types.updateConsole);
|
||||||
export const updateLogs = createAction(types.updateLogs);
|
export const updateLogs = createAction(types.updateLogs);
|
||||||
export const updateJSEnabled = createAction(types.updateJSEnabled);
|
export const updateJSEnabled = createAction(types.updateJSEnabled);
|
||||||
export const updateProjectFormValues = createAction(
|
export const updateSolutionFormValues = createAction(
|
||||||
types.updateProjectFormValues
|
types.updateSolutionFormValues
|
||||||
);
|
);
|
||||||
export const updateSuccessMessage = createAction(types.updateSuccessMessage);
|
export const updateSuccessMessage = createAction(types.updateSuccessMessage);
|
||||||
|
|
||||||
@@ -330,7 +330,7 @@ export const reducer = handleActions(
|
|||||||
...state,
|
...state,
|
||||||
backendFormValues: payload
|
backendFormValues: payload
|
||||||
}),
|
}),
|
||||||
[types.updateProjectFormValues]: (state, { payload }) => ({
|
[types.updateSolutionFormValues]: (state, { payload }) => ({
|
||||||
...state,
|
...state,
|
||||||
projectFormValues: payload
|
projectFormValues: payload
|
||||||
}),
|
}),
|
||||||
|
Reference in New Issue
Block a user