From a79e506c975f99032860f6d9ddc2160a7c11a536 Mon Sep 17 00:00:00 2001 From: Martin Krulis Date: Thu, 19 Sep 2019 01:28:29 +0200 Subject: [PATCH] Adding a configurable link to wiki page with runtime environments info. --- etc/env.json.example | 3 +- .../SubmitSolution/SubmitSolution.js | 36 +++++++++++++------ .../EditEnvironmentSimpleForm.js | 21 +++++++++-- src/locales/cs.json | 2 ++ src/locales/en.json | 2 ++ src/locales/whitelist_en.json | 2 ++ 6 files changed, 52 insertions(+), 14 deletions(-) diff --git a/etc/env.json.example b/etc/env.json.example index d0fd34e7e..e5c1d718f 100644 --- a/etc/env.json.example +++ b/etc/env.json.example @@ -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" } diff --git a/src/components/Solutions/SubmitSolution/SubmitSolution.js b/src/components/Solutions/SubmitSolution/SubmitSolution.js index dd0075262..374a7851c 100644 --- a/src/components/Solutions/SubmitSolution/SubmitSolution.js +++ b/src/components/Solutions/SubmitSolution/SubmitSolution.js @@ -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'; @@ -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: { @@ -186,16 +189,27 @@ class SubmitSolution extends Component { ) : !presubmitEnvironments ? (

{formatMessage(commonMessages.uploadFilesFirst)}

) : presubmitEnvironments.length > 0 ? ( - changeRuntimeEnvironment(e.target.value)} - componentClass="select" - defaultValue={selectedEnvironment}> - {presubmitEnvironments.map(rte => ( - - ))} - + + changeRuntimeEnvironment(e.target.value)} + componentClass="select" + defaultValue={selectedEnvironment}> + {presubmitEnvironments.map(rte => ( + + ))} + + {environmentsHelpUrl && ( +

+ +

+ )} +
) : (

{formatMessage(commonMessages.noEnvironments)}

)} diff --git a/src/components/forms/EditEnvironmentSimpleForm/EditEnvironmentSimpleForm.js b/src/components/forms/EditEnvironmentSimpleForm/EditEnvironmentSimpleForm.js index 9190580ef..4c9150b45 100644 --- a/src/components/forms/EditEnvironmentSimpleForm/EditEnvironmentSimpleForm.js +++ b/src/components/forms/EditEnvironmentSimpleForm/EditEnvironmentSimpleForm.js @@ -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() { @@ -27,6 +30,18 @@ class EditEnvironmentSimpleForm extends Component { return (
+ {environmentsHelpUrl && ( + +
+ +
+
+ )} + {runtimeEnvironments @@ -73,6 +88,8 @@ class EditEnvironmentSimpleForm extends Component { +
+ {submitFailed && ( diff --git a/src/locales/cs.json b/src/locales/cs.json index 5161caa0a..72d95d6fd 100644 --- a/src/locales/cs.json +++ b/src/locales/cs.json @@ -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ší wiki stránce.", "app.editEnvironmentSimpleForm.standaloneEnvironment": "Separované běhové prostředí", "app.editEnvironmentSimpleForm.submit": "Uložit prostředí", "app.editEnvironmentSimpleForm.submitting": "Ukládám...", @@ -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ší wiki stránce.", "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):", diff --git a/src/locales/en.json b/src/locales/en.json index f57142bb3..14749f73a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -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 wiki page.", "app.editEnvironmentSimpleForm.standaloneEnvironment": "Separated runtime environment", "app.editEnvironmentSimpleForm.submit": "Save Environments", "app.editEnvironmentSimpleForm.submitting": "Saving Environments...", @@ -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 wiki page.", "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):", diff --git a/src/locales/whitelist_en.json b/src/locales/whitelist_en.json index 484c00877..5e2097c0c 100644 --- a/src/locales/whitelist_en.json +++ b/src/locales/whitelist_en.json @@ -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", @@ -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",