Fix cancel new rps

pull/1029/head
Andrew Watkins 2017-03-21 14:31:00 -07:00
parent ba44273779
commit 8aa99442d3
4 changed files with 21 additions and 6 deletions

View File

@ -17,6 +17,7 @@ const DatabaseManager = ({
onCancelRetentionPolicy,
onCreateRetentionPolicy,
onUpdateRetentionPolicy,
onRemoveRetentionPolicy,
}) => {
return (
<div className="panel panel-info">
@ -43,6 +44,7 @@ const DatabaseManager = ({
onCancelRetentionPolicy={onCancelRetentionPolicy}
onCreateRetentionPolicy={onCreateRetentionPolicy}
onUpdateRetentionPolicy={onUpdateRetentionPolicy}
onRemoveRetentionPolicy={onRemoveRetentionPolicy}
/>
)
}
@ -73,6 +75,7 @@ DatabaseManager.propTypes = {
onCancelRetentionPolicy: func,
onCreateRetentionPolicy: func,
onUpdateRetentionPolicy: func,
onRemoveRetentionPolicy: func,
}
export default DatabaseManager

View File

@ -18,9 +18,17 @@ class DatabaseRow extends Component {
this.getInputValues = ::this.getInputValues
}
componentWillMount() {
if (this.props.retentionPolicy.isNew) {
this.setState({isEditing: true})
}
}
render() {
const {
onRemove,
retentionPolicy: {name, duration, replication, isDefault, isNew},
retentionPolicy,
database,
} = this.props
@ -67,11 +75,11 @@ class DatabaseRow extends Component {
ref={(r) => this.replication = r}
/>
</div>
</td>
</td>
<td className="text-right">
<YesNoButtons
onConfirm={isNew ? this.handleCreate : this.handleUpdate}
onCancel={this.handleEndEdit}
onCancel={isNew ? () => onRemove(database, retentionPolicy) : this.handleEndEdit}
/>
</td>
</tr>
@ -131,12 +139,12 @@ class DatabaseRow extends Component {
handleKeyDown(e) {
const {key} = e
const {retentionPolicy, database, onCancel} = this.props
const {retentionPolicy, database, onRemove} = this.props
if (key === 'Escape') {
if (retentionPolicy.isNew) {
onCancel(database, retentionPolicy)
onRemove(database, retentionPolicy)
return
}
@ -189,7 +197,7 @@ DatabaseRow.propTypes = {
isEditing: bool,
}),
database: shape(),
onCancel: func,
onRemove: func,
onCreate: func,
onUpdate: func,
notify: func,

View File

@ -19,6 +19,7 @@ const DatabaseTable = ({
onAddRetentionPolicy,
onCreateRetentionPolicy,
onUpdateRetentionPolicy,
onRemoveRetentionPolicy,
}) => {
return (
<div className="db-manager">
@ -53,6 +54,7 @@ const DatabaseTable = ({
retentionPolicy={rp}
onCreate={onCreateRetentionPolicy}
onUpdate={onUpdateRetentionPolicy}
onRemove={onRemoveRetentionPolicy}
/>
)
})
@ -77,6 +79,7 @@ DatabaseTable.propTypes = {
onCancelRetentionPolicy: func,
onCreateRetentionPolicy: func,
onUpdateRetentionPolicy: func,
onRemoveRetentionPolicy: func,
}
const DatabaseTableHeader = ({

View File

@ -35,9 +35,9 @@ class DatabaseManagerPage extends Component {
onStartDeleteDatabase={actions.startDeleteDatabase}
onAddRetentionPolicy={actions.addRetentionPolicy}
onEditRetentionPolicy={actions.editRetentionPolicy}
onCancelRetentionPolicy={actions.removeRetentionPolicy}
onCreateRetentionPolicy={actions.createRetentionPolicyAsync}
onUpdateRetentionPolicy={actions.updateRetentionPolicyAsync}
onRemoveRetentionPolicy={actions.removeRetentionPolicy}
/>
)
}
@ -108,6 +108,7 @@ DatabaseManagerPage.propTypes = {
updateDatabaseDeleteCode: func,
removeDatabaseDeleteCode: func,
editRetentionPolicy: func,
removeRetentionPolicy: func,
}),
notify: func,
}