-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into new_localization
- Loading branch information
Showing
14 changed files
with
383 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/components/forms/EditScoreConfigForm/EditScoreConfigForm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { canUseDOM } from 'exenv'; | ||
import { reduxForm, Field } from 'redux-form'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { Alert } from 'react-bootstrap'; | ||
|
||
import { SourceCodeField } from '../Fields'; | ||
import SubmitButton from '../SubmitButton'; | ||
|
||
if (canUseDOM) { | ||
require('codemirror/mode/yaml/yaml'); | ||
} | ||
|
||
const EditScoreConfigForm = ({ | ||
anyTouched, | ||
submitting, | ||
handleSubmit, | ||
hasFailed = false, | ||
hasSucceeded = false, | ||
invalid | ||
}) => | ||
<div> | ||
{hasFailed && | ||
<Alert bsStyle="danger"> | ||
<FormattedMessage | ||
id="app.editScoreConfigForm.failed" | ||
defaultMessage="Saving failed. Please try again later." | ||
/> | ||
</Alert>} | ||
|
||
<Field | ||
name="scoreConfig" | ||
component={SourceCodeField} | ||
mode="yaml" | ||
label={ | ||
<FormattedMessage | ||
id="app.editScoreConfigForm.scoreConfig" | ||
defaultMessage="Score configuration:" | ||
/> | ||
} | ||
/> | ||
|
||
<div className="text-center"> | ||
<SubmitButton | ||
id="editEnvironmentConfig" | ||
invalid={invalid} | ||
submitting={submitting} | ||
hasSucceeded={hasSucceeded} | ||
dirty={anyTouched} | ||
hasFailed={hasFailed} | ||
handleSubmit={handleSubmit} | ||
messages={{ | ||
submit: ( | ||
<FormattedMessage | ||
id="app.editScoreConfigForm.submit" | ||
defaultMessage="Change configuration" | ||
/> | ||
), | ||
submitting: ( | ||
<FormattedMessage | ||
id="app.editScoreConfigForm.submitting" | ||
defaultMessage="Saving configuration ..." | ||
/> | ||
), | ||
success: ( | ||
<FormattedMessage | ||
id="app.editScoreConfigForm.success" | ||
defaultMessage="Configuration was changed." | ||
/> | ||
) | ||
}} | ||
/> | ||
</div> | ||
</div>; | ||
|
||
EditScoreConfigForm.propTypes = { | ||
handleSubmit: PropTypes.func.isRequired, | ||
anyTouched: PropTypes.bool, | ||
submitting: PropTypes.bool, | ||
hasFailed: PropTypes.bool, | ||
hasSucceeded: PropTypes.bool, | ||
invalid: PropTypes.bool | ||
}; | ||
|
||
const validate = () => { | ||
const errors = {}; | ||
return errors; | ||
}; | ||
|
||
export default reduxForm({ | ||
form: 'editScoreConfig', | ||
validate | ||
})(EditScoreConfigForm); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default from './EditScoreConfigForm'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.