From 55e56ea652edebd114f045886834f59e459a4017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Sun, 23 Aug 2026 14:21:54 +0000 Subject: [PATCH] widgets panel keyed (516 -> 515) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also adds tUi to officerdev's useTranslation, mirroring officer-web: the brief says to reach for ui.* where the string already exists there, and 'Cancel' does. Panel strings stay in panel.* — a ui.* key may not name a feature, and a panel is one. --- .../src/apps/Widgets/WidgetPanel.tsx | 29 ++++++++++++------- .../officerdev/src/locales/en-GB.json | 28 ++++++++++++++++++ .../officerdev/src/locales/pt-PT.json | 28 ++++++++++++++++++ .../officerdev/src/locales/useTranslation.ts | 8 ++++- 4 files changed, 81 insertions(+), 12 deletions(-) diff --git a/src/workspaces/officerdev/src/apps/Widgets/WidgetPanel.tsx b/src/workspaces/officerdev/src/apps/Widgets/WidgetPanel.tsx index 491b92f6..abb7b600 100644 --- a/src/workspaces/officerdev/src/apps/Widgets/WidgetPanel.tsx +++ b/src/workspaces/officerdev/src/apps/Widgets/WidgetPanel.tsx @@ -6,6 +6,7 @@ import { useAuth } from 'hooks/useAuth'; import { Plus, X, RefreshCw } from 'lucide-react'; import { useWidgetRegistry } from '../../WidgetRegistry'; import { WidgetPicker } from './WidgetPicker'; +import { useTranslation } from '../../locales'; type Position = { x: number; y: number }; // percentages (0–100) @@ -102,20 +103,23 @@ const DraggableWidget = ({ instance, panelRef, onMove, onRemove }: DraggableWidg [instance.position, panelRef], ); - const endDrag = useCallback( - (ev: ReactPointerEvent) => { - if (!dragRef.current) return; - dragRef.current = null; - containerRef.current?.releasePointerCapture(ev.pointerId); - }, - [], - ); + const endDrag = useCallback((ev: ReactPointerEvent) => { + if (!dragRef.current) return; + dragRef.current = null; + containerRef.current?.releasePointerCapture(ev.pointerId); + }, []); const onPointerMove = useCallback( (ev: ReactPointerEvent) => { if (!dragRef.current) return; const panelRect = panelRef.current?.getBoundingClientRect(); - if (panelRect && (ev.clientX < panelRect.left || ev.clientX > panelRect.right || ev.clientY < panelRect.top || ev.clientY > panelRect.bottom)) { + if ( + panelRect && + (ev.clientX < panelRect.left || + ev.clientX > panelRect.right || + ev.clientY < panelRect.top || + ev.clientY > panelRect.bottom) + ) { endDrag(ev); return; } @@ -165,6 +169,7 @@ const DraggableWidget = ({ instance, panelRef, onMove, onRemove }: DraggableWidg // --- WidgetPanel --- export const WidgetPanel = ({ panelId }: { panelId: string }) => { + const { t } = useTranslation(); const [config, setConfig] = useWidgetPanelState(panelId); const [instances, setInstances] = useState(config.instances); const [showPicker, setShowPicker] = useState(false); @@ -220,7 +225,9 @@ export const WidgetPanel = ({ panelId }: { panelId: string }) => { /> ))} -
+
{showPicker && (
@@ -229,7 +236,7 @@ export const WidgetPanel = ({ panelId }: { panelId: string }) => {