mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 16:23:12 +09:00
Fix popconfirm on instance kill button
This commit is contained in:
1 file changed
+35
-26
@@ -21,6 +21,7 @@ export default function InstanceControlButton(props: InstanceControlButtonProps)
|
|||||||
const account = useAccount();
|
const account = useAccount();
|
||||||
const control = useContext(ControlContext);
|
const control = useContext(ControlContext);
|
||||||
const [switching, setSwitching] = useState<boolean>(false);
|
const [switching, setSwitching] = useState<boolean>(false);
|
||||||
|
const [popconfirm, setPopconfirm] = useState<string | null>(null);
|
||||||
|
|
||||||
const instanceId = props.instance.id;
|
const instanceId = props.instance.id;
|
||||||
const instanceStatus = props.instance.status;
|
const instanceStatus = props.instance.status;
|
||||||
@@ -88,35 +89,43 @@ export default function InstanceControlButton(props: InstanceControlButtonProps)
|
|||||||
if (account.hasPermission("core.instance.kill")) {
|
if (account.hasPermission("core.instance.kill")) {
|
||||||
actions.push({
|
actions.push({
|
||||||
key: "kill",
|
key: "kill",
|
||||||
|
label: "Kill",
|
||||||
danger: true,
|
danger: true,
|
||||||
disabled: instanceStatus === "stopped",
|
disabled: instanceStatus === "stopped",
|
||||||
label: (<Popconfirm
|
onClick: () => setPopconfirm("kill"),
|
||||||
title={<>
|
|
||||||
Killing this instance may leave you save and player data corrupted.
|
|
||||||
Are you sure you want to kill the instance?
|
|
||||||
</>}
|
|
||||||
placement="bottomRight"
|
|
||||||
okText="Kill"
|
|
||||||
okButtonProps={{ danger: true }}
|
|
||||||
onConfirm={() => {
|
|
||||||
control.sendTo(
|
|
||||||
{ instanceId },
|
|
||||||
new lib.InstanceKillRequest(),
|
|
||||||
).catch(
|
|
||||||
notifyErrorHandler("Error killing instance")
|
|
||||||
).finally(actionFinish);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Kill
|
|
||||||
</Popconfirm>),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return <VariableDropdownButton
|
return <div style={{ position: "relative", display: "inline-block" }}>
|
||||||
{...props}
|
<VariableDropdownButton
|
||||||
type="primary"
|
{...props}
|
||||||
actions={actions}
|
type="primary"
|
||||||
loading={switching}
|
actions={actions}
|
||||||
disabled={!(showStart || showStop)}
|
loading={switching}
|
||||||
/>;
|
disabled={!(showStart || showStop)}
|
||||||
|
/>
|
||||||
|
<Popconfirm
|
||||||
|
title={<>
|
||||||
|
Killing this instance may leave you save and player data corrupted.
|
||||||
|
Are you sure you want to kill the instance?
|
||||||
|
</>}
|
||||||
|
open={popconfirm === "kill"}
|
||||||
|
placement="bottomRight"
|
||||||
|
okText="Kill"
|
||||||
|
okButtonProps={{ danger: true }}
|
||||||
|
onCancel={() => setPopconfirm(null)}
|
||||||
|
onConfirm={() => {
|
||||||
|
control.sendTo(
|
||||||
|
{ instanceId },
|
||||||
|
new lib.InstanceKillRequest(),
|
||||||
|
).catch(
|
||||||
|
notifyErrorHandler("Error killing instance")
|
||||||
|
).finally(actionFinish);
|
||||||
|
setPopconfirm(null);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/* Used to position the popup under the button */}
|
||||||
|
<span style={{ position: "absolute", right: 0, top: "100%", width: 1, height: 1 }} />
|
||||||
|
</Popconfirm>
|
||||||
|
</div>;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user