mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
e9d64ebb23
* Got a hacky workspace implementation running * Removed some hax with reducer composition * Moved some more around * Moved files back out * Started on entities reducer * Split up some components * Moved nested modules back out of workspaces * Started on new Sidebar tree stuff * Better store stuff * Some more tweaks * Removed workspace update action * Re-implemented filtering in the Sidbare * Switch to get the newest response
51 lines
1016 B
JavaScript
51 lines
1016 B
JavaScript
import * as network from '../../lib/network'
|
|
import {loadStart, loadStop} from './global'
|
|
import {show} from './modals'
|
|
import {MODAL_REQUEST_RENAME} from '../../lib/constants'
|
|
|
|
export const REQUEST_CHANGE_FILTER = 'requests/filter';
|
|
|
|
const initialState = {
|
|
filter: ''
|
|
};
|
|
|
|
// ~~~~~~~~ //
|
|
// REDUCERS //
|
|
// ~~~~~~~~ //
|
|
|
|
export default function (state = initialState, action) {
|
|
switch (action.type) {
|
|
|
|
case REQUEST_CHANGE_FILTER:
|
|
const filter = action.filter;
|
|
return Object.assign({}, state, {filter});
|
|
|
|
default:
|
|
return state;
|
|
}
|
|
}
|
|
|
|
|
|
// ~~~~~~~ //
|
|
// ACTIONS //
|
|
// ~~~~~~~ //
|
|
|
|
export function changeFilter (filter) {
|
|
return {type: REQUEST_CHANGE_FILTER, filter};
|
|
}
|
|
|
|
export function send (request) {
|
|
return dispatch => {
|
|
dispatch(loadStart());
|
|
|
|
network.send(request, () => {
|
|
dispatch(loadStop());
|
|
});
|
|
}
|
|
}
|
|
|
|
export function showUpdateNamePrompt (request) {
|
|
const defaultValue = request.name;
|
|
return show(MODAL_REQUEST_RENAME, {defaultValue, request});
|
|
}
|