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 { Notification, UploadErrorCode } from 'Common/Enums';
|
||||||
import { langLink } from 'Common/Links';
|
import { langLink } from 'Common/Links';
|
||||||
import { doc, createElement } from 'Common/Globals';
|
import { doc, createElement } from 'Common/Globals';
|
||||||
|
import { getKeyByValue } from 'Common/Utils';
|
||||||
|
|
||||||
let I18N_DATA = {};
|
let I18N_DATA = {};
|
||||||
|
|
||||||
|
@ -39,8 +40,6 @@ const
|
||||||
|
|
||||||
i18nKey = key => key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase(),
|
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 => {
|
getNotificationMessage = code => {
|
||||||
let key = getKeyByValue(Notification, code);
|
let key = getKeyByValue(Notification, code);
|
||||||
if (key) {
|
if (key) {
|
||||||
|
|
|
@ -93,4 +93,6 @@ export const
|
||||||
})
|
})
|
||||||
.then(clearTimer, clearTimer);
|
.then(clearTimer, clearTimer);
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
|
getKeyByValue = (o, v) => Object.keys(o).find(key => o[key] === v);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { AbstractCollectionModel } from 'Model/AbstractCollection';
|
import { AbstractCollectionModel } from 'Model/AbstractCollection';
|
||||||
|
|
||||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
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 { ClientSideKeyName, FolderType, FolderMetadataKeys } from 'Common/EnumsUser';
|
||||||
import * as Cache from 'Common/Cache';
|
import * as Cache from 'Common/Cache';
|
||||||
import { Settings, SettingsGet } from 'Common/Globals';
|
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)
|
function getSystemFolderName(type, def)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case FolderType.Inbox:
|
case FolderType.Inbox:
|
||||||
return i18n('FOLDER_LIST/INBOX_NAME');
|
|
||||||
case FolderType.Sent:
|
case FolderType.Sent:
|
||||||
return i18n('FOLDER_LIST/SENT_NAME');
|
|
||||||
case FolderType.Drafts:
|
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:
|
case FolderType.Spam:
|
||||||
return i18n('GLOBAL/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
|
// no default
|
||||||
}
|
}
|
||||||
return def;
|
return def;
|
||||||
|
@ -287,7 +297,7 @@ export class FolderModel extends AbstractModel {
|
||||||
|
|
||||||
visible: () => folder.hasSubscriptions() | !SettingsUserStore.hideUnsubscribed(),
|
visible: () => folder.hasSubscriptions() | !SettingsUserStore.hideUnsubscribed(),
|
||||||
|
|
||||||
isSystemFolder: () => FolderType.User !== folder.type(),
|
isSystemFolder: () => FolderType.User !== folder.type() || !!folder.kolabType(),
|
||||||
|
|
||||||
hidden: () => {
|
hidden: () => {
|
||||||
let hasSubFolders = folder.hasSubscribedSubfolders();
|
let hasSubFolders = folder.hasSubscribedSubfolders();
|
||||||
|
@ -335,12 +345,11 @@ export class FolderModel extends AbstractModel {
|
||||||
manageFolderSystemName: () => {
|
manageFolderSystemName: () => {
|
||||||
if (folder.isSystemFolder()) {
|
if (folder.isSystemFolder()) {
|
||||||
translatorTrigger();
|
translatorTrigger();
|
||||||
let suffix = getSystemFolderName(folder.type(), '');
|
let suffix = getSystemFolderName(folder.type(), getKolabFolderName(folder.kolabType()));
|
||||||
if (folder.name() !== suffix && 'inbox' !== suffix.toLowerCase()) {
|
if (folder.name() !== suffix && 'inbox' !== suffix.toLowerCase()) {
|
||||||
return '(' + suffix + ')';
|
return '(' + suffix + ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue