Skip to content

Commit

Permalink
Merge branch 'pyro' of github.com:/modrinth/code into pyro
Browse files Browse the repository at this point in the history
  • Loading branch information
not-nullptr committed Oct 17, 2024
2 parents f264a6b + e8d2452 commit 732027a
Show file tree
Hide file tree
Showing 11 changed files with 218 additions and 112 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<template>
<div class="flex flex-row items-center gap-2 rounded-lg">
<ButtonStyled v-if="showStopButton" type="standard" color="red">
<button :disabled="!canTakeAction" @click="killServer">
<button :disabled="!canTakeAction || isStartingDelay || disabled" @click="killServer">
<div class="flex gap-1">
<SlashIcon class="h-5 w-5" />
<span>{{ killButtonText }}</span>
</div>
</button>
</ButtonStyled>
<ButtonStyled v-if="showStopButton" type="standard" color="red">
<button :disabled="!canTakeAction" @click="stopServer">
<button :disabled="!canTakeAction || isStartingDelay || disabled" @click="stopServer">
<div class="flex gap-1">
<StopCircleIcon class="h-5 w-5" />
<span>{{ stopButtonText }}</span>
Expand All @@ -18,7 +18,7 @@
</ButtonStyled>

<ButtonStyled type="standard" color="brand">
<button :disabled="!canTakeAction" @click="handleAction">
<button :disabled="!canTakeAction || isStartingDelay || disabled" @click="handleAction">
<div v-if="isStartingOrRestarting" class="grid place-content-center">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path
Expand Down Expand Up @@ -49,6 +49,7 @@ import { ButtonStyled } from "@modrinth/ui";
const props = defineProps<{
isOnline: boolean;
isActioning: boolean;
disabled: any;
}>();
const emit = defineEmits<{
Expand Down Expand Up @@ -106,9 +107,11 @@ const stopButtonText = computed(() => {
});
const killButtonText = computed(() => {
return currentState.value === ServerState.Stopping ? "Stopping..." : "Kill";
return "Kill";
});
const isStartingDelay = ref(false);
const updateState = (newState: ServerStateType) => {
currentState.value = newState;
};
Expand All @@ -122,6 +125,10 @@ const handleAction = () => {
} else {
updateState(ServerState.Starting);
emit("action", "start");
isStartingDelay.value = true;
setTimeout(() => {
isStartingDelay.value = false;
}, 5000);
}
};
Expand All @@ -135,7 +142,6 @@ const stopServer = () => {
const killServer = () => {
if (!canTakeAction.value) return;
updateState(ServerState.Stopping);
emit("action", "kill");
};
Expand Down
4 changes: 1 addition & 3 deletions apps/frontend/src/components/ui/servers/ServerIcon.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<template>
<client-only>
<img v-if="image" no-shadow size="lg" alt="Server Icon" :class="computedClass" :src="image" />
<img v-if="image" alt="Server Icon" :class="computedClass" :src="image" />
<img
v-else
no-shadow
size="lg"
alt="Server Icon"
:class="computedClass"
src="~/assets/images/servers/minecraft_server_icon.png"
Expand Down
2 changes: 2 additions & 0 deletions apps/frontend/src/composables/pyroFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export async function usePyroFetch<T>(path: string, options: PyroFetchOptions =
401: "Unauthorized",
403: "Forbidden",
404: "Not Found",
405: "Method Not Allowed",
429: "Too Many Requests",
500: "Internal Server Error",
502: "Bad Gateway",
};
Expand Down
Loading

0 comments on commit 732027a

Please sign in to comment.