Skip to content

Commit

Permalink
Adding a configurable link to wiki page with runtime environments info.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Krulis committed Sep 19, 2019
1 parent d925b42 commit a79e506
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 14 deletions.
3 changes: 2 additions & 1 deletion etc/env.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"ALLOW_CAS_REGISTRATION": false,
"URL_PATH_PREFIX": "",
"PERSISTENT_TOKENS_KEY_PREFIX": "recodex",
"CAS_HELPDESK_URL": "mailto:recodex@example.domain"
"CAS_HELPDESK_URL": "mailto:recodex@example.domain",
"ENVIRONMENTS_INFO_URL": "https://github.com/ReCodEx/wiki/wiki/Runtime-Environments"
}
36 changes: 25 additions & 11 deletions src/components/Solutions/SubmitSolution/SubmitSolution.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { injectIntl, intlShape, defineMessages } from 'react-intl';
import { injectIntl, intlShape, defineMessages, FormattedHTMLMessage } from 'react-intl';
import { Modal, Button, FormGroup, ControlLabel, FormControl, HelpBlock, Well, Row, Col } from 'react-bootstrap';

import { LoadingIcon, WarningIcon, SendIcon, DeleteIcon, CloseIcon } from '../../icons';
Expand All @@ -11,6 +11,9 @@ import Confirm from '../../forms/Confirm';

import { createGetUploadedFiles } from '../../../redux/selectors/upload';
import { hasEntryPoint } from '../../../redux/selectors/submission';
import { getConfigVar } from '../../../helpers/config';

const environmentsHelpUrl = getConfigVar('ENVIRONMENTS_INFO_URL');

