Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Removes site settings for delete sites #14260

Merged
merged 1 commit into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/browser/reducers/siteSettingsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const siteSettingsReducer = (state, action, immutableAction) => {
if (action.get('skipSync')) {
newEntry = newEntry.set('skipSync', true)
}
if (action.get('key') === 'ledgerPaymentsShown') {
newEntry = newEntry.delete('ledgerPayments')
}
newSiteSettings = newSiteSettings.set(hostPattern, newEntry)
})
state = state.set(propertyName, newSiteSettings)
Expand Down
15 changes: 7 additions & 8 deletions app/renderer/components/preferences/payment/deletedSites.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ const ImmutableComponent = require('../../immutableComponent')
// Style
const globalStyles = require('../../styles/global')

const permissionName = 'ledgerPaymentsShown'

class DeletedSitesContent extends ImmutableComponent {
constructor (props) {
super(props)
this.deletePermission = this.deletePermission.bind(this)
}

deletePermission (name, hostPattern) {
appActions.removeSiteSetting(hostPattern, name)
deletePermission (hostPattern) {
appActions.removeSiteSetting(hostPattern, 'ledgerPayments')
appActions.removeSiteSetting(hostPattern, 'ledgerPaymentsShown')
this.props.onHide()
}

Expand All @@ -46,7 +45,7 @@ class DeletedSitesContent extends ImmutableComponent {
iconClass={globalStyles.appIcons.remove}
size='1rem'
custom={styles.sitePermissions__list__item__button}
onClick={this.deletePermission.bind(this, permissionName, data.hostPattern)}
onClick={this.deletePermission.bind(this, data.hostPattern)}
/>
<span>{siteName}</span>
</div>
Expand All @@ -58,8 +57,8 @@ class DeletedSitesContent extends ImmutableComponent {
}

class DeletedSitesFooter extends ImmutableComponent {
clearPermissions (name) {
aboutActions.clearSiteSettings(name)
clearPermissions () {
aboutActions.clearSiteSettings('ledgerPaymentsShown')
this.props.onHide()
}

Expand All @@ -68,7 +67,7 @@ class DeletedSitesFooter extends ImmutableComponent {
<BrowserButton groupedItem secondaryColor
l10nId='clearAll'
testId='clearAll'
onClick={this.clearPermissions.bind(this, 'ledgerPaymentsShown')}
onClick={this.clearPermissions.bind(this)}
/>
<BrowserButton groupedItem primaryColor
l10nId='done'
Expand Down
24 changes: 24 additions & 0 deletions test/unit/app/browser/reducers/siteSettingsReducerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,30 @@ describe('siteSettingsReducer unit tests', function () {
assert.equal(newState.getIn(['siteSettings', 'https://example.com', 'skipSync']), undefined)
})
})

it('ledger delete flag is cleared', function () {
const beforeState = fakeAppState.setIn(['siteSettings'], Immutable.fromJS({
'https://example.com': {
ledgerPaymentsShown: false,
ledgerPayments: true
},
'https://example1.com': {
keyNameHere: 'keyValueHere'
},
'https://example2.com': {
ledgerPayments: true
}
}))
const afterState = siteSettingsReducer(beforeState, Immutable.fromJS({
actionType: appConstants.APP_CLEAR_SITE_SETTINGS,
key: 'ledgerPaymentsShown'
}))

const expectedState = afterState
.setIn(['siteSettings', 'https://example.com'], Immutable.Map())

assert.deepEqual(afterState.toJS(), expectedState.toJS())
})
})

describe('APP_ADD_NOSCRIPT_EXCEPTIONS', function () {
Expand Down