fix(canvas): hide toolbar items for disabled modules
Inject enabledModules into client, tag 25 module-specific toolbar buttons with data-requires-module, and filter out disabled items (plus empty groups) at page init. Spaces with all modules enabled are unaffected. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fcf4202045
commit
355b53ee17
|
|
@ -428,6 +428,7 @@ export function renderShell(opts: ShellOptions): string {
|
|||
// Provide module list to app switcher and offline runtime
|
||||
window.__rspaceModuleList = ${moduleListJSON};
|
||||
window.__rspaceAllModules = ${allModulesJSON};
|
||||
window.__rspaceEnabledModules = ${JSON.stringify(enabledModules)};
|
||||
const _switcher = document.querySelector('rstack-app-switcher');
|
||||
_switcher?.setModules(window.__rspaceModuleList);
|
||||
_switcher?.setAllModules(window.__rspaceAllModules);
|
||||
|
|
|
|||
|
|
@ -2051,7 +2051,7 @@
|
|||
<div class="toolbar-dropdown">
|
||||
<div class="toolbar-dropdown-header">Connect</div>
|
||||
<button id="new-chat" title="New Chat">💬 Chat</button>
|
||||
<button id="embed-meets" title="rMeets">📹 rMeets</button>
|
||||
<button id="embed-meets" title="rMeets" data-requires-module="rmeets">📹 rMeets</button>
|
||||
<button id="new-record" title="Record" class="toolbar-disabled">🔴 Record</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2064,8 +2064,8 @@
|
|||
<button id="new-transcription" title="Transcribe">🎤 Transcribe</button>
|
||||
<button id="new-stream" title="Stream" class="toolbar-disabled">📡 Stream</button>
|
||||
<button id="new-piano" title="Piano">🎹 Piano</button>
|
||||
<button id="embed-tube" title="Embed rTube">🎬 rTube</button>
|
||||
<button id="embed-photos" title="Embed rPhotos">📸 rPhotos</button>
|
||||
<button id="embed-tube" title="Embed rTube" data-requires-module="rtube">🎬 rTube</button>
|
||||
<button id="embed-photos" title="Embed rPhotos" data-requires-module="rphotos">📸 rPhotos</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -2078,15 +2078,15 @@
|
|||
<button id="new-image" title="Image">🖼️ Image</button>
|
||||
<button id="new-bookmark" title="Bookmark">🔖 Bookmark</button>
|
||||
<button id="new-google-item" title="Google">📎 Google</button>
|
||||
<button id="new-map" title="Map">🗺️ Map</button>
|
||||
<button id="new-map" title="Map" data-requires-module="rmaps">🗺️ Map</button>
|
||||
<button id="new-social-post" title="Social Post">📱 Social Post</button>
|
||||
<button id="embed-notes" title="Embed rNotes">📝 rNotes</button>
|
||||
<button id="embed-books" title="Embed rBooks">📚 rBooks</button>
|
||||
<button id="embed-forum" title="Embed rForum">💬 rForum</button>
|
||||
<button id="embed-files" title="Embed rFiles">📁 rFiles</button>
|
||||
<button id="embed-tasks" title="Embed rTasks">📋 rTasks</button>
|
||||
<button id="embed-cart" title="Embed rCart">🛒 rCart</button>
|
||||
<button id="embed-data" title="Embed rData">📊 rData</button>
|
||||
<button id="embed-notes" title="Embed rNotes" data-requires-module="rnotes">📝 rNotes</button>
|
||||
<button id="embed-books" title="Embed rBooks" data-requires-module="rbooks">📚 rBooks</button>
|
||||
<button id="embed-forum" title="Embed rForum" data-requires-module="rforum">💬 rForum</button>
|
||||
<button id="embed-files" title="Embed rFiles" data-requires-module="rfiles">📁 rFiles</button>
|
||||
<button id="embed-tasks" title="Embed rTasks" data-requires-module="rtasks">📋 rTasks</button>
|
||||
<button id="embed-cart" title="Embed rCart" data-requires-module="rcart">🛒 rCart</button>
|
||||
<button id="embed-data" title="Embed rData" data-requires-module="rdata">📊 rData</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -2095,9 +2095,9 @@
|
|||
<button class="toolbar-group-toggle" title="Connect"><span class="tg-icon">🔌</span><span class="tg-label">Connect</span></button>
|
||||
<div class="toolbar-dropdown">
|
||||
<div class="toolbar-dropdown-header">Connect</div>
|
||||
<button id="new-calendar" title="Calendar">📅 rCal</button>
|
||||
<button id="embed-inbox" title="Embed rInbox">📧 rInbox</button>
|
||||
<button id="embed-network" title="Embed rNetwork">🌍 rNetwork</button>
|
||||
<button id="new-calendar" title="Calendar" data-requires-module="rcal">📅 rCal</button>
|
||||
<button id="embed-inbox" title="Embed rInbox" data-requires-module="rinbox">📧 rInbox</button>
|
||||
<button id="embed-network" title="Embed rNetwork" data-requires-module="rnetwork">🌍 rNetwork</button>
|
||||
<button id="new-holon" title="Holon">🌐 Holon</button>
|
||||
<button id="new-holon-browser" title="Holon Browser">🔍 Holon Browser</button>
|
||||
</div>
|
||||
|
|
@ -2121,13 +2121,13 @@
|
|||
<button class="toolbar-group-toggle" title="Create"><span class="tg-icon">🛠️</span><span class="tg-label">Create</span></button>
|
||||
<div class="toolbar-dropdown">
|
||||
<div class="toolbar-dropdown-header">Create</div>
|
||||
<button id="new-splat" title="3D Splat">🔮 3D Splat</button>
|
||||
<button id="new-splat" title="3D Splat" data-requires-module="rsplat">🔮 3D Splat</button>
|
||||
<button id="new-blender" title="3D Blender">🧊 Blender</button>
|
||||
<button id="new-drawfast" title="Drawfast">✏️ Drawfast</button>
|
||||
<button id="new-freecad" title="FreeCAD">📐 FreeCAD</button>
|
||||
<button id="new-kicad" title="KiCAD PCB">🔌 KiCAD</button>
|
||||
<button id="embed-swag" title="Embed rSwag">🎨 rSwag</button>
|
||||
<button id="embed-pubs" title="Embed rPubs">📖 rPubs</button>
|
||||
<button id="embed-swag" title="Embed rSwag" data-requires-module="rswag">🎨 rSwag</button>
|
||||
<button id="embed-pubs" title="Embed rPubs" data-requires-module="rpubs">📖 rPubs</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -2143,7 +2143,7 @@
|
|||
<button id="new-conviction" title="Conviction">⏳ Conviction</button>
|
||||
<button id="new-token" title="Token">🪙 Token</button>
|
||||
<button id="new-multisig-email" title="Multi-Sig Email">✉️ Multi-Sig Email</button>
|
||||
<button id="embed-vote" title="Embed rVote">🗳️ rVote</button>
|
||||
<button id="embed-vote" title="Embed rVote" data-requires-module="rvote">🗳️ rVote</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -2152,8 +2152,8 @@
|
|||
<button class="toolbar-group-toggle" title="Spend"><span class="tg-icon">💰</span><span class="tg-label">Spend</span></button>
|
||||
<div class="toolbar-dropdown">
|
||||
<div class="toolbar-dropdown-header">Spend</div>
|
||||
<button id="embed-wallet" title="rWallet">💰 rWallet</button>
|
||||
<button id="embed-flows" title="rFlows">🌊 rFlows</button>
|
||||
<button id="embed-wallet" title="rWallet" data-requires-module="rwallet">💰 rWallet</button>
|
||||
<button id="embed-flows" title="rFlows" data-requires-module="rflows">🌊 rFlows</button>
|
||||
<button id="new-tx-builder" title="Transaction Builder">🔐 Tx Builder</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2163,11 +2163,11 @@
|
|||
<button class="toolbar-group-toggle" title="Travel"><span class="tg-icon">✈️</span><span class="tg-label">Travel</span></button>
|
||||
<div class="toolbar-dropdown">
|
||||
<div class="toolbar-dropdown-header">Travel</div>
|
||||
<button id="new-itinerary" title="Itinerary">🗓️ Itinerary</button>
|
||||
<button id="new-destination" title="Destination">📍 Destination</button>
|
||||
<button id="new-budget" title="Budget">💰 Budget</button>
|
||||
<button id="new-packing-list" title="Packing List">🎒 Packing List</button>
|
||||
<button id="new-booking" title="Booking">✈️ Booking</button>
|
||||
<button id="new-itinerary" title="Itinerary" data-requires-module="rtrips">🗓️ Itinerary</button>
|
||||
<button id="new-destination" title="Destination" data-requires-module="rtrips">📍 Destination</button>
|
||||
<button id="new-budget" title="Budget" data-requires-module="rtrips">💰 Budget</button>
|
||||
<button id="new-packing-list" title="Packing List" data-requires-module="rtrips">🎒 Packing List</button>
|
||||
<button id="new-booking" title="Booking" data-requires-module="rtrips">✈️ Booking</button>
|
||||
</div>
|
||||
</div>
|
||||
<button id="toolbar-collapse" title="Minimize toolbar"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="6" y1="18" x2="18" y2="18"/></svg></button>
|
||||
|
|
@ -4459,6 +4459,24 @@
|
|||
});
|
||||
});
|
||||
|
||||
// Hide toolbar items for disabled modules
|
||||
const _enabledMods = window.__rspaceEnabledModules;
|
||||
if (_enabledMods) {
|
||||
const _enabledSet = new Set(_enabledMods);
|
||||
document.querySelectorAll('[data-requires-module]').forEach(el => {
|
||||
if (!_enabledSet.has(el.dataset.requiresModule)) {
|
||||
el.style.display = 'none';
|
||||
}
|
||||
});
|
||||
// Hide empty toolbar groups (all visible items hidden)
|
||||
document.querySelectorAll('.toolbar-group').forEach(group => {
|
||||
const dropdown = group.querySelector('.toolbar-dropdown');
|
||||
if (!dropdown) return;
|
||||
const visibleItems = dropdown.querySelectorAll('button:not([style*="display: none"]):not(.toolbar-dropdown-header)');
|
||||
if (visibleItems.length === 0) group.style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
// rApp embed buttons — embed any module as a folk-rapp shape on the canvas
|
||||
const rAppModules = [
|
||||
{ btnId: "embed-notes", moduleId: "rnotes" },
|
||||
|
|
|
|||
Loading…
Reference in New Issue