mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-07 16:44:27 +01:00
feat: reducer and actions for creating a collection
This commit is contained in:
parent
efaa9aed21
commit
2431c0ac03
@ -25,6 +25,10 @@ const Sidebar = ({collections, actions, dispatch, activeRequestTabId}) => {
|
||||
|
||||
const handleConfirm = (values) => {
|
||||
console.log(values);
|
||||
dispatch({
|
||||
name: values.collectionName,
|
||||
type: actions.COLLECTION_CREATE
|
||||
});
|
||||
setModalOpen(false);
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
const SIDEBAR_COLLECTION_CLICK = "SIDEBAR_COLLECTION_CLICK";
|
||||
const SIDEBAR_COLLECTION_ITEM_CLICK = "SIDEBAR_COLLECTION_ITEM_CLICK";
|
||||
const COLLECTION_CREATE = "COLLECTION_CREATE";
|
||||
const REQUEST_TAB_CLICK = "REQUEST_TAB_CLICK";
|
||||
const REQUEST_TAB_CLOSE = "REQUEST_TAB_CLOSE";
|
||||
const REQUEST_URL_CHANGED = "REQUEST_URL_CHANGED";
|
||||
@ -14,6 +15,7 @@ const ADD_NEW_GQL_REQUEST = "ADD_NEW_GQL_REQUEST";
|
||||
export default {
|
||||
SIDEBAR_COLLECTION_CLICK,
|
||||
SIDEBAR_COLLECTION_ITEM_CLICK,
|
||||
COLLECTION_CREATE,
|
||||
REQUEST_TAB_CLICK,
|
||||
REQUEST_TAB_CLOSE,
|
||||
REQUEST_URL_CHANGED,
|
||||
|
@ -52,6 +52,18 @@ const reducer = (state, action) => {
|
||||
});
|
||||
}
|
||||
|
||||
case actions.COLLECTION_CREATE: {
|
||||
return produce(state, (draft) => {
|
||||
// todo: collection names must be unique across a user account
|
||||
draft.collections = draft.collections || [];
|
||||
draft.collections.push({
|
||||
id: nanoid(),
|
||||
name: action.name,
|
||||
items: []
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
case actions.REQUEST_TAB_CLICK: {
|
||||
return produce(state, (draft) => {
|
||||
draft.activeRequestTabId = action.requestTab.id;
|
||||
|
Loading…
Reference in New Issue
Block a user