@@ -3,17 +3,22 @@ import Popover from "@material-ui/core/Popover"
3
3
import { makeStyles } from "@material-ui/core/styles"
4
4
import { CloseDropdown , OpenDropdown } from "components/DropdownArrows/DropdownArrows"
5
5
import { DropdownContent } from "components/DropdownButton/DropdownContent/DropdownContent"
6
- import { FC , ReactNode , useRef , useState , useEffect } from "react"
6
+ import { FC , ReactNode , useEffect , useRef , useState } from "react"
7
7
import { CancelButton } from "./ActionCtas"
8
8
9
9
export interface DropdownButtonProps {
10
10
primaryAction : ReactNode
11
- secondaryActions : Array < { action : string , button : ReactNode } >
11
+ secondaryActions : Array < { action : string ; button : ReactNode } >
12
12
canCancel : boolean
13
13
handleCancel ?: ( ) => void
14
14
}
15
15
16
- export const DropdownButton : FC < DropdownButtonProps > = ( { primaryAction, secondaryActions, canCancel, handleCancel } ) => {
16
+ export const DropdownButton : FC < DropdownButtonProps > = ( {
17
+ primaryAction,
18
+ secondaryActions,
19
+ canCancel,
20
+ handleCancel,
21
+ } ) => {
17
22
const styles = useStyles ( )
18
23
const anchorRef = useRef < HTMLButtonElement > ( null )
19
24
const [ isOpen , setIsOpen ] = useState ( false )
@@ -31,48 +36,48 @@ export const DropdownButton: FC<DropdownButtonProps> = ({ primaryAction, seconda
31
36
32
37
return (
33
38
< span className = { styles . buttonContainer } >
34
- { /* primary workspace CTA */ }
35
- < span data-testid = "primary-cta" className = { styles . primaryCta } >
36
- { primaryAction }
37
- </ span >
38
- { canCancel && handleCancel ? (
39
- < CancelButton handleAction = { handleCancel } />
40
- ) : (
41
- < >
42
- { /* popover toggle button */ }
43
- < Button
44
- data-testid = "workspace-actions-button"
45
- aria-controls = "workspace-actions-menu"
46
- aria-haspopup = "true"
47
- className = { styles . dropdownButton }
48
- ref = { anchorRef }
49
- disabled = { ! secondaryActions . length }
50
- onClick = { ( ) => {
51
- setIsOpen ( true )
52
- } }
53
- >
54
- { isOpen ? < CloseDropdown /> : < OpenDropdown /> }
55
- </ Button >
56
- < Popover
57
- classes = { { paper : styles . popoverPaper } }
58
- id = { id }
59
- open = { isOpen }
60
- anchorEl = { anchorRef . current }
61
- onClose = { ( ) => setIsOpen ( false ) }
62
- anchorOrigin = { {
63
- vertical : "bottom" ,
64
- horizontal : "right" ,
65
- } }
66
- transformOrigin = { {
67
- vertical : "top" ,
68
- horizontal : "right" ,
69
- } }
70
- >
71
- { /* secondary workspace CTAs */ }
72
- < DropdownContent secondaryActions = { secondaryActions } />
73
- </ Popover >
74
- </ >
75
- ) }
39
+ { /* primary workspace CTA */ }
40
+ < span data-testid = "primary-cta" className = { styles . primaryCta } >
41
+ { primaryAction }
42
+ </ span >
43
+ { canCancel && handleCancel ? (
44
+ < CancelButton handleAction = { handleCancel } />
45
+ ) : (
46
+ < >
47
+ { /* popover toggle button */ }
48
+ < Button
49
+ data-testid = "workspace-actions-button"
50
+ aria-controls = "workspace-actions-menu"
51
+ aria-haspopup = "true"
52
+ className = { styles . dropdownButton }
53
+ ref = { anchorRef }
54
+ disabled = { ! secondaryActions . length }
55
+ onClick = { ( ) => {
56
+ setIsOpen ( true )
57
+ } }
58
+ >
59
+ { isOpen ? < CloseDropdown /> : < OpenDropdown /> }
60
+ </ Button >
61
+ < Popover
62
+ classes = { { paper : styles . popoverPaper } }
63
+ id = { id }
64
+ open = { isOpen }
65
+ anchorEl = { anchorRef . current }
66
+ onClose = { ( ) => setIsOpen ( false ) }
67
+ anchorOrigin = { {
68
+ vertical : "bottom" ,
69
+ horizontal : "right" ,
70
+ } }
71
+ transformOrigin = { {
72
+ vertical : "top" ,
73
+ horizontal : "right" ,
74
+ } }
75
+ >
76
+ { /* secondary workspace CTAs */ }
77
+ < DropdownContent secondaryActions = { secondaryActions } />
78
+ </ Popover >
79
+ </ >
80
+ ) }
76
81
</ span >
77
82
)
78
83
}
0 commit comments