mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 15:45:55 +08:00
Treat Kolab folders as SystemFolder and show the type in User -> Settings -> Folders
This commit is contained in:
parent
524cafe689
commit
fb86d15c02
|
@ -2,6 +2,7 @@ import ko from 'ko';
|
|||
import { Notification, UploadErrorCode } from 'Common/Enums';
|
||||
import { langLink } from 'Common/Links';
|
||||
import { doc, createElement } from 'Common/Globals';
|
||||
import { getKeyByValue } from 'Common/Utils';
|
||||
|
||||
let I18N_DATA = {};
|
||||
|
||||
|
@ -39,8 +40,6 @@ const
|
|||
|
||||
i18nKey = key => key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase(),
|
||||
|
||||
getKeyByValue = (o, v) => Object.keys(o).find(key => o[key] === v),
|
||||
|
||||
getNotificationMessage = code => {
|
||||
let key = getKeyByValue(Notification, code);
|
||||
if (key) {
|
||||
|
|
|
@ -93,4 +93,6 @@ export const
|
|||
})
|
||||
.then(clearTimer, clearTimer);
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
getKeyByValue = (o, v) => Object.keys(o).find(key => o[key] === v);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { AbstractCollectionModel } from 'Model/AbstractCollection';
|
||||
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
import { isArray, pInt } from 'Common/Utils';
|
||||
import { isArray, pInt, getKeyByValue } from 'Common/Utils';
|
||||
import { ClientSideKeyName, FolderType, FolderMetadataKeys } from 'Common/EnumsUser';
|
||||
import * as Cache from 'Common/Cache';
|
||||
import { Settings, SettingsGet } from 'Common/Globals';
|
||||
|
@ -161,21 +161,31 @@ export class FolderCollectionModel extends AbstractCollectionModel
|
|||
|
||||
}
|
||||
|
||||
function getKolabFolderName(type)
|
||||
{
|
||||
const types = {
|
||||
configuration: 'CONFIGURATION',
|
||||
event: 'CALENDAR',
|
||||
contact: 'CONTACTS',
|
||||
task: 'TASKS',
|
||||
note: 'NOTES',
|
||||
file: 'FILES',
|
||||
journal: 'JOURNAL'
|
||||
};
|
||||
return types[type] ? 'Kolab ' + i18n('SETTINGS_FOLDERS/TYPE_' + types[type]) : '';
|
||||
}
|
||||
|
||||
function getSystemFolderName(type, def)
|
||||
{
|
||||
switch (type) {
|
||||
case FolderType.Inbox:
|
||||
return i18n('FOLDER_LIST/INBOX_NAME');
|
||||
case FolderType.Sent:
|
||||
return i18n('FOLDER_LIST/SENT_NAME');
|
||||
case FolderType.Drafts:
|
||||
return i18n('FOLDER_LIST/DRAFTS_NAME');
|
||||
case FolderType.Trash:
|
||||
case FolderType.Archive:
|
||||
return i18n('FOLDER_LIST/' + getKeyByValue(FolderType, type).toUpperCase() + '_NAME');
|
||||
case FolderType.Spam:
|
||||
return i18n('GLOBAL/SPAM');
|
||||
case FolderType.Trash:
|
||||
return i18n('FOLDER_LIST/TRASH_NAME');
|
||||
case FolderType.Archive:
|
||||
return i18n('FOLDER_LIST/ARCHIVE_NAME');
|
||||
// no default
|
||||
}
|
||||
return def;
|
||||
|
@ -287,7 +297,7 @@ export class FolderModel extends AbstractModel {
|
|||
|
||||
visible: () => folder.hasSubscriptions() | !SettingsUserStore.hideUnsubscribed(),
|
||||
|
||||
isSystemFolder: () => FolderType.User !== folder.type(),
|
||||
isSystemFolder: () => FolderType.User !== folder.type() || !!folder.kolabType(),
|
||||
|
||||
hidden: () => {
|
||||
let hasSubFolders = folder.hasSubscribedSubfolders();
|
||||
|
@ -335,12 +345,11 @@ export class FolderModel extends AbstractModel {
|
|||
manageFolderSystemName: () => {
|
||||
if (folder.isSystemFolder()) {
|
||||
translatorTrigger();
|
||||
let suffix = getSystemFolderName(folder.type(), '');
|
||||
let suffix = getSystemFolderName(folder.type(), getKolabFolderName(folder.kolabType()));
|
||||
if (folder.name() !== suffix && 'inbox' !== suffix.toLowerCase()) {
|
||||
return '(' + suffix + ')';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue