feat: create addon tab, translation support for stats tab, fixes etc

This commit is contained in:
David Ralph
2021-08-14 17:23:54 +01:00
parent b8c793741f
commit 1a8bb69288
16 changed files with 326 additions and 13 deletions

View File

@@ -10,6 +10,7 @@ export default class Stats extends React.PureComponent {
this.state = {
stats: JSON.parse(localStorage.getItem('statsData')) || {}
};
this.language = window.language.modals.main.settings.sections.stats;
}
componentDidMount() {
@@ -31,23 +32,23 @@ export default class Stats extends React.PureComponent {
return (
<>
<h2>Notice</h2>
<p>You need to enable usage data in order to use this feature</p>
<Switch name='stats' text='Usage Stats' category='stats'/>
<p>{this.language.warning}</p>
<Switch name='stats' text={this.language.usage} category='stats'/>
</>
);
}
return (
<>
<h2>Stats</h2>
<p>Tabs opened: {this.state.stats['tabs-opened'] || 0}</p>
<p>Backgrounds favourited: {this.state.stats.feature ? this.state.stats.feature['background-favourite'] || 0 : 0}</p>
<p>Backgrounds downloaded: {this.state.stats.feature ? this.state.stats.feature['background-download'] || 0 : 0}</p>
<p>Quotes favourited: {this.state.stats.feature ? this.state.stats.feature['quoted-favourite'] || 0 : 0}</p>
<p>Quick links added: {this.state.stats.feature ? this.state.stats.feature['quicklink-add'] || 0 : 0}</p>
<p>Settings changed: {this.state.stats.setting ? Object.keys(this.state.stats.setting).length : 0}</p>
<p>Add-ons installed: {this.state.stats.marketplace ? this.state.stats.marketplace['install'] : 0}</p>
<Switch name='stats' text='Usage Stats' category='stats'/>
<h2>{this.language.title}</h2>
<p>{this.language.sections.tabs_opened}: {this.state.stats['tabs-opened'] || 0}</p>
<p>{this.language.sections.backgrounds_favourited}: {this.state.stats.feature ? this.state.stats.feature['background-favourite'] || 0 : 0}</p>
<p>{this.language.sections.backgrounds_downloaded}: {this.state.stats.feature ? this.state.stats.feature['background-download'] || 0 : 0}</p>
<p>{this.language.sections.quotes_favourited}: {this.state.stats.feature ? this.state.stats.feature['quoted-favourite'] || 0 : 0}</p>
<p>{this.language.sections.quicklinks_added}: {this.state.stats.feature ? this.state.stats.feature['quicklink-add'] || 0 : 0}</p>
<p>{this.language.sections.settings_changed}: {this.state.stats.setting ? Object.keys(this.state.stats.setting).length : 0}</p>
<p>{this.language.sections.addons_installed}: {this.state.stats.marketplace ? this.state.stats.marketplace['install'] : 0}</p>
<Switch name='stats' text={this.language.usage} category='stats'/>
<p>Turning this off will clear your statistics locally, but will not delete the anonymous data posted to umami.</p>
</>
);