diff --git a/webapp/channels/src/components/admin_console/__snapshots__/bleve_settings.test.jsx.snap b/webapp/channels/src/components/admin_console/__snapshots__/bleve_settings.test.tsx.snap similarity index 99% rename from webapp/channels/src/components/admin_console/__snapshots__/bleve_settings.test.jsx.snap rename to webapp/channels/src/components/admin_console/__snapshots__/bleve_settings.test.tsx.snap index 8e2237bae8..d2ac779815 100644 --- a/webapp/channels/src/components/admin_console/__snapshots__/bleve_settings.test.jsx.snap +++ b/webapp/channels/src/components/admin_console/__snapshots__/bleve_settings.test.tsx.snap @@ -76,6 +76,7 @@ exports[`components/BleveSettings should match snapshot, disabled 1`] = ` } onChange={[Function]} setByEnv={false} + type="input" value="" />
} + disabled={false} getExtraInfoText={[Function]} jobType="bleve_post_indexing" /> diff --git a/webapp/channels/src/components/admin_console/admin_definition.jsx b/webapp/channels/src/components/admin_console/admin_definition.jsx index 62fe822e2b..f409c41920 100644 --- a/webapp/channels/src/components/admin_console/admin_definition.jsx +++ b/webapp/channels/src/components/admin_console/admin_definition.jsx @@ -63,7 +63,7 @@ import CustomDataRetentionForm from './data_retention_settings/custom_policy_for import MessageExportSettings from './message_export_settings.jsx'; import DatabaseSettings from './database_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 ClusterSettings from './cluster_settings.jsx'; import CustomTermsOfServiceSettings from './custom_terms_of_service_settings'; diff --git a/webapp/channels/src/components/admin_console/admin_settings.tsx b/webapp/channels/src/components/admin_console/admin_settings.tsx index 2bb9442097..3af43880bd 100644 --- a/webapp/channels/src/components/admin_console/admin_settings.tsx +++ b/webapp/channels/src/components/admin_console/admin_settings.tsx @@ -63,7 +63,7 @@ export default abstract class AdminSettings React.ReactElement); + protected handleSaved?: ((config: AdminConfig) => React.ReactElement | void); protected canSave?: () => boolean; diff --git a/webapp/channels/src/components/admin_console/bleve_settings.test.jsx b/webapp/channels/src/components/admin_console/bleve_settings.test.tsx similarity index 92% rename from webapp/channels/src/components/admin_console/bleve_settings.test.jsx rename to webapp/channels/src/components/admin_console/bleve_settings.test.tsx index 8a8e89350e..34f0828705 100644 --- a/webapp/channels/src/components/admin_console/bleve_settings.test.jsx +++ b/webapp/channels/src/components/admin_console/bleve_settings.test.tsx @@ -4,7 +4,9 @@ import React from 'react'; 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', () => { return { @@ -21,7 +23,7 @@ describe('components/BleveSettings', () => { EnableSearching: false, EnableAutocomplete: false, }, - }; + } as AdminConfig; const wrapper = shallow( { EnableSearching: false, EnableAutocomplete: false, }, - }; + } as AdminConfig; const wrapper = shallow( { - 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 Props = BaseProps & { + config: AdminConfig; +}; +type State = BaseState & { + indexDir: string; + enableIndexing: boolean; + enableSearching: boolean; + enableAutocomplete: boolean; + canSave: boolean; + canPurgeAndIndex: boolean; +}; + +export default class BleveSettings extends AdminSettings { + 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; }; - getStateFromConfig(config) { + getStateFromConfig(config: Props['config']) { return { enableIndexing: config.BleveSettings.EnableIndexing, 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 (value === false) { this.setState({ @@ -67,7 +84,7 @@ export default class BleveSettings extends AdminSettings { return this.state.canSave; }; - getExtraInfo(job) { + getExtraInfo(job: Job) { if (job.status === JobStatuses.IN_PROGRESS) { return ( ; } renderTitle() { @@ -143,6 +160,7 @@ export default class BleveSettings extends AdminSettings { onChange={this.handleSettingChanged} setByEnv={this.isSetByEnv('BleveSettings.IndexDir')} disabled={this.props.isDisabled} + type='input' />