diff --git a/app/renderer/components/main/clearBrowsingDataPanel.js b/app/renderer/components/main/clearBrowsingDataPanel.js index 6e44f73733f..6cef0503228 100644 --- a/app/renderer/components/main/clearBrowsingDataPanel.js +++ b/app/renderer/components/main/clearBrowsingDataPanel.js @@ -3,10 +3,10 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ const React = require('react') -const Immutable = require('immutable') const ipc = require('electron').ipcRenderer // Components +const ReduxComponent = require('../reduxComponent') const Dialog = require('../common/dialog') const Button = require('../common/button') const SwitchControl = require('../common/switchControl') @@ -20,6 +20,7 @@ const { // Actions const appActions = require('../../../../js/actions/appActions') +const windowActions = require('../../../../js/actions/windowActions') // Constants const messages = require('../../../../js/constants/messages') @@ -36,24 +37,48 @@ class ClearBrowsingDataPanel extends React.Component { this.onToggleAutofillData = this.onToggleSetting.bind(this, 'autofillData') this.onToggleSavedSiteSettings = this.onToggleSetting.bind(this, 'savedSiteSettings') this.onClear = this.onClear.bind(this) - this.state = { - clearBrowsingDataDetail: props.clearBrowsingDataDefaults ? props.clearBrowsingDataDefaults : Immutable.Map() - } } + onToggleSetting (setting) { this.setState(({clearBrowsingDataDetail}) => ({ clearBrowsingDataDetail: clearBrowsingDataDetail.update(setting, isChecked => !isChecked) })) } + onClear () { - appActions.onClearBrowsingData(this.state.clearBrowsingDataDetail) - this.props.onHide() - let detail = this.state.clearBrowsingDataDetail - if (detail.get('allSiteCookies') && detail.get('browserHistory') && - detail.get('cachedImagesAndFiles')) { + appActions.onClearBrowsingData() + this.onHide() + + if ( + this.props.allSiteCookies && + this.props.browserHistory && + this.props.cachedImagesAndFiles + ) { ipc.send(messages.PREFS_RESTART) } } + + onHide () { + windowActions.setClearBrowsingDataPanelVisible(false) + } + + mergeProps (state, ownProps) { + const clearBrowsingDataDefaults = state.get('clearBrowsingDataDefaults') + + const props = {} + props.allSiteCookies = clearBrowsingDataDefaults.allSiteCookies + props.browserHistory = clearBrowsingDataDefaults.browserHistory + props.downloadHistory = clearBrowsingDataDefaults.downloadHistory + props.cachedImagesAndFiles = clearBrowsingDataDefaults.cachedImagesAndFiles + props.savedPasswords = clearBrowsingDataDefaults.savedPasswords + props.allSiteCookies = clearBrowsingDataDefaults.allSiteCookies + props.autocompleteData = clearBrowsingDataDefaults.autocompleteData + props.autofillData = clearBrowsingDataDefaults.autofillData + props.savedSiteSettings = clearBrowsingDataDefaults.savedSiteSettings + + return props + } + render () { return e.stopPropagation()}> @@ -62,45 +87,45 @@ class ClearBrowsingDataPanel extends React.Component {