@@ -2,6 +2,9 @@ import {useCallback, useEffect} from 'react';
22import { StringParam , useQueryParams } from 'use-query-params' ;
33import { Helmet } from 'react-helmet-async' ;
44
5+ import { Icon } from '@gravity-ui/uikit' ;
6+ import ArrowRotateLeftIcon from '@gravity-ui/icons/svgs/arrow-rotate-left.svg' ;
7+
58import {
69 getPDiskData ,
710 getPDiskStorage ,
@@ -17,6 +20,7 @@ import {PageMeta} from '../../components/PageMeta/PageMeta';
1720import { StatusIcon } from '../../components/StatusIcon/StatusIcon' ;
1821import { PDiskInfo } from '../../components/PDiskInfo/PDiskInfo' ;
1922import { InfoViewerSkeleton } from '../../components/InfoViewerSkeleton/InfoViewerSkeleton' ;
23+ import { ButtonWithConfirmDialog } from '../../components/ButtonWithConfirmDialog/ButtonWithConfirmDialog' ;
2024
2125import { PDiskGroups } from './PDiskGroups' ;
2226import { pdiskPageCn } from './shared' ;
@@ -46,20 +50,37 @@ export function PDisk() {
4650 } , [ dispatch ] ) ;
4751
4852 const fetchData = useCallback (
49- ( isBackground : boolean ) => {
53+ async ( isBackground ? : boolean ) => {
5054 if ( ! isBackground ) {
5155 dispatch ( setPDiskDataWasNotLoaded ( ) ) ;
5256 }
57+
5358 if ( nodeId && pDiskId ) {
54- dispatch ( getPDiskData ( { nodeId, pDiskId} ) ) ;
55- dispatch ( getPDiskStorage ( { nodeId, pDiskId} ) ) ;
59+ return Promise . all ( [
60+ dispatch ( getPDiskData ( { nodeId, pDiskId} ) ) ,
61+ dispatch ( getPDiskStorage ( { nodeId, pDiskId} ) ) ,
62+ ] ) ;
5663 }
64+
65+ return undefined ;
5766 } ,
5867 [ dispatch , nodeId , pDiskId ] ,
5968 ) ;
6069
6170 useAutofetcher ( fetchData , [ fetchData ] , true ) ;
6271
72+ const handleRestart = async ( ) => {
73+ if ( nodeId && pDiskId ) {
74+ return window . api . restartPDisk ( nodeId , pDiskId ) ;
75+ }
76+
77+ return undefined ;
78+ } ;
79+
80+ const handleAfterRestart = async ( ) => {
81+ return fetchData ( true ) ;
82+ } ;
83+
6384 const renderHelmet = ( ) => {
6485 const pDiskPagePart = pDiskId
6586 ? `${ pDiskPageKeyset ( 'pdisk' ) } ${ pDiskId } `
@@ -97,6 +118,23 @@ export function PDisk() {
97118 ) ;
98119 } ;
99120
121+ const renderControls = ( ) => {
122+ return (
123+ < div className = { pdiskPageCn ( 'controls' ) } >
124+ < ButtonWithConfirmDialog
125+ onConfirmAction = { handleRestart }
126+ onConfirmActionSuccess = { handleAfterRestart }
127+ buttonDisabled = { ! nodeId || ! pDiskId }
128+ buttonView = "normal"
129+ dialogContent = { pDiskPageKeyset ( 'restart-pdisk-dialog' ) }
130+ >
131+ < Icon data = { ArrowRotateLeftIcon } />
132+ { pDiskPageKeyset ( 'restart-pdisk-button' ) }
133+ </ ButtonWithConfirmDialog >
134+ </ div >
135+ ) ;
136+ } ;
137+
100138 const renderInfo = ( ) => {
101139 if ( pDiskLoading && ! pDiskWasLoaded ) {
102140 return < InfoViewerSkeleton className = { pdiskPageCn ( 'info' ) } rows = { 10 } /> ;
@@ -126,6 +164,7 @@ export function PDisk() {
126164 { renderHelmet ( ) }
127165 { renderPageMeta ( ) }
128166 { renderPageTitle ( ) }
167+ { renderControls ( ) }
129168 { renderInfo ( ) }
130169 { renderGroupsTable ( ) }
131170 </ div >
0 commit comments