mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 07:43:12 +09:00
Add button to download ctl config (#743)
* Move saveJson to util file * Add button to download ctl config * Add icon and tooltip to describe what the button does --------- Co-authored-by: Danielv123 <danielv@danielv.no>
This commit is contained in:
1 parent
42cd099eea
commit
0e6d33aa82
3 files changed
+43
-17
No files matched your search
@@ -10,6 +10,7 @@ import { useAccount } from "../model/account";
|
||||
import ControlContext from "./ControlContext";
|
||||
import { notifyErrorHandler } from "../util/notify";
|
||||
import { formatDuration } from "../util/time_format";
|
||||
import { saveJson } from "../util/save_file";
|
||||
import PageHeader from "./PageHeader";
|
||||
import PageLayout from "./PageLayout";
|
||||
import PluginExtra from "./PluginExtra";
|
||||
@@ -58,22 +59,6 @@ function CreateUserButton() {
|
||||
</>;
|
||||
}
|
||||
|
||||
// This is the most common and best supported method
|
||||
// For full support we should consider using npm:file-saver
|
||||
function saveFile(name: string, blob: Blob) {
|
||||
const a = document.createElement("a");
|
||||
a.href = URL.createObjectURL(blob);
|
||||
a.download = name;
|
||||
a.addEventListener("click", (e) => {
|
||||
setTimeout(() => URL.revokeObjectURL(a.href), 30 * 1000);
|
||||
});
|
||||
a.click();
|
||||
};
|
||||
|
||||
function saveJson(name: string, json: object) {
|
||||
return saveFile(name, new Blob([JSON.stringify(json, null, 2)], { type: "application/json" }));
|
||||
}
|
||||
|
||||
type UserBulkActionProps = {
|
||||
setApplyAction(func: () => Promise<void>): void,
|
||||
form: FormInstance,
|
||||
|
||||
Reference in new issue
Block a user