Compare commits

...
7 Commits
Author SHA1 Message Date
HorizonCode 51f5fa3e46 fix(themes): enforce strict semver versions
Require SemVer 2.0.0 when saving, validating, or publishing a theme, and validate again at the workshop upload boundary. This rejects partial versions, v-prefixed versions, leading-zero components, and arbitrary strings while preserving valid prerelease and build metadata.
2026-11-04 00:00:07 +01:00
HorizonCode 07cbfa39a6 fix(themes): require a newer version for each publish
Compare the proposed version with the version currently published in the workshop before opening the publish dialog and again before upload. Reject invalid semver, duplicate versions, and downgrades, while tracking the just-submitted version in-session so pending updates cannot be published twice.
2026-11-03 23:54:02 +01:00
HorizonCode 11aefee7ed feat(themes): persist publisher id in theme manifests
Publishing now stamps the signed-in EZPPFarm user ID into theme.json and saves it before packaging, so installed theme cards can resolve avatars by stable user ID. Older manifests keep the author-name fallback.
2026-11-03 23:45:00 +01:00
HorizonCode 5eea428802 fix(themes): show author avatars on installed theme cards
Installed theme cards rendered only an initial because their manifests store the author name, not an avatar URL. Use the EZPPFarm avatar endpoint with the author name and keep the initial as the image-load fallback, matching the community workshop presentation.
2026-11-03 23:39:25 +01:00
HorizonCode 760bd9a283 refactor(themes): align installed cards with the workshop layout
Installed theme cards now use the same visual hierarchy as workshop cards: status and API badges at the top, version on the preview, an author strip over the artwork, a compact title and description, and a footer with status plus compact actions. This removes the oversized primary button and duplicate version/author rows.
2026-11-03 23:13:44 +01:00
HorizonCode 47c022642f feat(themes): polish installed cards and add workshop theme details
Installed themes now use a 16:9 preview with stable card spacing and a single overflow menu for edit, restore, update, report and uninstall actions. Community theme previews and titles open a large detail dialog with a full-size preview, metadata, tags, review status and the relevant install action.
2026-11-03 23:08:35 +01:00
HorizonCode 5613c3be25 fix(workshop): make moderation and install flows production ready
Replace the remaining native prompt and confirm calls with an in-app action dialog, including focus handling and inline errors. Guard likes and concurrent moderation loads, surface stale-data errors, paginate the review queue, and keep load-more state local to each list. Allow the packaged app to reach the workshop host for API calls and previews.
2026-11-03 22:55:18 +01:00
7 changed files with 1408 additions and 299 deletions

No files matched your search

