Drop Capa enums

This commit is contained in:
the-djmaze 2022-03-05 22:25:32 +01:00
parent f44507a69b
commit 874f2592ca
14 changed files with 42 additions and 64 deletions

View file

@ -1,37 +1,23 @@
/* eslint quote-props: 0 */ /* eslint quote-props: 0 */
/** export const
* @enum {string}
*/
export const Capa = {
AdditionalAccounts: 'AdditionalAccounts',
AutoLogout: 'AutoLogout',
DangerousActions: 'DangerousActions',
GnuPG: 'GnuPG',
Identities: 'Identities',
OpenPGP: 'OpenPGP',
Search: 'Search',
SearchAdv: 'SearchAdv',
Themes: 'Themes',
UserBackground: 'UserBackground'
};
/** /**
* @enum {string} * @enum {string}
*/ */
export const Scope = { Scope = {
All: 'all', All: 'all',
None: 'none', None: 'none',
MessageList: 'MessageList', MessageList: 'MessageList',
FolderList: 'FolderList', FolderList: 'FolderList',
MessageView: 'MessageView', MessageView: 'MessageView',
Settings: 'Settings' Settings: 'Settings'
}; },
/** /**
* @enum {number} * @enum {number}
*/ */
export const UploadErrorCode = { UploadErrorCode = {
Normal: 0, Normal: 0,
FileIsTooBig: 1, FileIsTooBig: 1,
FilePartiallyUploaded: 3, FilePartiallyUploaded: 3,
@ -40,22 +26,22 @@ export const UploadErrorCode = {
OnSavingFile: 7, OnSavingFile: 7,
FileType: 98, FileType: 98,
Unknown: 99 Unknown: 99
}; },
/** /**
* @enum {number} * @enum {number}
*/ */
export const SaveSettingsStep = { SaveSettingsStep = {
Animate: -2, Animate: -2,
Idle: -1, Idle: -1,
TrueResult: 1, TrueResult: 1,
FalseResult: 0 FalseResult: 0
}; },
/** /**
* @enum {number} * @enum {number}
*/ */
export const Notification = { Notification = {
RequestError: 1, RequestError: 1,
RequestAborted: 2, RequestAborted: 2,

View file

@ -1,4 +1,4 @@
import { Capa, Scope } from 'Common/Enums'; import { Scope } from 'Common/Enums';
import { keyScope, leftPanelDisabled, SettingsCapa } from 'Common/Globals'; import { keyScope, leftPanelDisabled, SettingsCapa } from 'Common/Globals';
import { runSettingsViewModelHooks } from 'Common/Plugins'; import { runSettingsViewModelHooks } from 'Common/Plugins';
import { initOnStartOrLangChange, i18n } from 'Common/Translator'; import { initOnStartOrLangChange, i18n } from 'Common/Translator';
@ -32,11 +32,11 @@ export class SettingsUserScreen extends AbstractSettingsScreen {
settingsAddViewModel(ContactsUserSettings, 'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts'); settingsAddViewModel(ContactsUserSettings, 'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts');
} }
if (SettingsCapa(Capa.AdditionalAccounts) || SettingsCapa(Capa.Identities)) { if (SettingsCapa('AdditionalAccounts') || SettingsCapa('Identities')) {
settingsAddViewModel( settingsAddViewModel(
AccountsUserSettings, AccountsUserSettings,
'SettingsAccounts', 'SettingsAccounts',
SettingsCapa(Capa.AdditionalAccounts) SettingsCapa('AdditionalAccounts')
? 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME' ? 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME'
: 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', : 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME',
'accounts' 'accounts'
@ -47,17 +47,17 @@ export class SettingsUserScreen extends AbstractSettingsScreen {
settingsAddViewModel(FiltersUserSettings, 'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters'); settingsAddViewModel(FiltersUserSettings, 'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters');
} }
if (SettingsCapa(Capa.AutoLogout)) { if (SettingsCapa('AutoLogout')) {
settingsAddViewModel(SecurityUserSettings, 'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security'); settingsAddViewModel(SecurityUserSettings, 'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security');
} }
settingsAddViewModel(FoldersUserSettings, 'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders'); settingsAddViewModel(FoldersUserSettings, 'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders');
if (SettingsCapa(Capa.Themes)) { if (SettingsCapa('Themes')) {
settingsAddViewModel(ThemesUserSettings, 'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes'); settingsAddViewModel(ThemesUserSettings, 'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes');
} }
if (SettingsCapa(Capa.OpenPGP) || SettingsCapa(Capa.GnuPG)) { if (SettingsCapa('OpenPGP') || SettingsCapa('GnuPG')) {
settingsAddViewModel(OpenPgpUserSettings, 'SettingsOpenPGP', 'OpenPGP', 'openpgp'); settingsAddViewModel(OpenPgpUserSettings, 'SettingsOpenPGP', 'OpenPGP', 'openpgp');
} }

View file

@ -8,7 +8,7 @@ import {
import { addObservablesTo, addSubscribablesTo, addComputablesTo } from 'External/ko'; import { addObservablesTo, addSubscribablesTo, addComputablesTo } from 'External/ko';
import { Capa, SaveSettingsStep } from 'Common/Enums'; import { SaveSettingsStep } from 'Common/Enums';
import { Settings, SettingsGet, SettingsCapa } from 'Common/Globals'; import { Settings, SettingsGet, SettingsCapa } from 'Common/Globals';
import { translatorReload, convertLangName } from 'Common/Translator'; import { translatorReload, convertLangName } from 'Common/Translator';
@ -42,10 +42,10 @@ export class GeneralAdminSettings extends AbstractViewSettings {
addObservablesTo(this, { addObservablesTo(this, {
attachmentLimitTrigger: SaveSettingsStep.Idle, attachmentLimitTrigger: SaveSettingsStep.Idle,
themeTrigger: SaveSettingsStep.Idle, themeTrigger: SaveSettingsStep.Idle,
capaThemes: SettingsCapa(Capa.Themes), capaThemes: SettingsCapa('Themes'),
capaUserBackground: SettingsCapa(Capa.UserBackground), capaUserBackground: SettingsCapa('UserBackground'),
capaAdditionalAccounts: SettingsCapa(Capa.AdditionalAccounts), capaAdditionalAccounts: SettingsCapa('AdditionalAccounts'),
capaIdentities: SettingsCapa(Capa.Identities), capaIdentities: SettingsCapa('Identities'),
capaAttachmentThumbnails: SettingsCapa('AttachmentThumbnails'), capaAttachmentThumbnails: SettingsCapa('AttachmentThumbnails'),
dataFolderAccess: false dataFolderAccess: false
}); });

View file

@ -1,4 +1,3 @@
import { Capa } from 'Common/Enums';
import { SettingsGet, SettingsCapa } from 'Common/Globals'; import { SettingsGet, SettingsCapa } from 'Common/Globals';
import { addObservablesTo, addSubscribablesTo } from 'External/ko'; import { addObservablesTo, addSubscribablesTo } from 'External/ko';
@ -27,7 +26,7 @@ export class SecurityAdminSettings extends AbstractViewSettings {
adminPasswordUpdateError: false, adminPasswordUpdateError: false,
adminPasswordUpdateSuccess: false, adminPasswordUpdateSuccess: false,
capaOpenPGP: SettingsCapa(Capa.OpenPGP) capaOpenPGP: SettingsCapa('OpenPGP')
}); });
const reset = () => { const reset = () => {

View file

@ -1,6 +1,5 @@
import ko from 'ko'; import ko from 'ko';
import { Capa } from 'Common/Enums';
import { SettingsCapa, SettingsGet } from 'Common/Globals'; import { SettingsCapa, SettingsGet } from 'Common/Globals';
import { AccountUserStore } from 'Stores/User/Account'; import { AccountUserStore } from 'Stores/User/Account';
@ -14,8 +13,8 @@ import { IdentityPopupView } from 'View/Popup/Identity';
export class AccountsUserSettings /*extends AbstractViewSettings*/ { export class AccountsUserSettings /*extends AbstractViewSettings*/ {
constructor() { constructor() {
this.allowAdditionalAccount = SettingsCapa(Capa.AdditionalAccounts); this.allowAdditionalAccount = SettingsCapa('AdditionalAccounts');
this.allowIdentities = SettingsCapa(Capa.Identities); this.allowIdentities = SettingsCapa('Identities');
this.accounts = AccountUserStore.accounts; this.accounts = AccountUserStore.accounts;
this.loading = AccountUserStore.loading; this.loading = AccountUserStore.loading;

View file

@ -9,7 +9,6 @@ import { showScreenPopup } from 'Knoin/Knoin';
import { OpenPgpImportPopupView } from 'View/Popup/OpenPgpImport'; import { OpenPgpImportPopupView } from 'View/Popup/OpenPgpImport';
import { OpenPgpGeneratePopupView } from 'View/Popup/OpenPgpGenerate'; import { OpenPgpGeneratePopupView } from 'View/Popup/OpenPgpGenerate';
import { Capa } from 'Common/Enums';
import { SettingsCapa } from 'Common/Globals'; import { SettingsCapa } from 'Common/Globals';
export class OpenPgpUserSettings /*extends AbstractViewSettings*/ { export class OpenPgpUserSettings /*extends AbstractViewSettings*/ {
@ -20,7 +19,7 @@ export class OpenPgpUserSettings /*extends AbstractViewSettings*/ {
this.openpgpkeysPublic = OpenPGPUserStore.publicKeys; this.openpgpkeysPublic = OpenPGPUserStore.publicKeys;
this.openpgpkeysPrivate = OpenPGPUserStore.privateKeys; this.openpgpkeysPrivate = OpenPGPUserStore.privateKeys;
this.canOpenPGP = SettingsCapa(Capa.OpenPGP); this.canOpenPGP = SettingsCapa('OpenPGP');
this.canGnuPG = GnuPGUserStore.isSupported(); this.canGnuPG = GnuPGUserStore.isSupported();
this.canMailvelope = !!window.mailvelope; this.canMailvelope = !!window.mailvelope;

View file

@ -1,6 +1,5 @@
import { koComputable } from 'External/ko'; import { koComputable } from 'External/ko';
import { Capa } from 'Common/Enums';
import { SettingsCapa } from 'Common/Globals'; import { SettingsCapa } from 'Common/Globals';
import { i18n, trigger as translatorTrigger } from 'Common/Translator'; import { i18n, trigger as translatorTrigger } from 'Common/Translator';
@ -12,7 +11,7 @@ export class SecurityUserSettings extends AbstractViewSettings {
constructor() { constructor() {
super(); super();
this.capaAutoLogout = SettingsCapa(Capa.AutoLogout); this.capaAutoLogout = SettingsCapa('AutoLogout');
this.autoLogout = SettingsUserStore.autoLogout; this.autoLogout = SettingsUserStore.autoLogout;

View file

@ -1,6 +1,6 @@
import { addObservablesTo } from 'External/ko'; import { addObservablesTo } from 'External/ko';
import { SaveSettingsStep, UploadErrorCode, Capa } from 'Common/Enums'; import { SaveSettingsStep, UploadErrorCode } from 'Common/Enums';
import { changeTheme, convertThemeName } from 'Common/Utils'; import { changeTheme, convertThemeName } from 'Common/Utils';
import { themePreviewLink, serverRequest } from 'Common/Links'; import { themePreviewLink, serverRequest } from 'Common/Links';
import { i18n } from 'Common/Translator'; import { i18n } from 'Common/Translator';
@ -26,7 +26,7 @@ export class ThemesUserSettings /*extends AbstractViewSettings*/ {
this.themes = ThemeStore.themes; this.themes = ThemeStore.themes;
this.themesObjects = ko.observableArray(); this.themesObjects = ko.observableArray();
themeBackground.enabled = SettingsCapa(Capa.UserBackground); themeBackground.enabled = SettingsCapa('UserBackground');
this.background = themeBackground; this.background = themeBackground;
this.themeTrigger = ko.observable(SaveSettingsStep.Idle).extend({ debounce: 100 }); this.themeTrigger = ko.observable(SaveSettingsStep.Idle).extend({ debounce: 100 });

View file

@ -1,4 +1,3 @@
import { Scope } from 'Common/Enums';
import { keyScope, leftPanelDisabled, SettingsGet, elementById } from 'Common/Globals'; import { keyScope, leftPanelDisabled, SettingsGet, elementById } from 'Common/Globals';
import { addObservablesTo } from 'External/ko'; import { addObservablesTo } from 'External/ko';
import { ThemeStore } from 'Stores/Theme'; import { ThemeStore } from 'Stores/Theme';
@ -8,7 +7,7 @@ export const AppUserStore = {
}; };
addObservablesTo(AppUserStore, { addObservablesTo(AppUserStore, {
focusedState: Scope.None, focusedState: 'none',
threadsAllowed: false, threadsAllowed: false,
@ -19,7 +18,7 @@ AppUserStore.focusedState.subscribe(value => {
['FolderList','MessageList','MessageView'].forEach(name => { ['FolderList','MessageList','MessageView'].forEach(name => {
if (name === value) { if (name === value) {
keyScope(value); keyScope(value);
ThemeStore.isMobile() && leftPanelDisabled(Scope.FolderList !== value); ThemeStore.isMobile() && leftPanelDisabled('FolderList' !== value);
} }
let dom = elementById('V-Mail'+name); let dom = elementById('V-Mail'+name);
dom && dom.classList.toggle('focused', name === value); dom && dom.classList.toggle('focused', name === value);

View file

@ -1,6 +1,5 @@
import ko from 'ko'; import ko from 'ko';
import { Capa } from 'Common/Enums';
import { SettingsCapa } from 'Common/Globals'; import { SettingsCapa } from 'Common/Globals';
//import { EmailModel } from 'Model/Email'; //import { EmailModel } from 'Model/Email';
@ -102,7 +101,7 @@ export const GnuPGUserStore = new class {
* @returns {boolean} * @returns {boolean}
*/ */
isSupported() { isSupported() {
return SettingsCapa(Capa.GnuPG); return SettingsCapa('GnuPG');
} }
importKey(key, callback) { importKey(key, callback) {

View file

@ -1,4 +1,3 @@
import { Capa } from 'Common/Enums';
import { doc, createElement, SettingsCapa, SettingsGet } from 'Common/Globals'; import { doc, createElement, SettingsCapa, SettingsGet } from 'Common/Globals';
import { staticLink } from 'Common/Links'; import { staticLink } from 'Common/Links';
@ -22,7 +21,7 @@ export const
} }
init() { init() {
if (SettingsCapa(Capa.OpenPGP) && window.crypto && crypto.getRandomValues) { if (SettingsCapa('OpenPGP') && window.crypto && crypto.getRandomValues) {
const script = createElement('script', {src:staticLink('js/min/openpgp.min.js')}); const script = createElement('script', {src:staticLink('js/min/openpgp.min.js')});
script.onload = () => this.loadKeyrings(); script.onload = () => this.loadKeyrings();
script.onerror = () => { script.onerror = () => {
@ -61,7 +60,7 @@ export const
OpenPGPUserStore.loadKeyrings(); OpenPGPUserStore.loadKeyrings();
} }
if (SettingsCapa(Capa.GnuPG)) { if (SettingsCapa('GnuPG')) {
GnuPGUserStore.loadKeyrings(); GnuPGUserStore.loadKeyrings();
} }
} }

View file

@ -7,7 +7,6 @@ import { IdentityUserStore } from 'Stores/User/Identity';
import { AbstractViewPopup } from 'Knoin/AbstractViews'; import { AbstractViewPopup } from 'Knoin/AbstractViews';
import { Capa } from 'Common/Enums';
import { SettingsCapa } from 'Common/Globals'; import { SettingsCapa } from 'Common/Globals';
export class OpenPgpGeneratePopupView extends AbstractViewPopup { export class OpenPgpGeneratePopupView extends AbstractViewPopup {
@ -34,7 +33,7 @@ export class OpenPgpGeneratePopupView extends AbstractViewPopup {
saveGnuPGPrivate: false saveGnuPGPrivate: false
}); });
this.canGnuPG = SettingsCapa(Capa.GnuPG); this.canGnuPG = SettingsCapa('GnuPG');
this.email.subscribe(() => this.emailError(false)); this.email.subscribe(() => this.emailError(false));
} }

View file

@ -1,6 +1,6 @@
import ko from 'ko'; import ko from 'ko';
import { Capa, Scope } from 'Common/Enums'; import { Scope } from 'Common/Enums';
import { ComposeType, FolderType, MessageSetAction } from 'Common/EnumsUser'; import { ComposeType, FolderType, MessageSetAction } from 'Common/EnumsUser';
@ -67,9 +67,9 @@ export class MailMessageList extends AbstractViewRight {
this.newMoveToFolder = !!SettingsGet('NewMoveToFolder'); this.newMoveToFolder = !!SettingsGet('NewMoveToFolder');
this.allowSearch = SettingsCapa(Capa.Search); this.allowSearch = SettingsCapa('Search');
this.allowSearchAdv = SettingsCapa(Capa.SearchAdv); this.allowSearchAdv = SettingsCapa('SearchAdv');
this.allowDangerousActions = SettingsCapa(Capa.DangerousActions); this.allowDangerousActions = SettingsCapa('DangerousActions');
this.messageList = MessagelistUserStore; this.messageList = MessagelistUserStore;
@ -277,7 +277,7 @@ export class MailMessageList extends AbstractViewRight {
} }
clear() { clear() {
if (SettingsCapa(Capa.DangerousActions)) { if (SettingsCapa('DangerousActions')) {
showScreenPopup(FolderClearPopupView, [FolderUserStore.currentFolder()]); showScreenPopup(FolderClearPopupView, [FolderUserStore.currentFolder()]);
} }
} }
@ -296,7 +296,7 @@ export class MailMessageList extends AbstractViewRight {
} }
deleteWithoutMoveCommand() { deleteWithoutMoveCommand() {
if (SettingsCapa(Capa.DangerousActions)) { if (SettingsCapa('DangerousActions')) {
rl.app.deleteMessagesFromFolder( rl.app.deleteMessagesFromFolder(
FolderType.Trash, FolderType.Trash,
FolderUserStore.currentFolderFullName(), FolderUserStore.currentFolderFullName(),
@ -787,7 +787,7 @@ export class MailMessageList extends AbstractViewRight {
return false; return false;
}); });
if (SettingsCapa(Capa.Search)) { if (SettingsCapa('Search')) {
// search input focus // search input focus
shortcuts.add('/', '', [Scope.MessageList, Scope.MessageView], () => { shortcuts.add('/', '', [Scope.MessageList, Scope.MessageView], () => {
this.inputMessageListSearchFocus(true); this.inputMessageListSearchFocus(true);
@ -856,7 +856,7 @@ export class MailMessageList extends AbstractViewRight {
} }
advancedSearchClick() { advancedSearchClick() {
SettingsCapa(Capa.SearchAdv) SettingsCapa('SearchAdv')
&& showScreenPopup(AdvancedSearchPopupView, [MessagelistUserStore.mainSearch()]); && showScreenPopup(AdvancedSearchPopupView, [MessagelistUserStore.mainSearch()]);
} }

View file

@ -3,7 +3,7 @@ import { AccountUserStore } from 'Stores/User/Account';
import { MessageUserStore } from 'Stores/User/Message'; import { MessageUserStore } from 'Stores/User/Message';
//import { FolderUserStore } from 'Stores/User/Folder'; //import { FolderUserStore } from 'Stores/User/Folder';
import { Capa, Scope } from 'Common/Enums'; import { Scope } from 'Common/Enums';
import { settings } from 'Common/Links'; import { settings } from 'Common/Links';
import { showScreenPopup } from 'Knoin/Knoin'; import { showScreenPopup } from 'Knoin/Knoin';
@ -26,7 +26,7 @@ export class SystemDropDownUserView extends AbstractViewRight {
constructor() { constructor() {
super('SystemDropDown'); super('SystemDropDown');
this.allowAccounts = SettingsCapa(Capa.AdditionalAccounts); this.allowAccounts = SettingsCapa('AdditionalAccounts');
this.accountEmail = AccountUserStore.email; this.accountEmail = AccountUserStore.email;