You've already forked AstralRinth
forked from xxxOFFxxx/AstralRinth
185dd47668
* fix Signed-off-by: Evan Song <theevansong@gmail.com> * fix Signed-off-by: Evan Song <theevansong@gmail.com> * refactor(fileitem): optimize Signed-off-by: Evan Song <theevansong@gmail.com> * chore(fileitem): fixed width timestamp Signed-off-by: Evan Song <theevansong@gmail.com> * fix(fileitem): allow editing json5/jsonc Signed-off-by: Evan Song <theevansong@gmail.com> * feat: motd pt 1, auto backups scaffolding, editing navbar changes * feat: fancy sidebar animations * fix: files * fix: files pt2 * fix: faulty name validation disallowing spaces in file names Signed-off-by: Evan Song <theevansong@gmail.com> * refactor: fileitem props Signed-off-by: Evan Song <theevansong@gmail.com> * fix: upload files not refreshing files list Signed-off-by: Evan Song <theevansong@gmail.com> * fix(imgviewer): handle invalid/empty images Signed-off-by: Evan Song <theevansong@gmail.com> * fix: return of the sticky files header Signed-off-by: Evan Song <theevansong@gmail.com> * chore: prevent servericon from shrinking Signed-off-by: Evan Song <theevansong@gmail.com> * fix: wtf were we thinking with this anyway Signed-off-by: Evan Song <theevansong@gmail.com> * fix: further mobile optimization Signed-off-by: Evan Song <theevansong@gmail.com> * chore: propagate margin Signed-off-by: Evan Song <theevansong@gmail.com> * chore: truncation fixes Signed-off-by: Evan Song <theevansong@gmail.com> * fix: track navbar with sentinel Signed-off-by: Evan Song <theevansong@gmail.com> * chore: clean Signed-off-by: Evan Song <theevansong@gmail.com> * fix(files): a11y Signed-off-by: Evan Song <theevansong@gmail.com> * chore: improve inspector styles Signed-off-by: Evan Song <theevansong@gmail.com> * chore: clean Signed-off-by: Evan Song <theevansong@gmail.com> * feat: console preformance improvements, decrease blur * feat(mobile): new server header * fix: linting * fix: useless z indeces Signed-off-by: Evan Song <theevansong@gmail.com> * chore: adjust file filter names Signed-off-by: Evan Song <theevansong@gmail.com> * feat(files): true breadcrumbs Signed-off-by: Evan Song <theevansong@gmail.com> * fix(marketing): make custom responsive * fix(marketing): mobile file manager card * feat: trackable navtabs Signed-off-by: Evan Song <theevansong@gmail.com> * fix: oh no Signed-off-by: Evan Song <theevansong@gmail.com> * fix: smartly truncate Signed-off-by: Evan Song <theevansong@gmail.com> * fix(terminal): z-indexes * fix: autofocus more inputs Signed-off-by: Evan Song <theevansong@gmail.com> * fix: color Signed-off-by: Evan Song <theevansong@gmail.com> * chore: adjust copy Signed-off-by: Evan Song <theevansong@gmail.com> * chore: backup modal usability improvements Signed-off-by: Evan Song <theevansong@gmail.com> * fix: padding Signed-off-by: Evan Song <theevansong@gmail.com> * chore: title Signed-off-by: Evan Song <theevansong@gmail.com> * fix(content): update banner mobile support * fix: server listing icons Signed-off-by: Evan Song <theevansong@gmail.com> * fix: ignore clicks in server listing for labels Signed-off-by: Evan Song <theevansong@gmail.com> * feat(mobile): backup card * fix(backups): make plural conditional * fix: debounce file item selectitem Signed-off-by: Evan Song <theevansong@gmail.com> * fix: lint Signed-off-by: Evan Song <theevansong@gmail.com> * stuff Signed-off-by: Evan Song <theevansong@gmail.com> * fix: temp sidebar fix until i can be smart * chore: clean Signed-off-by: Evan Song <theevansong@gmail.com> * chore: explictly set button type in file modals Signed-off-by: Evan Song <theevansong@gmail.com> * fix: properly sort backups Signed-off-by: Evan Song <theevansong@gmail.com> * feat: add getautobackup method to pyroservers Signed-off-by: Evan Song <theevansong@gmail.com> * choer: update autobackup params Signed-off-by: Evan Song <theevansong@gmail.com> * chore: update autobackup methods (REALLY GUYS) Signed-off-by: Evan Song <theevansong@gmail.com> * feat: implement autobackups Signed-off-by: Evan Song <theevansong@gmail.com> * feat: implement backup-while-running preference Signed-off-by: Evan Song <theevansong@gmail.com> * feat: make server labels a component * feat: implement 'All details' modal * fix(mobile): server manage page * feat(files): mobile compatible * fix(info labels): wrap * chore(inspector): clean Signed-off-by: Evan Song <theevansong@gmail.com> * fix(backup settings): swap + and - * fix(manage): new -> plans instead of modal * feat: more small mobile fixes * fix(auto backup modal): manual input validation * fix(file browse navbar): home margin * feat(purchase modal): mobile support * fix(marketing): faded line alignments * feat: add servers to mobile nav * feat(network): dns record fixes * feat: make all settings work on mobile * fix(loader settings): modpack mobile * chore: clean Signed-off-by: Evan Song <theevansong@gmail.com> * feat(marketing): add 'Manage your servers' button * fix(marketing): only check servers if logged in * fix(network): allocation edit & delete button * fix(backups): use UiServersTeleportOverflowMenu * chore: linting * chore: but here comes the sentence case Signed-off-by: Evan Song <theevansong@gmail.com> * feat(marketing): make buttons consistent * lint Signed-off-by: Evan Song <theevansong@gmail.com> * fix(loader): prevent multiline version names in dropdown Signed-off-by: Evan Song <theevansong@gmail.com> * lint Signed-off-by: Evan Song <theevansong@gmail.com> * fix: copy Signed-off-by: Evan Song <theevansong@gmail.com> * fix: sentence case Signed-off-by: Evan Song <theevansong@gmail.com> * fix: linting * chore: rename dumbass preference key Signed-off-by: Evan Song <theevansong@gmail.com> * refactor: rewrite power action buttons Signed-off-by: Evan Song <theevansong@gmail.com> * fix: robust download logic Signed-off-by: Evan Song <theevansong@gmail.com> * fix(loader mobile): modpack dropdown width * fix: sentence case * fix(save & 'working on it'): look good on mobile * fix(TeleportDropdown): width * fix(inspecting error): mobile * fix: show action button dropdown when installing * fix(navtabs): temp fix for mobile scrolling issue * fix(install error): mobile compatible * chore: just remove tracking Signed-off-by: Evan Song <theevansong@gmail.com> * chore: clean Signed-off-by: Evan Song <theevansong@gmail.com> * chore: clean Signed-off-by: Evan Song <theevansong@gmail.com> * fix: cleanup * fix: broken svg clr in checkbox when using experimental styles Signed-off-by: Evan Song <theevansong@gmail.com> * chore: adjust vanilla icon Signed-off-by: Evan Song <theevansong@gmail.com> * chore: adjust loader props Signed-off-by: Evan Song <theevansong@gmail.com> * revert changes to serversidebar Signed-off-by: Evan Song <theevansong@gmail.com> * fix: server properties flicker Signed-off-by: Evan Song <theevansong@gmail.com> * fix(backups): plural * fix: cases where the telepoverflow would clash with viewport edge Signed-off-by: Evan Song <theevansong@gmail.com> * feat(backups): auto-backups label * fix(network): titlecase * feat(fileitem): new rename icon * fix(properties): wiki proper noun * fix: disable motd for the time being * chore: adjust wording for power conifmration Signed-off-by: Evan Song <theevansong@gmail.com> * feat: "external" to billing Signed-off-by: Evan Song <theevansong@gmail.com> * fix: icon Signed-off-by: Evan Song <theevansong@gmail.com> * fix: add EULA checkbox * chore: clean Signed-off-by: Evan Song <theevansong@gmail.com> * me and bro deciding which case rules to enforce Signed-off-by: Evan Song <theevansong@gmail.com> * feat(sftp): copy address & username, launch tooltip * feat(files): better move * chore: attempt to mitigate excessive stack depth type Signed-off-by: Evan Song <theevansong@gmail.com> * fix(loader): prevent versions 1.2.4 and below * feat(dns table): placeholder improvements * feat(pyroServer): error handling * fix: intrinsic size on loader icon Signed-off-by: Evan Song <theevansong@gmail.com> * chore: adjust wording Signed-off-by: Evan Song <theevansong@gmail.com> * fix: sentence case Signed-off-by: Evan Song <theevansong@gmail.com> * chore: adjust wording Signed-off-by: Evan Song <theevansong@gmail.com> * fix: types Signed-off-by: Evan Song <theevansong@gmail.com> * fix: "implemented" key in preference Signed-off-by: Evan Song <theevansong@gmail.com> * feat(connection lost): redesign * feat(connection error): make icon orange * fix: cleanup * chore(connection lost): redesign pt 2 Signed-off-by: Evan Song <theevansong@gmail.com> * fix: OOOOHHH MY GOD Signed-off-by: Evan Song <theevansong@gmail.com> * feat: implement capacity api on marketing Signed-off-by: Evan Song <theevansong@gmail.com> * chore: update createdat backup type Signed-off-by: Evan Song <theevansong@gmail.com> * refactor: all of backups Signed-off-by: Evan Song <theevansong@gmail.com> * chore: update backup types Signed-off-by: Evan Song <theevansong@gmail.com> * refactor: backups pt 2 Signed-off-by: Evan Song <theevansong@gmail.com> * fix: comically small icons Signed-off-by: Evan Song <theevansong@gmail.com> * chore: align designs Signed-off-by: Evan Song <theevansong@gmail.com> * chore: hide ram graph if ram as bytes enabled Signed-off-by: Evan Song <theevansong@gmail.com> * base add content page * Fix conflict * feat(content): mobile-compatible header, sticky * fix(marketing): md instead of sm for custom * fix: compiler macro warning Signed-off-by: Evan Song <theevansong@gmail.com> * again Signed-off-by: Evan Song <theevansong@gmail.com> * fix: loader type error Signed-off-by: Evan Song <theevansong@gmail.com> * fix: default uptime seconds prop Signed-off-by: Evan Song <theevansong@gmail.com> * fix: hydration errors on server listing Signed-off-by: Evan Song <theevansong@gmail.com> * feat: move custom URL to general Signed-off-by: Evan Song <theevansong@gmail.com> * feat: indiviudally checkj capacities Signed-off-by: Evan Song <theevansong@gmail.com> * fix: falsey Signed-off-by: Evan Song <theevansong@gmail.com> * fix: missing prop Signed-off-by: Evan Song <theevansong@gmail.com> * chore: Derive On That Thang Signed-off-by: Evan Song <theevansong@gmail.com> * chore: adjust gap Signed-off-by: Evan Song <theevansong@gmail.com> * fix: add default name for backups * fix: the backup number should PROBABLY be computed lol * fix(backups): truncate text, mobile fixes * fix(loader): modpack mobile fix * feat(plans): add vcpus * fix(backup modal): blank by default, maxlength * fix(subdomain): separate length & valid chars * feat: mrpack installs functionality (untested), forbidden handling, backups grammar * feat(content): make responsive on mobile * fix: disable plan buttons separately * fix(backup modal): update name max length * fix(purchase): wrapping on eula, eula link * fix: move skeleton * fix(server mobile header): truncation * fix(server header): proper alignment * Finish content page fixes * fix: who up rinthing Signed-off-by: Evan Song <theevansong@gmail.com> * wip Signed-off-by: Evan Song <theevansong@gmail.com> * fix(staging & email banner): z-index * feat: make eula tickbox more visible * fix: move "powered by pyro" below buttons on hero * fix: oops sorry ellie, also updated the main screenshot * feat: update content screenshot * fix: content page card should hide image on lg * feat: hide total storage for now * fix: terminal card now uses terminal icon * fix(marketing): make medium plan card border solid * feat: modloader card, move pyro BACK below buttons, beta release pill * fix: spinning logo should be behind hero * feat: surgically remove the hero's massive forehead * feat(marketing): mobile UI screenshot * fix(hero): z-index goes over mobile nav * fix: consistent borders, files breakpoints * chore: update turbo * chore: adjust hero sizing Signed-off-by: Evan Song <theevansong@gmail.com> * chore: mention region restrictions * chore: double check if we are at capcity Signed-off-by: Evan Song <theevansong@gmail.com> * fix: measure twice cut once Signed-off-by: Evan Song <theevansong@gmail.com> * chore: bro cut twice and measured once 💀 Signed-off-by: Evan Song <theevansong@gmail.com> * fix(marketing): login first * fix: out of capacity text when logged out * fix(slider): reset some values for frontend * feat: wip hero section Signed-off-by: Evan Song <theevansong@gmail.com> * New navigation to support the new products (#2879) * Nav * oops extra file * feat: mrpack uploading with existing modpack, fix: choose modpack duplicate * chore: clean Signed-off-by: Evan Song <theevansong@gmail.com> * feat: update features section Signed-off-by: Evan Song <theevansong@gmail.com> * Nav adjustments * fix: server manager empty state clashing with loading state Signed-off-by: Evan Song <theevansong@gmail.com> * chore: query param hard Signed-off-by: Evan Song <theevansong@gmail.com> * fix: do not count uptime if crashed Signed-off-by: Evan Song <theevansong@gmail.com> * fix: grammar Signed-off-by: Evan Song <theevansong@gmail.com> * hide hero img on lg breakpoints * Make plugins a plug * chore: prep for buffered text selection terminal Signed-off-by: Evan Song <theevansong@gmail.com> * fix: marketing responsive stuff, n fixes * fix hoverable prop * fix: edit mod spacing * fix: type error for display name in dropdown Signed-off-by: Evan Song <theevansong@gmail.com> * feat: custom plans * fix: no more console.log * fix: properly linked prop label Signed-off-by: Evan Song <theevansong@gmail.com> * fix(install hero mobile): padding * fix: prevent x overflow on servers page Signed-off-by: Evan Song <theevansong@gmail.com> * fix lint oh ym fucking god yal Signed-off-by: Evan Song <theevansong@gmail.com> * Migrate modpack install to search * fix(custom plan): warning icon variable * fix: loading probally and modal loader things * fix(marketing): login icon colours * fix(marketing): responsiveness * fix(marketing): responsiveness v2 * fix: sync button for icon tm * fix(marketing): responsiveness v3 * fix: hero image Signed-off-by: Evan Song <theevansong@gmail.com> * chore: clean Signed-off-by: Evan Song <theevansong@gmail.com> * chore: switch to cdn links Signed-off-by: Evan Song <theevansong@gmail.com> * chore: switch to cdn links Signed-off-by: Evan Song <theevansong@gmail.com> * chore: switch to cdn links Signed-off-by: Evan Song <theevansong@gmail.com> * chore: switch to cdn links Signed-off-by: Evan Song <theevansong@gmail.com> * Remove prod override --------- Signed-off-by: Evan Song <theevansong@gmail.com> Co-authored-by: Evan Song <theevansong@gmail.com> Co-authored-by: TheWander02 <48934424+thewander02@users.noreply.github.com> Co-authored-by: he3als <65787561+he3als@users.noreply.github.com> Co-authored-by: Evan Song <52982404+ferothefox@users.noreply.github.com> Co-authored-by: Lio <git@lio.cat> Co-authored-by: Jai A <jaiagr+gpg@pm.me> Co-authored-by: not-nullptr <needhelpwithrift@gmail.com> Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com> Co-authored-by: Prospector <prospectordev@gmail.com> Co-authored-by: sticks <tanner@teamhydra.dev>
508 lines
17 KiB
Vue
508 lines
17 KiB
Vue
<template>
|
|
<NewModal ref="modModal" header="Edit mod version">
|
|
<div>
|
|
<div class="mb-4 flex flex-col gap-4">
|
|
<div class="inline-flex flex-wrap items-center">
|
|
You're changing the version of
|
|
<div class="inline-flex flex-wrap items-center gap-1 text-nowrap pl-2">
|
|
<UiAvatar
|
|
:src="currentMod?.icon_url"
|
|
size="24px"
|
|
class="inline-block"
|
|
alt="Server Icon"
|
|
/>
|
|
<strong>{{ currentMod?.name + "." }}</strong>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div v-if="props.server.general?.upstream" class="flex items-center gap-2">
|
|
<InfoIcon class="hidden sm:block" />
|
|
<span class="text-sm text-secondary">
|
|
Your server was created from a modpack. Changing the mod version may cause unexpected
|
|
issues.
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="flex items-center gap-4">
|
|
<UiServersTeleportDropdownMenu
|
|
v-model="currentVersion"
|
|
name="Project"
|
|
:options="currentVersions"
|
|
placeholder="Select project..."
|
|
class="!w-full"
|
|
:display-name="
|
|
(version) => (typeof version === 'object' ? version?.version_number : version)
|
|
"
|
|
/>
|
|
</div>
|
|
<div class="mt-4 flex flex-row items-center gap-4">
|
|
<ButtonStyled color="brand">
|
|
<button :disabled="currentMod.changing" @click="changeModVersion">
|
|
<PlusIcon />
|
|
Install
|
|
</button>
|
|
</ButtonStyled>
|
|
<ButtonStyled>
|
|
<button @click="modModal.value.hide()">
|
|
<XIcon />
|
|
Cancel
|
|
</button>
|
|
</ButtonStyled>
|
|
</div>
|
|
</div>
|
|
</NewModal>
|
|
|
|
<div v-if="server.general && localMods" class="relative isolate flex h-full w-full flex-col">
|
|
<div ref="pyroContentSentinel" class="sentinel" data-pyro-content-sentinel />
|
|
<div class="relative flex h-full w-full flex-col">
|
|
<div class="sticky top-0 z-20 -mt-4 flex items-center justify-between bg-bg py-4">
|
|
<div class="flex w-full flex-col items-center gap-2 sm:flex-row sm:gap-4">
|
|
<div class="flex w-full items-center gap-2 sm:gap-4">
|
|
<div class="relative flex-1 text-sm">
|
|
<label class="sr-only" for="search">Search</label>
|
|
<SearchIcon
|
|
class="pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2"
|
|
aria-hidden="true"
|
|
/>
|
|
<input
|
|
id="search"
|
|
v-model="searchInput"
|
|
class="!h-9 !min-h-0 w-full border-[1px] border-solid border-button-border pl-9"
|
|
type="search"
|
|
name="search"
|
|
autocomplete="off"
|
|
placeholder="Search mods..."
|
|
@input="debouncedSearch"
|
|
/>
|
|
</div>
|
|
<ButtonStyled>
|
|
<UiServersTeleportOverflowMenu
|
|
position="bottom"
|
|
direction="left"
|
|
aria-label="Filter mods"
|
|
:options="[
|
|
{ id: 'all', action: () => (filterMethod = 'all') },
|
|
{ id: 'enabled', action: () => (filterMethod = 'enabled') },
|
|
{ id: 'disabled', action: () => (filterMethod = 'disabled') },
|
|
]"
|
|
>
|
|
<span class="whitespace-pre text-sm font-medium">
|
|
{{ filterMethodLabel }}
|
|
</span>
|
|
<FilterIcon aria-hidden="true" />
|
|
<DropdownIcon aria-hidden="true" class="h-5 w-5 text-secondary" />
|
|
<template #all> All mods </template>
|
|
<template #enabled> Only enabled </template>
|
|
<template #disabled> Only disabled </template>
|
|
</UiServersTeleportOverflowMenu>
|
|
</ButtonStyled>
|
|
</div>
|
|
<ButtonStyled v-if="hasMods" color="brand" type="outlined">
|
|
<nuxt-link
|
|
class="w-full text-nowrap sm:w-fit"
|
|
:to="`/mods?sid=${props.server.serverId}`"
|
|
>
|
|
<PlusIcon />
|
|
Add content
|
|
</nuxt-link>
|
|
</ButtonStyled>
|
|
</div>
|
|
</div>
|
|
<div v-if="hasMods" class="flex flex-col gap-2 transition-all">
|
|
<div ref="listContainer" class="relative w-full">
|
|
<div :style="{ position: 'relative', height: `${totalHeight}px` }">
|
|
<div :style="{ position: 'absolute', top: `${visibleTop}px`, width: '100%' }">
|
|
<template v-for="mod in visibleItems.items" :key="mod.filename">
|
|
<div
|
|
class="relative mb-2 flex w-full items-center justify-between rounded-xl bg-bg-raised"
|
|
:class="mod.disabled ? 'bg-table-alternateRow text-secondary' : ''"
|
|
style="height: 64px"
|
|
>
|
|
<NuxtLink
|
|
:to="
|
|
mod.project_id
|
|
? `/project/${mod.project_id}/version/${mod.version_id}`
|
|
: `files?path=mods`
|
|
"
|
|
class="group flex min-w-0 items-center rounded-xl p-2"
|
|
>
|
|
<div class="flex min-w-0 items-center gap-2">
|
|
<UiAvatar
|
|
:src="mod.icon_url"
|
|
size="sm"
|
|
alt="Server Icon"
|
|
:class="mod.disabled ? 'grayscale' : ''"
|
|
/>
|
|
<div class="flex min-w-0 flex-col">
|
|
<span class="flex min-w-0 items-center gap-2 text-lg font-bold">
|
|
<span class="truncate">{{
|
|
mod.name || mod.filename.replace(".disabled", "")
|
|
}}</span>
|
|
<span
|
|
v-if="mod.disabled"
|
|
class="hidden rounded-full bg-button-bg p-1 px-2 text-xs text-contrast sm:block"
|
|
>Disabled</span
|
|
>
|
|
</span>
|
|
<span class="min-w-0 text-xs text-secondary">{{
|
|
mod.version_number || "External mod"
|
|
}}</span>
|
|
</div>
|
|
</div>
|
|
</NuxtLink>
|
|
<div class="flex items-center gap-2 pr-4 font-semibold text-contrast">
|
|
<ButtonStyled v-if="mod.project_id" type="transparent">
|
|
<button
|
|
v-tooltip="'Edit mod version'"
|
|
:disabled="mod.changing"
|
|
class="!hidden sm:!block"
|
|
@click="beginChangeModVersion(mod)"
|
|
>
|
|
<template v-if="mod.changing">
|
|
<UiServersIconsLoadingIcon />
|
|
</template>
|
|
<template v-else>
|
|
<EditIcon />
|
|
</template>
|
|
</button>
|
|
</ButtonStyled>
|
|
<ButtonStyled type="transparent">
|
|
<button
|
|
v-tooltip="'Delete mod'"
|
|
:disabled="mod.changing"
|
|
class="!hidden sm:!block"
|
|
@click="removeMod(mod)"
|
|
>
|
|
<TrashIcon />
|
|
</button>
|
|
</ButtonStyled>
|
|
|
|
<!-- Dropdown for mobile -->
|
|
<div class="mr-2 flex items-center sm:hidden">
|
|
<UiServersIconsLoadingIcon
|
|
v-if="mod.changing"
|
|
class="mr-2 h-5 w-5 animate-spin"
|
|
style="color: var(--color-base)"
|
|
/>
|
|
<ButtonStyled v-else circular type="transparent">
|
|
<UiServersTeleportOverflowMenu
|
|
:options="[
|
|
{
|
|
id: 'edit',
|
|
action: () => beginChangeModVersion(mod),
|
|
shown: !!(mod.project_id && !mod.changing),
|
|
},
|
|
{
|
|
id: 'delete',
|
|
action: () => removeMod(mod),
|
|
},
|
|
]"
|
|
>
|
|
<MoreVerticalIcon aria-hidden="true" />
|
|
<template #edit>
|
|
<EditIcon class="h-5 w-5" />
|
|
<span>Edit</span>
|
|
</template>
|
|
<template #delete>
|
|
<TrashIcon class="h-5 w-5" />
|
|
<span>Delete</span>
|
|
</template>
|
|
</UiServersTeleportOverflowMenu>
|
|
</ButtonStyled>
|
|
</div>
|
|
|
|
<input
|
|
:id="`toggle-${mod.filename}`"
|
|
:checked="!mod.disabled"
|
|
:disabled="mod.changing"
|
|
class="switch stylized-toggle"
|
|
type="checkbox"
|
|
@change="toggleMod(mod)"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div v-else class="mt-4 flex h-full flex-col items-center justify-center text-center">
|
|
<PackageClosedIcon class="size-24 text-neutral-500" />
|
|
<p class="m-0 pb-2 pt-3 text-neutral-200">No mods found!</p>
|
|
<p class="m-0 pb-3 text-neutral-400">Add some mods to your server to manage them here.</p>
|
|
<ButtonStyled color="brand" class="mt-8">
|
|
<nuxt-link :to="`/mods?sid=${props.server.serverId}`">Add content</nuxt-link>
|
|
</ButtonStyled>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import {
|
|
SearchIcon,
|
|
EditIcon,
|
|
TrashIcon,
|
|
PackageClosedIcon,
|
|
FilterIcon,
|
|
DropdownIcon,
|
|
InfoIcon,
|
|
XIcon,
|
|
PlusIcon,
|
|
MoreVerticalIcon,
|
|
} from "@modrinth/assets";
|
|
import { ButtonStyled, NewModal } from "@modrinth/ui";
|
|
import { ref, computed, watch, onMounted, onUnmounted } from "vue";
|
|
import type { Server } from "~/composables/pyroServers";
|
|
|
|
const props = defineProps<{
|
|
server: Server<["general", "mods", "backups", "network", "startup", "ws", "fs"]>;
|
|
}>();
|
|
|
|
interface Mod {
|
|
name?: string;
|
|
filename: string;
|
|
project_id?: string;
|
|
version_id?: string;
|
|
version_number?: string;
|
|
icon_url?: string;
|
|
disabled: boolean;
|
|
changing?: boolean;
|
|
}
|
|
|
|
const ITEM_HEIGHT = 72;
|
|
const BUFFER_SIZE = 5;
|
|
|
|
const listContainer = ref<HTMLElement | null>(null);
|
|
const windowScrollY = ref(0);
|
|
const windowHeight = ref(0);
|
|
|
|
const localMods = ref<Mod[]>([]);
|
|
|
|
const searchInput = ref("");
|
|
const modSearchInput = ref("");
|
|
const filterMethod = ref("all");
|
|
|
|
const filterMethodLabel = computed(() => {
|
|
switch (filterMethod.value) {
|
|
case "disabled":
|
|
return "Only disabled";
|
|
case "enabled":
|
|
return "Only enabled";
|
|
default:
|
|
return "All mods";
|
|
}
|
|
});
|
|
|
|
const totalHeight = computed(() => {
|
|
const itemsHeight = filteredMods.value.length * ITEM_HEIGHT;
|
|
return itemsHeight;
|
|
});
|
|
|
|
const getVisibleRange = () => {
|
|
if (!listContainer.value) return { start: 0, end: 0 };
|
|
|
|
const containerTop = listContainer.value.getBoundingClientRect().top + window.scrollY;
|
|
const scrollTop = Math.max(0, windowScrollY.value - containerTop);
|
|
|
|
const start = Math.floor(scrollTop / ITEM_HEIGHT);
|
|
const visibleCount = Math.ceil(windowHeight.value / ITEM_HEIGHT);
|
|
|
|
return {
|
|
start: Math.max(0, start - BUFFER_SIZE),
|
|
end: Math.min(filteredMods.value.length, start + visibleCount + BUFFER_SIZE * 2),
|
|
};
|
|
};
|
|
|
|
const visibleTop = computed(() => {
|
|
const range = getVisibleRange();
|
|
return range.start * ITEM_HEIGHT;
|
|
});
|
|
|
|
const visibleItems = computed(() => {
|
|
const range = getVisibleRange();
|
|
const items = filteredMods.value;
|
|
|
|
return {
|
|
items: items.slice(Math.max(0, range.start), Math.min(items.length, range.end)),
|
|
};
|
|
});
|
|
|
|
const handleScroll = () => {
|
|
windowScrollY.value = window.scrollY;
|
|
};
|
|
|
|
const handleResize = () => {
|
|
windowHeight.value = window.innerHeight;
|
|
};
|
|
|
|
onMounted(() => {
|
|
windowHeight.value = window.innerHeight;
|
|
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
window.addEventListener("resize", handleResize, { passive: true });
|
|
handleScroll();
|
|
});
|
|
|
|
onUnmounted(() => {
|
|
window.removeEventListener("scroll", handleScroll);
|
|
window.removeEventListener("resize", handleResize);
|
|
});
|
|
|
|
watch(
|
|
() => props.server.mods?.data,
|
|
(newMods) => {
|
|
if (newMods) {
|
|
localMods.value = [...newMods];
|
|
}
|
|
},
|
|
{ immediate: true },
|
|
);
|
|
|
|
const debounce = <T extends (...args: any[]) => void>(
|
|
func: T,
|
|
wait: number,
|
|
): ((...args: Parameters<T>) => void) => {
|
|
let timeout: ReturnType<typeof setTimeout>;
|
|
return function (...args: Parameters<T>): void {
|
|
clearTimeout(timeout);
|
|
timeout = setTimeout(() => func(...args), wait);
|
|
};
|
|
};
|
|
|
|
const pyroContentSentinel = ref<HTMLElement | null>(null);
|
|
const debouncedSearch = debounce(() => {
|
|
modSearchInput.value = searchInput.value;
|
|
|
|
if (pyroContentSentinel.value) {
|
|
pyroContentSentinel.value.scrollIntoView({
|
|
behavior: "smooth",
|
|
block: "start",
|
|
});
|
|
}
|
|
}, 300);
|
|
|
|
async function toggleMod(mod: Mod) {
|
|
mod.changing = true;
|
|
|
|
const originalFilename = mod.filename;
|
|
try {
|
|
const newFilename = mod.filename.endsWith(".disabled")
|
|
? mod.filename.replace(".disabled", "")
|
|
: `${mod.filename}.disabled`;
|
|
|
|
const sourcePath = `/mods/${mod.filename}`;
|
|
const destinationPath = `/mods/${newFilename}`;
|
|
|
|
mod.disabled = newFilename.endsWith(".disabled");
|
|
mod.filename = newFilename;
|
|
|
|
await props.server.fs?.moveFileOrFolder(sourcePath, destinationPath);
|
|
|
|
await props.server.refresh(["general", "mods"]);
|
|
} catch (error) {
|
|
mod.filename = originalFilename;
|
|
mod.disabled = originalFilename.endsWith(".disabled");
|
|
|
|
console.error("Error toggling mod:", error);
|
|
addNotification({
|
|
text: `Something went wrong toggling ${mod.name || mod.filename.replace(".disabled", "")}`,
|
|
type: "error",
|
|
});
|
|
}
|
|
|
|
mod.changing = false;
|
|
}
|
|
|
|
async function removeMod(mod: Mod) {
|
|
mod.changing = true;
|
|
|
|
try {
|
|
await props.server.mods?.remove(`/mods/${mod.filename}`);
|
|
await props.server.refresh(["general", "mods"]);
|
|
} catch (error) {
|
|
console.error("Error removing mod:", error);
|
|
|
|
addNotification({
|
|
text: `couldn't remove ${mod.name || mod.filename}`,
|
|
type: "error",
|
|
});
|
|
}
|
|
|
|
mod.changing = false;
|
|
}
|
|
|
|
const modModal = ref();
|
|
const currentMod = ref();
|
|
const currentVersions = ref();
|
|
const currentVersion = ref();
|
|
|
|
async function beginChangeModVersion(mod: Mod) {
|
|
currentMod.value = mod;
|
|
currentVersions.value = await useBaseFetch(`project/${mod.project_id}/version`, {}, false, true);
|
|
currentVersion.value = currentVersions.value.find(
|
|
(version: any) => version.id === mod.version_id,
|
|
);
|
|
modModal.value.show();
|
|
}
|
|
|
|
async function changeModVersion() {
|
|
currentMod.value.changing = true;
|
|
try {
|
|
modModal.value.hide();
|
|
await props.server.mods?.remove(`/mods/${currentMod.value.filename}`);
|
|
await props.server.mods?.install(currentMod.value.project_id, currentVersion.value.id);
|
|
await props.server.refresh(["general", "mods"]);
|
|
} catch (error) {
|
|
console.error("Error changing mod version:", error);
|
|
}
|
|
currentMod.value.changing = false;
|
|
}
|
|
|
|
const hasMods = computed(() => {
|
|
return filteredMods.value?.length > 0;
|
|
});
|
|
|
|
const filteredMods = computed(() => {
|
|
const mods = modSearchInput.value.trim()
|
|
? localMods.value.filter(
|
|
(mod) =>
|
|
mod.name?.toLowerCase().includes(modSearchInput.value.toLowerCase()) ||
|
|
mod.filename.toLowerCase().includes(modSearchInput.value.toLowerCase()),
|
|
)
|
|
: localMods.value;
|
|
|
|
const statusFilteredMods = (() => {
|
|
switch (filterMethod.value) {
|
|
case "disabled":
|
|
return mods.filter((mod) => mod.disabled);
|
|
case "enabled":
|
|
return mods.filter((mod) => !mod.disabled);
|
|
default:
|
|
return mods;
|
|
}
|
|
})();
|
|
|
|
return statusFilteredMods.sort((a, b) => {
|
|
const aName = a.name || a.filename.replace(".disabled", "");
|
|
const bName = b.name || b.filename.replace(".disabled", "");
|
|
return aName.localeCompare(bName);
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.sentinel {
|
|
position: absolute;
|
|
top: -1rem;
|
|
left: 0;
|
|
right: 0;
|
|
height: 1px;
|
|
visibility: hidden;
|
|
}
|
|
|
|
.stylized-toggle:checked::after {
|
|
background: var(--color-accent-contrast) !important;
|
|
}
|
|
</style>
|