-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 150985-infrastructure-ui-hosts-view-add-link…
…s-to-apm-and-uptime-for-a-single-host
- Loading branch information
Showing
16 changed files
with
272 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
.../synthetics/public/apps/synthetics/components/monitor_add_edit/edit_monitor_not_found.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* 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, { useEffect, useState } from 'react'; | ||
import { EuiButton, EuiCallOut, EuiLink, EuiSpacer } from '@elastic/eui'; | ||
import { useFetcher } from '@kbn/observability-plugin/public'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { useGetUrlParams, useUrlParams } from '../../hooks'; | ||
import { deletePackagePolicy } from '../../state/monitor_management/api'; | ||
import { MonitorNotFoundPage } from '../monitor_details/monitor_not_found_page'; | ||
|
||
export const EditMonitorNotFound: React.FC = () => { | ||
return ( | ||
<> | ||
<LeftoverIntegrationFound /> | ||
<EuiSpacer size="m" /> | ||
<MonitorNotFoundPage /> | ||
</> | ||
); | ||
}; | ||
|
||
const LeftoverIntegrationFound: React.FC = () => { | ||
const { packagePolicyId } = useGetUrlParams(); | ||
const updateUrlParams = useUrlParams()[1]; | ||
|
||
const [isDeleting, setIsDeleting] = useState(false); | ||
|
||
const { data, loading } = useFetcher(() => { | ||
if (!packagePolicyId || !isDeleting) return; | ||
return deletePackagePolicy(packagePolicyId); | ||
}, [isDeleting, packagePolicyId]); | ||
|
||
useEffect(() => { | ||
if (isDeleting && data && !loading) { | ||
updateUrlParams({ packagePolicyId: undefined }, true); | ||
setIsDeleting(false); | ||
} | ||
}, [data, isDeleting, loading, updateUrlParams]); | ||
|
||
if (!packagePolicyId) return null; | ||
|
||
return ( | ||
<EuiCallOut title="Leftover integration found" color="warning" iconType="help"> | ||
<p> | ||
<FormattedMessage | ||
id="xpack.synthetics.leftOver.errors.title" | ||
defaultMessage="Please click on the button below to delete the integration. Normally this should not happen. | ||
Since the monitor has been deleted, the integration was supposed to be deleted automatically. If | ||
this happens often, report it by " | ||
/> | ||
<EuiLink | ||
data-test-subj="syntheticsLeftoverIntegrationFoundCreatingAnIssueLink" | ||
href="https://github.com/elastic/kibana/issues/new/choose" | ||
> | ||
<FormattedMessage | ||
id="xpack.synthetics.leftOver.errors.createIssue" | ||
defaultMessage="creating an issue." | ||
/> | ||
</EuiLink> | ||
</p> | ||
<EuiButton | ||
data-test-subj="syntheticsUseMonitorNotFoundDeleteIntegrationButton" | ||
color="danger" | ||
isLoading={loading && isDeleting} | ||
onClick={() => { | ||
setIsDeleting(true); | ||
}} | ||
> | ||
<FormattedMessage | ||
id="xpack.synthetics.leftOver.errors.delete" | ||
defaultMessage="Delete integration" | ||
/> | ||
</EuiButton> | ||
</EuiCallOut> | ||
); | ||
}; |
24 changes: 24 additions & 0 deletions
24
...hetics/public/apps/synthetics/components/monitor_add_edit/hooks/use_monitor_not_found.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* 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 { useEffect } from 'react'; | ||
import { IHttpFetchError, ResponseErrorBody } from '@kbn/core-http-browser'; | ||
import { useGetUrlParams, useUrlParams } from '../../../hooks'; | ||
|
||
export const useMonitorNotFound = (error?: IHttpFetchError<ResponseErrorBody>, id?: string) => { | ||
const { packagePolicyId } = useGetUrlParams(); | ||
const updateUrlParams = useUrlParams()[1]; | ||
|
||
useEffect(() => { | ||
if (id && packagePolicyId && !error) { | ||
updateUrlParams({ packagePolicyId: undefined }, true); | ||
} | ||
}, [error, id, packagePolicyId, updateUrlParams]); | ||
|
||
if (!error) return null; | ||
return error.body?.statusCode === 404; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
x-pack/plugins/synthetics/server/routes/monitor_cruds/delete_integration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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 { schema } from '@kbn/config-schema'; | ||
import { SyntheticsRestApiRouteFactory } from '../../legacy_uptime/routes/types'; | ||
import { SYNTHETICS_API_URLS } from '../../../common/constants'; | ||
|
||
export const deletePackagePolicyRoute: SyntheticsRestApiRouteFactory = () => ({ | ||
method: 'DELETE', | ||
path: SYNTHETICS_API_URLS.DELETE_PACKAGE_POLICY, | ||
validate: { | ||
params: schema.object({ | ||
packagePolicyId: schema.string({ minLength: 1, maxLength: 1024 }), | ||
}), | ||
}, | ||
handler: async ({ request, savedObjectsClient, server, uptimeEsClient }): Promise<any> => { | ||
const { packagePolicyId } = request.params; | ||
|
||
const response = await server.fleet.packagePolicyService.delete( | ||
savedObjectsClient, | ||
uptimeEsClient.baseESClient, | ||
[packagePolicyId], | ||
{ | ||
force: true, | ||
} | ||
); | ||
if (response?.[0].success) { | ||
return response; | ||
} else { | ||
throw new Error(response?.[0].body?.message); | ||
} | ||
}, | ||
}); |
Oops, something went wrong.