@@ -3,6 +3,7 @@ import React from 'react';
33import { ButtonWithConfirmDialog } from '../../../components/ButtonWithConfirmDialog/ButtonWithConfirmDialog' ;
44import { ETabletState } from '../../../types/api/tablet' ;
55import type { TTabletStateInfo } from '../../../types/api/tablet' ;
6+ import { useTypedSelector } from '../../../utils/hooks' ;
67import { b } from '../Tablet' ;
78import i18n from '../i18n' ;
89
@@ -14,6 +15,8 @@ interface TabletControlsProps {
1415export const TabletControls = ( { tablet, fetchData} : TabletControlsProps ) => {
1516 const { TabletId, HiveId} = tablet ;
1617
18+ const { isUserAllowedToMakeChanges} = useTypedSelector ( ( state ) => state . authentication ) ;
19+
1720 const _onKillClick = ( ) => {
1821 return window . api . killTablet ( TabletId ) ;
1922 } ;
@@ -43,7 +46,11 @@ export const TabletControls = ({tablet, fetchData}: TabletControlsProps) => {
4346 onConfirmAction = { _onKillClick }
4447 onConfirmActionSuccess = { fetchData }
4548 buttonClassName = { b ( 'control' ) }
46- buttonDisabled = { isDisabledRestart }
49+ buttonDisabled = { isDisabledRestart || ! isUserAllowedToMakeChanges }
50+ withPopover
51+ popoverContent = { i18n ( 'controls.kill-not-allowed' ) }
52+ popoverPlacement = { 'bottom' }
53+ popoverDisabled = { isUserAllowedToMakeChanges }
4754 >
4855 { i18n ( 'controls.kill' ) }
4956 </ ButtonWithConfirmDialog >
@@ -54,7 +61,11 @@ export const TabletControls = ({tablet, fetchData}: TabletControlsProps) => {
5461 onConfirmAction = { _onStopClick }
5562 onConfirmActionSuccess = { fetchData }
5663 buttonClassName = { b ( 'control' ) }
57- buttonDisabled = { isDisabledStop }
64+ buttonDisabled = { isDisabledStop || ! isUserAllowedToMakeChanges }
65+ withPopover
66+ popoverContent = { i18n ( 'controls.stop-not-allowed' ) }
67+ popoverPlacement = { 'bottom' }
68+ popoverDisabled = { isUserAllowedToMakeChanges }
5869 >
5970 { i18n ( 'controls.stop' ) }
6071 </ ButtonWithConfirmDialog >
@@ -63,7 +74,11 @@ export const TabletControls = ({tablet, fetchData}: TabletControlsProps) => {
6374 onConfirmAction = { _onResumeClick }
6475 onConfirmActionSuccess = { fetchData }
6576 buttonClassName = { b ( 'control' ) }
66- buttonDisabled = { isDisabledResume }
77+ buttonDisabled = { isDisabledResume || ! isUserAllowedToMakeChanges }
78+ withPopover
79+ popoverContent = { i18n ( 'controls.resume-not-allowed' ) }
80+ popoverPlacement = { 'bottom' }
81+ popoverDisabled = { isUserAllowedToMakeChanges }
6782 >
6883 { i18n ( 'controls.resume' ) }
6984 </ ButtonWithConfirmDialog >
0 commit comments