mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
39 lines
672 B
JavaScript
39 lines
672 B
JavaScript
|
const MODAL_SHOW = 'modals/show';
|
||
|
const MODAL_HIDE = 'modals/hide';
|
||
|
|
||
|
const initialState = [];
|
||
|
|
||
|
// ~~~~~~~~ //
|
||
|
// REDUCERS //
|
||
|
// ~~~~~~~~ //
|
||
|
|
||
|
export default function (state = initialState, action) {
|
||
|
switch (action.type) {
|
||
|
|
||
|
case MODAL_SHOW:
|
||
|
let id = action.id;
|
||
|
let data = action.data;
|
||
|
return [...state.filter(m => m.id !== action.id), {id, data}];
|
||
|
|
||
|
case MODAL_HIDE:
|
||
|
return state.filter(m => m.id !== action.id);
|
||
|
|
||
|
default:
|
||
|
return state
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
// ~~~~~~~ //
|
||
|
// ACTIONS //
|
||
|
// ~~~~~~~ //
|
||
|
|
||
|
export function hide (id) {
|
||
|
return {type: MODAL_HIDE, id}
|
||
|
}
|
||
|
|
||
|
export function show (id, data = {}) {
|
||
|
return {type: MODAL_SHOW, id, data};
|
||
|
}
|
||
|
|