Skip to content
Snippets Groups Projects

Master->develop (this MR contains no useful information)

Closed Hidde Leistra requested to merge master into develop
5 files
+ 5
5
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -40,16 +40,19 @@ class EditPanel extends React.Component {
}
static getDerivedStateFromProps (nextProps, prevState) {
// In case nothing is set, use an empty function that no-ops
const updateCallback = nextProps.updateCallback || (_ => {})
if (nextProps.feedback && prevState.id !== nextProps.feedback.id) {
const fb = nextProps.feedback
return {
id: fb.id,
name: fb.name,
description: fb.description,
score: fb.score
score: fb.score,
updateCallback: updateCallback
}
}
return null
return {updateCallback: updateCallback}
}
changeText = (event) => {
@@ -84,10 +87,15 @@ class EditPanel extends React.Component {
if (this.state.id) {
fb.id = this.state.id
api.put(uri, fb)
.then(() => this.props.goBack())
.then(() => {
this.state.updateCallback(fb)
this.props.goBack()
})
} else {
api.post(uri, fb)
.then(() => {
.then((response) => {
// Response is the feedback option
this.state.updateCallback(response)
this.setState({
id: null,
name: '',
@@ -101,14 +109,20 @@ class EditPanel extends React.Component {
deleteFeedback = () => {
if (this.state.id) {
api.del('feedback/' + this.props.problemID + '/' + this.state.id)
.then(() => this.props.goBack())
.then(() => {
this.state.updateCallback({
id: this.state.id,
deleted: true
})
this.props.goBack()
})
}
}
render () {
return (
<nav className='panel'>
<p className='panel-heading'>
<React.Fragment>
<p className={this.props.grading ? 'panel-heading' : 'panel-heading is-radiusless'}>
Manage feedback
</p>
@@ -168,7 +182,7 @@ class EditPanel extends React.Component {
onCancel={() => { this.setState({deleting: false}) }}
/>
</div>
</nav>
</React.Fragment>
)
}
}
Loading