mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-52843] : Migrate "components/admin_console/bleve_settings.jsx" and tests to Typescript (#23527)
This commit is contained in:
parent
5261c8266d
commit
bea5b05533
@ -76,6 +76,7 @@ exports[`components/BleveSettings should match snapshot, disabled 1`] = `
|
|||||||
}
|
}
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
setByEnv={false}
|
setByEnv={false}
|
||||||
|
type="input"
|
||||||
value=""
|
value=""
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
@ -335,6 +336,7 @@ exports[`components/BleveSettings should match snapshot, enabled 1`] = `
|
|||||||
}
|
}
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
setByEnv={false}
|
setByEnv={false}
|
||||||
|
type="input"
|
||||||
value="bleve.idx"
|
value="bleve.idx"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
@ -367,6 +369,7 @@ exports[`components/BleveSettings should match snapshot, enabled 1`] = `
|
|||||||
id="admin.bleve.createJob.help"
|
id="admin.bleve.createJob.help"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
disabled={false}
|
||||||
getExtraInfoText={[Function]}
|
getExtraInfoText={[Function]}
|
||||||
jobType="bleve_post_indexing"
|
jobType="bleve_post_indexing"
|
||||||
/>
|
/>
|
@ -63,7 +63,7 @@ import CustomDataRetentionForm from './data_retention_settings/custom_policy_for
|
|||||||
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.jsx';
|
||||||
import BleveSettings from './bleve_settings.jsx';
|
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';
|
||||||
import CustomTermsOfServiceSettings from './custom_terms_of_service_settings';
|
import CustomTermsOfServiceSettings from './custom_terms_of_service_settings';
|
||||||
|
@ -63,7 +63,7 @@ export default abstract class AdminSettings <Props extends BaseProps, State exte
|
|||||||
|
|
||||||
protected abstract renderSettings(): React.ReactElement;
|
protected abstract renderSettings(): React.ReactElement;
|
||||||
|
|
||||||
protected handleSaved?: ((config: AdminConfig) => React.ReactElement);
|
protected handleSaved?: ((config: AdminConfig) => React.ReactElement | void);
|
||||||
|
|
||||||
protected canSave?: () => boolean;
|
protected canSave?: () => boolean;
|
||||||
|
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {shallow} from 'enzyme';
|
import {shallow} from 'enzyme';
|
||||||
|
|
||||||
import BleveSettings from 'components/admin_console/bleve_settings.jsx';
|
import {AdminConfig} from '@mattermost/types/config';
|
||||||
|
|
||||||
|
import BleveSettings from 'components/admin_console/bleve_settings';
|
||||||
|
|
||||||
jest.mock('actions/admin_actions.jsx', () => {
|
jest.mock('actions/admin_actions.jsx', () => {
|
||||||
return {
|
return {
|
||||||
@ -21,7 +23,7 @@ describe('components/BleveSettings', () => {
|
|||||||
EnableSearching: false,
|
EnableSearching: false,
|
||||||
EnableAutocomplete: false,
|
EnableAutocomplete: false,
|
||||||
},
|
},
|
||||||
};
|
} as AdminConfig;
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<BleveSettings
|
<BleveSettings
|
||||||
config={config}
|
config={config}
|
||||||
@ -38,7 +40,7 @@ describe('components/BleveSettings', () => {
|
|||||||
EnableSearching: false,
|
EnableSearching: false,
|
||||||
EnableAutocomplete: false,
|
EnableAutocomplete: false,
|
||||||
},
|
},
|
||||||
};
|
} as AdminConfig;
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<BleveSettings
|
<BleveSettings
|
||||||
config={config}
|
config={config}
|
@ -4,30 +4,47 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {FormattedMessage} from 'react-intl';
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
|
||||||
|
import {AdminConfig} from '@mattermost/types/config';
|
||||||
|
import {Job} from '@mattermost/types/jobs';
|
||||||
|
|
||||||
import {blevePurgeIndexes} from 'actions/admin_actions.jsx';
|
import {blevePurgeIndexes} from 'actions/admin_actions.jsx';
|
||||||
import {JobStatuses, JobTypes} from 'utils/constants';
|
import {JobStatuses, JobTypes} from 'utils/constants';
|
||||||
import {t} from 'utils/i18n';
|
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 TextSetting from './text_setting';
|
import TextSetting from './text_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';
|
||||||
|
|
||||||
export default class BleveSettings extends AdminSettings {
|
type Props = BaseProps & {
|
||||||
getConfigFromState = (config) => {
|
config: AdminConfig;
|
||||||
config.BleveSettings.IndexDir = this.state.indexDir;
|
};
|
||||||
config.BleveSettings.EnableIndexing = this.state.enableIndexing;
|
|
||||||
config.BleveSettings.EnableSearching = this.state.enableSearching;
|
|
||||||
config.BleveSettings.EnableAutocomplete = this.state.enableAutocomplete;
|
|
||||||
|
|
||||||
|
type State = BaseState & {
|
||||||
|
indexDir: string;
|
||||||
|
enableIndexing: boolean;
|
||||||
|
enableSearching: boolean;
|
||||||
|
enableAutocomplete: boolean;
|
||||||
|
canSave: boolean;
|
||||||
|
canPurgeAndIndex: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class BleveSettings extends AdminSettings<Props, State> {
|
||||||
|
getConfigFromState = (config: Props['config']) => {
|
||||||
|
if (config && config.BleveSettings) {
|
||||||
|
config.BleveSettings.IndexDir = this.state.indexDir;
|
||||||
|
config.BleveSettings.EnableIndexing = this.state.enableIndexing;
|
||||||
|
config.BleveSettings.EnableSearching = this.state.enableSearching;
|
||||||
|
config.BleveSettings.EnableAutocomplete = this.state.enableAutocomplete;
|
||||||
|
}
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|
||||||
getStateFromConfig(config) {
|
getStateFromConfig(config: Props['config']) {
|
||||||
return {
|
return {
|
||||||
enableIndexing: config.BleveSettings.EnableIndexing,
|
enableIndexing: config.BleveSettings.EnableIndexing,
|
||||||
indexDir: config.BleveSettings.IndexDir,
|
indexDir: config.BleveSettings.IndexDir,
|
||||||
@ -38,7 +55,7 @@ export default class BleveSettings 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({
|
||||||
@ -67,7 +84,7 @@ export default class BleveSettings extends AdminSettings {
|
|||||||
return this.state.canSave;
|
return this.state.canSave;
|
||||||
};
|
};
|
||||||
|
|
||||||
getExtraInfo(job) {
|
getExtraInfo(job: Job) {
|
||||||
if (job.status === JobStatuses.IN_PROGRESS) {
|
if (job.status === JobStatuses.IN_PROGRESS) {
|
||||||
return (
|
return (
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
@ -78,7 +95,7 @@ export default class BleveSettings extends AdminSettings {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderTitle() {
|
renderTitle() {
|
||||||
@ -143,6 +160,7 @@ export default class BleveSettings extends AdminSettings {
|
|||||||
onChange={this.handleSettingChanged}
|
onChange={this.handleSettingChanged}
|
||||||
setByEnv={this.isSetByEnv('BleveSettings.IndexDir')}
|
setByEnv={this.isSetByEnv('BleveSettings.IndexDir')}
|
||||||
disabled={this.props.isDisabled}
|
disabled={this.props.isDisabled}
|
||||||
|
type='input'
|
||||||
/>
|
/>
|
||||||
<div className='form-group'>
|
<div className='form-group'>
|
||||||
<label
|
<label
|
||||||
@ -157,7 +175,7 @@ export default class BleveSettings extends AdminSettings {
|
|||||||
<div className='job-table-setting'>
|
<div className='job-table-setting'>
|
||||||
<JobsTable
|
<JobsTable
|
||||||
jobType={JobTypes.BLEVE_POST_INDEXING}
|
jobType={JobTypes.BLEVE_POST_INDEXING}
|
||||||
disabled={!this.state.canPurgeAndIndex || this.props.isDisabled}
|
disabled={!this.state.canPurgeAndIndex || Boolean(this.props.isDisabled)}
|
||||||
createJobButtonText={
|
createJobButtonText={
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='admin.bleve.createJob.title'
|
id='admin.bleve.createJob.title'
|
@ -21,7 +21,7 @@ import './table.scss';
|
|||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
jobs: Job[];
|
jobs: Job[];
|
||||||
getExtraInfoText?: (job: Job) => string;
|
getExtraInfoText?: (job: Job) => string | React.ReactElement;
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
createJobHelpText: React.ReactElement;
|
createJobHelpText: React.ReactElement;
|
||||||
jobType: JobType;
|
jobType: JobType;
|
||||||
|
@ -931,7 +931,7 @@ export const JobTypes = {
|
|||||||
BLEVE_POST_INDEXING: 'bleve_post_indexing',
|
BLEVE_POST_INDEXING: 'bleve_post_indexing',
|
||||||
LDAP_SYNC: 'ldap_sync',
|
LDAP_SYNC: 'ldap_sync',
|
||||||
MESSAGE_EXPORT: 'message_export',
|
MESSAGE_EXPORT: 'message_export',
|
||||||
};
|
} as const;
|
||||||
|
|
||||||
export const JobStatuses = {
|
export const JobStatuses = {
|
||||||
PENDING: 'pending',
|
PENDING: 'pending',
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import {IDMappedObjects} from './utilities';
|
import {IDMappedObjects} from './utilities';
|
||||||
|
|
||||||
export type JobType = 'data_retention' | 'elasticsearch_post_indexing' | 'ldap_sync' | 'message_export';
|
export type JobType = 'data_retention' | 'elasticsearch_post_indexing' | 'bleve_post_indexing' | 'ldap_sync' | 'message_export';
|
||||||
export type JobStatus = 'pending' | 'in_progress' | 'success' | 'error' | 'cancel_requested' | 'canceled' | 'warning';
|
export type JobStatus = 'pending' | 'in_progress' | 'success' | 'error' | 'cancel_requested' | 'canceled' | 'warning';
|
||||||
export type Job = JobTypeBase & {
|
export type Job = JobTypeBase & {
|
||||||
id: string;
|
id: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user