Skip to content

Commit 4eb4448

Browse files
Fix bugs
1 parent 47b9dad commit 4eb4448

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/components/ButtonWithConfirmDialog/ButtonWithConfirmDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export function ButtonWithConfirmDialog<T, K>({
7575
);
7676
};
7777

78+
// keep <span>: if button is disabled, popover won't open without this wrapper
7879
const renderContent = () => {
7980
if (withPopover) {
8081
return (

src/containers/Tablets/TabletsTable.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import {useIsUserAllowedToMakeChanges} from '../../utils/hooks/useIsUserAllowedT
2525

2626
import i18n from './i18n';
2727

28+
function isFollowerTablet(state: TTabletStateInfo) {
29+
return state.Leader === false;
30+
}
31+
2832
function getColumns({nodeId}: {nodeId?: string | number}) {
2933
const columns: DataTableColumn<TTabletStateInfo & {fqdn?: string}>[] = [
3034
{
@@ -34,7 +38,7 @@ function getColumns({nodeId}: {nodeId?: string | number}) {
3438
return i18n('Type');
3539
},
3640
render: ({row}) => {
37-
const isFollower = row.Leader === false;
41+
const isFollower = isFollowerTablet(row);
3842
return (
3943
<span>
4044
{row.Type} {isFollower ? <Text color="secondary">follower</Text> : ''}
@@ -138,7 +142,7 @@ function getColumns({nodeId}: {nodeId?: string | number}) {
138142
}
139143

140144
function TabletActions(tablet: TTabletStateInfo) {
141-
const isFollower = tablet.Leader === false;
145+
const isFollower = isFollowerTablet(tablet);
142146
const isDisabledRestart = tablet.State === ETabletState.Stopped || isFollower;
143147
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
144148
const [killTablet] = tabletApi.useKillTabletMutation();
@@ -148,6 +152,16 @@ function TabletActions(tablet: TTabletStateInfo) {
148152
return null;
149153
}
150154

155+
let popoverContent: React.ReactNode;
156+
157+
if (isFollower) {
158+
popoverContent = i18n('controls.kill-impossible-follower');
159+
} else if (!isUserAllowedToMakeChanges) {
160+
popoverContent = i18n('controls.kill-not-allowed');
161+
} else {
162+
popoverContent = i18n('dialog.kill-header');
163+
}
164+
151165
return (
152166
<ButtonWithConfirmDialog
153167
buttonView="outlined"
@@ -158,13 +172,7 @@ function TabletActions(tablet: TTabletStateInfo) {
158172
}}
159173
buttonDisabled={isDisabledRestart || !isUserAllowedToMakeChanges}
160174
withPopover
161-
popoverContent={
162-
isFollower
163-
? i18n('controls.kill-impossible-follower')
164-
: isUserAllowedToMakeChanges
165-
? i18n('dialog.kill-header')
166-
: i18n('controls.kill-not-allowed')
167-
}
175+
popoverContent={popoverContent}
168176
popoverPlacement={['right', 'bottom']}
169177
popoverDisabled={false}
170178
>

0 commit comments

Comments
 (0)