mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 08:13:12 +09:00
Respect disabled on the main dropdown button action
A plugin action can be disabled, and it becomes the main button when the user has no restart permission. Only the main button is disabled so the menu stays usable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
86befd1231
commit
bd912a8fd4
1 file changed
+5
-3
@@ -15,19 +15,20 @@ export default function VariableDropdownButton(props: VariableDropdownButtonProp
|
|||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mainDisabled = props.disabled || mainAction.disabled;
|
||||||
const buttonProps: DropdownButtonProps = {
|
const buttonProps: DropdownButtonProps = {
|
||||||
...props,
|
...props,
|
||||||
danger: mainAction.danger,
|
danger: mainAction.danger,
|
||||||
onClick: (event) => {
|
onClick: (event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
if (mainAction.onClick) {
|
if (!mainDisabled && mainAction.onClick) {
|
||||||
mainAction.onClick();
|
mainAction.onClick();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return menuActions.length === 0
|
return menuActions.length === 0
|
||||||
? <Button {...buttonProps}>
|
? <Button {...buttonProps} disabled={mainDisabled}>
|
||||||
{mainAction.label}
|
{mainAction.label}
|
||||||
</Button>
|
</Button>
|
||||||
: <Dropdown.Button
|
: <Dropdown.Button
|
||||||
@@ -35,7 +36,8 @@ export default function VariableDropdownButton(props: VariableDropdownButtonProp
|
|||||||
// stopPropagation is needed to prevent propagation to table rows
|
// stopPropagation is needed to prevent propagation to table rows
|
||||||
menu={{ items: menuActions, onClick: (e: any) => e.domEvent.stopPropagation() }}
|
menu={{ items: menuActions, onClick: (e: any) => e.domEvent.stopPropagation() }}
|
||||||
buttonsRender={([left, right]) => [
|
buttonsRender={([left, right]) => [
|
||||||
left, React.cloneElement(right as any, { onClick: (e: any) => e.stopPropagation() }),
|
React.cloneElement(left as any, { disabled: mainDisabled }),
|
||||||
|
React.cloneElement(right as any, { onClick: (e: any) => e.stopPropagation() }),
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{mainAction.label}
|
{mainAction.label}
|
||||||
|
|||||||
Reference in new issue
Block a user