forked from SuperblocksHQ/superblocks-lab
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store opened panes in the redux store (SuperblocksHQ#278)
- Loading branch information
unknown
committed
Dec 11, 2018
1 parent
258fa1d
commit 17224cc
Showing
15 changed files
with
102 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './panes.actions'; | ||
export * from './projects.actions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const panesActions = { | ||
ADD_PANE: 'ADD_PANE', | ||
addPane(id, name) { | ||
return { | ||
type: panesActions.ADD_PANE, | ||
data: { id, name } | ||
} | ||
}, | ||
|
||
REMOVE_PANE: 'REMOVE_PANE', | ||
removePane(id) { | ||
return { | ||
type: panesActions.REMOVE_PANE, | ||
data: { id } | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export function selectProject(id, name) { | ||
return { | ||
type: 'SELECT_PROJECT', | ||
data: { id, name } | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
import * as actions from './projects'; | ||
import ProjectItem from '../components/projecteditor/control/item/projectItem'; | ||
jest.mock('../components/projecteditor/control/item/projectItem'); // ProjectItem is now a mock constructor | ||
|
||
describe('actions', () => { | ||
it('should create an action to select the projec to open when re-loading the app', () => { | ||
const projectItem = new ProjectItem(); | ||
|
||
const expectedAction = { | ||
type: 'SELECT_PROJECT', | ||
data: { | ||
project: projectItem | ||
}, | ||
data: { id: 23, name: 'test' }, | ||
}; | ||
expect(actions.selectProject(projectItem)).toEqual(expectedAction); | ||
expect(actions.selectProject(23, 'test')).toEqual(expectedAction); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export const closeAllPanels = () => ({ type: 'CLOSE_ALL_PANELS' }); | ||
export const toggleTransactionsHistoryPanel = () => ({ type: 'TOGGLE_TRANSACTIONS_HISTORY_PANEL' }); | ||
export const openTransactionsHistoryPanel = () => ({ type: 'OPEN_TRANSACTIONS_HISTORY_PANEL' }); | ||
export const closeTransactionsHistoryPanel = () => ({ type: 'CLOSE_TRANSACTIONS_HISTORY_PANEL' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { panesActions } from '../actions' | ||
|
||
export const initialState = { | ||
panes: [] | ||
}; | ||
|
||
export default function panesReducer(state = initialState, action) { | ||
switch (action.type) { | ||
case panesActions.ADD_PANE: { | ||
return { | ||
...state, | ||
panes: state.panes.concat([ { ... action.data } ]) | ||
}; | ||
} | ||
case panesActions.REMOVE_PANE: { | ||
return { | ||
...state, | ||
panes: state.panes.filter(p => p.id !== action.data.id) | ||
} | ||
} | ||
default: | ||
return state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters