Skip to content

Commit baf1442

Browse files
authored
Confirmation dialog - Disable decline button on confirmation loading state (#454)
* Revert "Loading state on confirmation dialog (#452)" This reverts commit abfc11d. * Add props to confirmation dialog * v2.14.1
1 parent cc17aee commit baf1442

File tree

4 files changed

+8
-50
lines changed

4 files changed

+8
-50
lines changed

README.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,6 @@ export const MyComponent: FC<PropsT> = (props: PropsT) => <>...</>
2020

2121
You can find latest **master** storybook playground [here](https://netdata.github.io/netdata-ui/)
2222

23-
## Local development
24-
25-
First, install the dependencies
26-
```
27-
yarn
28-
```
29-
30-
then, build the project and start
31-
```
32-
yarn build && yarn start
33-
```
34-
35-
Open your browser to [localhost:6006](http://localhost:6006) and view the storybook locally.
36-
37-
3823
## Components
3924

4025
- [Theme and theme utils](https://github.com/netdata/netdata-ui/blob/master/src/theme)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netdata/netdata-ui",
3-
"version": "2.14.0",
3+
"version": "2.14.1",
44
"description": "netdata UI kit",
55
"main": "./lib/index.js",
66
"files": [

src/components/confirmation-dialog/confirmation-dialog.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import React from "react"
22
import Flex from "src/components/templates/flex"
33
import { Button } from "src/components/button"
44
import { Text } from "src/components/typography"
5-
import useToggle from "react-use/lib/useToggle"
65
import { Actions, Body, CloseButton, Content, Dialog, Header, Title, TitleIcon } from "./styled"
76

87
const BodyMessage = ({ children, ...rest }) =>
98
typeof children === "object" ? children : <Text {...rest}>{children}</Text>
109

1110
const 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>

src/components/confirmation-dialog/confirmation-dialog.stories.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,3 @@ Story.add("Confirmation dialog", () => {
1919
/>
2020
)
2121
})
22-
23-
Story.add("Confirmation dialog with loading", () => {
24-
return (
25-
<ConfirmationDialog
26-
confirmLabel="Yes"
27-
declineLabel="Please don't!"
28-
handleConfirm={(_, toggleLoading) => {
29-
console.log("Pressed confirm")
30-
setTimeout(() => toggleLoading(), 2000)
31-
}}
32-
handleDecline={() => alert("Pressed decline")}
33-
isConfirmPositive={boolean("isConfirmPositive", false)}
34-
message="We are about to fulfill your request, there is no return from here. Are you sure?"
35-
title="Are you sure you want to proceed?"
36-
showConfirmLoading={boolean("showConfirmLoading", true)}
37-
disableConfirmOnLoading={boolean("disableConfirmOnLoading", true)}
38-
/>
39-
)
40-
})

0 commit comments

Comments
 (0)