Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bb166b1
Add managed badge
qn895 Dec 22, 2021
a407aed
Add managed to module configs
qn895 Dec 22, 2021
ecde40d
Fix message
qn895 Dec 22, 2021
9e620bb
Add management to managed transforms
qn895 Jan 4, 2022
a9ba547
Merge remote-tracking branch 'upstream/main' into ml-ad-managed-badges
qn895 Jan 5, 2022
427be5b
Update texts
qn895 Jan 6, 2022
65cdb0a
Handle bool in custom settings table
qn895 Jan 6, 2022
cf88398
Change message
qn895 Jan 6, 2022
3f17443
Add modal/warnings for resetting and closing. Move start warning to m…
qn895 Jan 6, 2022
5b7fefa
Not clone AD managed settings
qn895 Jan 7, 2022
41f96b3
Not clone transform managed settings
qn895 Jan 7, 2022
210c4ac
Fix translations
qn895 Jan 7, 2022
7ecbc44
Merge remote-tracking branch 'upstream/main' into ml-ad-managed-badges
qn895 Jan 7, 2022
13a7878
Fix translations id
qn895 Jan 10, 2022
398f1d0
Merge remote-tracking branch 'upstream/main' into ml-ad-managed-badges
qn895 Jan 10, 2022
a238c51
Remove showEditJobConfirmModal
qn895 Jan 10, 2022
9bcb91e
Consolidate call out messages
qn895 Jan 10, 2022
3f1c96f
Merge remote-tracking branch 'upstream/main' into ml-ad-managed-badges
qn895 Jan 10, 2022
5577699
Consolidate call out messages
qn895 Jan 10, 2022
c2f823d
Add tooltip message
qn895 Jan 11, 2022
20dce3a
Add tooltip message
qn895 Jan 11, 2022
4820a46
Remove warning message for start transform
qn895 Jan 11, 2022
12671ba
Merge upstream/main into branch
qn895 Jan 12, 2022
6fcdf44
Remove managed flag in route instead of in client
qn895 Jan 12, 2022
3e2a40b
Merge remote-tracking branch 'upstream/main' into ml-ad-managed-badges
qn895 Jan 12, 2022
a46d36b
Add message for delete in space permission
qn895 Jan 13, 2022
a5131b5
Merge remote-tracking branch 'upstream/main' into ml-ad-managed-badges
qn895 Jan 13, 2022
78ccf47
Merge remote-tracking branch 'upstream/main' into ml-ad-managed-badges
qn895 Jan 14, 2022
352559c
Add remove managed setting during clone in route
qn895 Jan 14, 2022
af963d1
Add stopDatafeeds to declaration file
qn895 Jan 14, 2022
4915fd7
Merge remote-tracking branch 'upstream/main' into ml-ad-managed-badges
qn895 Jan 18, 2022
a7f844b
Add call out when editing managed transform
qn895 Jan 18, 2022
a13f502
Delete attr instead of setting it to false
qn895 Jan 18, 2022
93babe8
Merge branch 'main' into ml-ad-managed-badges
kibanamachine Jan 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { Moment } from 'moment';

import { MlCustomSettings } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { CombinedJob, CombinedJobWithStats } from './combined_job';
import type { MlAnomalyDetectionAlertRule } from '../alerts';
import type { MlJobBlocked } from './job';
Expand Down Expand Up @@ -39,6 +40,7 @@ export interface MlSummaryJob {
alertingRules?: MlAnomalyDetectionAlertRule[];
jobTags: Record<string, string>;
bucketSpanSeconds: number;
customSettings?: MlCustomSettings;
}

export interface AuditMessage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ import {
EuiButton,
EuiLoadingSpinner,
EuiText,
EuiSpacer,
} from '@elastic/eui';
import { JobType, CanDeleteJobResponse } from '../../../../common/types/saved_objects';
import { useMlApiContext } from '../../contexts/kibana';
import { useToastNotificationService } from '../../services/toast_notification_service';
import { ManagedJobsWarningCallout } from '../../jobs/jobs_list/components/confirm_modals/managed_jobs_warning_callout';

