Remove redundant action
parent
b8cd78b67d
commit
c86d50ecaf
|
@ -144,9 +144,9 @@ describe('Admin.Reducers', () => {
|
|||
})
|
||||
|
||||
it('can edit a database', () => {
|
||||
const name = 'dbOne'
|
||||
const actual = reducer(state, editDatabase(db1, name))
|
||||
const expected = [{...db1, name}]
|
||||
const updates = {name: 'dbOne'}
|
||||
const actual = reducer(state, editDatabase(db1, updates))
|
||||
const expected = [{...db1, ...updates}]
|
||||
|
||||
expect(actual.databases).to.deep.equal(expected)
|
||||
})
|
||||
|
|
|
@ -110,11 +110,11 @@ export const editRole = (role, updates) => ({
|
|||
},
|
||||
})
|
||||
|
||||
export const editDatabase = (database, name) => ({
|
||||
export const editDatabase = (database, updates) => ({
|
||||
type: 'EDIT_DATABASE',
|
||||
payload: {
|
||||
name,
|
||||
database,
|
||||
updates,
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -191,14 +191,6 @@ export const startDeleteDatabase = (database) => ({
|
|||
},
|
||||
})
|
||||
|
||||
export const updateDatabaseDeleteCode = (database, deleteCode) => ({
|
||||
type: 'UPDATE_DATABASE_DELETE_CODE',
|
||||
payload: {
|
||||
database,
|
||||
deleteCode,
|
||||
},
|
||||
})
|
||||
|
||||
export const removeDatabaseDeleteCode = (database) => ({
|
||||
type: 'REMOVE_DATABASE_DELETE_CODE',
|
||||
payload: {
|
||||
|
|
|
@ -191,7 +191,7 @@ const EditHeader = ({database, onEdit, onKeyDown, onConfirm, onCancel}) => (
|
|||
type="text"
|
||||
value={database.name}
|
||||
placeholder="database name"
|
||||
onChange={(e) => onEdit(database, e.target.value)}
|
||||
onChange={(e) => onEdit(database, {name: e.target.value})}
|
||||
onKeyDown={(e) => onKeyDown(e, database)}
|
||||
autoFocus={true}
|
||||
/>
|
||||
|
|
|
@ -68,7 +68,7 @@ class DatabaseManagerPage extends Component {
|
|||
return actions.deleteDatabaseAsync(source, database)
|
||||
}
|
||||
|
||||
actions.updateDatabaseDeleteCode(database, value)
|
||||
actions.editDatabase(database, {deleteCode: value})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,6 @@ DatabaseManagerPage.propTypes = {
|
|||
addDatabase: func,
|
||||
removeDatabase: func,
|
||||
startDeleteDatabase: func,
|
||||
updateDatabaseDeleteCode: func,
|
||||
removeDatabaseDeleteCode: func,
|
||||
editRetentionPolicy: func,
|
||||
removeRetentionPolicy: func,
|
||||
|
|
|
@ -119,9 +119,9 @@ export default function admin(state = initialState, action) {
|
|||
}
|
||||
|
||||
case 'EDIT_DATABASE': {
|
||||
const {database, name} = action.payload
|
||||
const {database, updates} = action.payload
|
||||
const newState = {
|
||||
databases: state.databases.map(db => db.links.self === database.links.self ? {...db, name} : db),
|
||||
databases: state.databases.map(db => db.links.self === database.links.self ? {...db, ...updates} : db),
|
||||
}
|
||||
|
||||
return {...state, ...newState}
|
||||
|
@ -189,15 +189,6 @@ export default function admin(state = initialState, action) {
|
|||
return {...state, ...newState}
|
||||
}
|
||||
|
||||
case 'UPDATE_DATABASE_DELETE_CODE': {
|
||||
const {database, deleteCode} = action.payload
|
||||
const newState = {
|
||||
databases: state.databases.map(db => db.links.self === database.links.self ? {...db, deleteCode} : db),
|
||||
}
|
||||
|
||||
return {...state, ...newState}
|
||||
}
|
||||
|
||||
case 'REMOVE_DATABASE_DELETE_CODE': {
|
||||
const {database} = action.payload
|
||||
delete database.deleteCode
|
||||
|
|
Loading…
Reference in New Issue