Skip to content

Commit

Permalink
feat: implement backup-while-running preference
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Song <theevansong@gmail.com>
  • Loading branch information
ferothefox committed Oct 29, 2024
1 parent 4f4b1c7 commit 2e7432f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
20 changes: 19 additions & 1 deletion apps/frontend/src/pages/servers/manage/[id]/backups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,16 @@
</div>
<div class="flex w-full gap-2 sm:w-fit">
<ButtonStyled type="standard" color="brand">
<button class="w-full sm:w-fit" @click="showCreateModel">
<button
v-tooltip="
isServerRunning && !userPreferences.backupWhileRunning
? 'Cannot create backup while server is running. You can disable this from your server Options > Preferences.'
: ''
"
class="w-full sm:w-fit"
:disabled="isServerRunning && !userPreferences.backupWhileRunning"
@click="showCreateModel"
>
<PlusIcon class="h-5 w-5" />
Create backup
</button>
Expand Down Expand Up @@ -221,6 +230,7 @@

<script setup lang="ts">
import { ButtonStyled, OverflowMenu, NewModal } from "@modrinth/ui";
import { useStorage } from "@vueuse/core";
import {
PlusIcon,
CheckIcon,
Expand All @@ -239,8 +249,16 @@ import type { Server } from "~/composables/pyroServers";
const props = defineProps<{
server: Server<["general", "mods", "backups", "network", "startup", "ws", "fs"]>;
isServerRunning: boolean;
}>();
const route = useNativeRoute();
const serverId = route.params.id;
const userPreferences = useStorage(`pyro-server-${serverId}-preferences`, {
backupWhileRunning: false,
});
defineEmits(["onDownload"]);
const data = computed(() => props.server.general);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const preferences = {
description:
"Don't ask for confirmation when starting, stopping, restarting, or killing the server.",
},
backupWhileRunning: {
displayName: "Create backups while running",
description: "Allow backups to be created while the server is online.",
},
} as const;
type PreferenceKeys = keyof typeof preferences;
Expand All @@ -65,6 +69,7 @@ const defaultPreferences: UserPreferences = {
ramAsNumber: false,
autoRestart: false,
dontAskAgain: false,
backupWhileRunning: false,
};
const userPreferences = useStorage<UserPreferences>(
Expand Down

0 comments on commit 2e7432f

Please sign in to comment.