-
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.
Showing
43 changed files
with
2,403 additions
and
70 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
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
46 changes: 46 additions & 0 deletions
46
x-pack/plugins/observability/public/hooks/slo/use_delete_slo.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,46 @@ | ||
/* | ||
* 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 { useCallback, useState } from 'react'; | ||
import { useKibana } from '../../utils/kibana_react'; | ||
|
||
interface UseDeleteSlo { | ||
loading: boolean; | ||
success: boolean; | ||
error: string | undefined; | ||
deleteSlo: (id: string) => void; | ||
} | ||
|
||
export function useDeleteSlo(): UseDeleteSlo { | ||
const { http } = useKibana().services; | ||
const [loading, setLoading] = useState(false); | ||
const [success, setSuccess] = useState(false); | ||
const [error, setError] = useState<string | undefined>(undefined); | ||
|
||
const deleteSlo = useCallback( | ||
async (id: string) => { | ||
setLoading(true); | ||
setError(''); | ||
setSuccess(false); | ||
|
||
try { | ||
await http.delete<string>(`/api/observability/slos/${id}`); | ||
setSuccess(true); | ||
} catch (e) { | ||
setError(e); | ||
} | ||
}, | ||
[http] | ||
); | ||
|
||
return { | ||
loading, | ||
error, | ||
success, | ||
deleteSlo, | ||
}; | ||
} |
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
Oops, something went wrong.