const shouldUnTagLabel = i18n.translate('xpack.ml.deleteJobCheckModal.shouldUnTagLabel', {
defaultMessage: 'Remove job from current space',
Expand Down Expand Up @@ -58,7 +60,8 @@ function getRespSummary(resp: CanDeleteJobResponse): JobCheckRespSummary {

function getModalContent(
jobIds: string[],
respSummary: JobCheckRespSummary
respSummary: JobCheckRespSummary,
hasManagedJob?: boolean
): ModalContentReturnType {
const { canDelete, canRemoveFromSpace, canTakeAnyAction } = respSummary;

Expand Down Expand Up @@ -107,13 +110,30 @@ function getModalContent(
/>
),
modalText: (
<EuiText>
<FormattedMessage
id="xpack.ml.deleteJobCheckModal.modalTextCanDelete"
defaultMessage="{ids} can be deleted."
values={{ ids: jobIds.join(', ') }}
/>
</EuiText>
<>
{hasManagedJob ? (
<>
<ManagedJobsWarningCallout
jobsCount={jobIds.length}
action={i18n.translate(
'xpack.ml.jobsList.deleteJobCheckModal.removeOrDeleteAction',
{
defaultMessage: 'removing or deleting',
}
)}
/>
<EuiSpacer size="s" />
</>
) : null}

<EuiText>
<FormattedMessage
id="xpack.ml.deleteJobCheckModal.modalTextCanDelete"
defaultMessage="{ids} can be deleted."
values={{ ids: jobIds.join(', ') }}
/>
</EuiText>
</>
),
};
} else if (canRemoveFromSpace) {
Expand All @@ -125,13 +145,27 @@ function getModalContent(
/>
),
modalText: (
<EuiText>
<FormattedMessage
id="xpack.ml.deleteJobCheckModal.modalTextCanUnTag"
defaultMessage="{ids} cannot be deleted but can be removed from the current space."
values={{ ids: jobIds.join(', ') }}
/>
</EuiText>
<>
{hasManagedJob ? (
<>
<ManagedJobsWarningCallout
jobsCount={jobIds.length}
action={i18n.translate('xpack.ml.jobsList.deleteJobCheckModal.removeAction', {
defaultMessage: 'removing',
})}
/>
<EuiSpacer size="s" />
</>
) : null}

<EuiText>
<FormattedMessage
id="xpack.ml.deleteJobCheckModal.modalTextCanUnTag"
defaultMessage="{ids} cannot be deleted but can be removed from the current space."
values={{ ids: jobIds.join(', ') }}
/>
</EuiText>
</>
),
};
} else {
Expand All @@ -146,6 +180,7 @@ interface Props {
jobType: JobType;
jobIds: string[];
setDidUntag?: React.Dispatch<React.SetStateAction<boolean>>;
hasManagedJob?: boolean;
}

export const DeleteJobCheckModal: FC<Props> = ({
Expand All @@ -155,6 +190,7 @@ export const DeleteJobCheckModal: FC<Props> = ({
jobType,
jobIds,
setDidUntag,
hasManagedJob,
}) => {
const [buttonContent, setButtonContent] = useState<JSX.Element | undefined>();
const [modalContent, setModalContent] = useState<JSX.Element | undefined>();
Expand All @@ -180,15 +216,15 @@ export const DeleteJobCheckModal: FC<Props> = ({
return;
}
setJobCheckRespSummary(respSummary);
const { buttonText, modalText } = getModalContent(jobIds, respSummary);
const { buttonText, modalText } = getModalContent(jobIds, respSummary, hasManagedJob);
setButtonContent(buttonText);
setModalContent(modalText);
});
if (typeof setDidUntag === 'function') {
setDidUntag(false);
}
setIsLoading(false);
}, []);
}, [hasManagedJob]);

