mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +09:00
Drop bulk copy from the selected saves actions
Copy on the same instance is rarely needed in bulk, and Transfer with Copy ticked covers copying to another instance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cd2933417a
commit
f338c5fd91
1 file changed
-25
@@ -139,16 +139,6 @@ function downloadSave(control: Control, instanceId: number, name: string) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function unusedSaveName(name: string, taken: Set<string>) {
|
|
||||||
const base = name.replace(/\.zip$/, "");
|
|
||||||
for (let i = 2; ; i++) {
|
|
||||||
const candidate = `${base}-${i}.zip`;
|
|
||||||
if (!taken.has(candidate)) {
|
|
||||||
return candidate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type TransferModalProps = {
|
type TransferModalProps = {
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
saves: lib.SaveDetails[];
|
saves: lib.SaveDetails[];
|
||||||
@@ -252,7 +242,6 @@ type BulkActionsProps = {
|
|||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
instanceId: number;
|
instanceId: number;
|
||||||
saves: lib.SaveDetails[];
|
saves: lib.SaveDetails[];
|
||||||
allNames: string[];
|
|
||||||
onDone: (failed: string[]) => void;
|
onDone: (failed: string[]) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -269,21 +258,9 @@ function BulkActions(props: BulkActionsProps) {
|
|||||||
.finally(() => setRunning(undefined));
|
.finally(() => setRunning(undefined));
|
||||||
}
|
}
|
||||||
|
|
||||||
function copy() {
|
|
||||||
const taken = new Set(props.allNames);
|
|
||||||
run("copy", save => {
|
|
||||||
const destination = unusedSaveName(save.name, taken);
|
|
||||||
taken.add(destination);
|
|
||||||
return control.send(new lib.InstanceCopySaveRequest(props.instanceId, save.name, destination));
|
|
||||||
}, "Error copying");
|
|
||||||
}
|
|
||||||
|
|
||||||
const disabled = props.disabled || running !== undefined;
|
const disabled = props.disabled || running !== undefined;
|
||||||
return <Space wrap>
|
return <Space wrap>
|
||||||
<Typography.Text type="secondary">{count} selected</Typography.Text>
|
<Typography.Text type="secondary">{count} selected</Typography.Text>
|
||||||
{account.hasPermission("core.instance.save.copy") && <Button
|
|
||||||
disabled={disabled} loading={running === "copy"} onClick={copy}
|
|
||||||
>Copy</Button>}
|
|
||||||
{account.hasPermission("core.instance.save.download") && <Button
|
{account.hasPermission("core.instance.save.download") && <Button
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
loading={running === "download"}
|
loading={running === "download"}
|
||||||
@@ -329,7 +306,6 @@ export default function SavesList(props: { instance: lib.InstanceDetails }) {
|
|||||||
const visibleSelected = visibleNames.filter(name => selectedNames.includes(name)).length;
|
const visibleSelected = visibleNames.filter(name => selectedNames.includes(name)).length;
|
||||||
const canTransfer = account.hasPermission("core.instance.save.transfer");
|
const canTransfer = account.hasPermission("core.instance.save.transfer");
|
||||||
const canSelect = account.hasAnyPermission(
|
const canSelect = account.hasAnyPermission(
|
||||||
"core.instance.save.copy",
|
|
||||||
"core.instance.save.download",
|
"core.instance.save.download",
|
||||||
"core.instance.save.transfer",
|
"core.instance.save.transfer",
|
||||||
"core.instance.save.delete",
|
"core.instance.save.delete",
|
||||||
@@ -465,7 +441,6 @@ export default function SavesList(props: { instance: lib.InstanceDetails }) {
|
|||||||
disabled={hostOffline}
|
disabled={hostOffline}
|
||||||
instanceId={props.instance.id!}
|
instanceId={props.instance.id!}
|
||||||
saves={selectedSaves}
|
saves={selectedSaves}
|
||||||
allNames={saveList.map(save => save.name)}
|
|
||||||
onDone={setSelectedNames}
|
onDone={setSelectedNames}
|
||||||
/>}
|
/>}
|
||||||
{account.hasPermission("core.instance.save.upload") && <Upload {...uploadProps} >
|
{account.hasPermission("core.instance.save.upload") && <Upload {...uploadProps} >
|
||||||
|
|||||||
Reference in new issue
Block a user