+2 -2
View File
@@ -32,8 +32,8 @@
"script-src": "'self' 'unsafe-inline' 'unsafe-eval' asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* https://analytics.ez-pp.farm",
"worker-src": ["'self'", "blob:"],
"style-src": "'self' 'unsafe-inline' asset: http://asset.localhost https://asset.localhost http://127.0.0.1:*",
"img-src": "'self' asset: http://asset.localhost https://asset.localhost blob: data: http://127.0.0.1:* https://assets.ppy.sh https://a.ez-pp.farm https://git.ez-pp.farm https://osu.direct",
"connect-src": "'self' ipc: http://ipc.localhost asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* https://ez-pp.farm https://api.ez-pp.farm https://c.ez-pp.farm https://analytics.ez-pp.farm https://git.ez-pp.farm https://osu.direct https://osu.ppy.sh https://api.fontsource.org https://cdn.jsdelivr.net",
"img-src": "'self' asset: http://asset.localhost https://asset.localhost blob: data: http://127.0.0.1:* https://assets.ppy.sh https://a.ez-pp.farm https://git.ez-pp.farm https://osu.direct https://themes.ez-pp.farm",
"connect-src": "'self' ipc: http://ipc.localhost asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* https://ez-pp.farm https://api.ez-pp.farm https://c.ez-pp.farm https://analytics.ez-pp.farm https://git.ez-pp.farm https://osu.direct https://osu.ppy.sh https://api.fontsource.org https://cdn.jsdelivr.net https://themes.ez-pp.farm",
"media-src": "'self' asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* blob:",
"font-src": [
"'self'",
+9 -1
View File
@@ -1,4 +1,5 @@
import { config } from './config';
import { normalizeThemeVersion } from './themeV2';
import {
reloadThemes,
themesDirectory,
@@ -727,6 +728,13 @@ export async function publishThemeToWorkshop(options: {
throw new Error('You must be logged in to EZPPFarm to publish themes.');
}
const version = normalizeThemeVersion(options.version ?? '1.0.0');
if (!version) {
throw new Error(
'Theme version must use semantic versioning, for example 1.2.3 or 1.2.3-beta.1.'
);
}
onProgress('Packaging theme archive...', 5);
const baseThemesDir = await themesDirectory();
@@ -771,7 +779,7 @@ export async function publishThemeToWorkshop(options: {
themeId: options.workshopId || options.themeId,
name: options.name,
description: options.description || '',
version: options.version || '1.0.0',
version,
apiVersion: options.apiVersion || '2.0.0',
totalSize,
totalChunks,
File diff suppressed because it is too large. Load diff
+118 -13
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import Logo from '$assets/logo.png';
import { publishThemeToWorkshop } from '$lib/communityThemes';
import { fetchCommunityThemeDetails, publishThemeToWorkshop } from '$lib/communityThemes';
import FontPreview from '$lib/components/theme/FontPreview.svelte';
import ThemeBehaviorInspector from '$lib/components/theme/ThemeBehaviorInspector.svelte';
import ThemeElementInspector from '$lib/components/theme/ThemeElementInspector.svelte';
@@ -75,6 +75,7 @@
normalizeChrome,
normalizeThemeTags,
normalizeThemeV2,
normalizeThemeVersion,
themeAssetName,
themeHasLaunchButton,
type ThemeV2Asset,
@@ -173,6 +174,7 @@
import { getCurrentWindow } from '@tauri-apps/api/window';
import { open, save as saveDialog } from '@tauri-apps/plugin-dialog';
import * as fs from '@tauri-apps/plugin-fs';
import semver from 'semver';
import { sileo } from 'sileo';
import { onMount, tick } from 'svelte';
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
@@ -287,6 +289,7 @@
let panStart = { x: 0, y: 0, panX: 0, panY: 0 };
const canvasScale = $derived(canvasFitScale * canvasZoom);
let statusMessage = $state('Ready');
let lastPublishedVersion = $state<string | undefined>(undefined);
let renamingId = $state<string | undefined>(undefined);
let draggingLayer = $state<LayerDragItem | undefined>(undefined);
let dropTarget = $state<LayerDropTarget | undefined>(undefined);
@@ -1803,6 +1806,7 @@
async function loadContext() {
loading = true;
lastPublishedVersion = undefined;
try {
const context = await invoke<ThemeEditorContext>('theme_editor_context');
const parsed = context.themeJson
@@ -2920,6 +2924,12 @@
notifyError('Add an author name so people know who made the theme.');
return false;
}
const version = normalizeThemeVersion(definition.version);
if (!version) {
notifyError('The version must use semantic versioning, for example 1.2.3 or 1.2.3-beta.1.');
return false;
}
if (definition.version !== version) definition.version = version;
const folderName = savedFolder ?? toSafeName(definition.name);
if (!folderName.replace(/_/g, '')) {
notifyError('The theme name needs at least one letter or number.');
@@ -3016,8 +3026,10 @@
if (!definition.name.trim()) error('The theme needs a name.');
if (!definition.author.trim()) error('The theme needs an author.');
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(definition.version.trim())) {
warning('The version should use semantic versioning, for example 1.0.0.');
if (!normalizeThemeVersion(definition.version)) {
error(
'The version must use semantic versioning, for example 1.0.0 or 1.0.0-beta.1, with no "v" prefix.'
);
}
if (!themeHasLaunchButton(definition)) {
error(
@@ -3340,10 +3352,68 @@
let publishStatusMessage = $state('');
let publishProgress = $state(0);
async function checkPublishVersion(): Promise<
{ ok: true; version: string } | { ok: false; error: string }
> {
const proposed = normalizeThemeVersion(definition.version);
if (!proposed) {
return {
ok: false,
error: 'Use a semantic version such as 1.2.3 in the Theme tab before publishing.',
};
}
let publishedVersion = lastPublishedVersion;
const workshopId = definition.workshopId?.trim();
if (workshopId) {
let remoteVersion: string;
try {
remoteVersion = (await fetchCommunityThemeDetails(workshopId)).version?.trim() ?? '';
} catch (error) {
console.warn('[Workshop] Could not verify the published theme version:', error);
return {
ok: false,
error:
'Could not verify the current workshop version. Check your connection and try again.',
};
}
const validRemote = normalizeThemeVersion(remoteVersion);
if (!validRemote) {
return {
ok: false,
error:
'The current workshop version could not be read. Contact a workshop administrator.',
};
}
if (!publishedVersion || semver.gt(validRemote, publishedVersion)) {
publishedVersion = validRemote;
}
}
if (publishedVersion) {
if (semver.eq(proposed, publishedVersion)) {
return {
ok: false,
error: `Version ${proposed} has already been published. Increase the version before publishing again.`,
};
}
if (!semver.gt(proposed, publishedVersion)) {
return {
ok: false,
error: `Version ${proposed} must be higher than the last published version ${publishedVersion}.`,
};
}
}
return { ok: true, version: proposed };
}
async function openPublishDialog() {
if (exporting || saving || publishing) return;
if (!$currentUser) {
const user = $currentUser;
if (!user) {
sileo.error({
title: 'Authentication Required',
description:
@@ -3361,8 +3431,23 @@
return;
}
if (dirty) {
await saveTheme({ notify: false });
const versionCheck = await checkPublishVersion();
if (!versionCheck.ok) {
sileo.error({
title: 'Version not publishable',
description: versionCheck.error,
});
return;
}
const versionChanged = definition.version !== versionCheck.version;
if (versionChanged) definition.version = versionCheck.version;
const authorIdChanged = definition.authorId !== user.id;
if (authorIdChanged) definition.authorId = user.id;
if (dirty || authorIdChanged || versionChanged) {
const saved = await saveTheme({ notify: false });
if (!saved) return;
}
publishThemeId = definition.workshopId ?? '';
@@ -3399,17 +3484,34 @@
async function handlePublishToWorkshop() {
if (publishing) return;
if (!savedFolder) {
await saveTheme({ notify: false });
if (!savedFolder) return;
}
const firstPublish = !definition.workshopId;
publishing = true;
publishProgress = 5;
publishStatusMessage = 'Packaging theme archive...';
publishStatusMessage = 'Checking version...';
try {
const versionCheck = await checkPublishVersion();
if (!versionCheck.ok) {
sileo.error({
title: 'Version not publishable',
description: versionCheck.error,
});
return;
}
if (definition.version !== versionCheck.version) {
definition.version = versionCheck.version;
const saved = await saveTheme({ notify: false });
if (!saved) return;
}
if (!savedFolder) {
const saved = await saveTheme({ notify: false });
if (!saved || !savedFolder) return;
}
publishStatusMessage = 'Packaging theme archive...';
const baseThemesDir = await themesDirectory();
const themeFolder = await path.join(baseThemesDir, savedFolder);
const themeId = savedFolder || toSafeName(definition.name);
@@ -3420,7 +3522,7 @@
workshopId: definition.workshopId,
name: definition.name,
description: definition.description || '',
version: definition.version || '1.0.0',
version: versionCheck.version,
apiVersion: definition.apiVersion || '2.0.0',
tags: definition.tags ?? [],
allowForking: definition.allowForking !== false,
@@ -3430,6 +3532,8 @@
},
});
lastPublishedVersion = versionCheck.version;
if (result.themeId) {
// Persist the server-assigned ID so the next publish updates this
// workshop record instead of creating another one.
@@ -6983,7 +7087,8 @@
</div>
</div>
<p class="text-[10px] leading-relaxed text-muted-foreground/70">
These details come from the Theme tab. Change them there before publishing.
These details come from the Theme tab. Published versions cannot be reused, so increase
the version before every update.
</p>
</div>
+18
View File
@@ -646,6 +646,8 @@ export type ThemeV2Definition = {
version: string;
apiVersion: '2.0';
author: string;
/** EZPPFarm user ID of the publisher, written when the theme is published. */
authorId?: number;
description?: string;
/** Workshop discovery tags for this theme. */
tags?: string[];
@@ -746,6 +748,16 @@ export const normalizeThemeTags = (raw: unknown): string[] => {
return tags;
};
const THEME_VERSION_PATTERN =
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
/** Accept only strict SemVer 2.0.0, preserving prerelease and build metadata. */
export const normalizeThemeVersion = (raw: unknown): string | undefined => {
if (typeof raw !== 'string') return undefined;
const version = raw.trim();
return version.length > 0 && THEME_VERSION_PATTERN.test(version) ? version : undefined;
};
const WORKSHOP_ID_PATTERN = /^[a-z0-9][a-z0-9_-]{0,63}$/;
/** Keep a server-assigned workshop ID while preserving legacy slug IDs. */
@@ -755,6 +767,11 @@ const normalizeWorkshopId = (raw: unknown): string | undefined => {
return WORKSHOP_ID_PATTERN.test(id) ? id : undefined;
};
const normalizeAuthorId = (raw: unknown): number | undefined => {
if (typeof raw !== 'number' || !Number.isSafeInteger(raw) || raw <= 0) return undefined;
return raw;
};
const clampInteger = (value: unknown, fallback: number, min: number, max: number) =>
Math.round(clamp(value, fallback, min, max));
@@ -1913,6 +1930,7 @@ export const normalizeThemeV2 = (raw: Partial<ThemeV2Definition>): ThemeV2Defini
version: text(raw.version, '1.0.0'),
apiVersion: '2.0',
author: text(raw.author, 'Unknown'),
authorId: normalizeAuthorId(raw.authorId),
description: text(raw.description),
tags: normalizeThemeTags(raw.tags),
workshopId: normalizeWorkshopId(raw.workshopId),
+10
View File
@@ -16,6 +16,8 @@ export type Theme = {
version: string;
apiVersion: string;
author: string;
/** EZPPFarm user ID stored in the manifest when the theme is published. */
authorId?: number;
description: string;
nsfw: boolean;
scriptUrl: string;
@@ -44,6 +46,7 @@ export type ThemeInfo = {
apiVersion?: string;
workshopId?: string;
author?: string;
authorId?: number;
description?: string;
nsfw?: boolean;
entry?: string;
@@ -173,6 +176,12 @@ const themeFromFolder = async (
version: parsed.version ?? '1.0.0',
apiVersion,
author: parsed.author ?? 'Unknown',
authorId:
typeof parsed.authorId === 'number' &&
Number.isSafeInteger(parsed.authorId) &&
parsed.authorId > 0
? parsed.authorId
: undefined,
description: parsed.description ?? '',
nsfw: parsed.nsfw === true,
scriptUrl,
@@ -523,6 +532,7 @@ export const reloadThemes = async () => {
preview: theme.preview,
version: theme.version,
author: theme.author,
authorId: theme.authorId,
apiVersion: theme.apiVersion,
description: theme.description,
nsfw: theme.nsfw,
+198 -103
View File
@@ -163,6 +163,7 @@
ChevronLeft,
ChevronRight,
Clock,
Ellipsis,
ExternalLink,
Flag,
Globe,
@@ -421,6 +422,14 @@
return ownedWorkshopThemeNames.includes(theme.name.trim().toLowerCase());
};
const themeAuthorAvatarUrl = (theme: Theme) => {
if (theme.authorId && theme.authorId > 0) {
return `https://a.ez-pp.farm/${theme.authorId}`;
}
const author = theme.author.trim();
return author ? `https://a.ez-pp.farm/${encodeURIComponent(author)}` : undefined;
};
onMount(() => {
let loadedUserId: number | undefined;
return currentUser.subscribe((user) => {
@@ -505,6 +514,29 @@
await config.value<string>('theme').set(theme.name);
};
const uninstallInstalledTheme = async (theme: Theme) => {
try {
const deleteResult = await deleteTheme(theme);
if (deleteResult) {
sileo.success({
title: 'Theme uninstalled',
description: `"${theme.name}" was removed from your library.`,
});
} else {
sileo.error({
title: 'Could not uninstall theme',
description: 'The theme files could not be removed.',
});
}
} catch (err) {
console.error(err);
sileo.error({
title: 'Could not uninstall theme',
description: err instanceof Error ? err.message : String(err),
});
}
};
const updateInstalledTheme = async (theme: Theme) => {
const wasActive = $active_custom_theme?.folder_name === theme.folder_name;
const updateResult = await downloadTheme(theme, true);
@@ -3911,6 +3943,28 @@
{#each filteredThemes as theme, index (theme.folder_name)}
{@const isActive =
$active_custom_theme?.folder_name === theme.folder_name}
{@const canEditTheme =
theme.status === 'installed' && Boolean(theme.definition)}
{@const canRestoreTheme =
theme.status === 'installed' && (theme.backups?.length ?? 0) > 0}
{@const canUpdateTheme =
theme.status === 'installed' && theme.updateAvailable}
{@const canReportTheme =
Boolean($currentUser && ownedWorkshopLoaded) &&
!isOwnInstalledTheme(theme) &&
theme.status === 'installed' &&
theme.name !== 'Default' &&
theme.folder_name !== 'default'}
{@const canUninstallTheme =
(theme.status === 'installed' || theme.status === 'deleting') &&
!isActive &&
theme.name !== 'Default'}
{@const hasThemeMenu =
canEditTheme ||
canRestoreTheme ||
canUpdateTheme ||
canReportTheme ||
canUninstallTheme}
<div
class="group flex flex-col overflow-hidden rounded-xl border bg-theme-900/30 {isActive
? 'border-primary/60 ring-1 ring-primary/15'
@@ -3925,7 +3979,7 @@
}}
>
<div
class="relative h-36 w-full shrink-0 overflow-hidden bg-theme-950/60"
class="relative aspect-video w-full shrink-0 overflow-hidden bg-theme-950/60"
>
<div
class="h-full w-full {$reduceAnimations
@@ -3966,17 +4020,37 @@
<div
class="pointer-events-none absolute inset-0 bg-gradient-to-t from-theme-950/75 via-transparent to-transparent"
></div>
<div
class="absolute top-1.5 left-1.5 flex max-w-[calc(100%-4.5rem)] flex-wrap items-center gap-1"
>
{#if isActive}
<Badge class="absolute top-1.5 left-1.5 text-[9px]">In use</Badge>
<Badge class="text-[9px]">In use</Badge>
{/if}
{#if theme.name !== 'Default' && theme.folder_name !== 'default' && theme.apiVersion}
<Badge
variant="secondary"
class="absolute top-1.5 right-1.5 bg-black/50 px-1.5 py-0 text-[9px] backdrop-blur-sm"
class="bg-black/50 px-1.5 py-0 text-[9px] backdrop-blur-sm"
>
API {theme.apiVersion.startsWith('2') ? '2.0' : '1.0'}
</Badge>
{/if}
</div>
<div class="absolute top-1.5 right-1.5 flex items-center gap-1">
{#if theme.nsfw}
<Badge
variant="destructive"
class="px-1.5 py-0 text-[9px]"
title="Adult content"
>
18+
</Badge>
{/if}
<span
class="rounded-md bg-black/60 px-1.5 py-0.5 text-[9px] font-medium text-white/90 backdrop-blur-sm"
>
v{theme.version}
</span>
</div>
{#if theme.nsfw && !revealedNsfw.includes(theme.name)}
<button
type="button"
@@ -3992,58 +4066,74 @@
{:else if theme.nsfw}
<button
type="button"
class="absolute bottom-1.5 left-1.5 z-10 flex items-center gap-1 rounded-full bg-black/60 px-1.5 py-0.5 text-[8px] font-medium text-white/80 backdrop-blur-sm hover:bg-black/75 hover:text-white"
class="absolute right-1.5 bottom-10 z-10 flex items-center gap-1 rounded-full bg-black/60 px-1.5 py-0.5 text-[8px] font-medium text-white/80 backdrop-blur-sm hover:bg-black/75 hover:text-white"
onclick={() => toggleNsfwPreview(theme.name)}
>
<ThemeIcon name="eye-off" set={iconSet} class="size-3" />
Hide preview
</button>
{/if}
{#if theme.nsfw}
<Badge
variant="destructive"
class="absolute right-1.5 bottom-1.5 px-1.5 py-0 text-[9px]"
title="Adult content"
<div
class="absolute right-2 bottom-2 left-2 flex items-center justify-between gap-2"
>
18+
</Badge>
{/if}
</div>
<div class="flex flex-1 flex-col gap-1.5 p-2.5">
<div class="flex items-start justify-between gap-1.5">
<div class="min-w-0">
<div class="flex min-w-0 items-center gap-1.5">
<Avatar.Root
class="size-5 shrink-0 border border-white/20 bg-theme-800"
>
<Avatar.Image
src={themeAuthorAvatarUrl(theme)}
alt={theme.author || 'Unknown author'}
class="object-cover"
/>
<Avatar.Fallback
class="text-[9px] font-bold text-white/80 uppercase"
>
{theme.author.trim().charAt(0) || '?'}
</Avatar.Fallback>
</Avatar.Root>
<span
class="block truncate text-[13px] leading-tight font-semibold"
class="truncate text-[11px] font-semibold text-white/95 drop-shadow-sm"
>
{theme.author || 'Unknown author'}
</span>
</div>
<span
class="shrink-0 text-[9px] {theme.updateAvailable
? 'text-primary'
: 'text-muted-foreground/90'}"
>
{theme.updateAvailable ? 'Update available' : 'Installed'}
</span>
</div>
</div>
<div class="flex flex-1 flex-col gap-2 p-3">
<h3 class="truncate text-[13px] font-bold text-theme-50">
{theme.name}
</span>
<span
class="mt-0.5 block truncate text-[10px] text-muted-foreground"
>
by {theme.author}
</span>
</div>
<span
class="shrink-0 rounded-full bg-theme-800/50 px-1.5 py-0.5 text-[9px] whitespace-nowrap tabular-nums text-muted-foreground"
>
{#if theme.updateAvailable && theme.availableVersion}
v{theme.version} <span class="text-primary">→</span>
v{theme.availableVersion}
{:else}
v{theme.version}
{/if}
</span>
</div>
</h3>
{#if theme.description}
<p
class="line-clamp-2 text-[10px] leading-snug text-muted-foreground"
class="line-clamp-2 text-[10px] leading-relaxed text-muted-foreground"
>
{theme.description}
</p>
{/if}
<div class="mt-auto flex items-center gap-1 pt-0.5">
<div
class="mt-auto flex items-center justify-between gap-2 border-t border-theme-800/40 pt-2.5"
>
<span class="min-w-0 truncate text-[9px] text-muted-foreground">
{#if theme.updateAvailable && theme.availableVersion}
<span class="text-primary"
>v{theme.availableVersion} available</span
>
{:else if isActive}
Active theme
{:else}
Installed
{/if}
</span>
<div class="flex shrink-0 items-center gap-1">
<Button
class="relative h-8 min-w-0 flex-1 overflow-hidden px-2 text-xs {theme.status ===
class="relative h-7 min-w-0 max-w-44 overflow-hidden px-2.5 text-xs {theme.status ===
'downloading' || theme.status === 'extracting'
? 'disabled:bg-primary disabled:opacity-100'
: ''}"
@@ -4089,70 +4179,78 @@
/>
</span>
</Button>
{#if theme.status === 'installed' && theme.definition}
{#if hasThemeMenu}
<DropdownMenu.Root>
<DropdownMenu.Trigger>
{#snippet child({ props })}
<Button
{...props}
variant="secondary"
size="icon"
class="size-7 shrink-0"
title="Edit theme"
class="size-7 shrink-0 text-muted-foreground hover:text-white"
title="More theme actions"
aria-label={`More actions for ${theme.name}`}
>
<Ellipsis class="size-3.5" />
</Button>
{/snippet}
</DropdownMenu.Trigger>
<DropdownMenu.Content
align="end"
class="w-48 border-theme-700 bg-theme-950 text-theme-50"
>
{#if canEditTheme}
<DropdownMenu.Item
class="gap-2 text-[11px]"
onclick={() => openThemeEditor(theme)}
>
<ThemeIcon name="edit" set={iconSet} class="size-3.5" />
</Button>
Edit theme
</DropdownMenu.Item>
{/if}
{#if theme.status === 'installed' && (theme.backups?.length ?? 0) > 0}
<Button
variant="secondary"
size="icon"
class="size-7 shrink-0"
title="Restore previous version ({new Date(
theme.backups![0].createdAt
).toLocaleDateString()})"
onclick={() => requestThemeRestore(theme, theme.backups![0])}
{#if canRestoreTheme}
<DropdownMenu.Item
class="gap-2 text-[11px]"
onclick={() =>
requestThemeRestore(theme, theme.backups![0])}
>
<ThemeIcon name="history" set={iconSet} class="size-3.5" />
</Button>
<ThemeIcon
name="history"
set={iconSet}
class="size-3.5"
/>
Restore previous version
</DropdownMenu.Item>
{/if}
{#if theme.status === 'installed' && theme.updateAvailable}
<Button
variant="secondary"
size="icon"
class="size-7 shrink-0"
title={`Update theme${theme.availableVersion ? ` to v${theme.availableVersion}` : ''}`}
{#if canUpdateTheme}
<DropdownMenu.Item
class="gap-2 text-[11px]"
onclick={() => updateInstalledTheme(theme)}
>
<ThemeIcon name="download" set={iconSet} class="size-3.5" />
</Button>
<ThemeIcon
name="download"
set={iconSet}
class="size-3.5"
/>
Update theme
</DropdownMenu.Item>
{/if}
{#if (theme.status === 'installed' || theme.status === 'deleting') && !isActive && theme.name !== 'Default'}
<Button
variant="destructive"
size="icon"
class="size-7 shrink-0"
title="Uninstall theme"
{#if canReportTheme}
<DropdownMenu.Item
class="gap-2 text-[11px]"
disabled={installedReportLoading}
onclick={() => void openInstalledReport(theme)}
>
<Flag class="size-3.5" />
Report theme
</DropdownMenu.Item>
{/if}
{#if canUninstallTheme}
<DropdownMenu.Separator class="my-1 bg-theme-800" />
<DropdownMenu.Item
class="gap-2 text-[11px] text-red-300 data-[highlighted]:bg-red-500/15 data-[highlighted]:text-red-200"
disabled={theme.status !== 'installed'}
onclick={async () => {
try {
const deleteResult = await deleteTheme(theme);
if (deleteResult) {
sileo.success({
title: 'Yaay!',
description: 'Theme uninstalled successfully!',
});
} else {
sileo.error({
title: 'Uhhm..',
description: 'Failed to uninstall theme.',
});
}
} catch (err) {
console.log(err);
sileo.error({
title: 'Uhhm..',
description: 'Failed to uninstall theme.',
});
}
}}
onclick={() => void uninstallInstalledTheme(theme)}
>
{#if theme.status === 'deleting'}
<ThemeIcon
@@ -4160,27 +4258,24 @@
set={iconSet}
class="size-3.5 animate-spin"
/>
Uninstalling...
{:else}
<ThemeIcon name="trash" set={iconSet} class="size-3.5" />
<ThemeIcon
name="trash"
set={iconSet}
class="size-3.5"
/>
Uninstall theme
{/if}
</Button>
</DropdownMenu.Item>
{/if}
{#if $currentUser && ownedWorkshopLoaded && !isOwnInstalledTheme(theme) && theme.status === 'installed' && theme.name !== 'Default' && theme.folder_name !== 'default'}
<Button
variant="secondary"
size="icon"
class="size-7 shrink-0 text-muted-foreground hover:bg-amber-500/15 hover:text-amber-300"
title="Report theme"
aria-label={`Report ${theme.name}`}
disabled={installedReportLoading}
onclick={() => void openInstalledReport(theme)}
>
<Flag class="size-3.5" />
</Button>
</DropdownMenu.Content>
</DropdownMenu.Root>
{/if}
</div>
</div>
</div>
</div>
{/each}
</div>
{/key}