WIP delete mapping in redux
parent
6f0b3ae48e
commit
a460e6c81f
|
@ -117,6 +117,13 @@ export const createMapping = mapping => ({
|
|||
},
|
||||
})
|
||||
|
||||
export const deleteMapping = mapping => ({
|
||||
type: 'CHRONOGRAF_DELETE_MAPPING',
|
||||
payload: {
|
||||
mapping,
|
||||
},
|
||||
})
|
||||
|
||||
// async actions (thunks)
|
||||
export const loadUsersAsync = url => async dispatch => {
|
||||
try {
|
||||
|
|
|
@ -21,6 +21,7 @@ class ProvidersTable extends Component {
|
|||
|
||||
handleCreateMap = newMap => {
|
||||
const {onCreateMap} = this.props
|
||||
//todo: better way of getting mapping id
|
||||
this.setState({isCreatingMap: false})
|
||||
const newMapID = this.props.mappings.length.toString()
|
||||
newMap.id = newMapID
|
||||
|
|
|
@ -6,7 +6,6 @@ import * as adminChronografActionCreators from 'src/admin/actions/chronograf'
|
|||
import {publishAutoDismissingNotification} from 'shared/dispatchers'
|
||||
|
||||
import ProvidersTable from 'src/admin/components/chronograf/ProvidersTable'
|
||||
import {createMapping} from '../actions/chronograf'
|
||||
|
||||
class ProvidersPage extends Component {
|
||||
constructor(props) {
|
||||
|
@ -24,7 +23,6 @@ class ProvidersPage extends Component {
|
|||
}
|
||||
|
||||
handleCreateMap = mapping => {
|
||||
// update the redux store
|
||||
this.props.actions.createMapping(mapping)
|
||||
}
|
||||
|
||||
|
@ -35,7 +33,9 @@ class ProvidersPage extends Component {
|
|||
// update the server
|
||||
}
|
||||
|
||||
handleDeleteMap = () => {}
|
||||
handleDeleteMap = mapping => {
|
||||
this.props.actions.deleteMapping(mapping)
|
||||
}
|
||||
|
||||
render() {
|
||||
const {organizations, mappings = []} = this.props
|
||||
|
|
|
@ -123,6 +123,14 @@ const adminChronograf = (state = initialState, action) => {
|
|||
mappings: [...state.mappings, mapping],
|
||||
}
|
||||
}
|
||||
|
||||
case 'CHRONOGRAF_DELETE_MAPPING': {
|
||||
const {mapping} = action.payload
|
||||
return {
|
||||
...state,
|
||||
mappings: state.mappings.filter(m => m.id !== mapping.id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return state
|
||||
|
|
Loading…
Reference in New Issue