// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react'; import {FormattedMessage} from 'react-intl'; import type {IntlShape} from 'react-intl'; import {localeTranslations} from 'common/utils/constants'; import type {SettingsDefinition} from 'types/settings'; import CheckSetting from './components/CheckSetting'; import DownloadSetting from './components/DownloadSetting'; import NotificationSetting from './components/NotificationSetting'; import RadioSetting from './components/RadioSetting'; import SelectSetting from './components/SelectSetting'; import ServerSetting from './components/ServerSetting'; import SpellCheckerSetting from './components/SpellCheckerSetting'; import UpdatesSetting from './components/UpdatesSetting'; const getLanguages = async (func: () => Promise) => { return (await func()).filter((language) => localeTranslations[language]). map((language) => ({label: localeTranslations[language], value: language})). sort((a, b) => a.label.localeCompare(b.label)); }; const definition: (intl: IntlShape) => Promise = async (intl: IntlShape) => { return { general: { title: ( ), icon: 'settings-outline', settings: [ { id: 'autoCheckForUpdates', component: UpdatesSetting, condition: (await window.desktop.getLocalConfiguration()).canUpgrade, }, { id: 'downloadLocation', component: DownloadSetting, }, { id: 'autostart', component: CheckSetting, condition: window.process.platform === 'win32' || window.process.platform === 'linux', props: { label: ( ), subLabel: ( ), }, }, { id: 'hideOnStart', component: CheckSetting, condition: window.process.platform === 'win32' || window.process.platform === 'linux', props: { label: ( ), subLabel: ( ), }, }, { id: 'showTrayIcon', component: CheckSetting, condition: window.process.platform === 'darwin' || window.process.platform === 'linux', props: { label: ( ), subLabel: ( ), }, }, { id: 'trayIconTheme', component: RadioSetting, condition: (window.process.platform === 'linux' || window.process.platform === 'win32') && (await window.desktop.getLocalConfiguration()).showTrayIcon, props: { label: ( ), options: [ { value: 'use_system', label: ( ), }, { value: 'light', label: ( ), }, { value: 'dark', label: ( ), }, ], }, }, { id: 'minimizeToTray', component: CheckSetting, condition: window.process.platform === 'linux' || window.process.platform === 'win32', props: { label: ( ), subLabel: ( <>
), }, }, { id: 'startInFullscreen', component: CheckSetting, condition: window.process.platform !== 'linux', props: { label: ( ), subLabel: ( ), }, }, ], }, notifications: { title: ( ), icon: 'bell-outline', settings: [ { id: 'showUnreadBadge', component: CheckSetting, condition: window.process.platform === 'darwin' || window.process.platform === 'win32', props: { heading: ( ), label: ( ), subLabel: ( ), }, }, { id: 'notifications', component: NotificationSetting, }, ], }, language: { title: ( ), icon: 'globe', settings: [ { id: 'appLanguage', component: SelectSetting, props: { label: ( ), subLabel: ( <>   ), placeholder: ( ), options: await getLanguages(window.desktop.getAvailableLanguages), }, }, { id: 'useSpellChecker', component: SpellCheckerSetting, props: { heading: (

), label: ( ), subLabel: ( <>   ), options: await getLanguages(window.desktop.getAvailableSpellCheckerLanguages), }, }, ], }, servers: { title: ( ), icon: 'server-variant', settings: [ { id: 'teams', component: ServerSetting, }, ], }, advanced: { title: ( ), icon: 'tune', settings: [ { id: 'logLevel', component: SelectSetting, props: { label: ( ), subLabel: ( ), bottomBorder: true, options: [ { value: 'error', label: intl.formatMessage({ id: 'renderer.components.settingsPage.loggingLevel.level.error', defaultMessage: 'Errors (error)', }), }, { value: 'warn', label: intl.formatMessage({ id: 'renderer.components.settingsPage.loggingLevel.level.warn', defaultMessage: 'Errors and Warnings (warn)', }), }, { value: 'info', label: intl.formatMessage({ id: 'renderer.components.settingsPage.loggingLevel.level.info', defaultMessage: 'Info (info)', }), }, { value: 'verbose', label: intl.formatMessage({ id: 'renderer.components.settingsPage.loggingLevel.level.verbose', defaultMessage: 'Verbose (verbose)', }), }, { value: 'debug', label: intl.formatMessage({ id: 'renderer.components.settingsPage.loggingLevel.level.debug', defaultMessage: 'Debug (debug)', }), }, { value: 'silly', label: intl.formatMessage({ id: 'renderer.components.settingsPage.loggingLevel.level.silly', defaultMessage: 'Finest (silly)', }), }, ], }, }, { id: 'enableMetrics', component: CheckSetting, props: { label: ( ), subLabel: ( ), }, }, { id: 'enableHardwareAcceleration', component: CheckSetting, props: { label: ( ), subLabel: ( <>   ), }, }, ], }, }; }; export default definition;