From e2da4773bdca696565351c0be1ded8a6c397b042 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnier Date: Sun, 24 May 2026 01:00:14 +0200 Subject: [PATCH] Fix: GMPlayerPrivacySelectorMenu must extend ApplicationV2 Modified GMPlayerPrivacySelectorMenu to extend ApplicationV2 (or fallback class) to be compatible with FoundryVTT's registerMenu API. FoundryVTT requires that menu types passed to registerMenu() must be a FormApplication or ApplicationV2 instance or subclass. Changes: - Added conditional _AppBase class (ApplicationV2 or fallback for tests) - Extended GMPlayerPrivacySelectorMenu from _AppBase - Added DEFAULT_OPTIONS static property for ApplicationV2 compatibility - Added super(options) call in constructor This fixes: Error: You must provide a menu type that is a FormApplication or ApplicationV2 instance or subclass Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- src/ui/gm/GMPlayerPrivacySelector.js | 36 +++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/ui/gm/GMPlayerPrivacySelector.js b/src/ui/gm/GMPlayerPrivacySelector.js index a3e9f51..7e7fde6 100644 --- a/src/ui/gm/GMPlayerPrivacySelector.js +++ b/src/ui/gm/GMPlayerPrivacySelector.js @@ -3,10 +3,30 @@ * * A settings menu entry that allows the GM to select a player and view their privacy settings. * This provides read-only access to all players' privacy panels. + * + * Extends ApplicationV2 to be compatible with FoundryVTT's registerMenu API. */ import { PlayerPrivacyPanel } from '../player/PlayerPrivacyPanel.js'; +// Conditional base class for test compatibility +// At module load time in tests, foundry is undefined → fallback class is used +const _AppBase = + typeof foundry !== 'undefined' && + foundry.applications?.api?.ApplicationV2 + ? foundry.applications.api.ApplicationV2 + : class _FallbackApp { + static DEFAULT_OPTIONS = {}; + get rendered() { return this._rendered ?? false; } + set rendered(v) { this._rendered = v; } + get element() { return this._element ?? null; } + set element(v) { this._element = v; } + async render() { this._rendered = true; } + async close() { this._rendered = false; } + _onRender() {} + _onClose() {} + }; + /** * Static references to DI dependencies (set during module initialization). */ @@ -68,12 +88,26 @@ function _registerSettingsMenu() { /** * GM Player Privacy Selector Menu class. * When instantiated by Foundry, it creates a user selector dialog. + * Extends ApplicationV2 (or fallback) for Foundry settings menu compatibility. */ -export class GMPlayerPrivacySelectorMenu { +export class GMPlayerPrivacySelectorMenu extends _AppBase { + static DEFAULT_OPTIONS = { + id: 'scrying-pool-gm-privacy-selector', + classes: ['scrying-pool', 'gm-privacy-selector'], + window: { + title: 'Player Privacy Selector', + resizable: false, + width: 400, + height: 'auto', + }, + position: {}, + }; + /** * @param {object} [options] - Foundry options (unused, but required by settings menu API) */ constructor(options = {}) { + super(options); this._adapter = _adapter; this._playerPrivacyManager = _playerPrivacyManager; this._options = options;