This commit is contained in:
Gregory Schier 2016-04-04 23:08:03 -07:00
parent e845a71ac5
commit 5d87b98344
7 changed files with 31 additions and 30 deletions

View File

@ -37,6 +37,8 @@ export function addRequest (requestGroupId = null) {
const request = buildRequest({name: 'My Request'});
dispatch({type: types.REQUEST_ADD, request});
// HACK: Add request to group right away. Not sure how to get around this
// TODO: Make this not need to know about RequestGroup actions
if (requestGroupId) {
const id = requestGroupId;
const requestId = request.id;
@ -90,7 +92,9 @@ export function updateRequest (requestPatch) {
export function duplicateRequest (oldRequest, requestGroupId) {
return (dispatch) => {
dispatch(loadStart());
const request = buildRequest(Object.assign({}, oldRequest, {id: null}));
const request = buildRequest(
Object.assign({}, oldRequest, {id: null, name: `${oldRequest.name} Copy`})
);
dispatch({type: types.REQUEST_ADD, request});
if (requestGroupId) {

View File

@ -59,7 +59,7 @@ class Sidebar extends Component {
const isActive = activeRequest && filteredRequests.find(r => r.id == activeRequest.id);
let folderIconClass = 'fa-folder';
let expanded = activeFilter || !requestGroup.collapsed;
let expanded = !requestGroup.collapsed;
folderIconClass += !expanded ? '' : '-open';
folderIconClass += isActive ? '' : '-o';

View File

@ -30,7 +30,7 @@ class App extends Component {
<div className="grid grid-collapse">
<section id="request-pane" className="pane col tall">
<div className="grid-v">
<header className="pane__header bg-super-light">
<header className="pane__header">
<RequestUrlBar
onUrlChange={updateRequestUrl}
onMethodChange={updateRequestMethod}
@ -106,7 +106,7 @@ class App extends Component {
const activeRequest = requests.all.find(r => r.id === requests.active);
return (
<div className="grid">
<div className="grid bg-super-dark">
<Sidebar
activateRequest={actions.activateRequest}
changeFilter={actions.changeFilter}
@ -133,9 +133,6 @@ App.propTypes = {
changeFilter: PropTypes.func.isRequired,
updateRequestMethod: PropTypes.func.isRequired,
toggleRequestGroup: PropTypes.func.isRequired
}).isRequired,
sidebar: PropTypes.shape({
}).isRequired,
requests: PropTypes.shape({
all: PropTypes.array.isRequired,
@ -151,7 +148,6 @@ function mapStateToProps (state) {
return {
actions: state.actions,
requests: state.requests,
sidebar: state.sidebar,
requestGroups: state.requestGroups,
loading: state.loading
};
@ -163,8 +159,7 @@ function mapDispatchToProps (dispatch) {
{},
bindActionCreators(GlobalActions, dispatch),
bindActionCreators(RequestActions, dispatch),
bindActionCreators(RequestGroupActions, dispatch),
bindActionCreators(SidebarActions, dispatch)
bindActionCreators(RequestGroupActions, dispatch)
)
}
}

View File

@ -23,8 +23,6 @@
width: 100%;
text-align: left;
box-sizing: border-box;
height: $line-height-sm;
line-height: $line-height-sm;
color: inherit;
&:hover {
@ -32,7 +30,7 @@
}
& > button {
padding: 0 $padding-md;
padding: $padding-sm;
color: inherit;
height: 100%;
width: 100%;

View File

@ -23,13 +23,11 @@ export default function (state = initialState, action) {
const settings = settingsReducer(state.settings, action);
const requests = requestsReducer(state.requests, action);
const requestGroups = requestGroupsReducer(state.requestGroups, action);
const sidebar = requestGroupsReducer(state.sidebar, action);
return Object.assign({}, state, {
settings,
requests,
requestGroups,
sidebar
requestGroups
});
}
};

View File

@ -38,29 +38,45 @@ function requestGroupsReducer (state = [], action) {
}
});
case types.REQUEST_GROUP_ADD_CHILD_REQUEST:
return state.map(rg => {
if (rg.id === action.id) {
rg.children = [
{type: 'Request', id: action.requestId},
...rg.children
];
}
return rg;
});
default:
return state;
}
}
export default function (state = initialState, action) {
let all;
switch (action.type) {
case types.REQUEST_GROUP_ADD:
let all = requestGroupsReducer(state.all, action);
all = requestGroupsReducer(state.all, action);
return Object.assign({}, state, {all});
case types.REQUEST_GROUP_DELETE:
// TODO: Remove from collapsed as well
let all = state.all.filter(rg => rg.id !== action.id);
all = state.all.filter(rg => rg.id !== action.id);
return Object.assign({}, state, {all});
case types.REQUEST_GROUP_ADD_CHILD_REQUEST:
all = requestGroupsReducer(state.all, action);
return Object.assign({}, state, {all});
case types.REQUEST_GROUP_TOGGLE:
let all = requestGroupsReducer(state.all, action);
all = requestGroupsReducer(state.all, action);
return Object.assign({}, state, {all});
case types.REQUEST_GROUP_UPDATE:
let all = requestGroupsReducer(state.all, action);
all = requestGroupsReducer(state.all, action);
return Object.assign({}, state, {all});
default:

View File

@ -1,10 +0,0 @@
const initialState = {
children: []
};
export default function (state = initialState, action) {
switch (action.type) {
default:
return state
}
}