+
+
+ this.setState({ enabled })}/>
+ this.setState({ started })}/>
+ this.setState({ primary_user: id })}/>
+ this.setState({ type: id })}/>
+
+
+ {!this.isNew && (
+
+ )}
+
+
+
{this.state.error}
+
}
}
-export default Instance
+export default withRouter(Instance)
diff --git a/maubot/management/frontend/src/pages/dashboard/index.js b/maubot/management/frontend/src/pages/dashboard/index.js
index 8196f60..a448fdc 100644
--- a/maubot/management/frontend/src/pages/dashboard/index.js
+++ b/maubot/management/frontend/src/pages/dashboard/index.js
@@ -61,8 +61,11 @@ class Dashboard extends Component {
this.setState({ [stateField]: data })
}
- add(stateField, entry) {
+ add(stateField, entry, oldID = undefined) {
const data = Object.assign({}, this.state[stateField])
+ if (oldID && oldID !== entry.id) {
+ delete data[oldID]
+ }
data[entry.id] = entry
this.setState({ [stateField]: data })
}
@@ -76,7 +79,8 @@ class Dashboard extends Component {
return React.createElement(type, {
[field]: entry,
onDelete: () => this.delete(stateField, id),
- onChange: newEntry => this.add(stateField, newEntry),
+ onChange: newEntry => this.add(stateField, newEntry, id),
+ ctx: this.state,
})
}
@@ -117,8 +121,9 @@ class Dashboard extends Component {