Skip to content

Commit 9426ae9

Browse files
committed
chore(frontend): delay enabling action buttons after server startup
Signed-off-by: Evan Song <theevansong@gmail.com>
1 parent 7bd9510 commit 9426ae9

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

apps/frontend/src/components/ui/servers/PanelServerActionButton.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<template>
22
<div class="flex flex-row items-center gap-2 rounded-lg">
33
<ButtonStyled v-if="showStopButton" type="standard" color="red">
4-
<button :disabled="!canTakeAction" @click="killServer">
4+
<button :disabled="!canTakeAction || isStartingDelay" @click="killServer">
55
<div class="flex gap-1">
66
<SlashIcon class="h-5 w-5" />
77
<span>{{ killButtonText }}</span>
88
</div>
99
</button>
1010
</ButtonStyled>
1111
<ButtonStyled v-if="showStopButton" type="standard" color="red">
12-
<button :disabled="!canTakeAction" @click="stopServer">
12+
<button :disabled="!canTakeAction || isStartingDelay" @click="stopServer">
1313
<div class="flex gap-1">
1414
<StopCircleIcon class="h-5 w-5" />
1515
<span>{{ stopButtonText }}</span>
@@ -18,7 +18,7 @@
1818
</ButtonStyled>
1919

2020
<ButtonStyled type="standard" color="brand">
21-
<button :disabled="!canTakeAction" @click="handleAction">
21+
<button :disabled="!canTakeAction || isStartingDelay" @click="handleAction">
2222
<div v-if="isStartingOrRestarting" class="grid place-content-center">
2323
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
2424
<path
@@ -106,9 +106,11 @@ const stopButtonText = computed(() => {
106106
});
107107
108108
const killButtonText = computed(() => {
109-
return currentState.value === ServerState.Stopping ? "Stopping..." : "Kill";
109+
return "Kill";
110110
});
111111
112+
const isStartingDelay = ref(false);
113+
112114
const updateState = (newState: ServerStateType) => {
113115
currentState.value = newState;
114116
};
@@ -122,6 +124,10 @@ const handleAction = () => {
122124
} else {
123125
updateState(ServerState.Starting);
124126
emit("action", "start");
127+
isStartingDelay.value = true;
128+
setTimeout(() => {
129+
isStartingDelay.value = false;
130+
}, 5000);
125131
}
126132
};
127133
@@ -135,7 +141,6 @@ const stopServer = () => {
135141
const killServer = () => {
136142
if (!canTakeAction.value) return;
137143
138-
updateState(ServerState.Stopping);
139144
emit("action", "kill");
140145
};
141146

0 commit comments

Comments
 (0)