const onUntagClick = async () => {
setIsUntagging(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React, { FC, useState, useEffect, useCallback, useMemo } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import {
EuiSpacer,
EuiModal,
EuiModalHeader,
EuiModalHeaderTitle,
EuiModalBody,
EuiModalFooter,
EuiButtonEmpty,
EuiButton,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { MlSummaryJob } from '../../../../../../common/types/anomaly_detection_jobs';
import { isManagedJob } from '../../../jobs_utils';
import { closeJobs } from '../utils';
import { ManagedJobsWarningCallout } from './managed_jobs_warning_callout';

type ShowFunc = (jobs: MlSummaryJob[]) => void;

interface Props {
setShowFunction(showFunc: ShowFunc): void;
unsetShowFunction(): void;
refreshJobs(): void;
}

export const CloseJobsConfirmModal: FC<Props> = ({
setShowFunction,
unsetShowFunction,
refreshJobs,
}) => {
const [modalVisible, setModalVisible] = useState(false);
const [hasManagedJob, setHasManaged] = useState(true);
const [jobsToReset, setJobsToReset] = useState<MlSummaryJob[]>([]);

const jobIds = useMemo(() => jobsToReset.map(({ id }) => id), [jobsToReset]);

useEffect(() => {
if (typeof setShowFunction === 'function') {
setShowFunction(showModal);
}
return () => {
if (typeof unsetShowFunction === 'function') {
unsetShowFunction();
}
};
}, []);

const showModal = useCallback((jobs: MlSummaryJob[]) => {
setJobsToReset(jobs);

if (jobs.some((j) => isManagedJob(j))) {
setModalVisible(true);
setHasManaged(true);
}
}, []);

const closeModal = useCallback(() => {
setModalVisible(false);
setHasManaged(false);
}, []);

if (modalVisible === false) {
return null;
}

if (hasManagedJob) {
const title = (
<FormattedMessage
id="xpack.ml.jobsList.startDatafeedsModal.closeDatafeedsTitle"
defaultMessage="Close {jobsCount, plural, one {{jobId}} other {# jobs}}?"
values={{
jobsCount: jobIds.length,
jobId: jobIds[0],
}}
/>
);

return (
<EuiModal data-test-subj="mlCloseJobsConfirmModal" onClose={closeModal}>
<EuiModalHeader>
<EuiModalHeaderTitle>{title}</EuiModalHeaderTitle>
</EuiModalHeader>
<EuiModalBody>
<ManagedJobsWarningCallout
jobsCount={jobIds.length}
action={i18n.translate(
'xpack.ml.jobsList.closeJobsModal.closeManagedDatafeedsDescription',
{
defaultMessage: 'closing',
}
)}
/>
</EuiModalBody>
<>
<EuiSpacer />
<EuiModalFooter>
<EuiButtonEmpty onClick={closeModal}>
<FormattedMessage
id="xpack.ml.jobsList.startDatafeedsConfirmModal.cancelButtonLabel"
defaultMessage="Cancel"
/>
</EuiButtonEmpty>

<EuiButton
onClick={() => {
closeJobs(jobsToReset, refreshJobs);
closeModal();
}}
fill
color="danger"
data-test-subj="mlCloseJobsConfirmModalButton"
>
<FormattedMessage
id="xpack.ml.jobsList.startDatafeedsConfirmModal.closeButtonLabel"
defaultMessage="Close {jobsCount, plural, one {job} other {jobs}}"
values={{
jobsCount: jobIds.length,
}}
/>
</EuiButton>
</EuiModalFooter>
</>
</EuiModal>
);
} else {
return <></>;
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { EuiCallOut, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import React from 'react';

export const ManagedJobsWarningCallout = ({
jobsCount,
action,
message,
}: {
jobsCount: number;
action?: string;
message?: string;
}) => {
return (
<>
<EuiSpacer size="s" />
<EuiCallOut color="warning">
{message ?? (
<FormattedMessage
id="xpack.ml.managedJobsWarningCallout"
defaultMessage="{jobsCount, plural, one {This job} other {At least one of these jobs}} is preconfigured by Elastic; {action} {jobsCount, plural, one {it} other {them}} might impact other parts of the product."
values={{
jobsCount,
action,
}}
/>
)}
</EuiCallOut>
</>
);
};
Loading