const commonMessages = defineMessages({
runtimeEnvironment: {
Expand Down Expand Up @@ -186,16 +189,27 @@ class SubmitSolution extends Component {
) : !presubmitEnvironments ? (
<p className="text-left callout callout-info">{formatMessage(commonMessages.uploadFilesFirst)}</p>
) : presubmitEnvironments.length > 0 ? (
<FormControl
onChange={e => changeRuntimeEnvironment(e.target.value)}
componentClass="select"
defaultValue={selectedEnvironment}>
{presubmitEnvironments.map(rte => (
<option key={rte.id} value={rte.id}>
{rte.name}
</option>
))}
</FormControl>
<React.Fragment>
<FormControl
onChange={e => changeRuntimeEnvironment(e.target.value)}
componentClass="select"
defaultValue={selectedEnvironment}>
{presubmitEnvironments.map(rte => (
<option key={rte.id} value={rte.id}>
{rte.name}
</option>
))}
</FormControl>
{environmentsHelpUrl && (
<p className="small text-muted em-margin-top">
<FormattedHTMLMessage
id="app.submitSolution.linkToWiki"
defaultMessage="Select the right environment, under which you wish to submit your solution. You may find more information about the environments at our <a href='{url}' target='_blank'>wiki page</a>."
values={{ url: environmentsHelpUrl }}
/>
</p>
)}
</React.Fragment>
) : (
<p className="text-left callout callout-danger">{formatMessage(commonMessages.noEnvironments)}</p>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { reduxForm, Field } from 'redux-form';
import { FormattedMessage, intlShape, injectIntl } from 'react-intl';
import { Alert, Grid, Row, Col, OverlayTrigger, Tooltip } from 'react-bootstrap';
import { FormattedMessage, FormattedHTMLMessage, intlShape, injectIntl } from 'react-intl';
import { Alert, Grid, Row, Col, OverlayTrigger, Tooltip, Well } from 'react-bootstrap';

import { CheckboxField } from '../Fields';
import SubmitButton from '../SubmitButton';
import Button from '../../widgets/FlatButton';
import Icon, { RefreshIcon, InfoIcon } from '../../icons';
import { STANDALONE_ENVIRONMENTS } from '../../../helpers/exercise/environments';
import { getConfigVar } from '../../../helpers/config';

const environmentsHelpUrl = getConfigVar('ENVIRONMENTS_INFO_URL');

class EditEnvironmentSimpleForm extends Component {
render() {
Expand All @@ -27,6 +30,18 @@ class EditEnvironmentSimpleForm extends Component {

return (
<div>
{environmentsHelpUrl && (
<Well bsSize="sm">
<div className="small text-muted">
<FormattedHTMLMessage
id="app.editEnvironmentSimpleForm.linkToWiki"
defaultMessage="Select all runtime environments the exercise should support. You may find more information about the environments at our <a href='{url}' target='_blank'>wiki page</a>."
values={{ url: environmentsHelpUrl }}
/>
</div>
</Well>
)}

<Grid fluid>
<Row>
{runtimeEnvironments
Expand Down Expand Up @@ -73,6 +88,8 @@ class EditEnvironmentSimpleForm extends Component {
</Row>
</Grid>

<hr />

{submitFailed && (
<Alert bsStyle="danger">
<FormattedMessage id="generic.savingFailed" defaultMessage="Saving failed. Please try again later." />
Expand Down
2 changes: 2 additions & 0 deletions src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
"app.editEnvironmentConfig.warnings.ambiguousVariable": "Tato proměnná je definovaná ve více pipelines. Nastavená hodnota bude použita ve všech.",
"app.editEnvironmentConfig.warnings.noPipelinesVariables": "Zatím nejsou vybrané žádné pipelines. Jména proměnných proto není možné verifikovat.",
"app.editEnvironmentConfig.warnings.unknownVariable": "Tato proměnná není definována v žádné pipeline.",
"app.editEnvironmentSimpleForm.linkToWiki": "Vyberte všechna běhová prostředí, která má tato úloha podporovat. Více informací o běhových prostředích naleznete na naší <a href='{url}' target='_blank'>wiki stránce</a>.",
"app.editEnvironmentSimpleForm.standaloneEnvironment": "Separované běhové prostředí",
"app.editEnvironmentSimpleForm.submit": "Uložit prostředí",
"app.editEnvironmentSimpleForm.submitting": "Ukládám...",
Expand Down Expand Up @@ -1218,6 +1219,7 @@
"app.submitSolution.emptyNoteSubmitConfirm": "Popis referenčního řešení je prázdný. Je nanejvýš vhodné, aby referenční řešení byla opatřena relevantním popiskem. Opravdu si přejete pokračovat v odevzdání?",
"app.submitSolution.emptyNoteWarning": "Popis referenčního řešení je prázdný. Je nanejvýš vhodné, aby referenční řešení byla opatřena relevantním popiskem.",
"app.submitSolution.entryPoint": "Vyberte vstupní bod (zaváděcí soubor vaší aplikace):",
"app.submitSolution.linkToWiki": "Vyberte běhové prostředí, pro které je určeno vaše řešení. Více informací o běhových prostředích naleznete na naší <a href='{url}' target='_blank'>wiki stránce</a>.",
"app.submitSolution.noEnvironments": "Nahrané soubory neodpovídají žádnému povolenému běhovému prostředí.",
"app.submitSolution.noteLabel": "Poznámka pro vás a vašeho vyučujícího:",
"app.submitSolution.runtimeEnvironment": "Vyberte běhové prostředí (programovací jazyk):",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
"app.editEnvironmentConfig.warnings.ambiguousVariable": "This variable is defined in multiple pipelines. The value will be used in all of them.",
"app.editEnvironmentConfig.warnings.noPipelinesVariables": "There are no pipelines set. Name of the variables may not be verified.",
"app.editEnvironmentConfig.warnings.unknownVariable": "This variable is not defined in any pipeline.",
"app.editEnvironmentSimpleForm.linkToWiki": "Select all runtime environments the exercise should support. You may find more information about the environments at our <a href='{url}' target='_blank'>wiki page</a>.",
"app.editEnvironmentSimpleForm.standaloneEnvironment": "Separated runtime environment",
"app.editEnvironmentSimpleForm.submit": "Save Environments",
"app.editEnvironmentSimpleForm.submitting": "Saving Environments...",
Expand Down Expand Up @@ -1218,6 +1219,7 @@
"app.submitSolution.emptyNoteSubmitConfirm": "The description is empty. Reference solutions are strongly encouraged to be labeled with relevant descriptions. Do you rellay wish to proceed with submit?",
"app.submitSolution.emptyNoteWarning": "The description is empty. Reference solutions are strongly encouraged to be labeled with relevant descriptions.",
"app.submitSolution.entryPoint": "Select the point of entry (bootstrap file of your application):",
"app.submitSolution.linkToWiki": "Select the right environment, under which you wish to submit your solution. You may find more information about the environments at our <a href='{url}' target='_blank'>wiki page</a>.",
"app.submitSolution.noEnvironments": "Uploaded files do not meet criteria of any allowed runtime environment.",
"app.submitSolution.noteLabel": "Note for you and your supervisor(s):",
"app.submitSolution.runtimeEnvironment": "Select runtime environment (programming language):",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/whitelist_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
"app.editEnvironmentConfig.warnings.ambiguousVariable",
"app.editEnvironmentConfig.warnings.noPipelinesVariables",
"app.editEnvironmentConfig.warnings.unknownVariable",
"app.editEnvironmentSimpleForm.linkToWiki",
"app.editEnvironmentSimpleForm.standaloneEnvironment",
"app.editEnvironmentSimpleForm.submit",
"app.editEnvironmentSimpleForm.submitting",
Expand Down Expand Up @@ -1218,6 +1219,7 @@
"app.submitSolution.emptyNoteSubmitConfirm",
"app.submitSolution.emptyNoteWarning",
"app.submitSolution.entryPoint",
"app.submitSolution.linkToWiki",
"app.submitSolution.noEnvironments",
"app.submitSolution.noteLabel",
"app.submitSolution.runtimeEnvironment",
Expand Down

0 comments on commit a79e506

Please sign in to comment.