feat(challenges): Added warning feedback for non-front-facing glitch url (#16709)

This commit is contained in:
Jason Kao
2018-02-14 20:03:19 -05:00
committed by Stuart Taylor
parent 1789f9da0a
commit 00cb394f08
2 changed files with 20 additions and 4 deletions

View File

@ -10,10 +10,15 @@ const propTypes = {
export default function SolutionInput({ solution, placeholder }) {
const validationState = getValidationState(solution);
return (
<FormGroup
controlId='solution'
validationState={ validationState }
validationState={
(validationState && validationState.includes('warning')) ?
'warning' :
validationState
}
>
<FormControl
name='solution'
@ -22,9 +27,16 @@ export default function SolutionInput({ solution, placeholder }) {
{ ...DOMOnlyProps(solution) }
/>
{
validationState === 'error' ?
<HelpBlock>Make sure you provide a proper URL.</HelpBlock> :
null
validationState === 'error' &&
<HelpBlock>Make sure you provide a proper URL.</HelpBlock>
}
{
validationState === 'glitch-warning' &&
<HelpBlock>
Make sure you have entered a shareable URL
(e.g. "https://green-camper.glitch.me", not
"https://glitch.com/#!/edit/green-camper".)
</HelpBlock>
}
</FormGroup>
);

View File

@ -65,6 +65,10 @@ export function getValidationState(field) {
return null;
}
if ((/https?:\/\/glitch\.com\/edit\/#!\/.*/g).test(field.value)) {
return 'glitch-warning';
}
return field.error ?
'error' :
'success';