[ML] Disabling datafeed editing when job is running (#60751)
* [ML] Disabling datafeed editing when job is running * changing variable Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
91e8e3e883
commit
de7151e204
|
@ -31,6 +31,7 @@ import { withKibana } from '../../../../../../../../../src/plugins/kibana_react/
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { collapseLiteralStrings } from '../../../../../../shared_imports';
|
||||
import { DATAFEED_STATE } from '../../../../../../common/constants/states';
|
||||
|
||||
export class EditJobFlyoutUI extends Component {
|
||||
_initialJobFormState = null;
|
||||
|
@ -41,6 +42,7 @@ export class EditJobFlyoutUI extends Component {
|
|||
this.state = {
|
||||
job: {},
|
||||
hasDatafeed: false,
|
||||
datafeedRunning: false,
|
||||
isFlyoutVisible: false,
|
||||
isConfirmationModalVisible: false,
|
||||
jobDescription: '',
|
||||
|
@ -157,10 +159,12 @@ export class EditJobFlyoutUI extends Component {
|
|||
|
||||
extractJob(job, hasDatafeed) {
|
||||
this.extractInitialJobFormState(job, hasDatafeed);
|
||||
const datafeedRunning = hasDatafeed && job.datafeed_config.state !== DATAFEED_STATE.STOPPED;
|
||||
|
||||
this.setState({
|
||||
job,
|
||||
hasDatafeed,
|
||||
datafeedRunning,
|
||||
jobModelMemoryLimitValidationError: '',
|
||||
jobGroupsValidationError: '',
|
||||
...cloneDeep(this._initialJobFormState),
|
||||
|
@ -283,6 +287,7 @@ export class EditJobFlyoutUI extends Component {
|
|||
jobModelMemoryLimitValidationError,
|
||||
isValidJobDetails,
|
||||
isValidJobCustomUrls,
|
||||
datafeedRunning,
|
||||
} = this.state;
|
||||
|
||||
const tabs = [
|
||||
|
@ -293,6 +298,7 @@ export class EditJobFlyoutUI extends Component {
|
|||
}),
|
||||
content: (
|
||||
<JobDetails
|
||||
datafeedRunning={datafeedRunning}
|
||||
jobDescription={jobDescription}
|
||||
jobGroups={jobGroups}
|
||||
jobModelMemoryLimit={jobModelMemoryLimit}
|
||||
|
@ -328,6 +334,7 @@ export class EditJobFlyoutUI extends Component {
|
|||
datafeedScrollSize={datafeedScrollSize}
|
||||
jobBucketSpan={jobBucketSpan}
|
||||
setDatafeed={this.setDatafeed}
|
||||
datafeedRunning={datafeedRunning}
|
||||
/>
|
||||
),
|
||||
},
|
||||
|
|
|
@ -7,7 +7,14 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import { EuiFieldText, EuiForm, EuiFormRow, EuiSpacer, EuiFieldNumber } from '@elastic/eui';
|
||||
import {
|
||||
EuiFieldText,
|
||||
EuiForm,
|
||||
EuiFormRow,
|
||||
EuiSpacer,
|
||||
EuiFieldNumber,
|
||||
EuiCallOut,
|
||||
} from '@elastic/eui';
|
||||
|
||||
import { calculateDatafeedFrequencyDefaultSeconds } from '../../../../../../../common/util/job_utils';
|
||||
import { getNewJobDefaults } from '../../../../../services/ml_server_info';
|
||||
|
@ -72,9 +79,21 @@ export class Datafeed extends Component {
|
|||
|
||||
render() {
|
||||
const { query, queryDelay, frequency, scrollSize, defaults } = this.state;
|
||||
const { datafeedRunning } = this.props;
|
||||
return (
|
||||
<React.Fragment>
|
||||
<EuiSpacer size="m" />
|
||||
{datafeedRunning && (
|
||||
<>
|
||||
<EuiCallOut color="warning">
|
||||
<FormattedMessage
|
||||
id="xpack.ml.jobsList.editJobFlyout.datafeed.readOnlyCalloutText"
|
||||
defaultMessage="Datafeed settings cannot be edited while the datafeed is running. Please stop the job if you wish to edit these settings."
|
||||
/>
|
||||
</EuiCallOut>
|
||||
<EuiSpacer size="l" />
|
||||
</>
|
||||
)}
|
||||
<EuiForm>
|
||||
<EuiFormRow
|
||||
label={
|
||||
|
@ -90,6 +109,7 @@ export class Datafeed extends Component {
|
|||
value={query}
|
||||
onChange={this.onQueryChange}
|
||||
height="200px"
|
||||
readOnly={datafeedRunning}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
<EuiFormRow
|
||||
|
@ -104,6 +124,7 @@ export class Datafeed extends Component {
|
|||
value={queryDelay}
|
||||
placeholder={defaults.queryDelay}
|
||||
onChange={this.onQueryDelayChange}
|
||||
disabled={datafeedRunning}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
<EuiFormRow
|
||||
|
@ -118,6 +139,7 @@ export class Datafeed extends Component {
|
|||
value={frequency}
|
||||
placeholder={defaults.frequency}
|
||||
onChange={this.onFrequencyChange}
|
||||
disabled={datafeedRunning}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
<EuiFormRow
|
||||
|
@ -132,6 +154,7 @@ export class Datafeed extends Component {
|
|||
value={scrollSize}
|
||||
placeholder={defaults.scrollSize}
|
||||
onChange={this.onScrollSizeChange}
|
||||
disabled={datafeedRunning}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiForm>
|
||||
|
@ -140,6 +163,7 @@ export class Datafeed extends Component {
|
|||
}
|
||||
}
|
||||
Datafeed.propTypes = {
|
||||
datafeedRunning: PropTypes.bool.isRequired,
|
||||
datafeedQuery: PropTypes.string.isRequired,
|
||||
datafeedQueryDelay: PropTypes.string.isRequired,
|
||||
datafeedFrequency: PropTypes.string.isRequired,
|
||||
|
|
|
@ -105,6 +105,7 @@ export class JobDetails extends Component {
|
|||
mmlValidationError,
|
||||
groupsValidationError,
|
||||
} = this.state;
|
||||
const { datafeedRunning } = this.props;
|
||||
return (
|
||||
<React.Fragment>
|
||||
<EuiSpacer size="m" />
|
||||
|
@ -152,6 +153,14 @@ export class JobDetails extends Component {
|
|||
defaultMessage="Model memory limit"
|
||||
/>
|
||||
}
|
||||
helpText={
|
||||
datafeedRunning ? (
|
||||
<FormattedMessage
|
||||
id="xpack.ml.jobsList.editJobFlyout.jobDetails.modelMemoryLimitLabelHelp"
|
||||
defaultMessage="Model memory limit cannot be edited while the datafeed is running."
|
||||
/>
|
||||
) : null
|
||||
}
|
||||
isInvalid={mmlValidationError !== ''}
|
||||
error={mmlValidationError}
|
||||
>
|
||||
|
@ -160,6 +169,7 @@ export class JobDetails extends Component {
|
|||
onChange={this.onMmlChange}
|
||||
isInvalid={mmlValidationError !== ''}
|
||||
error={mmlValidationError}
|
||||
disabled={datafeedRunning}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiForm>
|
||||
|
@ -168,6 +178,7 @@ export class JobDetails extends Component {
|
|||
}
|
||||
}
|
||||
JobDetails.propTypes = {
|
||||
datafeedRunning: PropTypes.bool.isRequired,
|
||||
jobDescription: PropTypes.string.isRequired,
|
||||
jobGroups: PropTypes.array.isRequired,
|
||||
jobModelMemoryLimit: PropTypes.string.isRequired,
|
||||
|
|
|
@ -24,7 +24,7 @@ export const datafeedConfigSchema = schema.object({
|
|||
})
|
||||
),
|
||||
frequency: schema.maybe(schema.string()),
|
||||
indices: schema.arrayOf(schema.string()),
|
||||
indices: schema.maybe(schema.arrayOf(schema.string())),
|
||||
indexes: schema.maybe(schema.arrayOf(schema.string())),
|
||||
job_id: schema.maybe(schema.string()),
|
||||
query: schema.maybe(schema.any()),
|
||||
|
|
Loading…
Reference in a new issue