-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathInstructionsEditor.jsx
More file actions
79 lines (72 loc) · 2.15 KB
/
InstructionsEditor.jsx
File metadata and controls
79 lines (72 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import React from 'react';
import PropTypes from 'prop-types';
import {t} from 'i18next';
import bindAll from 'lodash/bindAll';
import SimpleMDE from 'react-simplemde-editor';
export default class InstructionsEditor extends React.Component {
constructor() {
super();
bindAll(
this,
'_handleCancelEditing',
'_handleContinueEditing',
'_handleSaveChanges',
);
}
_handleCancelEditing() {
this.props.onCancelEditing();
}
_handleSaveChanges() {
this.props.onSaveChanges(this.props.projectKey, this.props.instructions);
}
_handleContinueEditing(newValue) {
this.props.onContinueEditing(this.props.projectKey, newValue);
}
render() {
return (
<div className="instructions-editor">
<div className="instructions-editor__menu">
<button
className="instructions-editor__menu-button"
onClick={this._handleSaveChanges}
>
{t('workspace.components.instructions.save')}
</button>
<button
className="instructions-editor__menu-button"
onClick={this._handleCancelEditing}
>
{t('workspace.components.instructions.cancel')}
</button>
</div>
<div className="instructions-editor__input-container">
<SimpleMDE
options={{
autofocus: true,
spellChecker: false,
}}
value={this.props.instructions}
onChange={this._handleContinueEditing}
/>
</div>
<div className="instructions-editor__footer">
<a
className="instructions-editor__footer-link"
href="https://guides.github.com/features/mastering-markdown/"
rel="noopener noreferrer"
target="_blank"
>
Styling with Markdown is supported
</a>
</div>
</div>
);
}
}
InstructionsEditor.propTypes = {
instructions: PropTypes.string.isRequired,
projectKey: PropTypes.string.isRequired,
onCancelEditing: PropTypes.func.isRequired,
onContinueEditing: PropTypes.func.isRequired,
onSaveChanges: PropTypes.func.isRequired,
};