From 7e5f424c5013a591e71f570b003e34f8e6788869 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Thu, 27 Jul 2017 11:22:02 +0800 Subject: [web] Minor fix for frontend and tests. --- web/src/js/__tests__/ducks/optionsSpec.js | 6 +++--- web/src/js/components/Modal/OptionModal.jsx | 9 ++++++--- web/src/js/ducks/options.js | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'web') diff --git a/web/src/js/__tests__/ducks/optionsSpec.js b/web/src/js/__tests__/ducks/optionsSpec.js index a0d11f9c..9178c14e 100644 --- a/web/src/js/__tests__/ducks/optionsSpec.js +++ b/web/src/js/__tests__/ducks/optionsSpec.js @@ -50,13 +50,13 @@ describe('sendUpdate', () => { }) }) -describe('dump', () => { +describe('save', () => { it('should dump options', () => { global.fetch = jest.fn() - store.dispatch(OptionsActions.dump()) + store.dispatch(OptionsActions.save()) expect(fetch).toBeCalledWith( - '/options/dump?_xsrf=undefined', + '/options/save?_xsrf=undefined', { credentials: "same-origin", method: "POST" diff --git a/web/src/js/components/Modal/OptionModal.jsx b/web/src/js/components/Modal/OptionModal.jsx index bc25214a..82ef8350 100644 --- a/web/src/js/components/Modal/OptionModal.jsx +++ b/web/src/js/components/Modal/OptionModal.jsx @@ -52,15 +52,18 @@ class PureOptionModal extends Component { this.state = { title: 'Options' } } + componentWillUnmount(){ + this.props.save() + } + render() { - const { hideModal, options, dump } = this.props + const { hideModal, options } = this.props const { title } = this.state return (
@@ -102,6 +105,6 @@ export default connect( }), { hideModal: modalAction.hideModal, - dump: optionAction.dump, + save: optionAction.save, } )(PureOptionModal) diff --git a/web/src/js/ducks/options.js b/web/src/js/ducks/options.js index d319b171..0da0fb8c 100644 --- a/web/src/js/ducks/options.js +++ b/web/src/js/ducks/options.js @@ -45,6 +45,6 @@ export function update(option, value) { } } -export function dump() { - return dispatch => fetchApi('/options/dump', { method: 'POST' }) +export function save() { + return dispatch => fetchApi('/options/save', { method: 'POST' }) } -- cgit v1.2.3