diff --git a/CHANGELOG.md b/CHANGELOG.md index 80a8693..1d54a8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 3.1.0 + +- Activity rows with no user behind them (failed logins, scheduled tasks) show a plain system icon instead of a generated pattern. +- New **System picture** setting: admins can upload a picture for those rows instead (Admin, Extensions, User Avatars). + ## 3.0.1 - Pictures now show in activity logs (a server's Activity tab, your account activity and the admin activity page). These lists drew a generated avatar and ignored the user's picture. diff --git a/README.md b/README.md index a6c08f5..0995891 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Pterodactyl 2.0 has no avatar uploads. Core draws a generated pattern in the nav - Lists that show a user's `image` (admin users, server owner, subusers) get the user's picture because this extension replaces the panel's user transformers with versions that swap in the uploaded URL. If another extension also replaces `Pterodactyl\Transformers\Api\Client\UserTransformer` or `Pterodactyl\Transformers\Api\Admin\UserTransformer`, only one of them will win. - The navigation bar avatar is not a replaceable component in 2.0, so the user's picture is laid over it with CSS that targets the "Account Settings" link. A panel update that changes that link could break it; the rest of the extension is unaffected. -- Activity rows draw a generated avatar from the username and are not replaceable either. The activity API already includes each actor's picture, so the extension matches rows to it by username and lays the picture over the generated avatar. A panel update that changes the activity row layout could break it. +- Activity rows draw a generated avatar from the username and are not replaceable either. The activity API already includes each actor's picture, so the extension matches rows to it by username and lays the picture over the generated avatar. Rows with no user (shown as "System") get the picture set in the extension's **System picture** setting, or a plain system icon when none is set. A panel update that changes the activity row layout could break it. ## API diff --git a/extension.json b/extension.json index 49d453f..ea4c6bd 100644 --- a/extension.json +++ b/extension.json @@ -2,7 +2,7 @@ "$schema": "./node_modules/@pterodactyl/sdk/manifest.schema.json", "id": "user-avatars", "name": "User Avatars", - "version": "3.0.1", + "version": "3.1.0", "description": "Let users upload their own profile picture, shown in the navigation bar, admin user lists, server subuser lists and activity logs.", "author": "RustixDev", "icon": "circle-user", diff --git a/package-lock.json b/package-lock.json index 22f41e5..e2833f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "user-avatars", - "version": "3.0.1", + "version": "3.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "user-avatars", - "version": "3.0.1", + "version": "3.1.0", "devDependencies": { "@base-ui/react": "^1.6.0", "@pterodactyl/sdk": "file:./sdk/pterodactyl-sdk-2.0.0-beta.4.tgz", diff --git a/package.json b/package.json index 59a3aec..3568f8a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "user-avatars", "private": true, - "version": "3.0.1", + "version": "3.1.0", "type": "module", "scripts": { "build": "vite build", diff --git a/src/UserAvatarsProvider.php b/src/UserAvatarsProvider.php index a9b5bfb..2f22715 100644 --- a/src/UserAvatarsProvider.php +++ b/src/UserAvatarsProvider.php @@ -4,6 +4,7 @@ use Pterodactyl\Extensions\ExtensionProvider; use Pterodactyl\Services\Extensions\ExtensionSettingDefinition; +use Pterodactyl\Services\Extensions\ExtensionSettingFiles; use Pterodactyl\Services\Extensions\ExtensionSettingsDefinition; use Pterodactyl\Transformers\Api\Admin\UserTransformer as CoreAdminUserTransformer; use Pterodactyl\Transformers\Api\Client\UserTransformer as CoreClientUserTransformer; @@ -25,6 +26,11 @@ public function boot(): void ->field('number') ->label('Largest upload (KB)') ->help('Uploads are cropped to a square and resized to 256 pixels, so the stored file is much smaller than this.'), + ExtensionSettingDefinition::make('system_picture', 'system_picture', null) + ->file(ExtensionSettingFiles::IMAGES, 1024) + ->frontend() + ->label('System picture') + ->help('Shown in activity logs on rows with no user behind them, like failed logins and scheduled tasks. Leave empty for a plain system icon.'), ])); $this->app->scoped(AvatarService::class, fn () => new AvatarService($this->settings())); diff --git a/src/client/avatars.spec.tsx b/src/client/avatars.spec.tsx index c021125..1f8671d 100644 --- a/src/client/avatars.spec.tsx +++ b/src/client/avatars.spec.tsx @@ -2,7 +2,7 @@ import { afterEach, beforeEach, expect, test } from 'vitest'; import { cleanup, render, screen, waitFor } from '@testing-library/react'; import { createExtensionTestHost } from '@pterodactyl/sdk/testing'; import AccountAvatarCard from './components/AccountAvatarCard'; -import ActivityAvatars, { ACTIVITY_CLASS } from './components/ActivityAvatars'; +import ActivityAvatars, { ACTIVITY_CLASS, SYSTEM_CLASS, decorateActivityRows, setSystemPicture } from './components/ActivityAvatars'; import AdminUserAvatar from './components/AdminUserAvatar'; import NavAvatar, { ROOT_CLASS, ROOT_VARIABLE } from './components/NavAvatar'; import { myAvatarQuery, userAvatarQuery } from './api'; @@ -100,6 +100,30 @@ test('activity rows show the actor picture in place of the generated avatar', as await waitFor(() => expect(admin.classList.contains(ACTIVITY_CLASS)).toBe(true)); expect(admin.style.backgroundImage).toContain(UPLOADED.url); expect(system.classList.contains(ACTIVITY_CLASS)).toBe(false); + expect(system.classList.contains(SYSTEM_CLASS)).toBe(true); + expect(admin.classList.contains(SYSTEM_CLASS)).toBe(false); list.remove(); }); + +test('system rows use the admin system picture when one is set', () => { + const list = document.createElement('div'); + list.innerHTML = ` +