mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-52831] Migrate "components/admin_console/message_export_settings.jsx" and tests to Typescript (#24933)
This commit is contained in:
parent
7caa5bce25
commit
df727947d1
@ -70,7 +70,7 @@ import FeatureFlags from './feature_flags.tsx';
|
|||||||
import GroupDetails from './group_settings/group_details';
|
import GroupDetails from './group_settings/group_details';
|
||||||
import GroupSettings from './group_settings/group_settings';
|
import GroupSettings from './group_settings/group_settings';
|
||||||
import LicenseSettings from './license_settings';
|
import LicenseSettings from './license_settings';
|
||||||
import MessageExportSettings from './message_export_settings.jsx';
|
import MessageExportSettings from './message_export_settings';
|
||||||
import OpenIdConvert from './openid_convert';
|
import OpenIdConvert from './openid_convert';
|
||||||
import PasswordSettings from './password_settings';
|
import PasswordSettings from './password_settings';
|
||||||
import PermissionSchemesSettings from './permission_schemes_settings';
|
import PermissionSchemesSettings from './permission_schemes_settings';
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
import {shallow} from 'enzyme';
|
import {shallow} from 'enzyme';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import MessageExportSettings from 'components/admin_console/message_export_settings.jsx';
|
import MessageExportSettings from 'components/admin_console/message_export_settings';
|
||||||
|
|
||||||
describe('components/MessageExportSettings', () => {
|
describe('components/MessageExportSettings', () => {
|
||||||
test('should match snapshot, disabled, actiance', () => {
|
test('should match snapshot, disabled, actiance', () => {
|
||||||
|
@ -2,8 +2,12 @@
|
|||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import type {ReactNode} from 'react';
|
||||||
import {FormattedMessage} from 'react-intl';
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
|
||||||
|
import type {AdminConfig} from '@mattermost/types/config';
|
||||||
|
import type {Job} from '@mattermost/types/jobs';
|
||||||
|
|
||||||
import ExternalLink from 'components/external_link';
|
import ExternalLink from 'components/external_link';
|
||||||
import FormattedMarkdownMessage from 'components/formatted_markdown_message';
|
import FormattedMarkdownMessage from 'components/formatted_markdown_message';
|
||||||
|
|
||||||
@ -11,6 +15,7 @@ import {DocLinks, JobTypes, exportFormats} from 'utils/constants';
|
|||||||
import {getSiteURL} from 'utils/url';
|
import {getSiteURL} from 'utils/url';
|
||||||
import * as Utils from 'utils/utils';
|
import * as Utils from 'utils/utils';
|
||||||
|
|
||||||
|
import type {BaseProps, BaseState} from './admin_settings';
|
||||||
import AdminSettings from './admin_settings';
|
import AdminSettings from './admin_settings';
|
||||||
import BooleanSetting from './boolean_setting';
|
import BooleanSetting from './boolean_setting';
|
||||||
import DropdownSetting from './dropdown_setting';
|
import DropdownSetting from './dropdown_setting';
|
||||||
@ -19,8 +24,19 @@ import RadioSetting from './radio_setting';
|
|||||||
import SettingsGroup from './settings_group';
|
import SettingsGroup from './settings_group';
|
||||||
import TextSetting from './text_setting';
|
import TextSetting from './text_setting';
|
||||||
|
|
||||||
export default class MessageExportSettings extends AdminSettings {
|
interface State extends BaseState {
|
||||||
getConfigFromState = (config) => {
|
enableComplianceExport: AdminConfig['MessageExportSettings']['EnableExport'];
|
||||||
|
exportFormat: AdminConfig['MessageExportSettings']['ExportFormat'];
|
||||||
|
exportJobStartTime: AdminConfig['MessageExportSettings']['DailyRunTime'];
|
||||||
|
globalRelayCustomerType: AdminConfig['MessageExportSettings']['GlobalRelaySettings']['CustomerType'];
|
||||||
|
globalRelaySMTPUsername: AdminConfig['MessageExportSettings']['GlobalRelaySettings']['SMTPUsername'];
|
||||||
|
globalRelaySMTPPassword: AdminConfig['MessageExportSettings']['GlobalRelaySettings']['SMTPPassword'];
|
||||||
|
globalRelayEmailAddress: AdminConfig['MessageExportSettings']['GlobalRelaySettings']['EmailAddress'];
|
||||||
|
globalRelaySMTPServerTimeout: AdminConfig['MessageExportSettings']['GlobalRelaySettings']['SMTPServerTimeout'];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class MessageExportSettings extends AdminSettings<BaseProps, State> {
|
||||||
|
getConfigFromState = (config: AdminConfig) => {
|
||||||
config.MessageExportSettings.EnableExport = this.state.enableComplianceExport;
|
config.MessageExportSettings.EnableExport = this.state.enableComplianceExport;
|
||||||
config.MessageExportSettings.ExportFormat = this.state.exportFormat;
|
config.MessageExportSettings.ExportFormat = this.state.exportFormat;
|
||||||
config.MessageExportSettings.DailyRunTime = this.state.exportJobStartTime;
|
config.MessageExportSettings.DailyRunTime = this.state.exportJobStartTime;
|
||||||
@ -31,18 +47,26 @@ export default class MessageExportSettings extends AdminSettings {
|
|||||||
SMTPUsername: this.state.globalRelaySMTPUsername,
|
SMTPUsername: this.state.globalRelaySMTPUsername,
|
||||||
SMTPPassword: this.state.globalRelaySMTPPassword,
|
SMTPPassword: this.state.globalRelaySMTPPassword,
|
||||||
EmailAddress: this.state.globalRelayEmailAddress,
|
EmailAddress: this.state.globalRelayEmailAddress,
|
||||||
|
SMTPServerTimeout: this.state.globalRelaySMTPServerTimeout,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|
||||||
getStateFromConfig(config) {
|
getStateFromConfig(config: AdminConfig) {
|
||||||
const state = {
|
const state: State = {
|
||||||
enableComplianceExport: config.MessageExportSettings.EnableExport,
|
enableComplianceExport: config.MessageExportSettings.EnableExport,
|
||||||
exportFormat: config.MessageExportSettings.ExportFormat,
|
exportFormat: config.MessageExportSettings.ExportFormat,
|
||||||
exportJobStartTime: config.MessageExportSettings.DailyRunTime,
|
exportJobStartTime: config.MessageExportSettings.DailyRunTime,
|
||||||
canRunJob: config.MessageExportSettings.EnableExport,
|
globalRelayCustomerType: '',
|
||||||
|
globalRelaySMTPUsername: '',
|
||||||
|
globalRelaySMTPPassword: '',
|
||||||
|
globalRelayEmailAddress: '',
|
||||||
|
globalRelaySMTPServerTimeout: 0,
|
||||||
|
saveNeeded: false,
|
||||||
|
saving: false,
|
||||||
|
serverError: null,
|
||||||
|
errorTooltip: false,
|
||||||
};
|
};
|
||||||
if (config.MessageExportSettings.GlobalRelaySettings) {
|
if (config.MessageExportSettings.GlobalRelaySettings) {
|
||||||
state.globalRelayCustomerType = config.MessageExportSettings.GlobalRelaySettings.CustomerType;
|
state.globalRelayCustomerType = config.MessageExportSettings.GlobalRelaySettings.CustomerType;
|
||||||
@ -53,7 +77,7 @@ export default class MessageExportSettings extends AdminSettings {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
getJobDetails = (job) => {
|
getJobDetails = (job: Job) => {
|
||||||
if (job.data) {
|
if (job.data) {
|
||||||
const message = [];
|
const message = [];
|
||||||
if (job.data.messages_exported) {
|
if (job.data.messages_exported) {
|
||||||
@ -246,7 +270,7 @@ export default class MessageExportSettings extends AdminSettings {
|
|||||||
id='admin.service.complianceExportDesc'
|
id='admin.service.complianceExportDesc'
|
||||||
defaultMessage='When true, Mattermost will export all messages that were posted in the last 24 hours. The export task is scheduled to run once per day. See <link>the documentation</link> to learn more.'
|
defaultMessage='When true, Mattermost will export all messages that were posted in the last 24 hours. The export task is scheduled to run once per day. See <link>the documentation</link> to learn more.'
|
||||||
values={{
|
values={{
|
||||||
link: (msg) => (
|
link: (msg: ReactNode) => (
|
||||||
<ExternalLink
|
<ExternalLink
|
||||||
href={DocLinks.COMPILANCE_EXPORT}
|
href={DocLinks.COMPILANCE_EXPORT}
|
||||||
location='message_export_settings'
|
location='message_export_settings'
|
||||||
@ -317,7 +341,7 @@ export default class MessageExportSettings extends AdminSettings {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
getExtraInfoText={this.getJobDetails}
|
getExtraInfoText={this.getJobDetails}
|
||||||
disabled={this.props.isDisabled || !this.state.canRunJob}
|
disabled={this.props.isDisabled || !this.state.enableComplianceExport}
|
||||||
/>
|
/>
|
||||||
</SettingsGroup>
|
</SettingsGroup>
|
||||||
);
|
);
|
Loading…
Reference in New Issue
Block a user