18
18
*/
19
19
20
20
import cockpit from "cockpit" ;
21
- import React , { useState } from "react" ;
21
+ import React from "react" ;
22
22
23
23
import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.js" ;
24
24
import { DescriptionList } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js" ;
25
- import { Dropdown , DropdownItem , MenuToggle } from "@patternfly/react-core" ;
26
- import { EllipsisVIcon , ExclamationCircleIcon , ExclamationTriangleIcon } from "@patternfly/react-icons" ;
25
+ import { DropdownList } from "@patternfly/react-core" ;
26
+ import { ExclamationCircleIcon , ExclamationTriangleIcon } from "@patternfly/react-icons" ;
27
27
import { Flex } from "@patternfly/react-core/dist/esm/layouts/Flex/index.js" ;
28
28
import { Icon } from "@patternfly/react-core/dist/esm/components/Icon/index.js" ;
29
29
30
30
import { format_temperature } from "../utils.js" ;
31
- import { superuser } from "superuser.js" ;
32
31
import { StorageCard , StorageDescription } from "../pages.jsx" ;
33
- import { useEvent } from "hooks.js " ;
32
+ import { StorageBarMenu , StorageMenuItem } from "../storage-controls.jsx " ;
34
33
35
34
const _ = cockpit . gettext ;
36
35
@@ -71,7 +70,6 @@ const nvmeCriticalWarning = {
71
70
} ;
72
71
73
72
const SmartActions = ( { smart_info } ) => {
74
- const [ isKebabOpen , setKebabOpen ] = useState ( false ) ;
75
73
const smartSelftestStatus = smart_info . SmartSelftestStatus ;
76
74
77
75
const runSelfTest = ( type ) => {
@@ -82,31 +80,30 @@ const SmartActions = ({ smart_info }) => {
82
80
smart_info . SmartSelftestAbort ( { } ) ;
83
81
} ;
84
82
85
- const testDisabled = ! superuser . allowed || smartSelftestStatus === "inprogress" ;
83
+ const testDisabled = smartSelftestStatus === "inprogress" ;
86
84
87
- return (
88
- < Dropdown
89
- toggle = { toggleRef => < MenuToggle ref = { toggleRef } icon = { < EllipsisVIcon /> } variant = "plain" aria-label = { _ ( "SMART actions" ) } onClick = { ( ) => setKebabOpen ( ! isKebabOpen ) } isExpanded = { isKebabOpen } /> }
90
- isPlain
91
- isOpen = { isKebabOpen }
92
- id = "smart-actions"
93
- >
94
- < DropdownItem key = "smart-short-test"
95
- isDisabled = { testDisabled }
96
- onClick = { ( ) => { setKebabOpen ( false ) ; runSelfTest ( 'short' ) } } >
85
+ const actionItems = (
86
+ < DropdownList >
87
+ < StorageMenuItem isDisabled = { testDisabled }
88
+ onClick = { ( ) => { runSelfTest ( 'short' ) } }
89
+ >
97
90
{ _ ( "Run short test" ) }
98
- </ DropdownItem > ,
99
- < DropdownItem key = "smart-extended-test"
100
- isDisabled = { testDisabled }
101
- onClick = { ( ) => { setKebabOpen ( false ) ; runSelfTest ( 'extended' ) } } >
91
+ </ StorageMenuItem >
92
+ < StorageMenuItem isDisabled = { testDisabled }
93
+ onClick = { ( ) => { runSelfTest ( 'extended' ) } }
94
+ >
102
95
{ _ ( "Run extended test" ) }
103
- </ DropdownItem > ,
104
- < DropdownItem key = "abort-smart-test"
105
- isDisabled = { testDisabled }
106
- onClick = { ( ) => { setKebabOpen ( false ) ; abortSelfTest ( ) } } >
96
+ </ StorageMenuItem >
97
+ < StorageMenuItem isDisabled = { ! testDisabled }
98
+ onClick = { ( ) => { abortSelfTest ( ) } }
99
+ >
107
100
{ _ ( "Abort test" ) }
108
- </ DropdownItem > ,
109
- </ Dropdown >
101
+ </ StorageMenuItem >
102
+ </ DropdownList >
103
+ ) ;
104
+
105
+ return (
106
+ < StorageBarMenu isKebab label = { _ ( "Actions" ) } menuItems = { actionItems } />
110
107
) ;
111
108
} ;
112
109
@@ -116,8 +113,6 @@ export const isSmartOK = (drive_type, smart_info) => {
116
113
} ;
117
114
118
115
export const SmartCard = ( { card, smart_info, drive_type } ) => {
119
- useEvent ( superuser , "changed" ) ;
120
-
121
116
const powerOnHours = ( drive_type === "ata" )
122
117
? Math . floor ( smart_info . SmartPowerOnSeconds / 3600 )
123
118
: smart_info . SmartPowerOnHours ;
0 commit comments