66import React from "react"
77import { useRouteContext } from "@tanstack/react-router"
88import { useMutation } from "@tanstack/react-query"
9- import { Button , Stack } from "@cloudoperators/juno-ui-components"
9+ import { Button } from "@cloudoperators/juno-ui-components"
10+ import { useActions } from "@cloudoperators/juno-messages-provider"
1011import { annotateResource } from "../api/annotateResource"
1112import { RouteContext } from "../../../routes/__root"
12- import { ErrorMessage } from "./ErrorBoundary/ErrorMessage"
1313
1414interface ReconcileButtonProps {
1515 resourceType : string
@@ -27,6 +27,7 @@ export const ReconcileButton: React.FC<ReconcileButtonProps> = ({
2727 onError,
2828} ) => {
2929 const { apiClient } = useRouteContext ( { strict : false } ) as RouteContext
30+ const { addMessage } = useActions ( )
3031
3132 const annotateMutation = useMutation ( {
3233 mutationFn : ( ) =>
@@ -42,7 +43,11 @@ export const ReconcileButton: React.FC<ReconcileButtonProps> = ({
4243 onSuccess : ( ) => {
4344 onReconcile ?.( )
4445 } ,
45- onError : ( error : Error ) => {
46+ onError : ( error ) => {
47+ addMessage ( {
48+ variant : "error" ,
49+ text : `Failed to reconcile ${ resourceType } "${ resourceName } ": ${ error . message } ` ,
50+ } )
4651 onError ?.( error )
4752 } ,
4853 } )
@@ -52,16 +57,13 @@ export const ReconcileButton: React.FC<ReconcileButtonProps> = ({
5257 }
5358
5459 return (
55- < Stack direction = "vertical" gap = "2" alignment = "end" >
56- < Button
57- variant = "subdued"
58- size = "small"
59- label = { annotateMutation . isPending ? "Reconciling" : "Reconcile" }
60- onClick = { handleReconcile }
61- progress = { annotateMutation . isPending }
62- disabled = { annotateMutation . isPending }
63- />
64- { annotateMutation . error && < ErrorMessage error = { annotateMutation . error } /> }
65- </ Stack >
60+ < Button
61+ variant = "subdued"
62+ size = "small"
63+ label = { annotateMutation . isPending ? "Reconciling" : "Reconcile" }
64+ onClick = { handleReconcile }
65+ progress = { annotateMutation . isPending }
66+ disabled = { annotateMutation . isPending }
67+ />
6668 )
6769}
0 commit comments