Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 35 additions & 14 deletions src/DockableApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
DXLocalTime,
} from './components';

import { loadLayout, saveLayout } from './store/layoutStore.js';
import { resetLayout, loadLayout, saveLayout } from './store/layoutStore.js';
import { DockableLayoutProvider } from './contexts';
import { useRig } from './contexts/RigContext.jsx';
import { calculateBearing, calculateDistance, formatDistance } from './utils/geo.js';
Expand Down Expand Up @@ -175,6 +175,12 @@ export const DockableApp = ({
return next;
});
}, []);
const handleResetLayout = useCallback(() => {
if (confirm('Reset panel layout to default? This will undo any customizations.')) {
const defaultLayout = resetLayout();
setModel(Model.fromJson(defaultLayout));
}
}, []);
const [showDXLocalTime, setShowDXLocalTime] = useState(false);
const [showDxccSelect, setShowDxccSelect] = useState(false);

Expand Down Expand Up @@ -417,7 +423,7 @@ export const DockableApp = ({
'on-air': { name: 'On Air', icon: '🔴' },
'id-timer': { name: 'ID Timer', icon: '📢' },
keybindings: { name: 'Keyboard Shortcuts', icon: '⌨️' },
'lock-layout': { name: 'Lock Layout', icon: '🔒' },
layout: { name: 'Layout', icon: '📐' },
};
}, [isLocalInstall]);

Expand Down Expand Up @@ -946,19 +952,34 @@ export const DockableApp = ({
content = <KeybindingsPanel keybindings={keybindingsList} nodeId={nodeId} />;
break;

case 'lock-layout':
case 'layout':
content = (
<button
onClick={toggleLayoutLock}
title={
layoutLocked
? 'Unlock layout — allow drag, resize, and close'
: 'Lock layout — prevent accidental changes'
}
className={`panel-layout-lock-button ${layoutLocked ? 'locked' : 'unlocked'}`}
>
{layoutLocked ? '🔒' : '🔓'} Layout {layoutLocked ? 'Locked' : 'Unlocked'}
</button>
<div className="panel" style={{ height: '100%' }}>
<button
onClick={toggleLayoutLock}
title={
layoutLocked
? 'Unlock layout — allow drag, resize, and close'
: 'Lock layout — prevent accidental changes'
}
className={`panel-layout-lock-button ${layoutLocked ? 'locked' : 'unlocked'}`}
>
{layoutLocked ? '🔒' : '🔓'} Layout {layoutLocked ? 'Locked' : 'Unlocked'}
</button>
<button
id="panel-layout-reset-button"
onClick={handleResetLayout}
className="panel-layout-reset-button"
title={layoutLocked ? 'Unlock layout to reset' : 'Reset panel layout'}
disabled={layoutLocked}
>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
<path d="M3 3v5h5" />
</svg>
{t('station.settings.layout.reset.button')}
</button>
</div>
);
break;

Expand Down
22 changes: 18 additions & 4 deletions src/store/layoutStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export const DEFAULT_LAYOUT = {
children: [
{
type: 'tab',
name: 'Lock Layout',
component: 'lock-layout',
id: 'lock-layout-tab',
name: 'Layout',
component: 'layout',
id: 'layout-tab',
enableClose: false,
},
],
Expand Down Expand Up @@ -119,7 +119,7 @@ export const PANEL_DEFINITIONS = {
'world-map': { name: 'World Map', icon: '🗺️', description: 'Interactive world map' },
'rig-control': { name: 'Rig Control', icon: '📻', description: 'Transceiver control and feedback' },
'on-air': { name: 'On Air', icon: '🔴', description: 'Large TX status indicator' },
'lock-layout': { name: 'Lock the Layout', icon: '🔒', description: 'Lock the layout' },
layout: { name: 'Layout', icon: '📐', description: 'Layout controls' },
};

// Load layout from localStorage
Expand All @@ -135,6 +135,20 @@ export const loadLayout = () => {
if (parsed.borders.length === 0) {
parsed.borders = DEFAULT_LAYOUT.borders;
saveLayout(parsed);
} else {
// Migrate lock-layout → layout rename
let migrated = false;
for (const border of parsed.borders) {
for (const child of border.children || []) {
if (child.component === 'lock-layout') {
child.component = 'layout';
child.id = 'layout-tab';
child.name = 'Layout';
migrated = true;
}
}
}
if (migrated) saveLayout(parsed);
}
return parsed;
}
Expand Down
8 changes: 8 additions & 0 deletions src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,12 @@ body::before {
/* ============================================
LOCK LAYOUT PANEL
============================================ */
.panel-layout-reset-button,
.panel-layout-lock-button {
width: 90%;
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
color: var(--text-muted);
background: var(--bg-tertiary);
Expand All @@ -378,6 +381,11 @@ body::before {
margin: 1em auto;
}

.panel-layout-reset-button:disabled {
cursor: not-allowed;
opacity: 0.5;
}

.panel-layout-lock-button.locked {
color: var(--accent-amber);
background: rgba(255, 170, 0, 0.15);
Expand Down