2016-07-07 07:11:13 +08:00
|
|
|
|
|
|
|
import {Capa, KeyState} from 'Common/Enums';
|
|
|
|
import {keyScope, leftPanelType, leftPanelDisabled} from 'Common/Globals';
|
|
|
|
import {runSettingsViewModelHooks} from 'Common/Plugins';
|
|
|
|
import {initOnStartOrLangChange, i18n} from 'Common/Translator';
|
|
|
|
|
|
|
|
import AppStore from 'Stores/User/App';
|
|
|
|
import AccountStore from 'Stores/User/Account';
|
|
|
|
|
|
|
|
import * as Settings from 'Storage/Settings';
|
2016-07-08 07:22:58 +08:00
|
|
|
import {addSettingsViewModel} from 'Knoin/Knoin';
|
2016-07-07 07:11:13 +08:00
|
|
|
|
|
|
|
import {AbstractSettingsScreen} from 'Screen/AbstractSettings';
|
|
|
|
|
2016-07-16 03:54:37 +08:00
|
|
|
import {GeneralUserSettings} from 'Settings/User/General';
|
|
|
|
import {ContactsUserSettings} from 'Settings/User/Contacts';
|
|
|
|
import {AccountsUserSettings} from 'Settings/User/Accounts';
|
|
|
|
import {FiltersUserSettings} from 'Settings/User/Filters';
|
|
|
|
import {SecurityUserSettings} from 'Settings/User/Security';
|
|
|
|
import {SocialUserSettings} from 'Settings/User/Social';
|
|
|
|
import {ChangePasswordUserSettings} from 'Settings/User/ChangePassword';
|
|
|
|
import {TemplatesUserSettings} from 'Settings/User/Templates';
|
|
|
|
import {FoldersUserSettings} from 'Settings/User/Folders';
|
|
|
|
import {ThemesUserSettings} from 'Settings/User/Themes';
|
|
|
|
import {OpenPgpUserSettings} from 'Settings/User/OpenPgp';
|
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import {SystemDropDownSettingsUserView} from 'View/User/Settings/SystemDropDown';
|
|
|
|
import {MenuSettingsUserView} from 'View/User/Settings/Menu';
|
|
|
|
import {PaneSettingsUserView} from 'View/User/Settings/Pane';
|
|
|
|
|
|
|
|
import {getApp} from 'Helper/Apps/User';
|
|
|
|
|
2016-07-07 07:11:13 +08:00
|
|
|
class SettingsUserScreen extends AbstractSettingsScreen
|
|
|
|
{
|
2016-07-16 05:29:42 +08:00
|
|
|
constructor() {
|
2016-07-07 07:11:13 +08:00
|
|
|
super([
|
2016-08-17 06:01:20 +08:00
|
|
|
SystemDropDownSettingsUserView,
|
|
|
|
MenuSettingsUserView,
|
|
|
|
PaneSettingsUserView
|
2016-07-07 07:11:13 +08:00
|
|
|
]);
|
|
|
|
|
|
|
|
initOnStartOrLangChange(() => {
|
|
|
|
this.sSettingsTitle = i18n('TITLES/SETTINGS');
|
|
|
|
}, () => {
|
|
|
|
this.setSettingsTitle();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Function=} fCallback
|
|
|
|
*/
|
|
|
|
setupSettings(fCallback = null) {
|
|
|
|
if (!Settings.capa(Capa.Settings))
|
|
|
|
{
|
|
|
|
if (fCallback)
|
|
|
|
{
|
|
|
|
fCallback();
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-16 03:54:37 +08:00
|
|
|
addSettingsViewModel(GeneralUserSettings,
|
2016-07-07 07:11:13 +08:00
|
|
|
'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true);
|
|
|
|
|
|
|
|
if (AppStore.contactsIsAllowed())
|
|
|
|
{
|
2016-07-16 03:54:37 +08:00
|
|
|
addSettingsViewModel(ContactsUserSettings,
|
2016-07-07 07:11:13 +08:00
|
|
|
'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Settings.capa(Capa.AdditionalAccounts) || Settings.capa(Capa.Identities))
|
|
|
|
{
|
2016-07-16 03:54:37 +08:00
|
|
|
addSettingsViewModel(AccountsUserSettings, 'SettingsAccounts',
|
2016-07-07 07:11:13 +08:00
|
|
|
Settings.capa(Capa.AdditionalAccounts) ? 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME' : 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', 'accounts');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Settings.capa(Capa.Sieve))
|
|
|
|
{
|
2016-07-16 03:54:37 +08:00
|
|
|
addSettingsViewModel(FiltersUserSettings,
|
2016-07-07 07:11:13 +08:00
|
|
|
'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Settings.capa(Capa.AutoLogout) || Settings.capa(Capa.TwoFactor))
|
|
|
|
{
|
2016-07-16 03:54:37 +08:00
|
|
|
addSettingsViewModel(SecurityUserSettings,
|
2016-07-07 07:11:13 +08:00
|
|
|
'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (AccountStore.isRootAccount() && (
|
|
|
|
(Settings.settingsGet('AllowGoogleSocial') && Settings.settingsGet('AllowGoogleSocialAuth')) ||
|
|
|
|
Settings.settingsGet('AllowFacebookSocial') ||
|
|
|
|
Settings.settingsGet('AllowTwitterSocial')))
|
|
|
|
{
|
2016-07-16 03:54:37 +08:00
|
|
|
addSettingsViewModel(SocialUserSettings,
|
2016-07-07 07:11:13 +08:00
|
|
|
'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Settings.settingsGet('ChangePasswordIsAllowed'))
|
|
|
|
{
|
2016-07-16 03:54:37 +08:00
|
|
|
addSettingsViewModel(ChangePasswordUserSettings,
|
2016-07-07 07:11:13 +08:00
|
|
|
'SettingsChangePassword', 'SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME', 'change-password');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Settings.capa(Capa.Templates))
|
|
|
|
{
|
2016-07-16 03:54:37 +08:00
|
|
|
addSettingsViewModel(TemplatesUserSettings,
|
2016-07-07 07:11:13 +08:00
|
|
|
'SettingsTemplates', 'SETTINGS_LABELS/LABEL_TEMPLATES_NAME', 'templates');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Settings.capa(Capa.Folders))
|
|
|
|
{
|
2016-07-16 03:54:37 +08:00
|
|
|
addSettingsViewModel(FoldersUserSettings,
|
2016-07-07 07:11:13 +08:00
|
|
|
'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Settings.capa(Capa.Themes))
|
|
|
|
{
|
2016-07-16 03:54:37 +08:00
|
|
|
addSettingsViewModel(ThemesUserSettings,
|
2016-07-07 07:11:13 +08:00
|
|
|
'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Settings.capa(Capa.OpenPGP))
|
|
|
|
{
|
2016-07-16 03:54:37 +08:00
|
|
|
addSettingsViewModel(OpenPgpUserSettings,
|
2016-07-07 07:11:13 +08:00
|
|
|
'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp');
|
|
|
|
}
|
|
|
|
|
|
|
|
runSettingsViewModelHooks(false);
|
|
|
|
|
|
|
|
if (fCallback)
|
|
|
|
{
|
|
|
|
fCallback();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
onShow() {
|
|
|
|
this.setSettingsTitle();
|
|
|
|
keyScope(KeyState.Settings);
|
|
|
|
leftPanelType('');
|
|
|
|
|
|
|
|
if (Settings.appSettingsGet('mobile'))
|
|
|
|
{
|
|
|
|
leftPanelDisabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setSettingsTitle() {
|
|
|
|
const sEmail = AccountStore.email();
|
2016-08-17 06:01:20 +08:00
|
|
|
getApp().setWindowTitle(('' === sEmail ? '' : sEmail + ' - ') + this.sSettingsTitle);
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export {SettingsUserScreen, SettingsUserScreen as default};
|