feat: update server header buttons

This commit is contained in:
tdgao
2026-04-14 18:36:35 -06:00
parent 95b1e71ea3
commit 34e1db3a30
3 changed files with 73 additions and 30 deletions
@@ -1,14 +1,14 @@
<template>
<div class="contents">
<div class="flex flex-row items-center gap-2 rounded-lg">
<ButtonStyled v-if="isInstalling" type="standard" color="brand" size="large">
<ButtonStyled v-if="isInstalling" type="standard" color="brand">
<button disabled class="flex-shrink-0">
<LoaderCircleIcon class="size-5 animate-spin" /> Installing...
</button>
</ButtonStyled>
<template v-else>
<ButtonStyled v-if="showStopButton" type="transparent" size="large">
<ButtonStyled v-if="showStopButton" type="standard" color="red">
<button
v-tooltip="busyTooltip"
:disabled="!canTakeAction"
@@ -21,9 +21,38 @@
</button>
</ButtonStyled>
<ButtonStyled type="standard" color="brand" size="large">
<div v-if="showRestartDropdown" class="joined-buttons">
<ButtonStyled type="standard" color="orange">
<button v-tooltip="busyTooltip" :disabled="!canTakeAction" @click="handlePrimaryAction">
<UpdatedIcon />
<span>{{ primaryActionText }}</span>
</button>
</ButtonStyled>
<ButtonStyled type="standard" color="orange">
<OverflowMenu
v-tooltip="busyTooltip"
:disabled="!canTakeAction"
:options="[
{
id: 'kill_server',
action: () => initiateAction('Kill'),
},
]"
>
<div class="w-2 text-xl relative top-0.5 right-1.5">
<DropdownIcon />
</div>
<template #kill_server>
<SlashIcon class="h-5 w-5" />
Kill server
</template>
</OverflowMenu>
</ButtonStyled>
</div>
<ButtonStyled v-else type="standard" color="brand">
<button v-tooltip="busyTooltip" :disabled="!canTakeAction" @click="handlePrimaryAction">
<component :is="isRunning || showStopButton ? UpdatedIcon : PlayIcon" />
<PlayIcon />
<span>{{ primaryActionText }}</span>
</button>
</ButtonStyled>
@@ -33,10 +62,17 @@
</template>
<script setup lang="ts">
import { LoaderCircleIcon, PlayIcon, StopCircleIcon, UpdatedIcon } from '@modrinth/assets'
import {
DropdownIcon,
LoaderCircleIcon,
PlayIcon,
SlashIcon,
StopCircleIcon,
UpdatedIcon,
} from '@modrinth/assets'
import { computed } from 'vue'
import { ButtonStyled } from '#ui/components'
import { ButtonStyled, OverflowMenu } from '#ui/components'
import { useServerPowerAction } from './use-server-power-action'
@@ -51,7 +87,6 @@ const props = withDefaults(
const {
isInstalling,
isRunning,
showStopButton,
busyTooltip,
canTakeAction,
@@ -61,4 +96,32 @@ const {
} = useServerPowerAction({
disabled: computed(() => props.disabled),
})
const showRestartDropdown = computed(() => primaryActionText.value === 'Restart')
</script>
<style scoped>
.joined-buttons {
display: flex;
align-items: center;
}
.joined-buttons > :deep(.btn) {
border-radius: 0;
}
.joined-buttons > :deep(.btn:first-child) {
border-top-left-radius: var(--radius-md);
border-bottom-left-radius: var(--radius-md);
}
.joined-buttons > :deep(.btn:last-child) {
border-top-right-radius: var(--radius-md);
border-bottom-right-radius: var(--radius-md);
margin-left: -1px;
}
.joined-buttons > :deep(.btn:not(:last-child)) {
border-right: none;
}
</style>
@@ -1,12 +1,8 @@
<template>
<div class="contents">
<ButtonStyled circular type="transparent" size="large">
<ButtonStyled circular type="transparent">
<TeleportOverflowMenu :options="menuOptions">
<MoreVerticalIcon aria-hidden="true" />
<template #kill>
<SlashIcon class="h-5 w-5" />
<span>Kill server</span>
</template>
<template #allServers>
<ServerIcon class="h-5 w-5" />
<span>All servers</span>
@@ -21,7 +17,7 @@
</template>
<script setup lang="ts">
import { ClipboardCopyIcon, MoreVerticalIcon, ServerIcon, SlashIcon } from '@modrinth/assets'
import { ClipboardCopyIcon, MoreVerticalIcon, ServerIcon } from '@modrinth/assets'
import { computed } from 'vue'
import { useRouter } from 'vue-router'
@@ -29,8 +25,6 @@ import { ButtonStyled } from '#ui/components'
import TeleportOverflowMenu from '#ui/components/base/TeleportOverflowMenu.vue'
import { injectModrinthServerContext } from '#ui/providers'
import { useServerPowerAction } from './use-server-power-action'
const props = withDefaults(
defineProps<{
disabled?: boolean
@@ -49,21 +43,7 @@ const props = withDefaults(
const router = useRouter()
const { serverId } = injectModrinthServerContext()
const { isInstalling, initiateAction } = useServerPowerAction({
disabled: computed(() => props.disabled),
})
const menuOptions = computed(() => [
...(isInstalling.value
? []
: [
{
id: 'kill',
label: 'Kill server',
icon: SlashIcon,
action: () => initiateAction('Kill'),
},
]),
{
id: 'allServers',
label: 'All servers',
@@ -147,7 +147,7 @@
:auto-hide="false"
placement="bottom-end"
>
<ButtonStyled circular size="large">
<ButtonStyled circular>
<button
v-tooltip="showSettingsHint ? undefined : 'Server settings'"
@click="