Skip to content

Commit

Permalink
🌱 Adding usage statistics button in the settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
Osvaldo Vega committed Dec 12, 2018
1 parent 03866a2 commit a9368ce
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
"Send LSK": "Send LSK",
"Send Lisk from Blockchain Application": "Send Lisk from Blockchain Application",
"Send Lisk to Blockchain Application": "Send Lisk to Blockchain Application",
"Send anonymus usage statistics": "Send anonymus usage statistics",
"Send request via E-mail": "Send request via E-mail",
"Send to Address": "Send to Address",
"Send to address": "Send to address",
Expand Down
11 changes: 11 additions & 0 deletions src/components/setting/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ class Setting extends React.Component {
checked: settings.advancedMode,
}}/>
</div>
<div className={`${styles.item} ${styles.network}`}>
<label>{t('Send anonymus usage statistics')}</label>
<Checkbox
theme={styles}
className={`${styles.smallSlider} statistics`}
onChange={() => settingsUpdated({ statistics: !settings.statistics })}
input={{
value: false,
checked: settings.statistics,
}}/>
</div>
<h4>{t('Local')}</h4>
<div className={styles.item}>
<label>{t('Currency')}</label>
Expand Down
18 changes: 18 additions & 0 deletions src/components/setting/setting.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('Setting', () => {
advancedMode: true,
showNetwork: false,
currency: settingsConst.currencies[0],
statistics: false,
};

const account = {
Expand Down Expand Up @@ -124,6 +125,23 @@ describe('Setting', () => {
expect(props.settingsUpdated).to.have.been.calledWith(expectedCallToSettingsUpdated);
});

it('should change usage statistics when clicking on checkbox', () => {
props.settings.currency = undefined;
wrapper = mount(<Router>
<Setting
store={store}
{...props}/>
</Router>, options);

wrapper.find('.statistics').at(0).find('input').simulate('change', { target: { checked: false, value: false } });
clock.tick(300);
wrapper.update();
const expectedCallToSettingsUpdated = {
statistics: !settings.statistics,
};
expect(props.settingsUpdated).to.have.been.calledWith(expectedCallToSettingsUpdated);
});

it('should change active currency setting to EUR', () => {
wrapper.find('.currency').at(1).simulate('click');
wrapper.update();
Expand Down
1 change: 1 addition & 0 deletions src/store/reducers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const initialState = JSON.parse(localStorage.getItem('settings')) || {
channels,
hardwareAccounts: {},
isRequestHowItWorksDisable: false,
statistics: false,
};

/**
Expand Down

0 comments on commit a9368ce

Please sign in to comment.