snappymail/dev/Screen/User/Settings.js

80 lines
2.4 KiB
JavaScript
Raw Normal View History

2022-03-06 05:25:32 +08:00
import { Scope } from 'Common/Enums';
2022-02-08 21:13:06 +08:00
import { keyScope, leftPanelDisabled, SettingsCapa } from 'Common/Globals';
2019-07-05 03:19:24 +08:00
import { runSettingsViewModelHooks } from 'Common/Plugins';
import { initOnStartOrLangChange, i18n } from 'Common/Translator';
2016-07-07 07:11:13 +08:00
import { AppUserStore } from 'Stores/User/App';
import { AccountUserStore } from 'Stores/User/Account';
import { ThemeStore } from 'Stores/Theme';
2016-07-07 07:11:13 +08:00
2021-01-26 18:46:30 +08:00
import { AbstractSettingsScreen, settingsAddViewModel } from 'Screen/AbstractSettings';
2019-07-05 03:19:24 +08:00
import { UserSettingsGeneral } from 'Settings/User/General';
import { UserSettingsContacts } from 'Settings/User/Contacts';
import { UserSettingsAccounts } from 'Settings/User/Accounts';
import { UserSettingsFilters } from 'Settings/User/Filters';
import { UserSettingsSecurity } from 'Settings/User/Security';
import { UserSettingsFolders } from 'Settings/User/Folders';
import { UserSettingsThemes } from 'Settings/User/Themes';
2019-07-05 03:19:24 +08:00
import { SystemDropDownUserView } from 'View/User/SystemDropDown';
2022-03-08 19:28:16 +08:00
import { SettingsMenuUserView } from 'View/User/Settings/Menu';
import { SettingsPaneUserView } from 'View/User/Settings/Pane';
2019-07-05 03:19:24 +08:00
2021-01-22 23:32:08 +08:00
export class SettingsUserScreen extends AbstractSettingsScreen {
2016-07-16 05:29:42 +08:00
constructor() {
2022-03-08 19:28:16 +08:00
super([SystemDropDownUserView, SettingsMenuUserView, SettingsPaneUserView]);
2019-07-05 03:19:24 +08:00
const views = [
UserSettingsGeneral
];
2016-07-07 07:11:13 +08:00
if (AppUserStore.allowContacts()) {
views.push(UserSettingsContacts);
2016-07-07 07:11:13 +08:00
}
2022-03-06 05:25:32 +08:00
if (SettingsCapa('AdditionalAccounts') || SettingsCapa('Identities')) {
views.push(UserSettingsAccounts);
2016-07-07 07:11:13 +08:00
}
2022-02-24 19:22:27 +08:00
if (SettingsCapa('Sieve')) {
views.push(UserSettingsFilters);
2016-07-07 07:11:13 +08:00
}
if (SettingsCapa('AutoLogout') || SettingsCapa('OpenPGP') || SettingsCapa('GnuPG')) {
views.push(UserSettingsSecurity);
2016-07-07 07:11:13 +08:00
}
views.push(UserSettingsFolders);
2016-07-07 07:11:13 +08:00
2022-03-06 05:25:32 +08:00
if (SettingsCapa('Themes')) {
views.push(UserSettingsThemes);
2016-07-07 07:11:13 +08:00
}
views.forEach((item, index) =>
2022-05-20 03:26:39 +08:00
settingsAddViewModel(item, item.name.replace('User', ''),
(item === UserSettingsAccounts && !SettingsCapa('AdditionalAccounts'))
? 'SETTINGS_ACCOUNTS/LEGEND_IDENTITIES' : 0,
0, 0 === index)
);
2016-07-07 07:11:13 +08:00
runSettingsViewModelHooks(false);
2021-09-23 15:44:46 +08:00
initOnStartOrLangChange(
() => this.sSettingsTitle = i18n('TITLES/SETTINGS'),
() => this.setSettingsTitle()
);
2016-07-07 07:11:13 +08:00
}
onShow() {
this.setSettingsTitle();
keyScope(Scope.Settings);
ThemeStore.isMobile() && leftPanelDisabled(true);
2016-07-07 07:11:13 +08:00
}
setSettingsTitle() {
const sEmail = AccountUserStore.email();
rl.setWindowTitle((sEmail ? sEmail + ' - ' : '') + this.sSettingsTitle);
2016-07-07 07:11:13 +08:00
}
}