mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-52845 : Migrate "components/admin_console/elasticsearch_settings.jsx" and tests to Typescript (#23821)
This commit is contained in:
parent
c1dfdb867a
commit
91efa7bfc8
@ -62,7 +62,7 @@ import GlobalDataRetentionForm from './data_retention_settings/global_policy_for
|
|||||||
import CustomDataRetentionForm from './data_retention_settings/custom_policy_form';
|
import CustomDataRetentionForm from './data_retention_settings/custom_policy_form';
|
||||||
import MessageExportSettings from './message_export_settings.jsx';
|
import MessageExportSettings from './message_export_settings.jsx';
|
||||||
import DatabaseSettings from './database_settings.jsx';
|
import DatabaseSettings from './database_settings.jsx';
|
||||||
import ElasticSearchSettings from './elasticsearch_settings.jsx';
|
import ElasticSearchSettings from './elasticsearch_settings';
|
||||||
import BleveSettings from './bleve_settings';
|
import BleveSettings from './bleve_settings';
|
||||||
import FeatureFlags from './feature_flags.tsx';
|
import FeatureFlags from './feature_flags.tsx';
|
||||||
import ClusterSettings from './cluster_settings.jsx';
|
import ClusterSettings from './cluster_settings.jsx';
|
||||||
|
@ -5,7 +5,7 @@ import React from 'react';
|
|||||||
import {shallow} from 'enzyme';
|
import {shallow} from 'enzyme';
|
||||||
|
|
||||||
import SaveButton from 'components/save_button';
|
import SaveButton from 'components/save_button';
|
||||||
import ElasticSearchSettings from 'components/admin_console/elasticsearch_settings.jsx';
|
import ElasticSearchSettings from 'components/admin_console/elasticsearch_settings';
|
||||||
|
|
||||||
jest.mock('actions/admin_actions.jsx', () => {
|
jest.mock('actions/admin_actions.jsx', () => {
|
||||||
return {
|
return {
|
||||||
|
@ -11,15 +11,39 @@ import {t} from 'utils/i18n';
|
|||||||
|
|
||||||
import ExternalLink from 'components/external_link';
|
import ExternalLink from 'components/external_link';
|
||||||
|
|
||||||
import AdminSettings from './admin_settings';
|
import AdminSettings, {BaseProps, BaseState} from './admin_settings';
|
||||||
import BooleanSetting from './boolean_setting';
|
import BooleanSetting from './boolean_setting';
|
||||||
import JobsTable from './jobs';
|
import JobsTable from './jobs';
|
||||||
import RequestButton from './request_button/request_button';
|
import RequestButton from './request_button/request_button';
|
||||||
import SettingsGroup from './settings_group';
|
import SettingsGroup from './settings_group';
|
||||||
import TextSetting from './text_setting';
|
import TextSetting from './text_setting';
|
||||||
|
import {AdminConfig} from '@mattermost/types/config';
|
||||||
|
import {Job, JobType} from '@mattermost/types/jobs';
|
||||||
|
|
||||||
export default class ElasticsearchSettings extends AdminSettings {
|
interface State extends BaseState {
|
||||||
getConfigFromState = (config) => {
|
connectionUrl: string;
|
||||||
|
skipTLSVerification: boolean;
|
||||||
|
ca: string;
|
||||||
|
clientCert: string;
|
||||||
|
clientKey: string;
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
sniff: boolean;
|
||||||
|
enableIndexing: boolean;
|
||||||
|
enableSearching: boolean;
|
||||||
|
enableAutocomplete: boolean;
|
||||||
|
configTested: boolean;
|
||||||
|
canSave: boolean;
|
||||||
|
canPurgeAndIndex: boolean;
|
||||||
|
ignoredPurgeIndexes: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Props = BaseProps & {
|
||||||
|
config: AdminConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class ElasticsearchSettings extends AdminSettings<Props, State> {
|
||||||
|
getConfigFromState = (config: AdminConfig) => {
|
||||||
config.ElasticsearchSettings.ConnectionURL = this.state.connectionUrl;
|
config.ElasticsearchSettings.ConnectionURL = this.state.connectionUrl;
|
||||||
config.ElasticsearchSettings.SkipTLSVerification = this.state.skipTLSVerification;
|
config.ElasticsearchSettings.SkipTLSVerification = this.state.skipTLSVerification;
|
||||||
config.ElasticsearchSettings.CA = this.state.ca;
|
config.ElasticsearchSettings.CA = this.state.ca;
|
||||||
@ -36,7 +60,7 @@ export default class ElasticsearchSettings extends AdminSettings {
|
|||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|
||||||
getStateFromConfig(config) {
|
getStateFromConfig(config: AdminConfig) {
|
||||||
return {
|
return {
|
||||||
connectionUrl: config.ElasticsearchSettings.ConnectionURL,
|
connectionUrl: config.ElasticsearchSettings.ConnectionURL,
|
||||||
skipTLSVerification: config.ElasticsearchSettings.SkipTLSVerification,
|
skipTLSVerification: config.ElasticsearchSettings.SkipTLSVerification,
|
||||||
@ -56,7 +80,7 @@ export default class ElasticsearchSettings extends AdminSettings {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSettingChanged = (id, value) => {
|
handleSettingChanged = (id: string, value: boolean) => {
|
||||||
if (id === 'enableIndexing') {
|
if (id === 'enableIndexing') {
|
||||||
if (value === false) {
|
if (value === false) {
|
||||||
this.setState({
|
this.setState({
|
||||||
@ -97,7 +121,7 @@ export default class ElasticsearchSettings extends AdminSettings {
|
|||||||
return this.state.canSave;
|
return this.state.canSave;
|
||||||
};
|
};
|
||||||
|
|
||||||
doTestConfig = (success, error) => {
|
doTestConfig = (success: () => void, error: (error: string) => void): void => {
|
||||||
const config = JSON.parse(JSON.stringify(this.props.config));
|
const config = JSON.parse(JSON.stringify(this.props.config));
|
||||||
this.getConfigFromState(config);
|
this.getConfigFromState(config);
|
||||||
|
|
||||||
@ -110,7 +134,7 @@ export default class ElasticsearchSettings extends AdminSettings {
|
|||||||
});
|
});
|
||||||
success();
|
success();
|
||||||
},
|
},
|
||||||
(err) => {
|
(err: string) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
configTested: false,
|
configTested: false,
|
||||||
canSave: false,
|
canSave: false,
|
||||||
@ -120,7 +144,7 @@ export default class ElasticsearchSettings extends AdminSettings {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
getExtraInfo(job) {
|
getExtraInfo(job: Job) {
|
||||||
if (job.status === JobStatuses.IN_PROGRESS) {
|
if (job.status === JobStatuses.IN_PROGRESS) {
|
||||||
return (
|
return (
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
@ -382,8 +406,8 @@ export default class ElasticsearchSettings extends AdminSettings {
|
|||||||
<div className='col-sm-8'>
|
<div className='col-sm-8'>
|
||||||
<div className='job-table-setting'>
|
<div className='job-table-setting'>
|
||||||
<JobsTable
|
<JobsTable
|
||||||
jobType={JobTypes.ELASTICSEARCH_POST_INDEXING}
|
jobType={JobTypes.ELASTICSEARCH_POST_INDEXING as JobType}
|
||||||
disabled={!this.state.canPurgeAndIndex || this.props.isDisabled}
|
disabled={!this.state.canPurgeAndIndex || this.props.isDisabled!}
|
||||||
createJobButtonText={
|
createJobButtonText={
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='admin.elasticsearch.createJob.title'
|
id='admin.elasticsearch.createJob.title'
|
@ -21,7 +21,7 @@ import './table.scss';
|
|||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
jobs: Job[];
|
jobs: Job[];
|
||||||
getExtraInfoText?: (job: Job) => string | React.ReactElement;
|
getExtraInfoText?: (job: Job) => React.ReactNode;
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
createJobHelpText: React.ReactElement;
|
createJobHelpText: React.ReactElement;
|
||||||
jobType: JobType;
|
jobType: JobType;
|
||||||
|
Loading…
Reference in New Issue
Block a user