From 7ae8b64699cc45a6dc05f3835051773b731032e1 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 23 Aug 2024 17:02:46 +1000 Subject: [PATCH] feat(ui): add log debug button --- invokeai/frontend/web/public/locales/en.json | 1 + .../Settings/CanvasSettingsLogDebugInfo.tsx | 19 +++++++++++++++++++ .../Settings/CanvasSettingsPopover.tsx | 2 ++ .../controlLayers/konva/CanvasManager.ts | 4 ++-- 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 invokeai/frontend/web/src/features/controlLayers/components/Settings/CanvasSettingsLogDebugInfo.tsx diff --git a/invokeai/frontend/web/public/locales/en.json b/invokeai/frontend/web/public/locales/en.json index ee0f629509..bace0d040e 100644 --- a/invokeai/frontend/web/public/locales/en.json +++ b/invokeai/frontend/web/public/locales/en.json @@ -1731,6 +1731,7 @@ "hidingType": "Hiding {{type}}", "showingType": "Showing {{type}}", "dynamicGrid": "Dynamic Grid", + "logDebugInfo": "Log Debug Info", "fill": { "fillStyle": "Fill Style", "solid": "Solid", diff --git a/invokeai/frontend/web/src/features/controlLayers/components/Settings/CanvasSettingsLogDebugInfo.tsx b/invokeai/frontend/web/src/features/controlLayers/components/Settings/CanvasSettingsLogDebugInfo.tsx new file mode 100644 index 0000000000..01323b2fa3 --- /dev/null +++ b/invokeai/frontend/web/src/features/controlLayers/components/Settings/CanvasSettingsLogDebugInfo.tsx @@ -0,0 +1,19 @@ +import { Button } from '@invoke-ai/ui-library'; +import { useCanvasManager } from 'features/controlLayers/contexts/CanvasManagerProviderGate'; +import { memo, useCallback } from 'react'; +import { useTranslation } from 'react-i18next'; + +export const CanvasSettingsLogDebugInfoButton = memo(() => { + const { t } = useTranslation(); + const canvasManager = useCanvasManager(); + const onClick = useCallback(() => { + canvasManager.logDebugInfo(); + }, [canvasManager]); + return ( + + ); +}); + +CanvasSettingsLogDebugInfoButton.displayName = 'CanvasSettingsLogDebugInfoButton'; diff --git a/invokeai/frontend/web/src/features/controlLayers/components/Settings/CanvasSettingsPopover.tsx b/invokeai/frontend/web/src/features/controlLayers/components/Settings/CanvasSettingsPopover.tsx index 8ad4aeb22a..34f1a11e4e 100644 --- a/invokeai/frontend/web/src/features/controlLayers/components/Settings/CanvasSettingsPopover.tsx +++ b/invokeai/frontend/web/src/features/controlLayers/components/Settings/CanvasSettingsPopover.tsx @@ -14,6 +14,7 @@ import { CanvasSettingsClearCachesButton } from 'features/controlLayers/componen import { CanvasSettingsClipToBboxCheckbox } from 'features/controlLayers/components/Settings/CanvasSettingsClipToBboxCheckbox'; import { CanvasSettingsDynamicGridSwitch } from 'features/controlLayers/components/Settings/CanvasSettingsDynamicGridSwitch'; import { CanvasSettingsInvertScrollCheckbox } from 'features/controlLayers/components/Settings/CanvasSettingsInvertScrollCheckbox'; +import { CanvasSettingsLogDebugInfoButton } from 'features/controlLayers/components/Settings/CanvasSettingsLogDebugInfo'; import { CanvasSettingsRecalculateRectsButton } from 'features/controlLayers/components/Settings/CanvasSettingsRecalculateRectsButton'; import { CanvasSettingsResetButton } from 'features/controlLayers/components/Settings/CanvasSettingsResetButton'; import { memo } from 'react'; @@ -58,6 +59,7 @@ const DebugSettings = () => { + ); }; diff --git a/invokeai/frontend/web/src/features/controlLayers/konva/CanvasManager.ts b/invokeai/frontend/web/src/features/controlLayers/konva/CanvasManager.ts index c033165435..09d641decb 100644 --- a/invokeai/frontend/web/src/features/controlLayers/konva/CanvasManager.ts +++ b/invokeai/frontend/web/src/features/controlLayers/konva/CanvasManager.ts @@ -152,10 +152,10 @@ export class CanvasManager { logDebugInfo() { // eslint-disable-next-line no-console - console.log(this); + console.log('Canvas manager', this); for (const adapter of this.adapters.getAll()) { // eslint-disable-next-line no-console - console.log(adapter); + console.log(adapter.id, adapter); } }