feat(challenges): Added warning feedback for non-front-facing glitch url (#16709)
This commit is contained in:
@ -10,10 +10,15 @@ const propTypes = {
|
|||||||
|
|
||||||
export default function SolutionInput({ solution, placeholder }) {
|
export default function SolutionInput({ solution, placeholder }) {
|
||||||
const validationState = getValidationState(solution);
|
const validationState = getValidationState(solution);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
controlId='solution'
|
controlId='solution'
|
||||||
validationState={ validationState }
|
validationState={
|
||||||
|
(validationState && validationState.includes('warning')) ?
|
||||||
|
'warning' :
|
||||||
|
validationState
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<FormControl
|
<FormControl
|
||||||
name='solution'
|
name='solution'
|
||||||
@ -22,9 +27,16 @@ export default function SolutionInput({ solution, placeholder }) {
|
|||||||
{ ...DOMOnlyProps(solution) }
|
{ ...DOMOnlyProps(solution) }
|
||||||
/>
|
/>
|
||||||
{
|
{
|
||||||
validationState === 'error' ?
|
validationState === 'error' &&
|
||||||
<HelpBlock>Make sure you provide a proper URL.</HelpBlock> :
|
<HelpBlock>Make sure you provide a proper URL.</HelpBlock>
|
||||||
null
|
}
|
||||||
|
{
|
||||||
|
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>
|
</FormGroup>
|
||||||
);
|
);
|
||||||
|
@ -65,6 +65,10 @@ export function getValidationState(field) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((/https?:\/\/glitch\.com\/edit\/#!\/.*/g).test(field.value)) {
|
||||||
|
return 'glitch-warning';
|
||||||
|
}
|
||||||
|
|
||||||
return field.error ?
|
return field.error ?
|
||||||
'error' :
|
'error' :
|
||||||
'success';
|
'success';
|
||||||
|
Reference in New Issue
Block a user