@@ -2,15 +2,13 @@ import React from "react"
22import Flex from "src/components/templates/flex"
33import { Button } from "src/components/button"
44import { Text } from "src/components/typography"
5- import useToggle from "react-use/lib/useToggle"
65import { Actions , Body , CloseButton , Content , Dialog , Header , Title , TitleIcon } from "./styled"
76
87const BodyMessage = ( { children, ...rest } ) =>
98 typeof children === "object" ? children : < Text { ...rest } > { children } </ Text >
109
1110const ConfirmationDialog = ( {
1211 confirmLabel = "Yes, remove" ,
13- confirmLoadingLabel = "Loading..." ,
1412 confirmWidth = "128px" ,
1513 "data-ga" : dataGA = "confirmation-dialog" ,
1614 "data-testid" : dataTestId = "confirmationDialog" ,
@@ -21,19 +19,12 @@ const ConfirmationDialog = ({
2119 hideIcon,
2220 iconName = "warning_triangle_hollow" ,
2321 isConfirmDisabled,
22+ isConfirmLoading,
23+ isDeclineDisabled,
2424 isConfirmPositive,
2525 message,
2626 title,
27- showConfirmLoading,
28- disableConfirmOnLoading,
2927} ) => {
30- const [ loading , toggleLoading ] = useToggle ( false )
31-
32- const onConfirm = e => {
33- if ( showConfirmLoading ) toggleLoading ( )
34- handleConfirm ( e , toggleLoading )
35- }
36-
3728 return (
3829 < Dialog onEsc = { handleDecline } >
3930 < Content data-testid = { dataTestId } >
@@ -55,6 +46,7 @@ const ConfirmationDialog = ({
5546 data-ga = { `${ dataGA } -::click-cancel::global-view` }
5647 data-testid = { `${ dataTestId } -cancelAction` }
5748 flavour = "hollow"
49+ disabled = { isDeclineDisabled }
5850 label = { declineLabel }
5951 onClick = { handleDecline }
6052 width = { declineWidth }
@@ -64,11 +56,11 @@ const ConfirmationDialog = ({
6456 data-ga = { `${ dataGA } -::click-confirm::global-view` }
6557 data-testid = { `${ dataTestId } -confirmAction` }
6658 danger = { ! isConfirmPositive && true }
67- disabled = { isConfirmDisabled || ( disableConfirmOnLoading && loading ) }
68- label = { loading ? confirmLoadingLabel : confirmLabel }
69- onClick = { onConfirm }
59+ disabled = { isConfirmDisabled }
60+ label = { confirmLabel }
61+ onClick = { handleConfirm }
7062 width = { confirmWidth }
71- isLoading = { loading }
63+ isLoading = { isConfirmLoading }
7264 />
7365 </ Actions >
7466 </ Content >
0 commit comments