77 </button >
88 </ButtonStyled >
99
10- <template v-else >
11- <ButtonStyled v-if =" showStopButton" type =" standard" color =" red" size =" large" >
12- <button
13- v-tooltip =" busyTooltip"
14- :disabled =" !canTakeAction"
15- @click =" initiateAction('Stop')"
16- >
17- <div class =" flex gap-1" >
18- <StopCircleIcon class =" h-5 w-5" />
19- <span >Stop</span >
20- </div >
10+ <template v-else-if =" showRestartButton " >
11+ <ButtonStyled type =" standard" color =" orange" size =" large" >
12+ <button v-tooltip =" busyTooltip" :disabled =" !canTakeAction" @click =" handlePrimaryAction" >
13+ <UpdatedIcon />
14+ <span >{{ primaryActionText }}</span >
2115 </button >
2216 </ButtonStyled >
2317
24- <div v-if =" showRestartDropdown" class =" joined-buttons" >
25- <ButtonStyled type =" standard" color =" orange" size =" large" >
26- <button v-tooltip =" busyTooltip" :disabled =" !canTakeAction" @click =" handlePrimaryAction" >
27- <UpdatedIcon />
28- <span >{{ primaryActionText }}</span >
29- </button >
30- </ButtonStyled >
31- <ButtonStyled type =" standard" color =" orange" size =" large" >
32- <OverflowMenu
33- v-tooltip =" busyTooltip"
34- :disabled =" !canTakeAction"
35- :options =" [
36- {
37- id: 'kill_server',
38- action: () => initiateAction('Kill'),
39- },
40- ]"
41- >
42- <div class =" w-0 text-xl relative top-0.5 right-2.5" >
43- <DropdownIcon />
44- </div >
18+ <JoinedButtons
19+ color =" red"
20+ size =" large"
21+ :actions =" stopSplitActions"
22+ :primary-disabled =" !canTakeAction"
23+ :dropdown-disabled =" !canKill"
24+ >
25+ <template #kill_server >
26+ <SlashIcon class =" h-5 w-5" />
27+ Kill server
28+ </template >
29+ </JoinedButtons >
30+ </template >
31+
32+ <template v-else-if =" isStopping " >
33+ <JoinedButtons
34+ color =" red"
35+ size =" large"
36+ :actions =" stopSplitActions"
37+ :primary-disabled =" true"
38+ :dropdown-disabled =" !canKill"
39+ :primary-muted =" true"
40+ >
41+ <template #kill_server >
42+ <SlashIcon class =" h-5 w-5" />
43+ Kill server
44+ </template >
45+ </JoinedButtons >
46+ </template >
4547
46- <template #kill_server >
47- <SlashIcon class =" h-5 w-5" />
48- Kill server
49- </template >
50- </OverflowMenu >
51- </ButtonStyled >
52- </div >
53- <ButtonStyled v-else type =" standard" color =" brand" size =" large" >
48+ <template v-else >
49+ <ButtonStyled type =" standard" color =" brand" size =" large" >
5450 <button v-tooltip =" busyTooltip" :disabled =" !canTakeAction" @click =" handlePrimaryAction" >
5551 <PlayIcon />
5652 <span >{{ primaryActionText }}</span >
6359
6460<script setup lang="ts">
6561import {
66- DropdownIcon ,
6762 LoaderCircleIcon ,
6863 PlayIcon ,
6964 SlashIcon ,
@@ -72,7 +67,7 @@ import {
7267} from ' @modrinth/assets'
7368import { computed } from ' vue'
7469
75- import { ButtonStyled , OverflowMenu } from ' #ui/components'
70+ import { ButtonStyled , type JoinedButtonAction , JoinedButtons } from ' #ui/components'
7671
7772import { useServerPowerAction } from ' ./use-server-power-action'
7873
@@ -87,41 +82,30 @@ const props = withDefaults(
8782
8883const {
8984 isInstalling,
90- showStopButton,
85+ isStopping,
86+ showRestartButton,
9187 busyTooltip,
9288 canTakeAction,
89+ canKill,
9390 primaryActionText,
9491 initiateAction,
9592 handlePrimaryAction,
9693} = useServerPowerAction ({
9794 disabled: computed (() => props .disabled ),
9895})
9996
100- const showRestartDropdown = computed (() => primaryActionText .value === ' Restart' )
97+ const stopSplitActions = computed <JoinedButtonAction []>(() => [
98+ {
99+ id: ' stop' ,
100+ label: isStopping .value ? ' Stopping' : ' Stop' ,
101+ icon: StopCircleIcon ,
102+ action : () => initiateAction (' Stop' ),
103+ },
104+ {
105+ id: ' kill_server' ,
106+ label: ' Kill server' ,
107+ icon: SlashIcon ,
108+ action : () => initiateAction (' Kill' ),
109+ },
110+ ])
101111 </script >
102-
103- <style scoped>
104- .joined-buttons {
105- display : flex ;
106- align-items : center ;
107- }
108-
109- .joined-buttons > :deep(.btn ) {
110- border-radius : 0 ;
111- }
112-
113- .joined-buttons > :deep(.btn :first-child ) {
114- border-top-left-radius : var (--radius-md );
115- border-bottom-left-radius : var (--radius-md );
116- }
117-
118- .joined-buttons > :deep(.btn :last-child ) {
119- border-top-right-radius : var (--radius-md );
120- border-bottom-right-radius : var (--radius-md );
121- margin-left : -1px ;
122- }
123-
124- .joined-buttons > :deep(.btn :not (:last-child )) {
125- border-right : none ;
126- }
127- </style >
0 commit comments